问:
Datastax 4.0 Error: Does not contain a valid host:port authority: ${dse.job.tracker}
Just got a single node cluster up and running with the new datastax 4.0.
Works great. We use hive to build and query our data.
On the server it self. I can start hive
$>dse hive
and query tables just fine.
When I try and use the newest Hive ODBC driver to run the same query I seeing this error.
It connects just fine, i can query the keyspace and see the tables. but when i try to run the query. Looks like the map/red gets in the queue, but then errors out with the following.

```<code>Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Estimated from input data size: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapred.reduce.tasks=<number>
java.lang.IllegalArgumentException: Does not contain a valid host:port authority: ${dse.job.tracker}
    at org.apache.hadoop.net.NetUtils.createSocketAddr(NetUtils.java:147)
    at org.apache.hadoop.net.NetUtils.createSocketAddr(NetUtils.java:128)
    at org.apache.hadoop.mapred.JobTracker.getAddress(JobTracker.java:2584)
    at org.apache.hadoop.mapred.JobClient.init(JobClient.java:474)
    at org.apache.hadoop.mapred.JobClient.<init>(JobClient.java:457)
    at org.apache.hadoop.hive.ql.exec.mr.ExecDriver.execute(ExecDriver.java:402)
    at org.apache.hadoop.hive.ql.exec.mr.MapRedTask.execute(MapRedTask.java:144)
    at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:151)
    at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:65)
    at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1414)
    at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1192)
    at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1020)
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:888)
    at org.apache.hadoop.hive.service.HiveServer$HiveServerHandler.execute(HiveServer.java:198)
    at org.apache.hadoop.hive.service.ThriftHive$Processor$execute.getResult(ThriftHive.java:646)
    at org.apache.hadoop.hive.service.ThriftHive$Processor$execute.getResult(ThriftHive.java:630)
    at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
    at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
    at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:225)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Job Submission failed with exception 'java.lang.IllegalArgumentException(Does not contain a valid host:port authority: ${dse.job.tracker})'
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
</code>```

Any thoughts on what i should try?
Thanks ahead of time for any thoughts and or suggestions/assistance you all can provide.
Cheers,
Eric

答:
```<code><configuration>
<property>
  <name>mapreduce.framework.name</name>
   <value>yarn</value>
 </property>
<property>
 <name>mapreduce.jobhistory.address</name>
 <value>localhost:10020</value>
</property>
<property>
 <name>mapreduce.jobtracker.address</name>
 <value>local</value>
</property>
<property>
 <name>mapreduce.jobtracker.http.address</name>
 <value>localhost:50030</value>
</property>
<property>
 <name>mapreduce.jobhhistory.webapp.address</name>
 <value>localhost:19888</value>
</property>

</configuration>
</code>```

Body:
Just got a single node cluster up and running with the new datastax 4.0.
Works great. We use hive to build and query our data.
On the server it self. I can start hive
$>dse hive
and query tables just fine.
When I try and use the newest Hive ODBC driver to run the same query I seeing this error.
It connects just fine, i can query the keyspace and see the tables. but when i try to run the query. Looks like the map/red gets in the queue, but then errors out with the following.

Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Estimated from input data size: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapred.reduce.tasks=<number>
java.lang.IllegalArgumentException: Does not contain a valid host:port authority: ${dse.job.tracker}
    at org.apache.hadoop.net.NetUtils.createSocketAddr(NetUtils.java:147)
    at org.apache.hadoop.net.NetUtils.createSocketAddr(NetUtils.java:128)
    at org.apache.hadoop.mapred.JobTracker.getAddress(JobTracker.java:2584)
    at org.apache.hadoop.mapred.JobClient.init(JobClient.java:474)
    at org.apache.hadoop.mapred.JobClient.<init>(JobClient.java:457)
    at org.apache.hadoop.hive.ql.exec.mr.ExecDriver.execute(ExecDriver.java:402)
    at org.apache.hadoop.hive.ql.exec.mr.MapRedTask.execute(MapRedTask.java:144)
    at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:151)
    at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:65)
    at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1414)
    at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1192)
    at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1020)
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:888)
    at org.apache.hadoop.hive.service.HiveServer$HiveServerHandler.execute(HiveServer.java:198)
    at org.apache.hadoop.hive.service.ThriftHive$Processor$execute.getResult(ThriftHive.java:646)
    at org.apache.hadoop.hive.service.ThriftHive$Processor$execute.getResult(ThriftHive.java:630)
    at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
    at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
    at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:225)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Job Submission failed with exception 'java.lang.IllegalArgumentException(Does not contain a valid host:port authority: ${dse.job.tracker})'
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

Any thoughts on what i should try?
Thanks ahead of time for any thoughts and or suggestions/assistance you all can provide.
Cheers,
Eric


来源: stackexchange

问:
border-left height in css
I have a fiddle and I am trying to copy as it is as shown in this image. At this moment, I am able to put borders across an image but for some reasons I am not able to increase the height of border-left. I am pretty sure it will done through CSS selectors but not sure how. The CSS which I have used to put the borders across an image is:</p>

```<code>.helmet-image1
{
position: relative;
left: 20px;
border-left: 2px solid rgb(254, 91, 31);
border-right: 2px solid rgb(254, 91, 31);
border-top: 2px solid rgb(254, 91, 31);
}
</code>```

答:
If you wrap the image in an element, you can use borders on the parent and pseudo elements of that parent element to fake a border that is a different height than the parent/image.

You can use bottom to control the height, or replace bottom with height and use something like height: calc(100% + 100px);

div
{
position: relative;
left: 20px;
border-right: 2px solid rgb(254, 91, 31);
border-top: 2px solid rgb(254, 91, 31);
display: inline-block;
}

img {
  vertical-align: top;
}

div {
  position: relative;
}

div::after{
  position: absolute;
  top: 0; left: 0; bottom: -100px;
  width: 2px;
  background: rgb(254,91,31);
  content: '';
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
<img class="helmet-image1" src="https://s24.postimg.org/m3yekb9n9/i_Stock-
516143705.png">
</div></code>```

ContentLicense: CC BY-SA 3.0

Title: border-left height in css

Body:
I have a fiddle and I am trying to copy as it is as shown in this image. At this moment, I am able to put borders across an image but for some reasons I am not able to increase the height of border-left. I am pretty sure it will done through CSS selectors but not sure how. The CSS which I have used to put the borders across an image is:

.helmet-image1
{
position: relative;
left: 20px;
border-left: 2px solid rgb(254, 91, 31);
border-right: 2px solid rgb(254, 91, 31);
border-top: 2px solid rgb(254, 91, 31);
}

Body:
If you wrap the image in an element, you can use borders on the parent and pseudo elements of that parent element to fake a border that is a different height than the parent/image.

You can use bottom to control the height, or replace bottom with height and use something like height: calc(100% + 100px);

div
{
position: relative;
left: 20px;
border-right: 2px solid rgb(254, 91, 31);
border-top: 2px solid rgb(254, 91, 31);
display: inline-block;
}

img {
  vertical-align: top;
}

div {
  position: relative;
}

div::after{
  position: absolute;
  top: 0; left: 0; bottom: -100px;
  width: 2px;
  background: rgb(254,91,31);
  content: '';
}

<div>
<img class="helmet-image1" src="https://s24.postimg.org/m3yekb9n9/i_Stock-
516143705.png">
</div>


问:
openCV mac OSX suggested webcam
Does anyone have a recommendation for a web cam to be used on a mac with opencv?

Thank you!

答: While OpenCV will work with essentially any USB webcam, there is a great deal of variety in image quality. I have personally had excellent luck with the PS3 Eye Cam in Ubuntu after removing the casing. Even though it is only $25-50, it can run up to 125 Hz and is less susceptible to motion blur. I am not sure how the open source Mac OS X drivers compare to the Linux drivers, but it is worth consideration.</p>

ContentLicense: CC BY-SA 2.5

Title: openCV mac OSX suggested webcam


问:
AWS reuse IP's in several security groups
I have several IP's and I want add access from exactly those IP's to some security groups.
Is there way to declare the IP's once and reuse them in security groups instead of declare those IP's on each security group?</p>

答:
There is no way to do an "include" in a security group, including a list of rules by reference.

However, by default, each instance can be a member of up to five security groups, so one common solution is to make each instance a member of two security groups -- one for common rules, and another for rules that are more specific and not shared across all the instances.

Note that it is possible to use a security group ID instead of an IP address in a security group rule, but this has nothing to do with the rules in the referenced group -- it is not an "include."  An inbound rule listing a security group ID allows inbound traffic from instances that are members of the listed group. It does not cause a security group to follow any of the rules in the other group.


问:
replace alphabets
I would like to replace the letters by their order number in the alphabet</p>

答:
```<code>import string

import pandas as pd

new_vals = {c: ord(c)-96 for c in string.ascii_lowercase}

df = pd.DataFrame({'Values': ['aaa', 'abc', 'def']})

df['Values_new'] = [''.join(str(new_vals[c]) for c in row) for row in df['Values']]
</code>```

df is now:

```<code>>>> df
  Values Values_new
0    aaa        111
1    abc        123
2    def        456
</code>```

Then you can go in and add your what-seems-like-decimal notation, although the logic there seems a little unclear to me (you have a comma listed above):

```<code>df['Values_new'] = [v[0] + '.' + v[1:] for v in df['Values_new']]
</code>```

Result:

```<code>>>> df
  Values Values_new
0    aaa       1.11
1    abc       1.23
2    def       4.56
</code>```

Title: replace alphabets

Body:
import string

import pandas as pd

new_vals = {c: ord(c)-96 for c in string.ascii_lowercase}

df = pd.DataFrame({'Values': ['aaa', 'abc', 'def']})

df['Values_new'] = [''.join(str(new_vals[c]) for c in row) for row in df['Values']]

df is now:

>>> df
  Values Values_new
0    aaa        111
1    abc        123
2    def        456

Then you can go in and add your what-seems-like-decimal notation, although the logic there seems a little unclear to me (you have a comma listed above):

df['Values_new'] = [v[0] + '.' + v[1:] for v in df['Values_new']]

Result:

>>> df
  Values Values_new
0    aaa       1.11
1    abc       1.23
2    def       4.56


问:
How many variables are too much for a class?
I want to see if anyone has a better design for a class (class as in OOP) I am writing. We have a script that puts shared folder stats in a CSV file. I am reading that in and putting it in a Share class.

My boss wants to know information like:

Total Number of Files

Total Size of Files

Number of Office Files

Size of Office Files

Number of Exe Files

Size of Exe Files

etc ....

I have a class with variables like $numOfficeFiles, $sizeOfficeFiles, etc. with a ton of get/set methods. Isn't there a better way to do this? What is the general rule if you have a class with a lot of variables/properties?

I think of this as a language agnostic question, but if it matters, I am using PHP.

答:
Just from what I glanced at:

If you keep an array with all of the file names in it, all of those variables can be computed on the fly.

OwnerDisplayName: Ben

LastEditorDisplayName: mmyers


问:
List of most occurrences of element
I have a list let's say {1,1,2,2,3,3,3,4,4,4}. I want to find a List of the elements that occur the most often (it has to be a list as there can be a situation like here that 3 and 4 occur most and I need to get that information. How can I achieve this using LINQ?</p>

答:
First you will have to group the numbers followed by ordering them so you will get the most frequently occurring number on the top.

```<code>int[] numbers = { 1, 1, 2, 2, 3, 3, 3, 4, 4, 4 };
var groups = numbers.GroupBy(i => i).OrderByDescending(g => g.Count());

foreach (var group in groups)
{
      // group.Key -> Represents the number in the list
}
</code>```

The groups variable will contain all the groups formed from the numbers list ordered by their occurrence, meaning the first group will be the top most occurring group followed by the next. In case of same occurrences, the groups will be ordered by their occurrence in the list for example 3 & 4 have equal occurrences whereas 3 comes first before 4 and hence the group formation will be in same order.

Title: List of most occurrences of element

Body:
First you will have to group the numbers followed by ordering them so you will get the most frequently occurring number on the top.

int[] numbers = { 1, 1, 2, 2, 3, 3, 3, 4, 4, 4 };
var groups = numbers.GroupBy(i => i).OrderByDescending(g => g.Count());

foreach (var group in groups)
{
      // group.Key -> Represents the number in the list
}

The groups variable will contain all the groups formed from the numbers list ordered by their occurrence, meaning the first group will be the top most occurring group followed by the next. In case of same occurrences, the groups will be ordered by their occurrence in the list for example 3 & 4 have equal occurrences whereas 3 comes first before 4 and hence the group formation will be in same order.


问:
How do I kick out of a running program?
How do I assign a variable to the ESC. key so that when it is pressed the program is shutdown?
I am doing a calculator and the only way that I have seen is doing it directly like:

```<code>Scanner console = new Scanner(System.in);
int x = 1;
while(x==1)
{...
System.out.println("Enter in -1 to exit program");
x = nextInt();
}
</code>```

I don't know if it is possible to assign, per say a -1 to the escape key. Let me know if you have any ideas? It would be astronomically appreciated. ;-) ... :-)

答:
It's a long time when i used a good library, so if you can use JNativeHook library you can easily solve this problem.

Here is an example :

```<code>import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;

public class TestEscKey implements NativeKeyListener{

    @Override
    public void nativeKeyPressed(NativeKeyEvent nke) {
        if(NativeKeyEvent.getKeyText(nke.getKeyCode()).equals("Echap")){
            System.out.println("I will exit!");
            System.exit(0);
        }else{
           //do another thing
        }
    }

    @Override
    public void nativeKeyReleased(NativeKeyEvent nke) {
    }

    @Override
    public void nativeKeyTyped(NativeKeyEvent nke) {
    }

    public static void main(String[] args) throws NativeHookException {
        try {

            GlobalScreen.registerNativeHook();
        } catch (NativeHookException ex) {
            System.out.println("There was a problem registering the native hook.\n"
                                + ex.getMessage());
            System.exit(1);
        }
        GlobalScreen.getInstance().addNativeKeyListener(new TestEscKey());
    }
}
</code>```

Title: How do I kick out of a running program?

Body:
How do I assign a variable to the ESC. key so that when it is pressed the program is shutdown?
I am doing a calculator and the only way that I have seen is doing it directly like:

Scanner console = new Scanner(System.in);
int x = 1;
while(x==1)
{...
System.out.println("Enter in -1 to exit program");
x = nextInt();
}

I don't know if it is possible to assign, per say a -1 to the escape key. Let me know if you have any ideas? It would be astronomically appreciated. ;-) ... :-)

Body:
It's a long time when i used a good library, so if you can use JNativeHook library you can easily solve this problem.

Here is an example :

import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;

public class TestEscKey implements NativeKeyListener{

    @Override
    public void nativeKeyPressed(NativeKeyEvent nke) {
        if(NativeKeyEvent.getKeyText(nke.getKeyCode()).equals("Echap")){
            System.out.println("I will exit!");
            System.exit(0);
        }else{
           //do another thing
        }
    }

    @Override
    public void nativeKeyReleased(NativeKeyEvent nke) {
    }

    @Override
    public void nativeKeyTyped(NativeKeyEvent nke) {
    }

    public static void main(String[] args) throws NativeHookException {
        try {

            GlobalScreen.registerNativeHook();
        } catch (NativeHookException ex) {
            System.out.println("There was a problem registering the native hook.\n"
                                + ex.getMessage());
            System.exit(1);
        }
        GlobalScreen.getInstance().addNativeKeyListener(new TestEscKey());
    }
}


问:
How to restrict access to some public websites
I am new to cloud computing. Sorry if this is a silly question. I have created a VM from azure portal. My requirement is not to allow the user using the VM to access public website. Can anyone help me how to achieve this functionality?

Thanks

答:
You probably have a Network Security Group that was created when you created the VM. In there you can specify rules for inbound and outbound data traffic.

Find the NSG and add a rule that blocks all outbound traffic from the VM. You should still be able to connect to the VM, it just can't connect anywhere. You can also make the rule only block traffic bound to the internet if you still wish for it to have access to other machines in the same virtual network.

Network Security Groups documentation: https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-nsg

ContentLicense: CC BY-SA 4.0


问:
How to optimize eloquent query which has a foreign key
I have two tables Tags and Admin , my tags table looks like the following:

And my admin table looks like the following:

The tag field in the admin table is a foreign key, and it references the ID in the tags table. What i wanted to do is , pull up the records in the admin table with a specific tag, now ofcourse the tag in the admin table references the id in the tags table.

So i have written the below query to retrieve the articles from the admin table , that have a specific tag(eg. Javascript).

```<code>public function showTagListing($tag) {
        $tagId = DB::table('tags')->where('tag', $tag)->first();
        $tagBlogList = DB::table('admin')->where('tag', $tagId->id )->orderBy('created_at' , 'desc')->get();
        return view('pages.taglisting', compact('tagBlogList', $tagBlogList));
    }
</code>```

I think i have written a few extra unneeded lines of code here for retrieving the article records , how can i make the code in one line ? How can i optimize these lines of code ?

答:
You could add some trickery to derive the $tag through dependency injection and resolve it by another column other than the primary key by adding some logic to the boot method of your RouteServiceProvider

```<code>Route::bind('tag', function ($value) {
    if (is_int($value)) {
        return App\Tag::findOrFail($value);
    } else {
        return App\Tag::where('tag', $value)->firstOrFail();
    }
});
</code>```

Then you can change your route so that it expects a tag instance, regardless of primary key integer or a tag string:

```<code>//no idea how your route looks, but the important part is {tag}
Route::get('/show-tag-listing/{tag}', 'TagController@showTagListing');
</code>```

Finally, update your function to resolve the tag through Dependency Injection:

```<code>public function showTagListing(App\Tag $tag) {
</code>```

Now you no longer need the $tagId =, you can just use $tag->id later.

You can also make sure you have your relationships established in the model files. Because you have the tag_id on the admin table, the $tag will have many admin records, and the admin will haveOne tag, like this:

```<code>// App\Tag class

public function admins()
{
     return $this->hasMany('App\Admin');
}

// App\Admin class

public function tag()
{
     return $this->belongsTo('App\Tag');
}
</code>```

Now instead of doing:

```<code>$tagBlogList = DB::table('admin')->where('tag', $tagId->id )->orderBy('created_at' , 'desc')->get();
</code>```

You can do:

```<code>$tagBlogList = $tag->admins()->orderBy('created_at', 'desc')->get();
</code>```

Body:
I have two tables Tags and Admin , my tags table looks like the following:

And my admin table looks like the following:

The tag field in the admin table is a foreign key, and it references the ID in the tags table. What i wanted to do is , pull up the records in the admin table with a specific tag, now ofcourse the tag in the admin table references the id in the tags table.

So i have written the below query to retrieve the articles from the admin table , that have a specific tag(eg. Javascript).

public function showTagListing($tag) {
        $tagId = DB::table('tags')->where('tag', $tag)->first();
        $tagBlogList = DB::table('admin')->where('tag', $tagId->id )->orderBy('created_at' , 'desc')->get();
        return view('pages.taglisting', compact('tagBlogList', $tagBlogList));
    }

I think i have written a few extra unneeded lines of code here for retrieving the article records , how can i make the code in one line ? How can i optimize these lines of code ?

Body:
You could add some trickery to derive the $tag through dependency injection and resolve it by another column other than the primary key by adding some logic to the boot method of your RouteServiceProvider

Route::bind('tag', function ($value) {
    if (is_int($value)) {
        return App\Tag::findOrFail($value);
    } else {
        return App\Tag::where('tag', $value)->firstOrFail();
    }
});

Then you can change your route so that it expects a tag instance, regardless of primary key integer or a tag string:

//no idea how your route looks, but the important part is {tag}
Route::get('/show-tag-listing/{tag}', 'TagController@showTagListing');

Finally, update your function to resolve the tag through Dependency Injection:

public function showTagListing(App\Tag $tag) {

Now you no longer need the $tagId =, you can just use $tag->id later.

You can also make sure you have your relationships established in the model files. Because you have the tag_id on the admin table, the $tag will have many admin records, and the admin will haveOne tag, like this:

// App\Tag class

public function admins()
{
     return $this->hasMany('App\Admin');
}

// App\Admin class

public function tag()
{
     return $this->belongsTo('App\Tag');
}

Now instead of doing:

$tagBlogList = DB::table('admin')->where('tag', $tagId->id )->orderBy('created_at' , 'desc')->get();

You can do:

$tagBlogList = $tag->admins()->orderBy('created_at', 'desc')->get();


问:
If Java is truly platform independent, why is there no one-for-all clearConsoleOutput libraryMethod?
I wanted to write an application for windows/mac/linux and I chose java because a java developer friend told me Java is platform independent.

I came to a problem where I wanted to clear the console (to make the reading easier on the user).

I've tried System.out.flush(); and Runtime.getRuntime().exec("cls");.

It seems the only real solution is to use a hack (and smelly code is bad) - Java: Clear the console (check "Dyndrilliac" answer).

The reason using this hack is bad, as other users have commented on "Dyndrilliac" answer, what happens when Microsoft or Apple changes the command name from "cls" or "clear" to something different? It pretty much breaks your application and you get an error (such as "command not recognized") from the OS Company.

So my question is: did Java decide not to implement a library that handles clearing console outputs due to keeping it up to date whenever Windows/Macs/Linux decides to change it's command names? Or did Java implement a library for handling this, and I just can't find it?

答: Java is independent in the way that it's not run directly on your OS. java run on jvm (java virtual machine) and because of that it should work the same in all OS. But the console that you print to it's the specific OS console and therefore, every OS will have it's own clear console command (because it's not the same console). You can build program with UI (using swing or other library) And control your output, or use some technics like in the post you linked to, it should work fine. </p>


问:
Regex to find a string between two special known characters
I'm trying to parse messages transmited over TCP for my own network protocol using regex without success.

My commands start with ! followed by COMMAND_NAME and a list of arguments in the format or ARGUMENT_NAME=ARGUMENT_VALUE enclosed in <>

for example:

```<code>!LOGIN?<USERNAME='user'><PASSWORD='password'>;
</code>```

my code :

```<code>public class CommandParser
{
    private Dictionary<string, string> arguments = new Dictionary<string, string>();

    public CommandParser(string input)
    {
        Match commandMatch = Regex.Match(input, @"\!([^)]*)\&");

        if (commandMatch.Success)
        {
            CommandName = commandMatch.Groups[1].Value;
        }

        // Here we call Regex.Match.
        MatchCollection matches = Regex.Matches(input,"(?<!\\S)<([a-z0-9]+)=(\'[a-z0-9]+\')>(?!\\S)",
            RegexOptions.IgnoreCase);

        //
        foreach (Match argumentMatch in matches)
        {
            arguments.Add(
                argumentMatch.Groups[1].Value,
                argumentMatch.Groups[2].Value);
        }
    }

    public string CommandName { get; set; }

    public Dictionary<string, string> Arguments
    {
        get { return arguments; }
    }

    /// <summary>
    ///
    /// </summary>
    public int ArgumentCount
    {
        get { return arguments.Count; }
    }
}
</code>```

答:
You do not need regex here and avoid them unless that's a last option left. You could do this with simple C# logic.

```<code>string input = "!LOGIN?<USERNAME='user'><PASSWORD='password'>";
string command = input.Substring(1, input.IndexOf('?') - 1);
Console.WriteLine($"command: {command}");
var parameters = input
                    .Replace($"!{command}?", string.Empty)
                    .Replace("<", "")
                    .Split(">".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

string[] kvpair;
foreach(var kv in parameters) {
    kvpair = kv.Split('=');
    Console.WriteLine($"pname: {kvpair[0]}, pvalue: {kvpair[1]}");
}
</code>```

Output:

```<code>command: LOGIN
pname: USERNAME, pvalue: 'user'
pname: PASSWORD, pvalue: 'password'
</code>```

Body:
I'm trying to parse messages transmited over TCP for my own network protocol using regex without success.

My commands start with ! followed by COMMAND_NAME and a list of arguments in the format or ARGUMENT_NAME=ARGUMENT_VALUE enclosed in <>

for example:

!LOGIN?<USERNAME='user'><PASSWORD='password'>;

my code :

public class CommandParser
{
    private Dictionary<string, string> arguments = new Dictionary<string, string>();

    public CommandParser(string input)
    {
        Match commandMatch = Regex.Match(input, @"\!([^)]*)\&");

        if (commandMatch.Success)
        {
            CommandName = commandMatch.Groups[1].Value;
        }

        // Here we call Regex.Match.
        MatchCollection matches = Regex.Matches(input,"(?<!\\S)<([a-z0-9]+)=(\'[a-z0-9]+\')>(?!\\S)",
            RegexOptions.IgnoreCase);

        //
        foreach (Match argumentMatch in matches)
        {
            arguments.Add(
                argumentMatch.Groups[1].Value,
                argumentMatch.Groups[2].Value);
        }
    }

    public string CommandName { get; set; }

    public Dictionary<string, string> Arguments
    {
        get { return arguments; }
    }

    ///
    ///
    ///
    public int ArgumentCount
    {
        get { return arguments.Count; }
    }
}

Body:
You do not need regex here and avoid them unless that's a last option left. You could do this with simple C# logic.

string input = "!LOGIN?<USERNAME='user'><PASSWORD='password'>";
string command = input.Substring(1, input.IndexOf('?') - 1);
Console.WriteLine($"command: {command}");
var parameters = input
                    .Replace($"!{command}?", string.Empty)
                    .Replace("<", "")
                    .Split(">".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

string[] kvpair;
foreach(var kv in parameters) {
    kvpair = kv.Split('=');
    Console.WriteLine($"pname: {kvpair[0]}, pvalue: {kvpair[1]}");
}

Output:

command: LOGIN
pname: USERNAME, pvalue: 'user'
pname: PASSWORD, pvalue: 'password'


问:
Laravel migration and PostgreSQL schemas
I'm using PostgreSQL and want to try Laravel.

First - my up() function:

```<code>public function up()
{
    Schema::create('entries.entries', function($t) {

        $t->increments('id');
        $t->string('username', 50);
        $t->string('email', 100);
        $t->text('comment');
        $t->timestamps();
    });
}
</code>```

And i have two questions:

1) I haven't shema entries in my database, so, how can i change my up function to create it too? I dont want to do it manually.

2) I got an error when executed migration:

```<code> sudo php artisan migrate

 [Illuminate\Database\QueryException]
     SQLSTATE[3F000]: Invalid schema name: 7 ERROR:  no schema has been selected
     to create in (SQL: create table "emigrations" ("migration" varchar(255) not null,
     "batch" integer not null))
</code>```

How can i fix it?

答:
Well i know that this question has more than 2 year's... but for the future people that reaches this. Laravel does not recognize the default 'public' schema of postgres by default and that's why you get the:

[Illuminate\Database\QueryException]

     SQLSTATE[3F000]: Invalid schema name: 7 ERROR:  no schema has been selected

     to create in (SQL: create table "emigrations" ("migration" varchar(255) not null,
     "batch" integer not null))

Thus to solve this error you just rename your Schema in postgres to anything besides public and, in your laravel project in the file config/database.php change the name of your pgsql conection schema to the one you want to use in your DB.

This should solve it.

It did for me anyways...

Body:
I'm using PostgreSQL and want to try Laravel.

First - my up() function:

public function up()
{
    Schema::create('entries.entries', function($t) {

        $t->increments('id');
        $t->string('username', 50);
        $t->string('email', 100);
        $t->text('comment');
        $t->timestamps();
    });
}

And i have two questions:

1) I haven't shema entries in my database, so, how can i change my up function to create it too? I dont want to do it manually.

2) I got an error when executed migration:

 sudo php artisan migrate

 [Illuminate\Database\QueryException]
     SQLSTATE[3F000]: Invalid schema name: 7 ERROR:  no schema has been selected
     to create in (SQL: create table "emigrations" ("migration" varchar(255) not null,
     "batch" integer not null))

How can i fix it?


问:
Parsing data from json in C#
I successfully got data to var content
The code how I did it:

```<code>public async void FetchAsync()
{
    var client = new RestClient("http://api.locopal.com");
    var request = new RestRequest("/countries", Method.POST);
    var response = client.Execute(request);
    var content = response.Content;
    var responseCountries = JArray.Parse(JObject.Parse(content)[""].ToString());
}
</code>```

But in line: var responseCountries = JArray.Parse(JObject.Parse(content)[""].ToString()); I got An unhandled exception occured.
This is the data from var content:

Countries from here need to be write down to list.

答:
You should deserialize the JSON into an object. You can create a POCO object with the properties from the JSON.

Example:

```<code>public class Country
{
    [JsonProperty("id")]
    public int Id { get; set; }

    [JsonProperty("nicename")]
    public string Name { get; set; }
}
</code>```

Edit: Follow same casing as in JSON

Title: Parsing data from json in C#

Body:
I successfully got data to var content
The code how I did it:

public async void FetchAsync()
{
    var client = new RestClient("http://api.locopal.com");
    var request = new RestRequest("/countries", Method.POST);
    var response = client.Execute(request);
    var content = response.Content;
    var responseCountries = JArray.Parse(JObject.Parse(content)[""].ToString());
}

But in line: var responseCountries = JArray.Parse(JObject.Parse(content)[""].ToString()); I got An unhandled exception occured.
This is the data from var content:

Countries from here need to be write down to list.

Body:
You should deserialize the JSON into an object. You can create a POCO object with the properties from the JSON.

Example:

public class Country
{
    [JsonProperty("id")]
    public int Id { get; set; }

    [JsonProperty("nicename")]
    public string Name { get; set; }
}

Edit: Follow same casing as in JSON


问:
Classificaion with fitcsvm in matlab produces an error
I had tried the following code

```<code>clear all;close all;
data =  [27 9   2
11.6723281  28.93422177 2
25  9   2
23  8   2
5.896096039 23.97745722 1
21  6   2
21.16823369 5.292058423 2
4.242640687 13.43502884 1
22  6   2];
Attributes = data(:,1:2);
Classes = data(:,3);
train = [1 3 4 5 6 7];
testInds = [2 8 9];
test1 = data(testInds,1:2);
YTest =data(testInds,3);
%%# Train
svmStruct = svmtrain(Attributes(train,:),Classes(train),'ShowPlot',true);

 SVMModel = fitcsvm(Attributes(train,:),Classes(train))
 classOrder = SVMModel.ClassNames
sv = SVMModel.SupportVectors;
figure
gscatter(data(:,1),data(:,2),Classes)
hold on
plot(sv(:,1), sv(:,2),'ko','MarkerSize',10)
legend('good','bad','Support Vector')
hold off
[label,score] = predict(SVMModel,test1);
% [predict_label, accuracy, prob_estimates] = predict(SVMModel,test1)
table(YTest(1:2),label(1:2),score(1:10,2),'VariableNames',...
    {'TrueLabel','PredictedLabel','Score'})
</code>```

I tried the above code. First two column are my data and last column is the group id. SVMModel is the classification. I'm getting error as

Index exceeds matrix dimensions.

Error in Untitled (line 34)
table(YTest(1:2),label(1:2),score(1:10,2),'VariableNames',...
I tried to test an instance. But both statements produces an error

```<code>[label,score] = predict(SVMModel,test);
 label           = svmclassify(SVMModel, test);
</code>```

答:
You simply flipped predictors and labels - it is fitcsvm(predictors,labels), or in your case fitcsvm(Attributes(train,:),Classes(train))

edit:

```<code>plot(sv(:,1), sv(:,2),'ko','MarkerSize',10) % you obviously do not want to plot the same data twice in the same plot...
</code>```

For the prediction: [predict_label, accuracy, prob_estimates] = svmpredict(Classes(test), Attributes(test,:), SVMModel); looks fine.

Body:
I had tried the following code

clear all;close all;
data =  [27 9   2
11.6723281  28.93422177 2
25  9   2
23  8   2
5.896096039 23.97745722 1
21  6   2
21.16823369 5.292058423 2
4.242640687 13.43502884 1
22  6   2];
Attributes = data(:,1:2);
Classes = data(:,3);
train = [1 3 4 5 6 7];
testInds = [2 8 9];
test1 = data(testInds,1:2);
YTest =data(testInds,3);
%%# Train
svmStruct = svmtrain(Attributes(train,:),Classes(train),'ShowPlot',true);

 SVMModel = fitcsvm(Attributes(train,:),Classes(train))
 classOrder = SVMModel.ClassNames
sv = SVMModel.SupportVectors;
figure
gscatter(data(:,1),data(:,2),Classes)
hold on
plot(sv(:,1), sv(:,2),'ko','MarkerSize',10)
legend('good','bad','Support Vector')
hold off
[label,score] = predict(SVMModel,test1);
% [predict_label, accuracy, prob_estimates] = predict(SVMModel,test1)
table(YTest(1:2),label(1:2),score(1:10,2),'VariableNames',...
    {'TrueLabel','PredictedLabel','Score'})

I tried the above code. First two column are my data and last column is the group id. SVMModel is the classification. I'm getting error as

Index exceeds matrix dimensions.

Error in Untitled (line 34)
table(YTest(1:2),label(1:2),score(1:10,2),'VariableNames',...
I tried to test an instance. But both statements produces an error

[label,score] = predict(SVMModel,test);
 label           = svmclassify(SVMModel, test);

Body:
You simply flipped predictors and labels - it is fitcsvm(predictors,labels), or in your case fitcsvm(Attributes(train,:),Classes(train))

edit:

plot(sv(:,1), sv(:,2),'ko','MarkerSize',10) % you obviously do not want to plot the same data twice in the same plot...

For the prediction: [predict_label, accuracy, prob_estimates] = svmpredict(Classes(test), Attributes(test,:), SVMModel); looks fine.


答:
```<code>public function showTagListing($tag)
{
    $tagBlogList = DB::table('admin')
        ->join('tags', 'tags.id', '=', 'admin.tag')
        ->where('tags.tag', $tag)
        ->latest()
        ->select('admin.*')
        ->get();

    return view('pages.taglisting', compact('tagBlogList'));
}
</code>```

If you want to go the Eloquent way then you can do this. Create the appropriate model with relationship.

```<code>public function showTagListing($tag)
{
    $tagBlogList = Admin::whereHas('tags', function ($query) use($tag) {
            $query->where('tag', $tag);
        })
        ->latest()
        ->get();

    return view('pages.taglisting', compact('tagBlogList'));
}
</code>```

Title: How to optimize eloquent query which has a foreign key

Body:
public function showTagListing($tag)
{
    $tagBlogList = DB::table('admin')
        ->join('tags', 'tags.id', '=', 'admin.tag')
        ->where('tags.tag', $tag)
        ->latest()
        ->select('admin.*')
        ->get();

    return view('pages.taglisting', compact('tagBlogList'));
}

If you want to go the Eloquent way then you can do this. Create the appropriate model with relationship.

public function showTagListing($tag)
{
    $tagBlogList = Admin::whereHas('tags', function ($query) use($tag) {
            $query->where('tag', $tag);
        })
        ->latest()
        ->get();

    return view('pages.taglisting', compact('tagBlogList'));
}


问:
How to store PHP CURL cookies internally and pass them to another curl request?
Hello Stackoverflow community,

I have a really annoying issue with PHP CURL cookies that I have been trying to solve for months with no success.

I have two CURL functions that run subsequently to login a user to an external site and then get a page from that site, which contains useful data.

Here's the login function:

```<code>function login($url, $data) {
  $login = curl_init();
  curl_setopt($login, CURLOPT_COOKIEJAR, 'cookies_' . session_id() . '.txt');
  curl_setopt($login, CURLOPT_TIMEOUT, 30000);
  curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($login, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($login, CURLOPT_URL, $url);
  curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
  curl_setopt($login, CURLOPT_POST, TRUE);
  curl_setopt($login, CURLOPT_POSTFIELDS, $data);
  $content = curl_exec ($login);
  curl_close ($login);
  unset($login);
  unset($data);
  return $content;
}
</code>```

And the data fetching function which uses the cookie file generated by the login function to identify that the user has logged in:

```<code>function grab_data($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies_' . session_id() . '.txt');
  curl_setopt($ch, CURLOPT_TIMEOUT, 30000);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  $content = curl_exec($ch);
  curl_close($ch);
  unset($ch);
  unset($data);
  return $content;
}
</code>```

Now, onto the problem. The login function works fine, but the problem is that it has to save the cookies that external site generates to a file on the server. If a lot of users are logging that puts a lot of load on the server, is impractical and is a security hole because it saves personal user cookies to a file on the server, which is widely accessible. The cookies are very important because they contain session information and are required for the data fetching function to get the user data from the external site. So, I want to somehow store the personal user cookies internally, perhaps in a PHP variable but I have a hard time achieving that. I have already tried methods suggested in this question, which suggest setting CURLOPT_HEADER to true and then using preg_match to extract the cookies from header but I had no luck because:

If I disable CURLOPT_COOKIEJAR in the login function, the login fails.

If I set CURLOPT_COOKIEJAR to something like '-', login works, but then I have problem in the data fetching function because I don't know how to pass the extracted cookies to the data fetching function (I tried many methods and nothing worked except the CURLOPT_COOKIEFILE variant.

Can anyone give me a working solution for storing cookies internally and the passing them to another request? If it is not possible to do that with CURL, can you suggest another approach to acomplish this?

Thanks is advance. It is a really long post but I wanted to include as much information as I could, so you can better understand my needs.

答:
The easiest way is:

to store cookie-files in separate directory

set permission chmod('path/to/dir', 0600);

2nd way - if you use apache you can deny access this way

Body:
Hello Stackoverflow community,

I have a really annoying issue with PHP CURL cookies that I have been trying to solve for months with no success.

I have two CURL functions that run subsequently to login a user to an external site and then get a page from that site, which contains useful data.

Here's the login function:

function login($url, $data) {
  $login = curl_init();
  curl_setopt($login, CURLOPT_COOKIEJAR, 'cookies_' . session_id() . '.txt');
  curl_setopt($login, CURLOPT_TIMEOUT, 30000);
  curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($login, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($login, CURLOPT_URL, $url);
  curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
  curl_setopt($login, CURLOPT_POST, TRUE);
  curl_setopt($login, CURLOPT_POSTFIELDS, $data);
  $content = curl_exec ($login);
  curl_close ($login);
  unset($login);
  unset($data);
  return $content;
}

And the data fetching function which uses the cookie file generated by the login function to identify that the user has logged in:

function grab_data($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies_' . session_id() . '.txt');
  curl_setopt($ch, CURLOPT_TIMEOUT, 30000);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  $content = curl_exec($ch);
  curl_close($ch);
  unset($ch);
  unset($data);
  return $content;
}

Now, onto the problem. The login function works fine, but the problem is that it has to save the cookies that external site generates to a file on the server. If a lot of users are logging that puts a lot of load on the server, is impractical and is a security hole because it saves personal user cookies to a file on the server, which is widely accessible. The cookies are very important because they contain session information and are required for the data fetching function to get the user data from the external site. So, I want to somehow store the personal user cookies internally, perhaps in a PHP variable but I have a hard time achieving that. I have already tried methods suggested in this question, which suggest setting CURLOPT_HEADER to true and then using preg_match to extract the cookies from header but I had no luck because:

If I disable CURLOPT_COOKIEJAR in the login function, the login fails.

If I set CURLOPT_COOKIEJAR to something like '-', login works, but then I have problem in the data fetching function because I don't know how to pass the extracted cookies to the data fetching function (I tried many methods and nothing worked except the CURLOPT_COOKIEFILE variant.

Can anyone give me a working solution for storing cookies internally and the passing them to another request? If it is not possible to do that with CURL, can you suggest another approach to acomplish this?

Thanks is advance. It is a really long post but I wanted to include as much information as I could, so you can better understand my needs.


Title: How to use Splot for data in gnuplot

Body:
I am from Brazil, so my english is terrible.. I am a begginer in gnuplot and I've been trying to plot a surface. I have a x, y, z data, like points in a 3D space: Points_3D

I understood that i have to grid the data, and i tried to use splot in this way:

set dgrid3d 11, 7

splot 'abs.txt' u 1:2:3 with lines title 'abs'

As you can see, I don't have a lot of point (only 8x12), then the surface plotted is like this: Surface, but this is not the kind of surface I want, because it is not getting all the point, and i would like a softened surface, without this peaks.

I tried to use othes values at "set dgrid3d", but it didn't work. Does anyone know what i should do?

In an other data i have a lot of values in y and only a few values in x, like 8x100, what should i do in this case also??

My data is something like:

       2  0.250000000      0.33333334326744080

       2  0.500000000      0.33333334326744080

       2   1.00000000      0.33333334326744080

       2   2.00000000      0.33333334326744080

       2   4.00000000      0.33333331346511841

       2   8.00000000      0.33333328366279602

       2   16.0000000      0.33333316445350647

       2   32.0000000      0.33333286643028259

       2   64.0000000      0.33333197236061096

       2   128.000000      0.33332949876785278

       2   256.000000      0.33332267403602600

       2   512.000000      0.33330380916595459

       3  0.250000000       8.3333335816860199E-002

       3  0.500000000       8.3333335816860199E-002

       3   1.00000000       8.3333335816860199E-002

       3   2.00000000       8.3333328366279602E-002

       3   4.00000000       8.3333313465118408E-002

       3   8.00000000       8.3333276212215424E-002

       3   16.0000000       8.3333164453506470E-002

       3   32.0000000       8.3332858979701996E-002

       3   64.0000000       8.3331987261772156E-002

       3   128.000000       8.3329580724239349E-002

       3   256.000000       8.3322964608669281E-002

       3   512.000000       8.3304964005947113E-002

       4   0.250000000      3.3333335071802139E-002

       and continues...

Body:
Add a blank line at the end of every row. like this:

   2  0.250000000      0.33333334326744080
   2  0.500000000      0.33333334326744080
   2   1.00000000      0.33333334326744080
   2   2.00000000      0.33333334326744080
   2   4.00000000      0.33333331346511841
   2   8.00000000      0.33333328366279602
   2   16.0000000      0.33333316445350647
   2   32.0000000      0.33333286643028259
   2   64.0000000      0.33333197236061096
   2   128.000000      0.33332949876785278
   2   256.000000      0.33332267403602600
   2   512.000000      0.33330380916595459

   3  0.250000000       8.3333335816860199E-002
   3  0.500000000       8.3333335816860199E-002
   3   1.00000000       8.3333335816860199E-002
   3   2.00000000       8.3333328366279602E-002
   3   4.00000000       8.3333313465118408E-002
   3   8.00000000       8.3333276212215424E-002
   3   16.0000000       8.3333164453506470E-002
   3   32.0000000       8.3332858979701996E-002
   3   64.0000000       8.3331987261772156E-002
   3   128.000000       8.3329580724239349E-002
   3   256.000000       8.3322964608669281E-002
   3   512.000000       8.3304964005947113E-002

   4   0.250000000      3.3333335071802139E-002
.........

then plot it:

splot "abs.txt" u 1:2:3 w pm3d


答:
Unfortunately, you can't.

ESC can't be read by the Scanner. You are supposed to use a key listener by a UI library (for instance, Swing). Have a look at "How to write a key listener?".

In this case, you should ask for a number from a user which is a key of the loop break (like you actually did).

Title: How do I kick out of a running program?


问:
Angular 1.6: Data not showing until scope function execute
Title might sound a bit strange but that's how it is.

Code:

```<code>angular.module('app')

.controller('TenantsCtrl', ['$scope', 'tenantsService','$window','loginService', function ($scope, tenantsService, $window, loginService) {
    $scope.mode = "list";
    $scope.g = [];
    $scope.editTenant = {
      firstName: "",
      lastName: "",
      room: "",
      to: "",
      from: ""
    }
    tenantsService.get().then((data) => {
        data.tenants.map((tenant) => {
          tenant.to = new Date(tenant.to).toLocaleDateString('ro-RO')
          tenant.from = new Date(tenant.from).toLocaleDateString('ro-RO')
        });
        console.log(typeof data.tenants);
        $scope.g = data.tenants;
        console.log($scope.g)
      }).catch((reason) => {
        loginService.doLogout();
        if(confirm(`${reason}. Please login`)) {
          $window.location.href="#!/login";
        }
      })
  $scope.showTenantForm = function(tenant) {
    console.log($scope.g)
  }

 }]);
</code>```

View:

```<code><div class="page-header">
    <h1>Cazati <button class="btn btn-xs btn-primary" ng-click="showTenantForm()">Cazeaza</button></h1>
</div>
<div class="row"  ng-cloak>
    {{g}}
    <table class="table table-hover">
        <thead>
            <tr>
                <th>Nume</th>
                <th>Camera</th>
                <th>Cazat din</th>
                <th>Cazat pana la</th>
                <th>Cazat de</th>
                <!--<th>Status</th>-->
                <th>Modifica</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="x in g">
                <td>{{x.lastName}} {{x.firstName}}</td>
                <td>{{x.room}}</td>
                <td>{{x.to}}</td>
                <td>{{x.from}}</td>
                <td></td>
                <td>
                    <button type="button" ng-click="editTenant(tenant.id)" class="btn btn-danger btn-xs">Modifica</button>
                </td>
            </tr>
        </tbody>
    </table>
</div>
</code>```

Problem: data from table isn't shown. Strangely it gets shown only when press the button from header and the function gets called.

Data from service comes correctly.

Update: tenantsService

```<code>angular.module('app')
.service('graphQLService', ['baseUrl', 'loginService', function (baseUrl, loginService) {
  var graphQLService = {};
  graphQLService.sendQuery = function (query, vars) {
    var self = this;
    vars = vars || {};
    return new Promise(function(resolve, reject) {
      // use fetch to get the result
      fetch(baseUrl + '/gql', {
        method: 'post',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          query,
          vars,
          authToken: loginService.getToken()
        })
      })

      .then(function(response) {
        var status = response.status;
        if(status != 401) {
          return response.json().then((res) => {
            resolve(res.data);
          })
        } else {
          reject(response.statusText);
        }
        if(response.status == 401) {

        }
      })
      .catch(reject);
    });
  };
  return graphQLService;
}]);
</code>```

答:
Add a $scope.$apply() after you get your response and you manipulate your data, and after that you assign your data to your g scope variable. So:

```<code>$scope.g = data.tenants;
$scope.$apply();
</code>```

AngularJS already wraps a lot of its code inside the $scope.$apply method. This in order to trigger the $scope.$digest method, which is the one responsible for refreshing all the bindings inside the related scope and update the values and so the views.
For example, if you were using the custom $http service, it's executed inside the $scope.$apply, so you don't need to call it explicitly.
In your case, you are not using the standard $http, so you need to trigger it manually.

The code was working after calling the other function because the ng-click is wrapped inside the $apply as well, so it refreshes all the bindings in the scope.

If you want to read more about it, this is a pretty good article:

http://jimhoskins.com/2012/12/17/angularjs-and-apply.html

I hope it helps

Body:
Title might sound a bit strange but that's how it is.

Code:

angular.module('app')

.controller('TenantsCtrl', ['$scope', 'tenantsService','$window','loginService', function ($scope, tenantsService, $window, loginService) {
    $scope.mode = "list";
    $scope.g = [];
    $scope.editTenant = {
      firstName: "",
      lastName: "",
      room: "",
      to: "",
      from: ""
    }
    tenantsService.get().then((data) => {
        data.tenants.map((tenant) => {
          tenant.to = new Date(tenant.to).toLocaleDateString('ro-RO')
          tenant.from = new Date(tenant.from).toLocaleDateString('ro-RO')
        });
        console.log(typeof data.tenants);
        $scope.g = data.tenants;
        console.log($scope.g)
      }).catch((reason) => {
        loginService.doLogout();
        if(confirm(`${reason}. Please login`)) {
          $window.location.href="#!/login";
        }
      })
  $scope.showTenantForm = function(tenant) {
    console.log($scope.g)
  }

 }]);

View:

Cazati <button class="btn btn-xs btn-primary" ng-click="showTenantForm()">Cazeaza</button>

    {{g}}

                Nume
                Camera
                Cazat din
                Cazat pana la
                Cazat de

                Modifica

                {{x.lastName}} {{x.firstName}}
                {{x.room}}
                {{x.to}}
                {{x.from}}

                    <button type="button" ng-click="editTenant(tenant.id)" class="btn btn-danger btn-xs">Modifica</button>

Problem: data from table isn't shown. Strangely it gets shown only when press the button from header and the function gets called.

Data from service comes correctly.

Update: tenantsService

angular.module('app')
.service('graphQLService', ['baseUrl', 'loginService', function (baseUrl, loginService) {
  var graphQLService = {};
  graphQLService.sendQuery = function (query, vars) {
    var self = this;
    vars = vars || {};
    return new Promise(function(resolve, reject) {
      // use fetch to get the result
      fetch(baseUrl + '/gql', {
        method: 'post',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          query,
          vars,
          authToken: loginService.getToken()
        })
      })

      .then(function(response) {
        var status = response.status;
        if(status != 401) {
          return response.json().then((res) => {
            resolve(res.data);
          })
        } else {
          reject(response.statusText);
        }
        if(response.status == 401) {

        }
      })
      .catch(reject);
    });
  };
  return graphQLService;
}]);

Body:
Add a $scope.$apply() after you get your response and you manipulate your data, and after that you assign your data to your g scope variable. So:

$scope.g = data.tenants;
$scope.$apply();

AngularJS already wraps a lot of its code inside the $scope.$apply method. This in order to trigger the $scope.$digest method, which is the one responsible for refreshing all the bindings inside the related scope and update the values and so the views.
For example, if you were using the custom $http service, it's executed inside the $scope.$apply, so you don't need to call it explicitly.
In your case, you are not using the standard $http, so you need to trigger it manually.

The code was working after calling the other function because the ng-click is wrapped inside the $apply as well, so it refreshes all the bindings in the scope.

If you want to read more about it, this is a pretty good article:

http://jimhoskins.com/2012/12/17/angularjs-and-apply.html

I hope it helps


问:
Getting values in double array from index. Swift
I have a collection view made up of 4 sections.

Each section is an array of strings, like this:

```<code>var picList: [String] = ["Bird", "Cat", "Cow", "Dog", "Duck", "Elephant", "Fish", "Giraffe", "Lion", "Mouse", "Sheep", "Snake" ]

var vehiclesList: [String] = ["Airplane", "Ambulance", "Boat", "Bus", "Car", "Fire_Engine", "Helicopter", "Motorcycle", "Tank", "Tractor", "Train", "Truck" ]

var fruitsList: [String] = ["Apple", "Banana", "Grapes", "Mango", "Orange", "Peach", "Pineapple", "Strawberry", "Watermelon" ]

var bodyPartsList: [String] = ["Arm", "Ear", "Eye", "Face", "Feet", "Hand", "Hair", "Legs", "Mouth", "Nose" ]
</code>```

I created a UITapGestureRecognizer for the cell, that when I click on the cell, I get the index.

Here is the tapMethod

```<code>func handleTap(sender: UITapGestureRecognizer) {
        print("tap")

        if let indexPath = self.collectionView?.indexPathForItem(at: sender.location(in: self.collectionView)) {

            let cell = collectionView?.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! PicViewCell

            print("index path: + \(indexPath)")

        } else {
            print("")
        }

    }
</code>```

Now the index prints like this [0,0] (if I press on the first item, ie bird). [2,4] if I press on the 4th item in the 2nd secion (ie mango). But I don't know how to translate the index, to get the corresponding string value. I mean something like this:

var itemName: String = [2,4] (and itemName would be mango)

I'm new to swift, so any help would be great.

Thanks so much.

答:
What you need is an array of arrays, aka a 2D array - [[String]].

```<code>var array = [picList, vehicleList, fruitsList, bodyPartsList]
</code>```

Then, you can access this with 2 indices like this:

```<code>var itemName = array[2][4]
</code>```

Body:
I have a collection view made up of 4 sections.

Each section is an array of strings, like this:

var picList: [String] = ["Bird", "Cat", "Cow", "Dog", "Duck", "Elephant", "Fish", "Giraffe", "Lion", "Mouse", "Sheep", "Snake" ]

var vehiclesList: [String] = ["Airplane", "Ambulance", "Boat", "Bus", "Car", "Fire_Engine", "Helicopter", "Motorcycle", "Tank", "Tractor", "Train", "Truck" ]

var fruitsList: [String] = ["Apple", "Banana", "Grapes", "Mango", "Orange", "Peach", "Pineapple", "Strawberry", "Watermelon" ]

var bodyPartsList: [String] = ["Arm", "Ear", "Eye", "Face", "Feet", "Hand", "Hair", "Legs", "Mouth", "Nose" ]

I created a UITapGestureRecognizer for the cell, that when I click on the cell, I get the index.

Here is the tapMethod

func handleTap(sender: UITapGestureRecognizer) {
        print("tap")

        if let indexPath = self.collectionView?.indexPathForItem(at: sender.location(in: self.collectionView)) {

            let cell = collectionView?.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! PicViewCell

            print("index path: + \(indexPath)")

        } else {
            print("")
        }

    }

Now the index prints like this [0,0] (if I press on the first item, ie bird). [2,4] if I press on the 4th item in the 2nd secion (ie mango). But I don't know how to translate the index, to get the corresponding string value. I mean something like this:

var itemName: String = [2,4] (and itemName would be mango)

I'm new to swift, so any help would be great.

Thanks so much.

Body:
What you need is an array of arrays, aka a 2D array - [[String]].

var array = [picList, vehicleList, fruitsList, bodyPartsList]

Then, you can access this with 2 indices like this:

var itemName = array[2][4]


问:
is there a developer api for pandora on android?
I was looking around but couldnt find one, was wondering if anybody knows of such an api?
basically I want to be able to switch songs and play songs on pandora from my application on android.</p>

答:
There is.

https://6xq.net/pandora-apidoc/

But I've read that Pandora changes it up sometimes to discourage people from writing their own (probably ad-free) clients, so there's no guarantee that it will last.


问:
border-left height in css
I have a fiddle and I am trying to copy as it is as shown in this image. At this moment, I am able to put borders across an image but for some reasons I am not able to increase the height of border-left. I am pretty sure it will done through CSS selectors but not sure how. The CSS which I have used to put the borders across an image is:</p>

```<code>.helmet-image1
{
position: relative;
left: 20px;
border-left: 2px solid rgb(254, 91, 31);
border-right: 2px solid rgb(254, 91, 31);
border-top: 2px solid rgb(254, 91, 31);
}
</code>```

答:
You could solve this by putting a container outside your image, and setting the container height.</p>

```<code>.container {
  border-left: 2px solid rgb(254, 91, 31);
  border-right: 2px solid rgb(254, 91, 31);
  border-top: 2px solid rgb(254, 91, 31);
  height: 400px;
  display: inline-block;
}
.helmet-image1
{
  position: relative;
  left: 20px;
}

<div class="container">
    <img class="helmet-image1"
    src="https://s24.postimg.org/m3yekb9n9/i_Stock-516143705.png">
</div>
</code>```

Title: border-left height in css

Body:
I have a fiddle and I am trying to copy as it is as shown in this image. At this moment, I am able to put borders across an image but for some reasons I am not able to increase the height of border-left. I am pretty sure it will done through CSS selectors but not sure how. The CSS which I have used to put the borders across an image is:

.helmet-image1
{
position: relative;
left: 20px;
border-left: 2px solid rgb(254, 91, 31);
border-right: 2px solid rgb(254, 91, 31);
border-top: 2px solid rgb(254, 91, 31);
}

Body:
You could solve this by putting a container outside your image, and setting the container height.

.container {
  border-left: 2px solid rgb(254, 91, 31);
  border-right: 2px solid rgb(254, 91, 31);
  border-top: 2px solid rgb(254, 91, 31);
  height: 400px;
  display: inline-block;
}
.helmet-image1
{
  position: relative;
  left: 20px;
}

<div class="container">
    <img class="helmet-image1"
    src="https://s24.postimg.org/m3yekb9n9/i_Stock-516143705.png">
</div>


答:
You could declare a class like the following

```<code>public class Country
{
    [JsonProperty("id")]
    public int Id { get; set; }

    [JsonProperty("nicename")]
    public string Name { get; set; }
}
</code>```

and then deserialize the json as below:

```<code>var responseCountries = JsonConvert.DeserializeObject<IEnumerable<Country>>(content);
</code>```

Title: Parsing data from json in C#

Body:
You could declare a class like the following

public class Country
{
    [JsonProperty("id")]
    public int Id { get; set; }

    [JsonProperty("nicename")]
    public string Name { get; set; }
}

and then deserialize the json as below:

var responseCountries = JsonConvert.DeserializeObject<IEnumerable<Country>>(content);


问:
CSS: display element without rescaling of a "table"
I am trying to display an element into my table after a click of an image without resizing this element. But obviously the row size is bigger it.

var lastelementmenu;
    var event_cache_site = document.querySelector('.event_cache_site');
    var properties = document.querySelectorAll(".event_list_view_properties_click");//3 points
    for(var i= 0 ;i<properties.length;i++){
        //evenement au click
        properties[i].addEventListener('click',function(e){
            var div = this.nextElementSibling;
            lastelementmenu = div;
            div.style.display = "block";
            event_cache_site.style.display = "block";
        });
    }
    event_cache_site.addEventListener('click', () => {
        lastelementmenu.style.display = "none";
        event_cache_site.style.display = "none";
    });```
<pre class="snippet-code-css lang-css prettyprint-override"><code>*{
    font-size:16px;
      box-sizing: border-box;
}
html{
    font-size:50%;
    background-color: #f5f5f5;
}
.event_list_view{

    width: 150rem;
    margin: 5rem auto;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    font-size: 1.5rem;
}
.event_list_view tbody{
    background-color: #fff;
}
.event_list_view thead tr{
    border-bottom: 0px solid rgba(0,0,0,0.54);
    box-shadow: 0 -1px 0 rgba(0,0,0,0.12) inset;

}
.event_list_view_array{
    width: 100%;
    border-collapse: collapse;
}
.event_list_view_cell{
    padding: 3rem 2rem;
}
.event_list_view_array thead{
    /*background-color: #f5f5f5;*/
     background-color: transparent;
}
.event_list_view_array thead th{
    color: rgba(0,0,0,0.54);
    font-weight: normal;
    font-family: Roboto,"Helvetica Neue",sans-serif
}
.event_list_view_new{
    background: rgb(3, 155, 229);
    float: right;
    margin : 1rem ;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.event_list_view_new p{
    padding: 0rem 1rem;
}
.event_list_view_new a{
    text-decoration: none;
    color: #FFF;

}
.event_list_view_legend{
    padding: 1rem 2rem;
    text-align: left;
}
.event_list_view_properties{
    background-color: #fff;
    display: none;
    z-index: 17;
    position: relative;
    top: -5rem;
    padding: 0rem 1rem;
    left: -7rem;
    width: 10rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

}
.event_list_view_properties ul {
    list-style-type: none;
    margin: 0rem 0rem;
    padding: 0rem;
}
.event_list_view_properties li {
    padding: 0.5rem 0rem;
}
.event_list_view_properties a {
    text-decoration: none;
    color: rgba(0,0,0,0.5);
    margin: 1rem 0rem;
}
.event_list_view_properties_bg{/*
    background-image: url(../images/icon/properties.svg);
    width: 10rem;
    height: 5rem;*/
}
.event_cache_site{
    z-index: 14;
    position: fixed;
    top: 0;
    bottom:0;
    left: 0;
    right: 0;
    background: none;
}</code>```

NOUVEL EVENEMENT

Titre

Contenu

Date

Groupe

  <col span="1" style="width: 15%;">
  <col span="1" style="width: 60%;">
  <col span="1" style="width: 15%;">
  <col span="1" style="width: 5%;">
  <col span="1" style="width: 5%;">';

 title0

content0

2017-05-11 11:00:00

A

Modifier

supprimer

 title1

content1

2017-05-11 11:00:00

A

Modifier

supprimer

 title2

content2

2017-05-11 11:00:00

A

Modifier

supprimer

```

After clicking
How can I solve it ?
Thanks

答:
Use position: absolute on that instead, and add position: relative to the td parent. You may need to adjust your top and left/right to move the menu where you want.

var lastelementmenu;
    var event_cache_site = document.querySelector('.event_cache_site');
    var properties = document.querySelectorAll(".event_list_view_properties_click");//3 points
    for(var i= 0 ;i<properties.length;i++){
        //evenement au click
        properties[i].addEventListener('click',function(e){
            var div = this.nextElementSibling;
            lastelementmenu = div;
            div.style.display = "block";
            event_cache_site.style.display = "block";
        });
    }
    event_cache_site.addEventListener('click', () => {
        lastelementmenu.style.display = "none";
        event_cache_site.style.display = "none";
    });```
<pre class="snippet-code-css lang-css prettyprint-override"><code>*{
    font-size:16px;
      box-sizing: border-box;
}
html{
    font-size:50%;
    background-color: #f5f5f5;
}
.event_list_view{

    width: 150rem;
    margin: 5rem auto;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    font-size: 1.5rem;
}
.event_list_view tbody{
    background-color: #fff;
}
.event_list_view thead tr{
    border-bottom: 0px solid rgba(0,0,0,0.54);
    box-shadow: 0 -1px 0 rgba(0,0,0,0.12) inset;

}
.event_list_view_array{
    width: 100%;
    border-collapse: collapse;
}
.event_list_view_cell{
    padding: 3rem 2rem;
}
.event_list_view_array thead{
    /*background-color: #f5f5f5;*/
     background-color: transparent;
}
.event_list_view_array thead th{
    color: rgba(0,0,0,0.54);
    font-weight: normal;
    font-family: Roboto,"Helvetica Neue",sans-serif
}
.event_list_view_new{
    background: rgb(3, 155, 229);
    float: right;
    margin : 1rem ;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.event_list_view_new p{
    padding: 0rem 1rem;
}
.event_list_view_new a{
    text-decoration: none;
    color: #FFF;

}
.event_list_view_legend{
    padding: 1rem 2rem;
    text-align: left;
}
.event_list_view_properties{
    background-color: #fff;
    display: none;
    z-index: 17;
    position: absolute;
    top: 50%;
    padding: 0rem 1rem;
    right: 70%;
    width: 10rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

}
.event_list_view_properties ul {
    list-style-type: none;
    margin: 0rem 0rem;
    padding: 0rem;
}
.event_list_view_properties li {
    padding: 0.5rem 0rem;
}
.event_list_view_properties a {
    text-decoration: none;
    color: rgba(0,0,0,0.5);
    margin: 1rem 0rem;
}
.event_list_view_properties_bg{/*
    background-image: url(../images/icon/properties.svg);
    width: 10rem;
    height: 5rem;*/
}
.event_cache_site{
    z-index: 14;
    position: fixed;
    top: 0;
    bottom:0;
    left: 0;
    right: 0;
    background: none;
}

td {
  position: relative;
}</code>```

NOUVEL EVENEMENT

Titre

Contenu

Date

Groupe

  <col span="1" style="width: 15%;">
  <col span="1" style="width: 60%;">
  <col span="1" style="width: 15%;">
  <col span="1" style="width: 5%;">
  <col span="1" style="width: 5%;">';

 title0

content0

2017-05-11 11:00:00

A

Modifier

supprimer

 title1

content1

2017-05-11 11:00:00

A

Modifier

supprimer

 title2

content2

2017-05-11 11:00:00

A

Modifier

supprimer

```

Body:
I am trying to display an element into my table after a click of an image without resizing this element. But obviously the row size is bigger it.

var lastelementmenu;
    var event_cache_site = document.querySelector('.event_cache_site');
    var properties = document.querySelectorAll(".event_list_view_properties_click");//3 points
    for(var i= 0 ;i<properties.length;i++){
        //evenement au click
        properties[i].addEventListener('click',function(e){
            var div = this.nextElementSibling;
            lastelementmenu = div;
            div.style.display = "block";
            event_cache_site.style.display = "block";
        });
    }
    event_cache_site.addEventListener('click', () => {
        lastelementmenu.style.display = "none";
        event_cache_site.style.display = "none";
    });

*{
    font-size:16px;
      box-sizing: border-box;
}
html{
    font-size:50%;
    background-color: #f5f5f5;
}
.event_list_view{

    width: 150rem;
    margin: 5rem auto;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    font-size: 1.5rem;
}
.event_list_view tbody{
    background-color: #fff;
}
.event_list_view thead tr{
    border-bottom: 0px solid rgba(0,0,0,0.54);
    box-shadow: 0 -1px 0 rgba(0,0,0,0.12) inset;

}
.event_list_view_array{
    width: 100%;
    border-collapse: collapse;
}
.event_list_view_cell{
    padding: 3rem 2rem;
}
.event_list_view_array thead{
    /*background-color: #f5f5f5;*/
     background-color: transparent;
}
.event_list_view_array thead th{
    color: rgba(0,0,0,0.54);
    font-weight: normal;
    font-family: Roboto,"Helvetica Neue",sans-serif
}
.event_list_view_new{
    background: rgb(3, 155, 229);
    float: right;
    margin : 1rem ;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.event_list_view_new p{
    padding: 0rem 1rem;
}
.event_list_view_new a{
    text-decoration: none;
    color: #FFF;

}
.event_list_view_legend{
    padding: 1rem 2rem;
    text-align: left;
}
.event_list_view_properties{
    background-color: #fff;
    display: none;
    z-index: 17;
    position: relative;
    top: -5rem;
    padding: 0rem 1rem;
    left: -7rem;
    width: 10rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

}
.event_list_view_properties ul {
    list-style-type: none;
    margin: 0rem 0rem;
    padding: 0rem;
}
.event_list_view_properties li {
    padding: 0.5rem 0rem;
}
.event_list_view_properties a {
    text-decoration: none;
    color: rgba(0,0,0,0.5);
    margin: 1rem 0rem;
}
.event_list_view_properties_bg{/*
    background-image: url(../images/icon/properties.svg);
    width: 10rem;
    height: 5rem;*/
}
.event_cache_site{
    z-index: 14;
    position: fixed;
    top: 0;
    bottom:0;
    left: 0;
    right: 0;
    background: none;
}

NOUVEL EVENEMENT

Titre

Contenu

Date

Groupe

  <col span="1" style="width: 15%;">
  <col span="1" style="width: 60%;">
  <col span="1" style="width: 15%;">
  <col span="1" style="width: 5%;">
  <col span="1" style="width: 5%;">';

 title0

content0

2017-05-11 11:00:00

A

Modifier

supprimer

 title1

content1

2017-05-11 11:00:00

A

Modifier

supprimer

 title2

content2

2017-05-11 11:00:00

A

Modifier

supprimer

After clicking
How can I solve it ?
Thanks

Body:
Use position: absolute on that instead, and add position: relative to the td parent. You may need to adjust your top and left/right to move the menu where you want.

var lastelementmenu;
    var event_cache_site = document.querySelector('.event_cache_site');
    var properties = document.querySelectorAll(".event_list_view_properties_click");//3 points
    for(var i= 0 ;i<properties.length;i++){
        //evenement au click
        properties[i].addEventListener('click',function(e){
            var div = this.nextElementSibling;
            lastelementmenu = div;
            div.style.display = "block";
            event_cache_site.style.display = "block";
        });
    }
    event_cache_site.addEventListener('click', () => {
        lastelementmenu.style.display = "none";
        event_cache_site.style.display = "none";
    });

*{
    font-size:16px;
      box-sizing: border-box;
}
html{
    font-size:50%;
    background-color: #f5f5f5;
}
.event_list_view{

    width: 150rem;
    margin: 5rem auto;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    font-size: 1.5rem;
}
.event_list_view tbody{
    background-color: #fff;
}
.event_list_view thead tr{
    border-bottom: 0px solid rgba(0,0,0,0.54);
    box-shadow: 0 -1px 0 rgba(0,0,0,0.12) inset;

}
.event_list_view_array{
    width: 100%;
    border-collapse: collapse;
}
.event_list_view_cell{
    padding: 3rem 2rem;
}
.event_list_view_array thead{
    /*background-color: #f5f5f5;*/
     background-color: transparent;
}
.event_list_view_array thead th{
    color: rgba(0,0,0,0.54);
    font-weight: normal;
    font-family: Roboto,"Helvetica Neue",sans-serif
}
.event_list_view_new{
    background: rgb(3, 155, 229);
    float: right;
    margin : 1rem ;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.event_list_view_new p{
    padding: 0rem 1rem;
}
.event_list_view_new a{
    text-decoration: none;
    color: #FFF;

}
.event_list_view_legend{
    padding: 1rem 2rem;
    text-align: left;
}
.event_list_view_properties{
    background-color: #fff;
    display: none;
    z-index: 17;
    position: absolute;
    top: 50%;
    padding: 0rem 1rem;
    right: 70%;
    width: 10rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

}
.event_list_view_properties ul {
    list-style-type: none;
    margin: 0rem 0rem;
    padding: 0rem;
}
.event_list_view_properties li {
    padding: 0.5rem 0rem;
}
.event_list_view_properties a {
    text-decoration: none;
    color: rgba(0,0,0,0.5);
    margin: 1rem 0rem;
}
.event_list_view_properties_bg{/*
    background-image: url(../images/icon/properties.svg);
    width: 10rem;
    height: 5rem;*/
}
.event_cache_site{
    z-index: 14;
    position: fixed;
    top: 0;
    bottom:0;
    left: 0;
    right: 0;
    background: none;
}

td {
  position: relative;
}

<html>
<table class="event_list_view_array">
 <thead>
  <tr>
   <th colspan="5"><div class="event_list_view_new"><a href="?state=new"><p >NOUVEL EVENEMENT</p></a></div></th>
  <tr>
  <tr>
   <th><div class="event_list_view_legend">Titre</div></th>
   <th><div class="event_list_view_legend">Contenu</div></th>
   <th><div class="event_list_view_legend">Date</div></th>
   <th><div class="event_list_view_legend">Groupe</div></th>
   <th><div class="event_list_view_legend"></div></th>
  </tr>
 </thead>
 <tbody>
  <col span="1" style="width: 15%;">
  <col span="1" style="width: 60%;">
  <col span="1" style="width: 15%;">
  <col span="1" style="width: 5%;">
  <col span="1" style="width: 5%;">';
   <tr>
   <td><div class="event_list_view_cell"> title0 </div></td>
   <td><div class="event_list_view_cell">content0</div></td>
   <td><div class="event_list_view_cell">2017-05-11 11:00:00</div></td>
   <td><div class="event_list_view_cell">A</div></td>
   <td>
    <div class="event_list_view_cell event_list_view_properties_click" >
     <img src="images/icon/properties.svg" alt="properties">
    </div>
    <div class="event_list_view_cell event_list_view_properties">
     <ul>
      <li><a href="#">Modifier</a></li>
      <li><a href="#">supprimer</a></li>
     </ul>
    </div>
   </td>
  </tr>
  <tr>
   <td><div class="event_list_view_cell"> title1 </div></td>
   <td><div class="event_list_view_cell">content1</div></td>
   <td><div class="event_list_view_cell">2017-05-11 11:00:00</div></td>
   <td><div class="event_list_view_cell">A</div></td>
   <td>
    <div class="event_list_view_cell event_list_view_properties_click" >
     <img src="images/icon/properties.svg" alt="properties">
    </div>
    <div class="event_list_view_cell event_list_view_properties">
     <ul>
      <li><a href="#">Modifier</a></li>
      <li><a href="#">supprimer</a></li>
     </ul>
    </div>
   </td>
  </tr>
  <tr>
   <td><div class="event_list_view_cell"> title2 </div></td>
   <td><div class="event_list_view_cell">content2</div></td>
   <td><div class="event_list_view_cell">2017-05-11 11:00:00</div></td>
   <td><div class="event_list_view_cell">A</div></td>
   <td>
    <div class="event_list_view_cell event_list_view_properties_click" >
     <img src="images/icon/properties.svg" alt="properties">
    </div>
    <div class="event_list_view_cell event_list_view_properties">
     <ul>
      <li><a href="#">Modifier</a></li>
      <li><a href="#">supprimer</a></li>
     </ul>
    </div>
   </td>
  </tr>
 </tbody>
</table>
<div class="event_cache_site" style="display:none;"></div>
</html>


问:
How to search for specific maven plugin
How can I find maven plugin ? e.g I am searching findbugs-maven-plugin in https://mvnrepository.com/ but this will search for dependencies:

```<code><dependency>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>3.0.4</version>
</dependency>
</code>```

I am searching for:

```<code> <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>3.0.5-SNAPSHOT</version>
      </plugin>
    </plugins>
</code>```

答:
You can find it in the following link:

https://oss.sonatype.org/content/repositories/snapshots/org/codehaus/mojo/findbugs-maven-plugin/3.0.5-SNAPSHOT/

Enjoy!

Title: How to search for specific maven plugin

Body:
How can I find maven plugin ? e.g I am searching findbugs-maven-plugin in https://mvnrepository.com/ but this will search for dependencies:

<dependency>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>3.0.4</version>
</dependency>

I am searching for:

 <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>3.0.5-SNAPSHOT</version>
      </plugin>
    </plugins>


问:
DotNetOpenAuth Issue with Yahoo!
I use OpenID authentication and all of the providers have been tested and work fine when running the website from Visual Studio. I have deployed the website to the server and the Google and myOpenID work just fine but Yahoo! OpenID provider just throws this error...

The OpenID Provider issued an
  assertion for an Identifier whose
  discovery information did not match.
  Assertion endpoint info:
  ClaimedIdentifier:
  https://me.yahoo.com/a/KyzgPcp9v8xRcWxFNKx357hQTxZ9P7Udww8bPkpv3oNSoogH0IXw#11950
  ProviderLocalIdentifier:
  https://me.yahoo.com/a/KyzgPcp9v8xRcWxFNKx357hQTxZ9P7Udww8bPkpv3oNSoogH0IXw
  ProviderEndpoint:
  https://open.login.yahooapis.com/openid/op/auth
  OpenID version: 2.0 Service Type URIs:
  Discovered endpoint info: [{
  ClaimedIdentifier:
  http://specs.openid.net/auth/2.0/identifier_select
  ProviderLocalIdentifier:
  http://specs.openid.net/auth/2.0/identifier_select
  ProviderEndpoint:
  https://open.login.yahooapis.com/openid/op/auth
  OpenID version: 2.0 Service Type URIs:
  http://specs.openid.net/auth/2.0/server
  http://specs.openid.net/extensions/pape/1.0
  http://openid.net/srv/ax/1.0
  http://specs.openid.net/extensions/oauth/1.0
  http://specs.openid.net/extensions/ui/1.0/lang-pref
  http://specs.openid.net/extensions/ui/1.0/mode/popup
  http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier
  http://www.idmanagement.gov/schema/2009/05/icam/no-pii.pdf
  http://www.idmanagement.gov/schema/2009/05/icam/openid-trust-level1.pdf
  http://csrc.nist.gov/publications/nistpubs/800-63/SP800-63V1_0_2.pdf
  },]

If anyone has any idea why this is happening I would really appreciate it. This only occurs on the server so I can't debug it easily.

Thank You.

答: This suggests that your RP is performing discovery on the original identifier ("yahoo.com") instead of the claimed identifier in the assertion.  Can you activate logging and include the entire surrounding log from the server in your question?</p>

Title: DotNetOpenAuth Issue with Yahoo!


问:
Gatekeeper Path Randomization for Developer signed DMG?
We are packaging our app for drag and drop installation DMG as following:

```<code>Application Name/Application.app
Application Name/Readme
Application Name/Examples/...
Application Name/Documentation/...
</code>```

And user is supposed to d&d Application Name Folder to /Applications/.
Everything is code signed including DMG.

From most information I read this should be enough to prevent app translocation happening, but for some reason it isn't for some of our Sierra users?

The solution for them would be beside d&d folder to /Applications is to do another drag & drop (move) Application.app somewhere and back to /Applications/Application Name/ or move only Application Name/Application.app overwriting /Applications/Application Name/Application.app.

Now the question is why do only some users have this issue, and shouldn't code signing dmg prevent app translocation from happening?

I verified they have selected Allow apps downloaded from Mac App Store and identified developers.

答:
I had this same problem on my side and had to go get some help via DTS, so I thought I'd repay the favor by replying here:

To avoid translocation, it turns out that not only is the disk image DMG supposed to be signed, but the file format for the image needs to be very specific: UDRO.

You can see more information about UDRO when you look at the man page for the hdiutil command line tool.

Body:
We are packaging our app for drag and drop installation DMG as following:

Application Name/Application.app
Application Name/Readme
Application Name/Examples/...
Application Name/Documentation/...

And user is supposed to d&d Application Name Folder to /Applications/.
Everything is code signed including DMG.

From most information I read this should be enough to prevent app translocation happening, but for some reason it isn't for some of our Sierra users?

The solution for them would be beside d&d folder to /Applications is to do another drag & drop (move) Application.app somewhere and back to /Applications/Application Name/ or move only Application Name/Application.app overwriting /Applications/Application Name/Application.app.

Now the question is why do only some users have this issue, and shouldn't code signing dmg prevent app translocation from happening?

I verified they have selected Allow apps downloaded from Mac App Store and identified developers.


问:
Create dynamic switchery
I want to create dynamic switchery and create and button object with jquery and some dynamic variable for this then I want the Html object to append to Html I can't do it below link is my code
Visit jsfiddle.net/eu3a0k3m/2/

my js codes:

```<code>var count = 3;
$("#btn").click(function(){
    CreateInlineChildWithSwitchery(++count);
});
function CreateInlineChildWithSwitchery (countOfChilds){

      var Integer_LastSwitcheryId = count;

      var btn = $('<input type="checkbox" id="js-switch' + Integer_LastSwitcheryId + '" class="js-switch' + Integer_LastSwitcheryId + ' js-check-change' + Integer_LastSwitcheryId + ' col-lg-3" data-switchery="true">');
console.log(btn)
$('#all-encyclopedia').append(
        $("#tpl ").html()
                                  .replace(/{switchery}/g,btn)
      );

      eval("elem" + Integer_LastSwitcheryId.toString() + "=document.querySelector('#js-switch"+Integer_LastSwitcheryId.toString()+"')");

      eval("switchery" + Integer_LastSwitcheryId.toString() +"={elem" + Integer_LastSwitcheryId.toString() + ",  color: '#1AB394',secondaryColor: '#688ab0'}");

      eval("changeCheckbox" + Integer_LastSwitcheryId.toString() + "=document.querySelector('.js-check-change"+Integer_LastSwitcheryId.toString()+"')");

      eval("changeField" + Integer_LastSwitcheryId.toString() + "=document.querySelector('.js-check-change-field"+Integer_LastSwitcheryId.toString()+"')");

  }

  for(i=1;i<4;i++)
      CreateInlineChildWithSwitchery(count++);
</code>```

my Html codes:

```<code><script type="text/tpl" id="tpl">
{switchery}
</script>
<button id="btn">insert Switchery</button>
<div id="all-encyclopedia"></div>
</code>```

答:
You don't need to use eval. just call the Switchery constructor after you inserted the checkbox into the page.

var count = 3;
$("#btn").click(function() {
  CreateInlineChildWithSwitchery(++count);
});

function CreateInlineChildWithSwitchery(id) {
  var btn = $('<input>').attr({
    id: 'js-switch' + id,
    type: 'checkbox',
    class: ['js-switch' + id, 'js-check-change' + id, 'col-lg3'].join(" "),
  }).data({
    switchery: true,
  })[0]

  $('#all-encyclopedia').append(
    $("#tpl").html().replace(/{switchery}/g, btn.outerHTML));

  new Switchery($('#' + 'js-switch' + id)[0], {
    color: '#1AB394',
    secondaryColor: '#688ab0'
  })
}

for (i = 1; i < 4; i++)
  CreateInlineChildWithSwitchery(count++);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/switchery/0.8.2/switchery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/switchery/0.8.2/switchery.min.css" rel="stylesheet"/>

<script type="text/tpl" id="tpl">
  {switchery}
</script>
<button id="btn">insert Switchery</button>
<div id="all-encyclopedia"></div></code>```

Title: Create dynamic switchery

Body:
I want to create dynamic switchery and create and button object with jquery and some dynamic variable for this then I want the Html object to append to Html I can't do it below link is my code
Visit jsfiddle.net/eu3a0k3m/2/

my js codes:

var count = 3;
$("#btn").click(function(){
    CreateInlineChildWithSwitchery(++count);
});
function CreateInlineChildWithSwitchery (countOfChilds){

      var Integer_LastSwitcheryId = count;

      var btn = $('<input type="checkbox" id="js-switch' + Integer_LastSwitcheryId + '" class="js-switch' + Integer_LastSwitcheryId + ' js-check-change' + Integer_LastSwitcheryId + ' col-lg-3" data-switchery="true">');
console.log(btn)
$('#all-encyclopedia').append(
        $("#tpl ").html()
                                  .replace(/{switchery}/g,btn)
      );

      eval("elem" + Integer_LastSwitcheryId.toString() + "=document.querySelector('#js-switch"+Integer_LastSwitcheryId.toString()+"')");

      eval("switchery" + Integer_LastSwitcheryId.toString() +"={elem" + Integer_LastSwitcheryId.toString() + ",  color: '#1AB394',secondaryColor: '#688ab0'}");

      eval("changeCheckbox" + Integer_LastSwitcheryId.toString() + "=document.querySelector('.js-check-change"+Integer_LastSwitcheryId.toString()+"')");

      eval("changeField" + Integer_LastSwitcheryId.toString() + "=document.querySelector('.js-check-change-field"+Integer_LastSwitcheryId.toString()+"')");

  }

  for(i=1;i<4;i++)
      CreateInlineChildWithSwitchery(count++);

my Html codes:

<button id="btn">insert Switchery</button>

Body:
You don't need to use eval. just call the Switchery constructor after you inserted the checkbox into the page.

var count = 3;
$("#btn").click(function() {
  CreateInlineChildWithSwitchery(++count);
});

function CreateInlineChildWithSwitchery(id) {
  var btn = $('<input>').attr({
    id: 'js-switch' + id,
    type: 'checkbox',
    class: ['js-switch' + id, 'js-check-change' + id, 'col-lg3'].join(" "),
  }).data({
    switchery: true,
  })[0]

  $('#all-encyclopedia').append(
    $("#tpl").html().replace(/{switchery}/g, btn.outerHTML));

  new Switchery($('#' + 'js-switch' + id)[0], {
    color: '#1AB394',
    secondaryColor: '#688ab0'
  })
}

for (i = 1; i < 4; i++)
  CreateInlineChildWithSwitchery(count++);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/switchery/0.8.2/switchery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/switchery/0.8.2/switchery.min.css" rel="stylesheet"/>

<script type="text/tpl" id="tpl">
  {switchery}
</script>
<button id="btn">insert Switchery</button>
<div id="all-encyclopedia"></div>


问:
NullPointerException when autowiring into non-spring managed class (POJO) - Spring Boot
I'm relatively new to Spring Boot and dependency injection overall, so please forgive any noob things going on here. I'm building an API and am having trouble when injecting dependencies into a POJO resource (DTO).

When I call the method in the POJO this.numComments = commentSvc.getAllForPhoto(this.getId()); I am getting a NullPointerException. However, when I do this from another spring-managed bean and pass the values into the constructor, it works fine.

After reading around, it looks like I need to do something with aspectJ and Load Time Weaving, but I'm not sure what that would look like in my code.

In essence, my approach looks something like this:

PhotoResource.java (POJO)

```<code>public class PhotoResource extends BaseRepresentable {

   @Autowired
   CommentService commentSvc;

   private Long id;
   private Integer numComments;

   PhotoResource(PhotoEntity entity){
   super(entity);
   this.setId(entity.getId);
   this.numComments = commentSvc.getAllForPhoto(this.getId());
   }
}
</code>```

CommentService.java

```<code>@Service
public class CommentService{
   public List<CommentResource> getAllForPhoto(Long photoId) {
   // code to get all comments for photo
   }
}
</code>```

Application.java

```<code>@SpringBootApplication
public class Application {
   public static void main(String[] args) {
      SpringApplication.run(Application.class);
   }
}
</code>```

答:
Spring won't inject the dependency unless you ask the Spring container to manage the bean. In order for commentSvc to be injected into PhotoResource class, you need to annotate it with @Component or @Bean or @Service, e.g.:

```<code>@Component
public class PhotoResource extends BaseRepresentable {
   @Autowired
   CommentService commentSvc;
}
</code>```

And make sure the package of this class is included into @ComponentScan packages.

Also, the following won't compile:

```<code>@Service
public class CommentService(){
</code>```

You don't need paranthesis to declare a class, it should be:

```<code>@Service
public class CommentService{
</code>```

Body:
I'm relatively new to Spring Boot and dependency injection overall, so please forgive any noob things going on here. I'm building an API and am having trouble when injecting dependencies into a POJO resource (DTO).

When I call the method in the POJO this.numComments = commentSvc.getAllForPhoto(this.getId()); I am getting a NullPointerException. However, when I do this from another spring-managed bean and pass the values into the constructor, it works fine.

After reading around, it looks like I need to do something with aspectJ and Load Time Weaving, but I'm not sure what that would look like in my code.

In essence, my approach looks something like this:

PhotoResource.java (POJO)

public class PhotoResource extends BaseRepresentable {

   @Autowired
   CommentService commentSvc;

   private Long id;
   private Integer numComments;

   PhotoResource(PhotoEntity entity){
   super(entity);
   this.setId(entity.getId);
   this.numComments = commentSvc.getAllForPhoto(this.getId());
   }
}

CommentService.java

@Service
public class CommentService{
   public List<CommentResource> getAllForPhoto(Long photoId) {
   // code to get all comments for photo
   }
}

Application.java

@SpringBootApplication
public class Application {
   public static void main(String[] args) {
      SpringApplication.run(Application.class);
   }
}

Body:
Spring won't inject the dependency unless you ask the Spring container to manage the bean. In order for commentSvc to be injected into PhotoResource class, you need to annotate it with @Component or @Bean or @Service, e.g.:

@Component
public class PhotoResource extends BaseRepresentable {
   @Autowired
   CommentService commentSvc;
}

And make sure the package of this class is included into @ComponentScan packages.

Also, the following won't compile:

@Service
public class CommentService(){

You don't need paranthesis to declare a class, it should be:

@Service
public class CommentService{


问:
System.Exception: Call to Node module failed with error: Error: URLs requested via Http on the server must be absolute

System.Exception: Call to Node module failed with error: Error: URLs
  requested via Http on the server must be absolute. URL:
  /Account/GetUser/

This error happens when calling http from Angular Universal. From the server, I have no access to the 'location' object.

Why is there a restriction in Angular preventing calling web services from a relative url?

How can I retrieve the host name without using 'location'?

答:
I fixed this by importing the following component...

import { Component, Inject } from '@angular/core';

I then construct my component e.g.

constructor(http: Http, @Inject('ORIGIN_URL')originUrl: string) {...

Then when I want to invoke my API I do this:

http.get(originUrl + 'YOUR API URI HERE').subscribe(result => {...});