问:
How to Edit Extensible Service Proxy configuration file
I need to integrate OAuth2 in my Project with AppEngine Backend. I am planning to use firebase Auth with AppEngine to take care of security.
Tutorial used : https://cloud.google.com/endpoints/docs/authenticating-users#configuring_extensible_service_proxy_to_support_client_authentication

Where is the Extensible Service Proxy configuration file? and how do we edit it ?

答:
I found this question looking for the same thing. I am using cloud-endpoints v2 and GAE. My backend is in python.

For me, in June 2017, it is in the [yournameandversion]openapi.json, not a yaml file, but it is included automatically when you follow this tutorial


来源: stackexchange

问:
CSS on Mouse Down
Usually I would use :hover, but I want my website to be accessible on touchscreen media too.

I know I can use :active, but as soon as I let go of the mouse button, it goes back to its inactive state.

Effectively I want:

Mouse Down : Div goes green

Mouse Up: Div stays green

Mouse Down: Div goes red

Mouse Up: Div stays red

Instead of:

Mouse Down: Div goes green

Mouse Up: Div goes red

答:
Here is how to do a pure css toggle 'button' (CSS3 required):

.toggle-button
{
  background-color: #FF0000;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.toggle-box:checked + .toggle-button
{
  background-color: #00FF00;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="checkbox" class="toggle-box" id="toggle-1" />
<label for="toggle-1" class="toggle-button">Click Me</label></code>```

Of course, as always, IE fails at CSS (can't figure out the :checked pseudo-class), so you're probably better off just using JavaScript.

ContentLicense: CC BY-SA 2.5

Title: CSS on Mouse Down

Body:
Here is how to do a pure css toggle 'button' (CSS3 required):

.toggle-button
{
  background-color: #FF0000;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.toggle-box:checked + .toggle-button
{
  background-color: #00FF00;
}

<input type="checkbox" class="toggle-box" id="toggle-1" />
<label for="toggle-1" class="toggle-button">Click Me</label>

Of course, as always, IE fails at CSS (can't figure out the :checked pseudo-class), so you're probably better off just using JavaScript.

ContentLicense: CC BY-SA 3.0


问:
Selecting unique lines based on two columns in mysql
I've been trying to figure out a way to select lines that are unique based on the values of two columns. For example, here is a sample/example of my file:

```<code>s      r
10    12
10    13
14    10
10    12
14    10
12    10
</code>```

And this is what I want my output to look like:

```<code>s      r
10    12
10    13
14    10
</code>```

I've tried to use this code

```<code>SELECT * FROM `message` WHERE (`s_id`=$b_id or 'r_id'=$b_id) GROUP BY
r_id
</code>```

However, it only select 10,12  10,11 and i also needed 14,10 i mean the third row

in this case $b_id is obtained from session and it may be s or r

答:
Do it like this

```<code>select distinctrow s_id,r_id from table where s_id = 10 or r_id = 10
</code>```

or else use "having" clause and group by both columns

Body:
I've been trying to figure out a way to select lines that are unique based on the values of two columns. For example, here is a sample/example of my file:

s      r
10    12
10    13
14    10
10    12
14    10
12    10

And this is what I want my output to look like:

s      r
10    12
10    13
14    10

I've tried to use this code

SELECT * FROM `message` WHERE (`s_id`=$b_id or 'r_id'=$b_id) GROUP BY
r_id

However, it only select 10,12  10,11 and i also needed 14,10 i mean the third row

in this case $b_id is obtained from session and it may be s or r

Body:
Do it like this

select distinctrow s_id,r_id from table where s_id = 10 or r_id = 10

or else use "having" clause and group by both columns


问:
Bootstrap tables overflowing with long unspaced text
I'm using Bootstrap and I have a table with a few columns, the last of which sometimes has a long piece of text without spaces. I noticed that under certain screen sizes, the table would overflow its parent div and create ugly overlapping with its sibling table.

I played around with it and I think the problem has to do with the text being unspaced. I created a jsfiddle that demonstrates what I mean.

As you can see, the top leftmost table is well behaved and simply grows vertically to accommodate more text. However, the bottom left table leads to an overflow on the right due to the long unspaced text and the right column of the bottom left table winds up "under" its sibling.

Does anyone have any tips on how I can fix this so that the very long text gets clipped or partially split onto a new line?

答:
You can use below css. This will wrap the text and apply ... in the end of the text.

e.g. This_is_a_large_text will be changed to This_is_a_lar...

```<code>td {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</code>```

You can also add tool tip to show the complete text value.

```<code><td data-toggle="tooltip" title="${text}">${text}</td>
</code>```

Body:
You can use below css. This will wrap the text and apply ... in the end of the text.

e.g. This_is_a_large_text will be changed to This_is_a_lar...

td {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

You can also add tool tip to show the complete text value.

<td data-toggle="tooltip" title="${text}">${text}</td>


问:
Puzzled by something in .reduce() method (Javascript)
in the next function where I use the reduce method in Javascript, I don't understand why I get different results when I use "current" or "array[index] in my if statement (inside my reduce method).

Aren't current and array[index] the same thing?

```<code>function pairwise(arr, arg) {

  return arr.reduce(function(acc,current, index, array){
    for(var i=index+1;i<array.length; i++){
      if(current+array[i]===arg){
        acc += index+i;
        array[index]=array[i]=NaN;
      }
    }

    return acc;
  }, 0)

  }
</code>```

Thank you !!

答:
You mean in this line?

```<code>array[index]=array[i]=NaN;
</code>```

If you assign to array[index], you're modifying the array.

If you assign to current, you're just overwriting the local variable current, but that doesn't have any lasting effect on the array from which that value came.

```<code>let arr = [1, 2, 3],
    current = arr[0];

current = 42;  // obviously does not modify arr
arr[0] = 42;   // obviously modifies arr
</code>```

Body:
in the next function where I use the reduce method in Javascript, I don't understand why I get different results when I use "current" or "array[index] in my if statement (inside my reduce method).

Aren't current and array[index] the same thing?

function pairwise(arr, arg) {

  return arr.reduce(function(acc,current, index, array){
    for(var i=index+1;i<array.length; i++){
      if(current+array[i]===arg){
        acc += index+i;
        array[index]=array[i]=NaN;
      }
    }

    return acc;
  }, 0)

  }

Thank you !!

Body:
You mean in this line?

array[index]=array[i]=NaN;

If you assign to array[index], you're modifying the array.

If you assign to current, you're just overwriting the local variable current, but that doesn't have any lasting effect on the array from which that value came.

let arr = [1, 2, 3],
    current = arr[0];

current = 42;  // obviously does not modify arr
arr[0] = 42;   // obviously modifies arr


问:
What is the best way to store XML data in an Excel file
I am looking for a way to store XML data in an Excel file.
The data should be completely hidden to the user, it should not be in a cell or comment, even hidden.
Also, the data should be preserved when the user opens and then saves the file with Excel.
I am not looking for a way to map cells to external XML data. The XML data should be inside the xlsx file.

The data will be entered using a C# tool, not Excel itself.

答: Excel is an application for storing, manipulating, and viewing data, and thusly, it is not designed to store arbitrary unreadable data. However, as you alluded to, you could use hidden fields on a separate sheet to put some information.</p>


问:
Generics and Inheritance corner case
I have following code and it is not behaving as i am thinking. I have put the comments inline , that what is happening and what is expected.

```<code>class C<T> {
    void m(T arg) {
    }
}

interface I {
    void m(Class arg);
}

class D extends C<Class<String>> implements I {
}
// expected : error -- conflicting inherited methods
// actual: error -- abstract method not overridden

abstract class E extends C<Class<String>> implements I {
}
// expected : error -- conflicting inherited methods
// actual: no error, but no bridge method
</code>```

Can some one please help me understand this behavior.

答:
The problem can be reduced to this basic fact about Java generics that it is safe to assign an instantiated generic type to raw type but the reverse is not true. When overriding a method, unsafe conversions are not permitted. Therefore Class<String> cannot override raw Class type.

In this case:

```<code>    Class a = String.class; //type safe
    Class<String> b = a; //not type safe
</code>```

Title: Generics and Inheritance corner case

Body:
I have following code and it is not behaving as i am thinking. I have put the comments inline , that what is happening and what is expected.

class C<T> {
    void m(T arg) {
    }
}

interface I {
    void m(Class arg);
}

class D extends C<Class<String>> implements I {
}
// expected : error -- conflicting inherited methods
// actual: error -- abstract method not overridden

abstract class E extends C<Class<String>> implements I {
}
// expected : error -- conflicting inherited methods
// actual: no error, but no bridge method

Can some one please help me understand this behavior.

Body:
The problem can be reduced to this basic fact about Java generics that it is safe to assign an instantiated generic type to raw type but the reverse is not true. When overriding a method, unsafe conversions are not permitted. Therefore Class<String> cannot override raw Class type.

In this case:

    Class a = String.class; //type safe
    Class<String> b = a; //not type safe


问:
what will happen when the aof file for redis is too big, even after rewriting?
I am reading something about redis persistence, right now two ways are available for keeping the redis persistence.

AOF

RDB

ok, i will skip the basic meanings of "AOF" and "RDB", I have a question about the "AOF", My question is "what will happen when the aof file for redis is too big, even after being rewrited ?", I have searched on google, but no result, somesone said the redis-server will fail to startup when the size of "AOF" file reach 3G or 4G. Could anyone can tell me ? Thanks a lot.

答:
Redis doesn't limit the size of AOF file. You can safely have a large AOF file. One of my Redis instance writes an AOF file with a size of 95G, and it can reload the file successfully. Of course, it takes a very long time.

somesone said the redis-server will fail to startup when the size of "AOF" file reach 3G or 4G

I'm not sure if the problem someone met, is because of the limit of file system. For some old file system, the size of a single file CANNOT exceed 2G or 4G. However, for modern file system, the limit has been removed.


问:
How to set auto refresh for grocery crud?
I am using grocery crud library to show my database record and it is working perfectly. But how can I get real time record from database without refreshing the page. To do this I put a script in template file name is list_template.php in flexigrid theme.

```<code>setInterval(function(){ $('#crud_search').trigger('click'); },10000);
</code>```

which is refreshing the record too but it is always showing me record from starting not the current page. The current page means if i am on page 3 it is showing page 1 as interval.

答:
I had a similar problem with autoload and i solved doing this:

I just created a js file called refresh on assets/js/refresh, and added the following:

js file

```<code>var interval = null;

window.onload = function() {
    interval = setInterval(callFunc, 5000);
};

function callFunc() {
       $("#ajax_refresh_and_loading").trigger("click");
}
</code>```

Controller side

```<code>$jsfile = 'assets/bootstrap/js/refresh.js';
        $crud->set_js($jsfile);
</code>```

I hope this is what you need.

Body:
I am using grocery crud library to show my database record and it is working perfectly. But how can I get real time record from database without refreshing the page. To do this I put a script in template file name is list_template.php in flexigrid theme.

setInterval(function(){ $('#crud_search').trigger('click'); },10000);

which is refreshing the record too but it is always showing me record from starting not the current page. The current page means if i am on page 3 it is showing page 1 as interval.

Body:
I had a similar problem with autoload and i solved doing this:

I just created a js file called refresh on assets/js/refresh, and added the following:

js file

var interval = null;

window.onload = function() {
    interval = setInterval(callFunc, 5000);
};

function callFunc() {
       $("#ajax_refresh_and_loading").trigger("click");
}

Controller side

$jsfile = 'assets/bootstrap/js/refresh.js';
        $crud->set_js($jsfile);

I hope this is what you need.


问:
nuget package being removed on build
I have a Wix Toolset boostrapper UI project which I'd like to "host" certain assemblies which the UI project itself does not need (I'm trying to simplify my life by having Wix only look in the setup UI's bin directory for all the assemblies).

I can add, say, AutoFac to the UI project. But when I build the project, the Autofac dependency gets stripped out and its DLL is not copied to the bin directory. This isn't terribly surprising since Autofac is not used in the UI project itself, so I guess it's some kind of optimization.

What I'd like to do is override that optimization in this case, and force VS to add the Autofac assemblies to the bin directory.

Is there a VS setting to do this?

答:
Is there a VS setting to do this?

If I understand you correctly, you want to force VS to add the Autofac assemblies to bin directory, you can try to add a copy task in the post build event to copy the Autofac assemblies to the bin directory after build (Right click project->Properties->Build Event->Post-build event command line).

```<code>xcopy.exe $(AutofacPath)Autofac.dll $(ProjectDir)$(OutDir)
</code>```

Reference: https://msdn.microsoft.com/en-us/library/ke5z92ks.aspx?f=255&MSPPError=-2147217396

Update for Mark comment:

But a post-build copy requires that nuget "installed" the Autofac package, which is what it's not doing.

Yes, you could copy from some other project where Autofac is. What`s more, the build event can do more things. You can use another command line to install the Autofac in the post-build event before xcopy commandline:

```<code>D:\nuget.exe install AutoFac
</code>```

With this command, nuget will download that package, and set it into the Bin folder.

Now things will be simple, we just need to add below command line in the post-build event:

```<code>D:\nuget.exe install AutoFac
xcopy.exe "$(ProjectDir)$(OutDir)Autofac.4.6.0\lib\net45\Autofac.dll" "$(ProjectDir)$(OutDir)"
</code>```

Note: You need to specify the path where nuget.exe is located in the command line, like D:\.

Title: nuget package being removed on build

Body:
Is there a VS setting to do this?

If I understand you correctly, you want to force VS to add the Autofac assemblies to bin directory, you can try to add a copy task in the post build event to copy the Autofac assemblies to the bin directory after build (Right click project->Properties->Build Event->Post-build event command line).

xcopy.exe $(AutofacPath)Autofac.dll $(ProjectDir)$(OutDir)

Reference: https://msdn.microsoft.com/en-us/library/ke5z92ks.aspx?f=255&MSPPError=-2147217396

Update for Mark comment:

But a post-build copy requires that nuget "installed" the Autofac package, which is what it's not doing.

Yes, you could copy from some other project where Autofac is. What`s more, the build event can do more things. You can use another command line to install the Autofac in the post-build event before xcopy commandline:

D:\nuget.exe install AutoFac

With this command, nuget will download that package, and set it into the Bin folder.

Now things will be simple, we just need to add below command line in the post-build event:

D:\nuget.exe install AutoFac
xcopy.exe "$(ProjectDir)$(OutDir)Autofac.4.6.0\lib\net45\Autofac.dll" "$(ProjectDir)$(OutDir)"

Note: You need to specify the path where nuget.exe is located in the command line, like D:\.


问:
Asynchronous web request not working in WCF
I am using third party API to add log API Call, i want to call this API Asynchronously to does not affect timing for main API call, also this process is low priority (even API result will not used.)

I have tried below code but it seems not work to me:

```<code>string strLogURL = "www.example.com";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(strLogURL);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
    string json = new JavaScriptSerializer().Serialize(objAPILog);
    streamWriter.Write(json);
    streamWriter.Flush();
    streamWriter.Close();
}
httpWebRequest.BeginGetResponse(new AsyncCallback(FinishWebRequest), httpWebRequest);
</code>```

Can anyone have idea how to call API from WCF asynchronously?

答:
If asynchrony is all that you're looking for then you can achieve just that by using HttpClient with async/await. Then you can either fire & forget, or ensure that it has finished before leaving your calling-method.

```<code>public void DoSomeWork()
{
    PerformWebWork("http://example.com", new object());

    // Perform other work
    // Forget webWork Task

    // Finish
}

public async Task DoSomeWorkAsync()
{
    Task webWorkTask = PerformWebWork("http://example.com", new object());

    // Perform other work

    // Ensure webWorkTask finished
    await webWorkTask;

    // Finish
}

public async Task PerformWebWork(string url, object objAPILog)
{
    string serializedContent = new JavaScriptSerializer().Serialize(objAPILog);
    using (HttpClient client = new HttpClient())
    {
        StringContent content = new StringContent(serializedContent);
        HttpResponseMessage postResponse = await client.PostAsync(url, content);
    }
}
</code>```

Body:
I am using third party API to add log API Call, i want to call this API Asynchronously to does not affect timing for main API call, also this process is low priority (even API result will not used.)

I have tried below code but it seems not work to me:

string strLogURL = "www.example.com";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(strLogURL);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
    string json = new JavaScriptSerializer().Serialize(objAPILog);
    streamWriter.Write(json);
    streamWriter.Flush();
    streamWriter.Close();
}
httpWebRequest.BeginGetResponse(new AsyncCallback(FinishWebRequest), httpWebRequest);

Can anyone have idea how to call API from WCF asynchronously?

Body:
If asynchrony is all that you're looking for then you can achieve just that by using HttpClient with async/await. Then you can either fire & forget, or ensure that it has finished before leaving your calling-method.

public void DoSomeWork()
{
    PerformWebWork("http://example.com", new object());

    // Perform other work
    // Forget webWork Task

    // Finish
}

public async Task DoSomeWorkAsync()
{
    Task webWorkTask = PerformWebWork("http://example.com", new object());

    // Perform other work

    // Ensure webWorkTask finished
    await webWorkTask;

    // Finish
}

public async Task PerformWebWork(string url, object objAPILog)
{
    string serializedContent = new JavaScriptSerializer().Serialize(objAPILog);
    using (HttpClient client = new HttpClient())
    {
        StringContent content = new StringContent(serializedContent);
        HttpResponseMessage postResponse = await client.PostAsync(url, content);
    }
}


问:
How to avoid Dependency Injection constructor madness?
I find that my constructors are starting to look like this:

```<code>public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... )
</code>```

with ever increasing parameter list. Since "Container" is my dependency injection container, why can't I just do this:

```<code>public MyClass(Container con)
</code>```

for every class? What are the downsides? If I do this, it feels like I'm using a glorified static. Please share your thoughts on IoC and Dependency Injection madness.

答:
Problem :

1) Constructor with ever increasing parameter list.

2) If class is inherited (Ex: RepositoryBase) then changing constructor
signature causes change in the derived classes.

Solution 1

Pass IoC Container to constructor

Why

No more ever increasing parameter list

Constructor's signature becomes simple

Why not

Makes you class tightly coupled to IoC container. (That causes problems when  1. you want to use that class in other projects where you use different IoC container. 2. you decide to change IoC container)

Makes you class less descriptive. (You can't really look at class constructor and say what it needs for functioning.)

Class can access potentially all service.

Solution 2

Create a class which groups all service and pass it to constructor

```<code> public abstract class EFRepositoryBase
 {
    public class Dependency
    {
        public DbContext DbContext { get; }
        public IAuditFactory AuditFactory { get; }

         public Dependency(
            DbContext dbContext,
            IAuditFactory auditFactory)
        {
            DbContext = dbContext;
            AuditFactory = auditFactory;
        }
    }

    protected readonly DbContext DbContext;
    protected readonly IJobariaAuditFactory auditFactory;

    protected EFRepositoryBase(Dependency dependency)
    {
        DbContext = dependency.DbContext;
        auditFactory= dependency.JobariaAuditFactory;
    }
  }
</code>```

Derived class

```<code>  public class ApplicationEfRepository : EFRepositoryBase
  {
     public new class Dependency : EFRepositoryBase.Dependency
     {
         public IConcreteDependency ConcreteDependency { get; }

         public Dependency(
            DbContext dbContext,
            IAuditFactory auditFactory,
            IConcreteDependency concreteDependency)
        {
            DbContext = dbContext;
            AuditFactory = auditFactory;
            ConcreteDependency = concreteDependency;
        }
     }

      IConcreteDependency _concreteDependency;

      public ApplicationEfRepository(
          Dependency dependency)
          : base(dependency)
      {
        _concreteDependency = dependency.ConcreteDependency;
      }
   }
</code>```

Why

Adding new dependency to class does not affect derived classes

Class is agnostic of IoC Container

Class is descriptive (in aspect of its dependencies). By convention, if you want to know what class A Depends on, that information is accumulated in A.Dependency

Constructor signature becomes simple

Why not

need to create additional class

service registration becomes complex (You need to register every X.Dependency separately)

Conceptually same as passing IoC Container

..

Solution 2 is just a raw though, if there is solid argument against it, then descriptive comment would be appreciated

Body:
I find that my constructors are starting to look like this:

public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... )

with ever increasing parameter list. Since "Container" is my dependency injection container, why can't I just do this:

public MyClass(Container con)

for every class? What are the downsides? If I do this, it feels like I'm using a glorified static. Please share your thoughts on IoC and Dependency Injection madness.

Body:
Problem :

1) Constructor with ever increasing parameter list.

2) If class is inherited (Ex: RepositoryBase) then changing constructor
signature causes change in the derived classes.

Solution 1

Pass IoC Container to constructor

Why

No more ever increasing parameter list

Constructor's signature becomes simple

Why not

Makes you class tightly coupled to IoC container. (That causes problems when  1. you want to use that class in other projects where you use different IoC container. 2. you decide to change IoC container)

Makes you class less descriptive. (You can't really look at class constructor and say what it needs for functioning.)

Class can access potentially all service.

Solution 2

Create a class which groups all service and pass it to constructor

 public abstract class EFRepositoryBase
 {
    public class Dependency
    {
        public DbContext DbContext { get; }
        public IAuditFactory AuditFactory { get; }

         public Dependency(
            DbContext dbContext,
            IAuditFactory auditFactory)
        {
            DbContext = dbContext;
            AuditFactory = auditFactory;
        }
    }

    protected readonly DbContext DbContext;
    protected readonly IJobariaAuditFactory auditFactory;

    protected EFRepositoryBase(Dependency dependency)
    {
        DbContext = dependency.DbContext;
        auditFactory= dependency.JobariaAuditFactory;
    }
  }

Derived class

  public class ApplicationEfRepository : EFRepositoryBase
  {
     public new class Dependency : EFRepositoryBase.Dependency
     {
         public IConcreteDependency ConcreteDependency { get; }

         public Dependency(
            DbContext dbContext,
            IAuditFactory auditFactory,
            IConcreteDependency concreteDependency)
        {
            DbContext = dbContext;
            AuditFactory = auditFactory;
            ConcreteDependency = concreteDependency;
        }
     }

      IConcreteDependency _concreteDependency;

      public ApplicationEfRepository(
          Dependency dependency)
          : base(dependency)
      {
        _concreteDependency = dependency.ConcreteDependency;
      }
   }

Why

Adding new dependency to class does not affect derived classes

Class is agnostic of IoC Container

Class is descriptive (in aspect of its dependencies). By convention, if you want to know what class A Depends on, that information is accumulated in A.Dependency

Constructor signature becomes simple

Why not

need to create additional class

service registration becomes complex (You need to register every X.Dependency separately)

Conceptually same as passing IoC Container

..

Solution 2 is just a raw though, if there is solid argument against it, then descriptive comment would be appreciated


问:
How to catch routes in *ngIf
So I want to make an anchor element on my Header disappear when a specific page is hit. How can I catch the url in the *ngIf when that page is hit.

I have a header which will remain same for all pages. Just need to hide an anchor element when I am routed at /home. How to catch this "/home" in *ngIf?

*ngIf = "href='/home'" is not working. Any alternatives?

答:
mycomponent.component.ts

import { Router } from '@angular/router'

class MyComponent {
    constructor(public router: Router) { }
}
```
<p><em>mycomponent.component.html</em></p>
<pre class="lang-html prettyprint-override"><code><div *ngIf="router.url === '/some/route'">
    <!-- … -->
</div>
</code>```

ContentLicense: CC BY-SA 4.0

Title: How to catch routes in *ngIf

Body:
mycomponent.component.ts

import { Router } from '@angular/router'

class MyComponent {
    constructor(public router: Router) { }
}

mycomponent.component.html

<div *ngIf="router.url === '/some/route'">
    <!-- … -->
</div>


问:
Add & load a jquery tab
I have a jquery tabs object which starts with one tab defined. That tab displays a table of data, and I want that clicking on an item in the table creates a new tab and loads content via ajax. So pretty dynamic.

So far I have a function that I call from an onclick event from the first tab. The function adds a new tab. Next, I tried to set a url but that doesn't work. How do I do this?

```<code>function addTab() {
    $( "#tabs" ).tabs( "add", "#tabs-x", "New Tab" );
    $( "#tabs" ).tabs( "url" , 1 , "http://mysite.com/details.php" );
}
</code>```

Note that I will be passing an id parameter to the addTab function and in turn to the url, but I just wanna get these initial mechanics down.

答:
You can only change an existing remove tab with the url method, so you'd need to have it remote initially, like this:

```<code>function addTab() {
    $( "#tabs" ).tabs( "add", "http://mysite.com/temp", "New Tab" );
    $( "#tabs" ).tabs( "url" , 1 , "http://mysite.com/details.php" );
}
</code>```

Or just set it initially when adding would be simpler:

```<code>function addTab() {
    $( "#tabs" ).tabs( "add", "http://mysite.com/details.php", "New Tab" );
}
</code>```

Title: Add & load a jquery tab

Body:
I have a jquery tabs object which starts with one tab defined. That tab displays a table of data, and I want that clicking on an item in the table creates a new tab and loads content via ajax. So pretty dynamic.

So far I have a function that I call from an onclick event from the first tab. The function adds a new tab. Next, I tried to set a url but that doesn't work. How do I do this?

function addTab() {
    $( "#tabs" ).tabs( "add", "#tabs-x", "New Tab" );
    $( "#tabs" ).tabs( "url" , 1 , "http://mysite.com/details.php" );
}

Note that I will be passing an id parameter to the addTab function and in turn to the url, but I just wanna get these initial mechanics down.

Body:
You can only change an existing remove tab with the url method, so you'd need to have it remote initially, like this:

function addTab() {
    $( "#tabs" ).tabs( "add", "http://mysite.com/temp", "New Tab" );
    $( "#tabs" ).tabs( "url" , 1 , "http://mysite.com/details.php" );
}

Or just set it initially when adding would be simpler:

function addTab() {
    $( "#tabs" ).tabs( "add", "http://mysite.com/details.php", "New Tab" );
}


问:
Renew Push certificate and keep current App Store App working
I have an app on app store, which is using an iOS Provisioning Profile (Distribution) which is expired.
This Profile contains Push Certificate that's also expired (and does not appear anymore in the portal).

Question 1:
Is there a way to recreate the push certificate and then renew the profile?  (I still have the push certificate (expired) on my keychain)?

Question 2:
Do I need to re-submit the app to app store with a new profile that contains the new Push certificate?

Since the push certificate is expired, I can probably not send notifications to the existing users of the app.

答:
Adding few words about VoIP push certificates.

Like Push certificates VoIP certificates cannot be renewed, you have to create a new one.

VoIP notifications will not work, if your VoIP certificate is expired or you revoke it.

If you create a new certificate, you need to deploy the new p12 on server side. VoIP certificate is also not part of application build, so you don't have to submit app again.


问:
How to create a boolean property/binding whose value is based on an integer?
I want to create a class which holds boolean information via an int: if its value is greater than 0 the boolean's value is true, otherwise false.

This is a class that encapsulates this behavior:

```<code>public class CumulativeBoolean {

    private int cumulative = 0;

    public boolean get() {
        return cumulative > 0;
    }

    public void set(boolean val) {
        cumulative += val ? 1 : -1;
    }
}
</code>```

I want to create a JavaFX class from this design that allows binding and listening. I looked at extending either BooleanBinding or BooleanPropertyBase, they both hold a private boolean value as their value while what I want is an int.

This is what I have for BooleanBinding:

```<code>public class CumulativeBooleanBinding extends BooleanBinding {

    private int cumulative = 0;

    public void set(boolean val) {
        cumulative += val ? 1 : -1;
        invalidate();
    }

    @Override
    protected boolean computeValue() {
        return cumulative != 0;
    }
}
</code>```

However, I don't think that the idea of BooleanBinding was to support a set functionality, and there is also the issue of setting the value while the value is bound.

BooleanPropertyBase, on the other hand, does not allow me to invalidate when updating since its markInvalid method and valid fields are private.

How could I achieve this?

答:
Wouldn't be easier to create IntegerProperty and then create BooleanBinding from that property? Like this:

```<code>IntegerProperty cumulative = new SimpleIntegerProperty();
BooleanBinding greaterThanZeroCumulative = cumulative.greaterThan(0);
</code>```

Body:
I want to create a class which holds boolean information via an int: if its value is greater than 0 the boolean's value is true, otherwise false.

This is a class that encapsulates this behavior:

public class CumulativeBoolean {

    private int cumulative = 0;

    public boolean get() {
        return cumulative > 0;
    }

    public void set(boolean val) {
        cumulative += val ? 1 : -1;
    }
}

I want to create a JavaFX class from this design that allows binding and listening. I looked at extending either BooleanBinding or BooleanPropertyBase, they both hold a private boolean value as their value while what I want is an int.

This is what I have for BooleanBinding:

public class CumulativeBooleanBinding extends BooleanBinding {

    private int cumulative = 0;

    public void set(boolean val) {
        cumulative += val ? 1 : -1;
        invalidate();
    }

    @Override
    protected boolean computeValue() {
        return cumulative != 0;
    }
}

However, I don't think that the idea of BooleanBinding was to support a set functionality, and there is also the issue of setting the value while the value is bound.

BooleanPropertyBase, on the other hand, does not allow me to invalidate when updating since its markInvalid method and valid fields are private.

How could I achieve this?

Body:
Wouldn't be easier to create IntegerProperty and then create BooleanBinding from that property? Like this:

IntegerProperty cumulative = new SimpleIntegerProperty();
BooleanBinding greaterThanZeroCumulative = cumulative.greaterThan(0);


问:
Intellij IDEA how to add my own keys for code completion
psvm + tab would make:

```<code>public static void main(String[] args) {

}
</code>```

And now I want to have cml for:

```<code>CommandLineRunner runner () {
    return args -> {

    };
}
</code>```

How to add it in IDEA?

答:
Checkout IntelliJ IDEA Live Templates documentation

Basically you can create abbreviations like that :

go to File ->  Settings... -> Editor -> Live Templates

Add a live template with the + sign

define at least abbreviation and text template

define the appropriate JAVA context

That's it.

Body:
psvm + tab would make:

public static void main(String[] args) {

}

And now I want to have cml for:

CommandLineRunner runner () {
    return args -> {

    };
}

How to add it in IDEA?


问:
Django gives 400 Bad request error in image upload using ajax
I am using quill editor to upload an image and the an ajax function is used to send the image to views.py.

This is the python function for uploading the image.

views.py

```<code>def upload_image(request):
    if request.method == 'POST':
        handle_uploaded_file(request.FILES.get('file'))
        return HttpResponse("Successful")

    return HttpResponse("Failed")

def handle_uploaded_file(file):
    with open('upload/', 'wb+' ) as destination:
        for chunk in file.chunk():
            destination.write(chunk)
</code>```

This is the ajax request:

```<code>function upload(file, callback) {
    console.log('called');

      var formData = new FormData();
      formData.append('file', file);
      $.ajax({
         url : '{% url 'dashboard:upload_image' %} ',
         type : 'POST',
         data : formData,
         contentType: 'multipart/form-data',
         headers: { "X-CSRFToken": $.cookie("csrftoken") },
         processData: false,
         success: function(data) {
            console.log('success');
            callback(data.url)
         }
      });
   }
</code>```

Function calling upload() :

```<code>function(value) {
              let fileInput = this.container.querySelector('input.ql-image[type=file]');
              if (fileInput == null) {
                fileInput = document.createElement('input');
                fileInput.setAttribute('type', 'file');
                fileInput.setAttribute('accept', 'image/*');
                fileInput.classList.add('ql-image');
                fileInput.addEventListener('change', () => {
                  if (fileInput.files != null) {
                    upload();
                  }
                });
                this.container.appendChild(fileInput);
              }
              fileInput.click();
            }
        }
</code>```

答:
Error in string

```<code>with open('upload/', 'wb+' ) as destination:
</code>```

Wrong path. Set the file name.

Body:
I am using quill editor to upload an image and the an ajax function is used to send the image to views.py.

This is the python function for uploading the image.

views.py

def upload_image(request):
    if request.method == 'POST':
        handle_uploaded_file(request.FILES.get('file'))
        return HttpResponse("Successful")

    return HttpResponse("Failed")

def handle_uploaded_file(file):
    with open('upload/', 'wb+' ) as destination:
        for chunk in file.chunk():
            destination.write(chunk)

This is the ajax request:

function upload(file, callback) {
    console.log('called');

      var formData = new FormData();
      formData.append('file', file);
      $.ajax({
         url : '{% url 'dashboard:upload_image' %} ',
         type : 'POST',
         data : formData,
         contentType: 'multipart/form-data',
         headers: { "X-CSRFToken": $.cookie("csrftoken") },
         processData: false,
         success: function(data) {
            console.log('success');
            callback(data.url)
         }
      });
   }

Function calling upload() :

function(value) {
              let fileInput = this.container.querySelector('input.ql-image[type=file]');
              if (fileInput == null) {
                fileInput = document.createElement('input');
                fileInput.setAttribute('type', 'file');
                fileInput.setAttribute('accept', 'image/*');
                fileInput.classList.add('ql-image');
                fileInput.addEventListener('change', () => {
                  if (fileInput.files != null) {
                    upload();
                  }
                });
                this.container.appendChild(fileInput);
              }
              fileInput.click();
            }
        }

Body:
Error in string

with open('upload/', 'wb+' ) as destination:

Wrong path. Set the file name.


问:
fetch() header shows as application/x-www-form-urlencoded instead of application/json
Update #2: This has been solved, see my own answer (which I cannot yet accept).

I'm running a React app on heroku using a node.js backend via Express. In the frontend, I want to send a POST request containing a JSON payload, which is sent like this:

```<code>fetch('/api/shows', {
        method: 'POST',
        accept: 'application/json',
        headers: new Headers({
            'Content-Type': 'application/json',
        }),
        // mode: 'cors',    // tried this, but no effect
        // cache: 'default',    // tried this, but no effect
        body: JSON.stringify({ "foo": "bar" }),
    }).then(response => {
        return response.json();
    }).then(response => {
        // … handling the response …
    }).catch(err => {
        // … handling errors …
    });
</code>```

The backend is set up like this:

```<code>const express = require('express');
const bodyParser = require('body-parser');

const app = express();

app.set('port', (process.env.PORT || 3001));

if (process.env.NODE_ENV === 'production') {
    app.use(express.static('frontend/build'));
}

app.post('/api/shows', bodyParser.json(), (req, res) => {
    const data = req.body;
    console.log(data); // shows {}
});
</code>```

Locally this all works fine, but deployed on heroku the request comes in with content type application/x-www-form-urlencoded instead of application/json, which is why the body-parser middleware doesn't parse the JSON.

Oddly enough this did work a couple days ago when I tried it once and I'm not aware of any changes I made in this area in the meantime.

What is causing the header to be wrong despite being explicitly set for the request? I could configure the middleware to read it anyway, but this seems like a workaround. I'd like to understand the actual root cause of the problem instead.

Update #1

I think it may have to do with the URL setup. Using a curl request from the command-line to serve the backend, the data is received when using http://my-app.herokuapp.com/api/shows, but not when using http://myurl.info/api/shows.

答:
As is the case so often, shortly after posting I've figured it out. The problem had actually nothing to do with the application whatsoever.

I'm using my own URL through a provider and had setup a reidrection to myapp.herokuapp.com, which turned out to be the problem. Heroku explains in detail how to configure a domain for a Heroku app and after following that procedure to use a CNAME entry, everything is working fine.

Body:
Update #2: This has been solved, see my own answer (which I cannot yet accept).

I'm running a React app on heroku using a node.js backend via Express. In the frontend, I want to send a POST request containing a JSON payload, which is sent like this:

fetch('/api/shows', {
        method: 'POST',
        accept: 'application/json',
        headers: new Headers({
            'Content-Type': 'application/json',
        }),
        // mode: 'cors',    // tried this, but no effect
        // cache: 'default',    // tried this, but no effect
        body: JSON.stringify({ "foo": "bar" }),
    }).then(response => {
        return response.json();
    }).then(response => {
        // … handling the response …
    }).catch(err => {
        // … handling errors …
    });

The backend is set up like this:

const express = require('express');
const bodyParser = require('body-parser');

const app = express();

app.set('port', (process.env.PORT || 3001));

if (process.env.NODE_ENV === 'production') {
    app.use(express.static('frontend/build'));
}

app.post('/api/shows', bodyParser.json(), (req, res) => {
    const data = req.body;
    console.log(data); // shows {}
});

Locally this all works fine, but deployed on heroku the request comes in with content type application/x-www-form-urlencoded instead of application/json, which is why the body-parser middleware doesn't parse the JSON.

Oddly enough this did work a couple days ago when I tried it once and I'm not aware of any changes I made in this area in the meantime.

What is causing the header to be wrong despite being explicitly set for the request? I could configure the middleware to read it anyway, but this seems like a workaround. I'd like to understand the actual root cause of the problem instead.

Update #1

I think it may have to do with the URL setup. Using a curl request from the command-line to serve the backend, the data is received when using http://my-app.herokuapp.com/api/shows, but not when using http://myurl.info/api/shows.


问:
producer-consumer using synchronization
I wrote code to implement the Producer-Consumer problem and it seems to be working fine without the need to synchronize.Is it possible?

How do I test the code and check if it is actually working right or not? How do I know if deadlock will occur? Right now,I am not breaking out of the loops(i.e. the Producer keeps inserting and the consumer keeps consuming in an infinite loop).I am using a circular queue of size 3(for sake of simplicity) as the shared resource.

Here is my code:

```<code>import java.util.*;

public class PCImpl implements Runnable
{
Thread t;
QforPC qObj;

 public static void main(String[] args)
 {
     QforPC qObject=new QforPC();

     //These create 2 different objects! Each object has it's own thread of execution.
     //Synchronization is needed when 2 threads use the same object
    new PCImpl("Producer",qObject);
    new PCImpl("Consumer",qObject);
 }

 PCImpl(String name,QforPC qObj)
 {
     this.qObj=qObj;
     t=new Thread(this,name);
     t.start();
 }

 public void run()
 {
         if(Thread.currentThread().getName().equals("Producer"))
         {
             while(true)
             {
                  Random rgen=new Random();
                  int n=rgen.nextInt(100);
                  if(n!=0)
                              qObj.Producer(n);
                         try
                    {
                       Thread.sleep(200);
                     }
                      catch(InterruptedException e)
                    {

                    }
               }

            }

         if(Thread.currentThread().getName().equals("Consumer"))
         {
             while(true)
                  {
                 try
               {
                 Thread.sleep(1500);
               }
                catch(InterruptedException e)
               {
                  }
              qObj.Consumer();

              }
         }

  }
}

public class QforPC
{
int[] q={0,0,0};
int r=0,f=0;
  public void Producer(int item)
     {

         if(r!=q.length && canProducer())
         {
             q[r]=item;
             System.out.println("The item inserted into the queue is:"+ item);
             r++;
         }
         if(r==q.length && f>0)
             r=0;
         else if(r==q.length && f==q.length)
         {
             r=0;
             f=0;
         }
     }

     public void Consumer()
     {
         int item;
         System.out.println("The value of isQueue empty is:"+ isEmpty());

         if(f!=q.length && isEmpty()==false)
         {
             System.out.println("Entered the consumer method");
             item=q[f];
             System.out.println("The item fetched from the queue is:"+item);
             q[f]=0;
             f++;
         }
         if(f==q.length && r<f)
             f=0;

     }

     public boolean isEmpty()
     {
         for(int k=0;k<q.length;k++)
         {
             if(q[k]==0 && k==q.length-1)
                 return true;

         }
         return false;
     }

     public boolean canProducer()
     {
         for(int k=0;k<q.length;k++)
         {
                 if(q[k]==0)
                 return true;

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

答:
There's no such thing as the Producer-Consumer problem. Producer-Consumer is a design pattern that may or may not be an effective implementation of a solution to a problem, not a problem in and of itself.

I'm SURE there are plenty of producer-consumer implementations that don't require synching. It entirely depends on what you're trying to accomplish and what kind of data you're producing/consuming.

Also, you have to have a problem to solve if you want to say you're implementation works without synchronizing. Works at doing what? I have no idea what you're doing.

Title: producer-consumer using synchronization

Body:
I wrote code to implement the Producer-Consumer problem and it seems to be working fine without the need to synchronize.Is it possible?

How do I test the code and check if it is actually working right or not? How do I know if deadlock will occur? Right now,I am not breaking out of the loops(i.e. the Producer keeps inserting and the consumer keeps consuming in an infinite loop).I am using a circular queue of size 3(for sake of simplicity) as the shared resource.

Here is my code:

import java.util.*;

public class PCImpl implements Runnable
{
Thread t;
QforPC qObj;

 public static void main(String[] args)
 {
     QforPC qObject=new QforPC();

     //These create 2 different objects! Each object has it's own thread of execution.
     //Synchronization is needed when 2 threads use the same object
    new PCImpl("Producer",qObject);
    new PCImpl("Consumer",qObject);
 }

 PCImpl(String name,QforPC qObj)
 {
     this.qObj=qObj;
     t=new Thread(this,name);
     t.start();
 }

 public void run()
 {
         if(Thread.currentThread().getName().equals("Producer"))
         {
             while(true)
             {
                  Random rgen=new Random();
                  int n=rgen.nextInt(100);
                  if(n!=0)
                              qObj.Producer(n);
                         try
                    {
                       Thread.sleep(200);
                     }
                      catch(InterruptedException e)
                    {

                    }
               }

            }

         if(Thread.currentThread().getName().equals("Consumer"))
         {
             while(true)
                  {
                 try
               {
                 Thread.sleep(1500);
               }
                catch(InterruptedException e)
               {
                  }
              qObj.Consumer();

              }
         }

  }
}

public class QforPC
{
int[] q={0,0,0};
int r=0,f=0;
  public void Producer(int item)
     {

         if(r!=q.length && canProducer())
         {
             q[r]=item;
             System.out.println("The item inserted into the queue is:"+ item);
             r++;
         }
         if(r==q.length && f>0)
             r=0;
         else if(r==q.length && f==q.length)
         {
             r=0;
             f=0;
         }
     }

     public void Consumer()
     {
         int item;
         System.out.println("The value of isQueue empty is:"+ isEmpty());

         if(f!=q.length && isEmpty()==false)
         {
             System.out.println("Entered the consumer method");
             item=q[f];
             System.out.println("The item fetched from the queue is:"+item);
             q[f]=0;
             f++;
         }
         if(f==q.length && r<f)
             f=0;

     }

     public boolean isEmpty()
     {
         for(int k=0;k<q.length;k++)
         {
             if(q[k]==0 && k==q.length-1)
                 return true;

         }
         return false;
     }

     public boolean canProducer()
     {
         for(int k=0;k<q.length;k++)
         {
                 if(q[k]==0)
                 return true;

         }
         return false;
     }
}


问:
Vim syntax highlighting for FAME
This is probably a shot in the dark considering how obscure the FAME programming language is, but is anyone familiar with already extant FAME syntax highlighting file for Vim?</p>

答:
I have made a syntax highlighting file for Notepad++.

It's not perfect, feel free to upgrade it.

```<code><NotepadPlus>
<UserLang name="FAME" ext="pro inp" udlVersion="2.1">
    <Settings>
        <Global caseIgnored="yes" allowFoldOfComments="yes" foldCompact="yes" forcePureLC="0" decimalSeparator="0" />
        <Prefix Keywords1="no" Keywords2="yes" Keywords3="yes" Keywords4="no" Keywords5="no" Keywords6="yes" Keywords7="yes" Keywords8="yes" />
    </Settings>
    <KeywordLists>
        <Keywords name="Comments">00-- 01 02 03/* 04*/</Keywords>
        <Keywords name="Numbers, prefix1"></Keywords>
        <Keywords name="Numbers, prefix2"></Keywords>
        <Keywords name="Numbers, extras1"></Keywords>
        <Keywords name="Numbers, extras2"></Keywords>
        <Keywords name="Numbers, suffix1"></Keywords>
        <Keywords name="Numbers, suffix2"></Keywords>
        <Keywords name="Numbers, range"></Keywords>
        <Keywords name="Operators1">&</Keywords>
        <Keywords name="Operators2"></Keywords>
        <Keywords name="Folders in code1, open">' + ,</Keywords>
        <Keywords name="Folders in code1, middle">; = , + " :</Keywords>
        <Keywords name="Folders in code1, close">,</Keywords>
        <Keywords name="Folders in code2, open"></Keywords>
        <Keywords name="Folders in code2, middle"></Keywords>
        <Keywords name="Folders in code2, close"></Keywords>
        <Keywords name="Folders in comment, open">--=</Keywords>
        <Keywords name="Folders in comment, middle"></Keywords>
        <Keywords name="Folders in comment, close">=--</Keywords>
        <Keywords name="Keywords1">BLOCK
CD
CLOSE
CREATE
DISPLAY
END
EXHIBIT
EXIT
HELP
INFO
INPUT
MESSAGE
OPEN
OUTPUT
REDO
REFILE
RESET
SETENV
SLEEP
SUBSTITUTE
SYSTEM
TYPE
UNSAVE
UNSETENV
WRITE
BLOCK
CD
CLOSE
CREATE
DISPLAY
END
EXHIBIT
EXIT
HELP
INFO
INPUT
MESSAGE
OPEN
OUTPUT
REDO
REFILE
RESET
SETENV
SLEEP
SUBSTITUTE
SYSTEM
TYPE
UNSAVE
UNSETENV
WRITE
ALIAS
ASSOCIATE
ATTRIBUTE
BASIS
CATALOG
COPY
DBSTATUS
DELETE
DESCRIPTION
DIMENSION
DOCUMENTATION
EXTRADOTS
FORMULA
GLFORMULA
GLNAME
MODIFY
NEW
OBSERVED
POST
RENAME
REOPEN
RESTORE
SCALAR
SEARCH
SERIES
SET
STRINGLENGTH
UPDATE
WHATS
WHICH
CONNECT
DISCONNECT
OPEN
EXIT
CLOSE
OPEN
RABORT
RASSERT
RATTRIBUTE
RCOMMIT
RCOPY
RDELETE
RRENAME
RSET
ADJUST
BEST
CORRELATE
EXTRAPOLATE
FIT
STEST
SUMMARIZE
APPLY
BACKTO
ENTER
ENTRY
FIELD
FORM
GHOST
INITIALIZE
LEAVE
MENU
RECALCULATE
REENTER
TERMINATE
TRIGGER
UNGHOST
VALIDATE
CLEAR
DATA
DATA PIE
DRAW ARROW
DRAW BOX
DRAW LINE
DRAW MARKING
DRAW NOTE
DRAW REGION
DRAW TEXT
GRAPH
GRAPH PIE
PICTURE
REFRESH
BLANK
FOOTING
HEADING
LINE
NEWPAGE
PRINT
REPORT
SCORE
SELECT
STROKE
TEXT
VALPRINT
ACCEPT
ARGUMENT
CANCEL
CATCH
CLOAD
COMPILE
ESCAPE
EXEC
EXECUTE
FUNCTION
IF
LOAD
LOCAL
LOOP
NEXT
PEEL
PROCEDURE
PROMPT
READ
RESIGNAL
RETURN
SIGNAL
TRY
UNLOAD
CONCEAL
HIDE
REVEAL
XYGET
ITEM
GLUE
OVER
IGNORE
IMAGE
FALSE
TRUE
DISP
OTHERWISE
ELSE
DECIMAL
channel
TRACE</Keywords>
        <Keywords name="Keywords2">ANNUAL
BIMONTHLY
BIWEEKLY
BUSINESS
DAILY
HOURLY
MILLISECONDLY
MINUTELY
MONTHLY
PPY
QUARTERLY
SECONDLY
SEMIANNUAL
TENDAY
TWICEMONTHLY
WEEKLY
YPP</Keywords>
        <Keywords name="Keywords3">ACCESS
ACF
AGGR
AGR
ALIAS
ALL
ALPHA
AMORT
ANNPCT
ANY
AR
ARGUMENT
ARIMA
ARMA
ASSOCIATE
AVE
BASEFREQ
BASETYPE
BASIS
BIWK
BOOLFMT
CASEORDER
CAVE
CHANNELS
CHANNELTYPE
CHR
CLASS
CMAX
CMIN
COLOR
CONNAME
CONVERT
CORR
CPROD
CREATED
CROSSLIST
CSUM
CTOT
DATEFMT
DATEOF
DATEORDER
DAY
DB
DBCREATED
DBUPDATED
DBVERSION
DESCRIPTION
DIFF
DIMCHAR
DIMENSION
DIMNUM
DOCUMENTATION
DTY
EMA
EOF
ERRORTEXT
EVAL
EXISTS
EXTRACT
EXTRADOTS
FILE
FILESPEC
FIRST
FIRSTCASE
FIRSTDATE
FIRSTVALUE
FONT
FPERIOD
FREQ
FYEAR
GETENV
GETID
GROWTH
HOUR
ID
INDENT
INDEX
INISCAN
INTERP
IRR
KIND
LARGEST
LAST
LASTCASE
LASTDATE
LASTERROR
LASTVALUE
LASTWARNING
LEFT
LENGTH
LENGTHCASE
LENGTHDATE
LIST
LMAX
LMIN
LOCATION
LOOKUP
LOWER
LTRIM
MA
MAGIC
MAKE
MAKEDATE
MAVE
MAVEC
MAX
MAXCASE
MAXDATE
MCORR
MEAN
MEDIAN
MERGE
MILLISECOND
MIN
MINCASE
MINDATE
MINUTE
MIRROR
MISSING
MMAX
MMEDIAN
MMIN
MONTH
MOVE
MSTDDEV
MSUM
MVAR
NAME
NAMELOC
NL
NORMAL
NOW
NPV
NUMBER
NUMFMT
OBSERVED
ORD
OVERLAY
PACF
PACK
PAD
PAYBACK
PCT
PENDING
PERIOD
PIXELS
POINTS
PRECFMT
PROD
REALNAME
REMEVAL
REPEAT
REPLACE
REVERSE
RIGHT
ROBLOC
ROBVAR
RTRIM
SANNPCT
SARIMA
SCAN
SCREENINFO
SCRIPT
SECOND
SELECTNAMES
SERIES
SHIFT
SHIFTMTH
SHIFTYR
SL
SLICE
SMALLEST
SORTDATA
SORTINDEX
SORTNAMES
SOURCE
SPECIAL
STDDEV
STRING
STRINGLENGTH
STUFF
SUBSTRING
SUM
SYSTEM
SYSTEMERROR
THISDAY
TIME
TODAY
TOT
TRIM
TUNE
TYPE
UNIFORM
UNIQUE
UPDATED
UPPER
VAR
WEEKDAY
WILDLIST
WILDNAMES
WINFRAMEINFO
WININFO
YEAR
YTD
YTYDIFF
YTYPCT
$</Keywords>
        <Keywords name="Keywords4">ALL
AND
AUTO
BLANK
BOOLEAN
BREAK
CASE
CASEORDER
CIRCLE
COMPLETE
DASH
DATA
DATE
DATEORDER
DESCRIPTION
DIALOG
DIV
DMAX
DMIN
DOT
ELSE
EQ
EQL
ERRORTEXT
EXCEPT
FALSE
FIRSTCASE
FIRSTDATE
FRACTION
FULL
GE
GT
HORIZONTAL
IF
INFINITY
INFO
INPUT
INTERSECT
KEYBOARD
LASTCASE
LASTDATE
LASTERROR
LASTWARNING
LE
LENGTHCASE
LENGTHDATE
LOCAL
LT
MAJOR
MATCH
MAXCASE
MAXDATE
MESSAGE
MINCASE
MINDATE
MOD
N
NA
NAMELIST
NC
ND
NE
NEGINFINITY
NEL
NEWLINE
NO
NOARG
NONE
NORMAL
NOT
NOTHING
NOW
NULL
NUMERIC
OFF
ON
OR
OUTPUT
PERIODICITY
PI
PICTURE
PRECISION
PREVIOUS
PRTn
QUOTE
SCAN
SCIRCLE
SQUARE
SSQUARE
STANDARD
STARMAGICDATE
STEP
STRIANGLE
STRING
SUBSET
SYSTEMERROR
T
TERMINAL
THEN
TIME
TODAY
TOTAL
TRIANGLE
TRUE
UNIFORM
UNION
UNSPEC
VALUE
VERSION
WORK
XOR
YES
AS
TO
IN
FOR
error</Keywords>
        <Keywords name="Keywords5">ACCEPT
ARGUMENT
CANCEL
CATCH
CLOAD
COMPILE
ESCAPE
EXECUTE
FUNCTION
Function Call
IF
LOAD
LOCAL
LOOP
NEXT
PEEL
PROCEDURE
Procedure Call
PROMPT
READ
RESIGNAL
RETURN
SIGNAL
TRY
UNLOAD</Keywords>
        <Keywords name="Keywords6">@</Keywords>
        <Keywords name="Keywords7">&&</Keywords>
        <Keywords name="Keywords8">%
</Keywords>
        <Keywords name="Delimiters">00" 01 02" 03( 04 05) 06{ 07 08} 09[ 10 11] 12< 13 14> 15 16 17 18 19 20 21 22 23</Keywords>
    </KeywordLists>
    <Styles>
        <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
        <WordsStyle name="COMMENTS" fgColor="008000" bgColor="F0F0F0" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS2" fgColor="FF8000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS3" fgColor="18B4C5" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS4" fgColor="BF4043" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS5" fgColor="5C2E2E" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS6" fgColor="0080FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="00FF40" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS8" fgColor="CC7700" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="OPERATORS" fgColor="FF0000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="FOLDER IN CODE2" fgColor="FFFF00" bgColor="FFFFFF" fontName="@FangSong" fontStyle="3" nesting="0" />
        <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS1" fgColor="0080C0" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="F3F3F3" fontName="Source Code Pro" fontStyle="0" nesting="117702655" />
        <WordsStyle name="DELIMITERS3" fgColor="8000FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFC4C4" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FF8000" fontName="Source Code Pro" fontStyle="1" nesting="512" />
        <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
    </Styles>
</UserLang>
</code>```

Title: Vim syntax highlighting for FAME

Body:
I have made a syntax highlighting file for Notepad++.

It's not perfect, feel free to upgrade it.

<NotepadPlus>
<UserLang name="FAME" ext="pro inp" udlVersion="2.1">
    <Settings>
        <Global caseIgnored="yes" allowFoldOfComments="yes" foldCompact="yes" forcePureLC="0" decimalSeparator="0" />
        <Prefix Keywords1="no" Keywords2="yes" Keywords3="yes" Keywords4="no" Keywords5="no" Keywords6="yes" Keywords7="yes" Keywords8="yes" />
    </Settings>
    <KeywordLists>
        <Keywords name="Comments">00-- 01 02 03/* 04*/</Keywords>
        <Keywords name="Numbers, prefix1"></Keywords>
        <Keywords name="Numbers, prefix2"></Keywords>
        <Keywords name="Numbers, extras1"></Keywords>
        <Keywords name="Numbers, extras2"></Keywords>
        <Keywords name="Numbers, suffix1"></Keywords>
        <Keywords name="Numbers, suffix2"></Keywords>
        <Keywords name="Numbers, range"></Keywords>
        <Keywords name="Operators1">&amp;</Keywords>
        <Keywords name="Operators2"></Keywords>
        <Keywords name="Folders in code1, open">&apos; + ,</Keywords>
        <Keywords name="Folders in code1, middle">; = , + &quot; :</Keywords>
        <Keywords name="Folders in code1, close">,</Keywords>
        <Keywords name="Folders in code2, open"></Keywords>
        <Keywords name="Folders in code2, middle"></Keywords>
        <Keywords name="Folders in code2, close"></Keywords>
        <Keywords name="Folders in comment, open">--=</Keywords>
        <Keywords name="Folders in comment, middle"></Keywords>
        <Keywords name="Folders in comment, close">=--</Keywords>
        <Keywords name="Keywords1">BLOCK&#x000D;&#x000A;CD&#x000D;&#x000A;CLOSE&#x000D;&#x000A;CREATE&#x000D;&#x000A;DISPLAY&#x000D;&#x000A;END&#x000D;&#x000A;EXHIBIT&#x000D;&#x000A;EXIT&#x000D;&#x000A;HELP&#x000D;&#x000A;INFO&#x000D;&#x000A;INPUT&#x000D;&#x000A;MESSAGE&#x000D;&#x000A;OPEN&#x000D;&#x000A;OUTPUT&#x000D;&#x000A;REDO&#x000D;&#x000A;REFILE&#x000D;&#x000A;RESET&#x000D;&#x000A;SETENV&#x000D;&#x000A;SLEEP&#x000D;&#x000A;SUBSTITUTE&#x000D;&#x000A;SYSTEM&#x000D;&#x000A;TYPE&#x000D;&#x000A;UNSAVE&#x000D;&#x000A;UNSETENV&#x000D;&#x000A;WRITE&#x000D;&#x000A;BLOCK&#x000D;&#x000A;CD&#x000D;&#x000A;CLOSE&#x000D;&#x000A;CREATE&#x000D;&#x000A;DISPLAY&#x000D;&#x000A;END&#x000D;&#x000A;EXHIBIT&#x000D;&#x000A;EXIT&#x000D;&#x000A;HELP&#x000D;&#x000A;INFO&#x000D;&#x000A;INPUT&#x000D;&#x000A;MESSAGE&#x000D;&#x000A;OPEN&#x000D;&#x000A;OUTPUT&#x000D;&#x000A;REDO&#x000D;&#x000A;REFILE&#x000D;&#x000A;RESET&#x000D;&#x000A;SETENV&#x000D;&#x000A;SLEEP&#x000D;&#x000A;SUBSTITUTE&#x000D;&#x000A;SYSTEM&#x000D;&#x000A;TYPE&#x000D;&#x000A;UNSAVE&#x000D;&#x000A;UNSETENV&#x000D;&#x000A;WRITE&#x000D;&#x000A;ALIAS&#x000D;&#x000A;ASSOCIATE&#x000D;&#x000A;ATTRIBUTE&#x000D;&#x000A;BASIS&#x000D;&#x000A;CATALOG&#x000D;&#x000A;COPY&#x000D;&#x000A;DBSTATUS&#x000D;&#x000A;DELETE&#x000D;&#x000A;DESCRIPTION&#x000D;&#x000A;DIMENSION&#x000D;&#x000A;DOCUMENTATION&#x000D;&#x000A;EXTRADOTS&#x000D;&#x000A;FORMULA&#x000D;&#x000A;GLFORMULA&#x000D;&#x000A;GLNAME&#x000D;&#x000A;MODIFY&#x000D;&#x000A;NEW&#x000D;&#x000A;OBSERVED&#x000D;&#x000A;POST&#x000D;&#x000A;RENAME&#x000D;&#x000A;REOPEN&#x000D;&#x000A;RESTORE&#x000D;&#x000A;SCALAR&#x000D;&#x000A;SEARCH&#x000D;&#x000A;SERIES&#x000D;&#x000A;SET&#x000D;&#x000A;STRINGLENGTH&#x000D;&#x000A;UPDATE&#x000D;&#x000A;WHATS&#x000D;&#x000A;WHICH&#x000D;&#x000A;CONNECT&#x000D;&#x000A;DISCONNECT&#x000D;&#x000A;OPEN&#x000D;&#x000A;EXIT&#x000D;&#x000A;CLOSE&#x000D;&#x000A;OPEN&#x000D;&#x000A;RABORT&#x000D;&#x000A;RASSERT&#x000D;&#x000A;RATTRIBUTE&#x000D;&#x000A;RCOMMIT&#x000D;&#x000A;RCOPY&#x000D;&#x000A;RDELETE&#x000D;&#x000A;RRENAME&#x000D;&#x000A;RSET&#x000D;&#x000A;ADJUST&#x000D;&#x000A;BEST&#x000D;&#x000A;CORRELATE&#x000D;&#x000A;EXTRAPOLATE&#x000D;&#x000A;FIT&#x000D;&#x000A;STEST&#x000D;&#x000A;SUMMARIZE&#x000D;&#x000A;APPLY&#x000D;&#x000A;BACKTO&#x000D;&#x000A;ENTER&#x000D;&#x000A;ENTRY&#x000D;&#x000A;FIELD&#x000D;&#x000A;FORM&#x000D;&#x000A;GHOST&#x000D;&#x000A;INITIALIZE&#x000D;&#x000A;LEAVE&#x000D;&#x000A;MENU&#x000D;&#x000A;RECALCULATE&#x000D;&#x000A;REENTER&#x000D;&#x000A;TERMINATE&#x000D;&#x000A;TRIGGER&#x000D;&#x000A;UNGHOST&#x000D;&#x000A;VALIDATE&#x000D;&#x000A;CLEAR&#x000D;&#x000A;DATA&#x000D;&#x000A;DATA PIE&#x000D;&#x000A;DRAW ARROW&#x000D;&#x000A;DRAW BOX&#x000D;&#x000A;DRAW LINE&#x000D;&#x000A;DRAW MARKING&#x000D;&#x000A;DRAW NOTE&#x000D;&#x000A;DRAW REGION&#x000D;&#x000A;DRAW TEXT&#x000D;&#x000A;GRAPH&#x000D;&#x000A;GRAPH PIE&#x000D;&#x000A;PICTURE&#x000D;&#x000A;REFRESH&#x000D;&#x000A;BLANK&#x000D;&#x000A;FOOTING&#x000D;&#x000A;HEADING&#x000D;&#x000A;LINE&#x000D;&#x000A;NEWPAGE&#x000D;&#x000A;PRINT&#x000D;&#x000A;REPORT&#x000D;&#x000A;SCORE&#x000D;&#x000A;SELECT&#x000D;&#x000A;STROKE&#x000D;&#x000A;TEXT&#x000D;&#x000A;VALPRINT&#x000D;&#x000A;ACCEPT&#x000D;&#x000A;ARGUMENT&#x000D;&#x000A;CANCEL&#x000D;&#x000A;CATCH&#x000D;&#x000A;CLOAD&#x000D;&#x000A;COMPILE&#x000D;&#x000A;ESCAPE&#x000D;&#x000A;EXEC&#x000D;&#x000A;EXECUTE&#x000D;&#x000A;FUNCTION&#x000D;&#x000A;IF&#x000D;&#x000A;LOAD&#x000D;&#x000A;LOCAL&#x000D;&#x000A;LOOP&#x000D;&#x000A;NEXT&#x000D;&#x000A;PEEL&#x000D;&#x000A;PROCEDURE&#x000D;&#x000A;PROMPT&#x000D;&#x000A;READ&#x000D;&#x000A;RESIGNAL&#x000D;&#x000A;RETURN&#x000D;&#x000A;SIGNAL&#x000D;&#x000A;TRY&#x000D;&#x000A;UNLOAD&#x000D;&#x000A;CONCEAL&#x000D;&#x000A;HIDE&#x000D;&#x000A;REVEAL&#x000D;&#x000A;XYGET&#x000D;&#x000A;ITEM&#x000D;&#x000A;GLUE&#x000D;&#x000A;OVER&#x000D;&#x000A;IGNORE&#x000D;&#x000A;IMAGE&#x000D;&#x000A;FALSE&#x000D;&#x000A;TRUE&#x000D;&#x000A;DISP&#x000D;&#x000A;OTHERWISE&#x000D;&#x000A;ELSE&#x000D;&#x000A;DECIMAL&#x000D;&#x000A;channel&#x000D;&#x000A;TRACE</Keywords>
        <Keywords name="Keywords2">ANNUAL&#x000D;&#x000A;BIMONTHLY&#x000D;&#x000A;BIWEEKLY&#x000D;&#x000A;BUSINESS&#x000D;&#x000A;DAILY&#x000D;&#x000A;HOURLY&#x000D;&#x000A;MILLISECONDLY&#x000D;&#x000A;MINUTELY&#x000D;&#x000A;MONTHLY&#x000D;&#x000A;PPY&#x000D;&#x000A;QUARTERLY&#x000D;&#x000A;SECONDLY&#x000D;&#x000A;SEMIANNUAL&#x000D;&#x000A;TENDAY&#x000D;&#x000A;TWICEMONTHLY&#x000D;&#x000A;WEEKLY&#x000D;&#x000A;YPP</Keywords>
        <Keywords name="Keywords3">ACCESS&#x000D;&#x000A;ACF&#x000D;&#x000A;AGGR&#x000D;&#x000A;AGR&#x000D;&#x000A;ALIAS&#x000D;&#x000A;ALL&#x000D;&#x000A;ALPHA&#x000D;&#x000A;AMORT&#x000D;&#x000A;ANNPCT&#x000D;&#x000A;ANY&#x000D;&#x000A;AR&#x000D;&#x000A;ARGUMENT&#x000D;&#x000A;ARIMA&#x000D;&#x000A;ARMA&#x000D;&#x000A;ASSOCIATE&#x000D;&#x000A;AVE&#x000D;&#x000A;BASEFREQ&#x000D;&#x000A;BASETYPE&#x000D;&#x000A;BASIS&#x000D;&#x000A;BIWK&#x000D;&#x000A;BOOLFMT&#x000D;&#x000A;CASEORDER&#x000D;&#x000A;CAVE&#x000D;&#x000A;CHANNELS&#x000D;&#x000A;CHANNELTYPE&#x000D;&#x000A;CHR&#x000D;&#x000A;CLASS&#x000D;&#x000A;CMAX&#x000D;&#x000A;CMIN&#x000D;&#x000A;COLOR&#x000D;&#x000A;CONNAME&#x000D;&#x000A;CONVERT&#x000D;&#x000A;CORR&#x000D;&#x000A;CPROD&#x000D;&#x000A;CREATED&#x000D;&#x000A;CROSSLIST&#x000D;&#x000A;CSUM&#x000D;&#x000A;CTOT&#x000D;&#x000A;DATEFMT&#x000D;&#x000A;DATEOF&#x000D;&#x000A;DATEORDER&#x000D;&#x000A;DAY&#x000D;&#x000A;DB&#x000D;&#x000A;DBCREATED&#x000D;&#x000A;DBUPDATED&#x000D;&#x000A;DBVERSION&#x000D;&#x000A;DESCRIPTION&#x000D;&#x000A;DIFF&#x000D;&#x000A;DIMCHAR&#x000D;&#x000A;DIMENSION&#x000D;&#x000A;DIMNUM&#x000D;&#x000A;DOCUMENTATION&#x000D;&#x000A;DTY&#x000D;&#x000A;EMA&#x000D;&#x000A;EOF&#x000D;&#x000A;ERRORTEXT&#x000D;&#x000A;EVAL&#x000D;&#x000A;EXISTS&#x000D;&#x000A;EXTRACT&#x000D;&#x000A;EXTRADOTS&#x000D;&#x000A;FILE&#x000D;&#x000A;FILESPEC&#x000D;&#x000A;FIRST&#x000D;&#x000A;FIRSTCASE&#x000D;&#x000A;FIRSTDATE&#x000D;&#x000A;FIRSTVALUE&#x000D;&#x000A;FONT&#x000D;&#x000A;FPERIOD&#x000D;&#x000A;FREQ&#x000D;&#x000A;FYEAR&#x000D;&#x000A;GETENV&#x000D;&#x000A;GETID&#x000D;&#x000A;GROWTH&#x000D;&#x000A;HOUR&#x000D;&#x000A;ID&#x000D;&#x000A;INDENT&#x000D;&#x000A;INDEX&#x000D;&#x000A;INISCAN&#x000D;&#x000A;INTERP&#x000D;&#x000A;IRR&#x000D;&#x000A;KIND&#x000D;&#x000A;LARGEST&#x000D;&#x000A;LAST&#x000D;&#x000A;LASTCASE&#x000D;&#x000A;LASTDATE&#x000D;&#x000A;LASTERROR&#x000D;&#x000A;LASTVALUE&#x000D;&#x000A;LASTWARNING&#x000D;&#x000A;LEFT&#x000D;&#x000A;LENGTH&#x000D;&#x000A;LENGTHCASE&#x000D;&#x000A;LENGTHDATE&#x000D;&#x000A;LIST&#x000D;&#x000A;LMAX&#x000D;&#x000A;LMIN&#x000D;&#x000A;LOCATION&#x000D;&#x000A;LOOKUP&#x000D;&#x000A;LOWER&#x000D;&#x000A;LTRIM&#x000D;&#x000A;MA&#x000D;&#x000A;MAGIC&#x000D;&#x000A;MAKE&#x000D;&#x000A;MAKEDATE&#x000D;&#x000A;MAVE&#x000D;&#x000A;MAVEC&#x000D;&#x000A;MAX&#x000D;&#x000A;MAXCASE&#x000D;&#x000A;MAXDATE&#x000D;&#x000A;MCORR&#x000D;&#x000A;MEAN&#x000D;&#x000A;MEDIAN&#x000D;&#x000A;MERGE&#x000D;&#x000A;MILLISECOND&#x000D;&#x000A;MIN&#x000D;&#x000A;MINCASE&#x000D;&#x000A;MINDATE&#x000D;&#x000A;MINUTE&#x000D;&#x000A;MIRROR&#x000D;&#x000A;MISSING&#x000D;&#x000A;MMAX&#x000D;&#x000A;MMEDIAN&#x000D;&#x000A;MMIN&#x000D;&#x000A;MONTH&#x000D;&#x000A;MOVE&#x000D;&#x000A;MSTDDEV&#x000D;&#x000A;MSUM&#x000D;&#x000A;MVAR&#x000D;&#x000A;NAME&#x000D;&#x000A;NAMELOC&#x000D;&#x000A;NL&#x000D;&#x000A;NORMAL&#x000D;&#x000A;NOW&#x000D;&#x000A;NPV&#x000D;&#x000A;NUMBER&#x000D;&#x000A;NUMFMT&#x000D;&#x000A;OBSERVED&#x000D;&#x000A;ORD&#x000D;&#x000A;OVERLAY&#x000D;&#x000A;PACF&#x000D;&#x000A;PACK&#x000D;&#x000A;PAD&#x000D;&#x000A;PAYBACK&#x000D;&#x000A;PCT&#x000D;&#x000A;PENDING&#x000D;&#x000A;PERIOD&#x000D;&#x000A;PIXELS&#x000D;&#x000A;POINTS&#x000D;&#x000A;PRECFMT&#x000D;&#x000A;PROD&#x000D;&#x000A;REALNAME&#x000D;&#x000A;REMEVAL&#x000D;&#x000A;REPEAT&#x000D;&#x000A;REPLACE&#x000D;&#x000A;REVERSE&#x000D;&#x000A;RIGHT&#x000D;&#x000A;ROBLOC&#x000D;&#x000A;ROBVAR&#x000D;&#x000A;RTRIM&#x000D;&#x000A;SANNPCT&#x000D;&#x000A;SARIMA&#x000D;&#x000A;SCAN&#x000D;&#x000A;SCREENINFO&#x000D;&#x000A;SCRIPT&#x000D;&#x000A;SECOND&#x000D;&#x000A;SELECTNAMES&#x000D;&#x000A;SERIES&#x000D;&#x000A;SHIFT&#x000D;&#x000A;SHIFTMTH&#x000D;&#x000A;SHIFTYR&#x000D;&#x000A;SL&#x000D;&#x000A;SLICE&#x000D;&#x000A;SMALLEST&#x000D;&#x000A;SORTDATA&#x000D;&#x000A;SORTINDEX&#x000D;&#x000A;SORTNAMES&#x000D;&#x000A;SOURCE&#x000D;&#x000A;SPECIAL&#x000D;&#x000A;STDDEV&#x000D;&#x000A;STRING&#x000D;&#x000A;STRINGLENGTH&#x000D;&#x000A;STUFF&#x000D;&#x000A;SUBSTRING&#x000D;&#x000A;SUM&#x000D;&#x000A;SYSTEM&#x000D;&#x000A;SYSTEMERROR&#x000D;&#x000A;THISDAY&#x000D;&#x000A;TIME&#x000D;&#x000A;TODAY&#x000D;&#x000A;TOT&#x000D;&#x000A;TRIM&#x000D;&#x000A;TUNE&#x000D;&#x000A;TYPE&#x000D;&#x000A;UNIFORM&#x000D;&#x000A;UNIQUE&#x000D;&#x000A;UPDATED&#x000D;&#x000A;UPPER&#x000D;&#x000A;VAR&#x000D;&#x000A;WEEKDAY&#x000D;&#x000A;WILDLIST&#x000D;&#x000A;WILDNAMES&#x000D;&#x000A;WINFRAMEINFO&#x000D;&#x000A;WININFO&#x000D;&#x000A;YEAR&#x000D;&#x000A;YTD&#x000D;&#x000A;YTYDIFF&#x000D;&#x000A;YTYPCT&#x000D;&#x000A;$</Keywords>
        <Keywords name="Keywords4">ALL&#x000D;&#x000A;AND&#x000D;&#x000A;AUTO&#x000D;&#x000A;BLANK&#x000D;&#x000A;BOOLEAN&#x000D;&#x000A;BREAK&#x000D;&#x000A;CASE&#x000D;&#x000A;CASEORDER&#x000D;&#x000A;CIRCLE&#x000D;&#x000A;COMPLETE&#x000D;&#x000A;DASH&#x000D;&#x000A;DATA&#x000D;&#x000A;DATE&#x000D;&#x000A;DATEORDER&#x000D;&#x000A;DESCRIPTION&#x000D;&#x000A;DIALOG&#x000D;&#x000A;DIV&#x000D;&#x000A;DMAX&#x000D;&#x000A;DMIN&#x000D;&#x000A;DOT&#x000D;&#x000A;ELSE&#x000D;&#x000A;EQ&#x000D;&#x000A;EQL&#x000D;&#x000A;ERRORTEXT&#x000D;&#x000A;EXCEPT&#x000D;&#x000A;FALSE&#x000D;&#x000A;FIRSTCASE&#x000D;&#x000A;FIRSTDATE&#x000D;&#x000A;FRACTION&#x000D;&#x000A;FULL&#x000D;&#x000A;GE&#x000D;&#x000A;GT&#x000D;&#x000A;HORIZONTAL&#x000D;&#x000A;IF&#x000D;&#x000A;INFINITY&#x000D;&#x000A;INFO&#x000D;&#x000A;INPUT&#x000D;&#x000A;INTERSECT&#x000D;&#x000A;KEYBOARD&#x000D;&#x000A;LASTCASE&#x000D;&#x000A;LASTDATE&#x000D;&#x000A;LASTERROR&#x000D;&#x000A;LASTWARNING&#x000D;&#x000A;LE&#x000D;&#x000A;LENGTHCASE&#x000D;&#x000A;LENGTHDATE&#x000D;&#x000A;LOCAL&#x000D;&#x000A;LT&#x000D;&#x000A;MAJOR&#x000D;&#x000A;MATCH&#x000D;&#x000A;MAXCASE&#x000D;&#x000A;MAXDATE&#x000D;&#x000A;MESSAGE&#x000D;&#x000A;MINCASE&#x000D;&#x000A;MINDATE&#x000D;&#x000A;MOD&#x000D;&#x000A;N&#x000D;&#x000A;NA&#x000D;&#x000A;NAMELIST&#x000D;&#x000A;NC&#x000D;&#x000A;ND&#x000D;&#x000A;NE&#x000D;&#x000A;NEGINFINITY&#x000D;&#x000A;NEL&#x000D;&#x000A;NEWLINE&#x000D;&#x000A;NO&#x000D;&#x000A;NOARG&#x000D;&#x000A;NONE&#x000D;&#x000A;NORMAL&#x000D;&#x000A;NOT&#x000D;&#x000A;NOTHING&#x000D;&#x000A;NOW&#x000D;&#x000A;NULL&#x000D;&#x000A;NUMERIC&#x000D;&#x000A;OFF&#x000D;&#x000A;ON&#x000D;&#x000A;OR&#x000D;&#x000A;OUTPUT&#x000D;&#x000A;PERIODICITY&#x000D;&#x000A;PI&#x000D;&#x000A;PICTURE&#x000D;&#x000A;PRECISION&#x000D;&#x000A;PREVIOUS&#x000D;&#x000A;PRTn&#x000D;&#x000A;QUOTE&#x000D;&#x000A;SCAN&#x000D;&#x000A;SCIRCLE&#x000D;&#x000A;SQUARE&#x000D;&#x000A;SSQUARE&#x000D;&#x000A;STANDARD&#x000D;&#x000A;STARMAGICDATE&#x000D;&#x000A;STEP&#x000D;&#x000A;STRIANGLE&#x000D;&#x000A;STRING&#x000D;&#x000A;SUBSET&#x000D;&#x000A;SYSTEMERROR&#x000D;&#x000A;T&#x000D;&#x000A;TERMINAL&#x000D;&#x000A;THEN&#x000D;&#x000A;TIME&#x000D;&#x000A;TODAY&#x000D;&#x000A;TOTAL&#x000D;&#x000A;TRIANGLE&#x000D;&#x000A;TRUE&#x000D;&#x000A;UNIFORM&#x000D;&#x000A;UNION&#x000D;&#x000A;UNSPEC&#x000D;&#x000A;VALUE&#x000D;&#x000A;VERSION&#x000D;&#x000A;WORK&#x000D;&#x000A;XOR&#x000D;&#x000A;YES&#x000D;&#x000A;AS&#x000D;&#x000A;TO&#x000D;&#x000A;IN&#x000D;&#x000A;FOR&#x000D;&#x000A;error</Keywords>
        <Keywords name="Keywords5">ACCEPT&#x000D;&#x000A;ARGUMENT&#x000D;&#x000A;CANCEL&#x000D;&#x000A;CATCH&#x000D;&#x000A;CLOAD&#x000D;&#x000A;COMPILE&#x000D;&#x000A;ESCAPE&#x000D;&#x000A;EXECUTE&#x000D;&#x000A;FUNCTION&#x000D;&#x000A;Function Call&#x000D;&#x000A;IF&#x000D;&#x000A;LOAD&#x000D;&#x000A;LOCAL&#x000D;&#x000A;LOOP&#x000D;&#x000A;NEXT&#x000D;&#x000A;PEEL&#x000D;&#x000A;PROCEDURE&#x000D;&#x000A;Procedure Call&#x000D;&#x000A;PROMPT&#x000D;&#x000A;READ&#x000D;&#x000A;RESIGNAL&#x000D;&#x000A;RETURN&#x000D;&#x000A;SIGNAL&#x000D;&#x000A;TRY&#x000D;&#x000A;UNLOAD</Keywords>
        <Keywords name="Keywords6">@</Keywords>
        <Keywords name="Keywords7">&amp;&amp;</Keywords>
        <Keywords name="Keywords8">%&#x000D;&#x000A;</Keywords>
        <Keywords name="Delimiters">00&quot; 01 02&quot; 03( 04 05) 06{ 07 08} 09[ 10 11] 12&lt; 13 14&gt; 15 16 17 18 19 20 21 22 23</Keywords>
    </KeywordLists>
    <Styles>
        <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
        <WordsStyle name="COMMENTS" fgColor="008000" bgColor="F0F0F0" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS2" fgColor="FF8000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS3" fgColor="18B4C5" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS4" fgColor="BF4043" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS5" fgColor="5C2E2E" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS6" fgColor="0080FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="00FF40" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="KEYWORDS8" fgColor="CC7700" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="OPERATORS" fgColor="FF0000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="FOLDER IN CODE2" fgColor="FFFF00" bgColor="FFFFFF" fontName="@FangSong" fontStyle="3" nesting="0" />
        <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS1" fgColor="0080C0" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="F3F3F3" fontName="Source Code Pro" fontStyle="0" nesting="117702655" />
        <WordsStyle name="DELIMITERS3" fgColor="8000FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
        <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFC4C4" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FF8000" fontName="Source Code Pro" fontStyle="1" nesting="512" />
        <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
        <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
    </Styles>
</UserLang>


问:
how to accept a List<List<String>> from json in rest web services
I have json input as

```<code>{"subkeys":[{"1","2", "3"},{"4","5","6"},{"7","8","9"}]
</code>```

I need to get this as List < List < String > > or List < String[] >.

```<code>@PUT
@Path("/{key}/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public MyResponse loadData( List<List<String>> subkeys) {

}
</code>```

I got the error like

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of     IllegalAnnotationExceptions
java.util.List is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
    at java.util.List
    at private java.util.List     foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse._return

答:
The problem I can see here is due to the wrong format of the JSON input, the correct JSON in your case is:

```<code>{
  "data" :[
  {
  "keys": ["123","456","789"],

  "subkeys": [
      ["1", "2", "3"],
      ["1", "2", "3"],
      ["1", "2", "3"]
   ]
  }
  ]
}
</code>```

try with this and let know.

my code is as follows

```<code>@PUT @Path("/{key}/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public MyResponse loadData( MonitoringDataRequest monReq) {
}

@XmlRootElement(name="data")
public class MonitoringDataRequest {
    private List<MonitoringData> data;

    @XmlElement
    public void setData(List<MonitoringData> data) {
        this.data = data;
    }

    public List<MonitoringData> getData() {
        return data;
    }

}

@XmlRootElement(name="monitoring_data")
public class MonitoringData {

    private List<String> keys;
    private List<SubkeyData> subKeys;

    @XmlElement
    public void setKeys(List<String> keys) {
        this.keys = keys;
    }

    public List<String> getKeys() {
        return keys;
    }

    @XmlElement(name="subkeys")
    public void setSubKeys(List<SubkeyData> subKeys) {
         this.subKeys = subKeys;
    }

    public List<SubkeyData> getSubKeys() {
         return subKeys;
    }

}

@XmlRootElement(name="subkeys")
//@XmlAccessorType(XmlAccessType.NONE)
public class SubkeyData
{

    private List<String[]> subkeys;

    @XmlElement
    public void setSubkeys(List<String[]> subkeys)
    {
        this.subkeys = subkeys;
    }

    public List<String[]> getSubkeys()
    {
        return subkeys;
    }

}
</code>```

Body:
I have json input as

{"subkeys":[{"1","2", "3"},{"4","5","6"},{"7","8","9"}]

I need to get this as List < List < String > > or List < String[] >.

@PUT
@Path("/{key}/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public MyResponse loadData( List<List<String>> subkeys) {

}

I got the error like

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of     IllegalAnnotationExceptions
java.util.List is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
    at java.util.List
    at private java.util.List     foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse._return

Body:
The problem I can see here is due to the wrong format of the JSON input, the correct JSON in your case is:

{
  "data" :[
  {
  "keys": ["123","456","789"],

  "subkeys": [
      ["1", "2", "3"],
      ["1", "2", "3"],
      ["1", "2", "3"]
   ]
  }
  ]
}

try with this and let know.

my code is as follows

@PUT @Path("/{key}/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public MyResponse loadData( MonitoringDataRequest monReq) {
}

@XmlRootElement(name="data")
public class MonitoringDataRequest {
    private List<MonitoringData> data;

    @XmlElement
    public void setData(List<MonitoringData> data) {
        this.data = data;
    }

    public List<MonitoringData> getData() {
        return data;
    }

}

@XmlRootElement(name="monitoring_data")
public class MonitoringData {

    private List<String> keys;
    private List<SubkeyData> subKeys;

    @XmlElement
    public void setKeys(List<String> keys) {
        this.keys = keys;
    }

    public List<String> getKeys() {
        return keys;
    }

    @XmlElement(name="subkeys")
    public void setSubKeys(List<SubkeyData> subKeys) {
         this.subKeys = subKeys;
    }

    public List<SubkeyData> getSubKeys() {
         return subKeys;
    }

}

@XmlRootElement(name="subkeys")
//@XmlAccessorType(XmlAccessType.NONE)
public class SubkeyData
{

    private List<String[]> subkeys;

    @XmlElement
    public void setSubkeys(List<String[]> subkeys)
    {
        this.subkeys = subkeys;
    }

    public List<String[]> getSubkeys()
    {
        return subkeys;
    }

}


问:
Get page by name or by number interop Word
I'm trying to access a page in Word by it's name or number. I thought I was going in the right direction but there doesn't seem to be a page.name or page.number property. The issue is in my if statement where I'm trying to say if there is a page named Page 4 Content then select it.

```<code>    var wordApplication = (word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
    string path = CommonMethods.getFile(fileName);

    myDoc = wordApplication.Documents.Open(path);
    wordApplication.Visible = true;
    wordApplication.WindowState = word.WdWindowState.wdWindowStateMaximize;

    word.Pages pages = myDoc.ActiveWindow.ActivePane.Pages;

    foreach (word.Page p in pages )
    {
        if (p.)
        {

        }
    }
</code>```

答:
As you already mentioned there is no number or name property on the page object.

In order to get the page number you have to access the Information property of a Range or Selection object on that page.

In addition to that I recommend to study the article Selecting or referring to a page in the Word object model by Shauna Kelly. In her article she explains in detail why it is often not a good idea to rely on the page object for automated document processing. The reason for that is that Word uses a flow layout instead of a fixed layout. In order to determine the current page rendering Word has to talk to the current printer driver. This means that your page breaks may vary depending on your printer.

Body:
I'm trying to access a page in Word by it's name or number. I thought I was going in the right direction but there doesn't seem to be a page.name or page.number property. The issue is in my if statement where I'm trying to say if there is a page named Page 4 Content then select it.

    var wordApplication = (word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
    string path = CommonMethods.getFile(fileName);

    myDoc = wordApplication.Documents.Open(path);
    wordApplication.Visible = true;
    wordApplication.WindowState = word.WdWindowState.wdWindowStateMaximize;

    word.Pages pages = myDoc.ActiveWindow.ActivePane.Pages;

    foreach (word.Page p in pages )
    {
        if (p.)
        {

        }
    }


问:
When selected option from dropdown then how to hide that selected option into another dropdown using jQuery

<select>
  <option value = "volvo" > Volvo < /option>
  <option value = "saab" > Saab < /option>
  <option value = "vw" > VW < /option>
  <option value = "audi"> Audi < /option>
</select>```

I am having many dropdown where all dropdown having same option value but when user select option then that selected value should hide or remove in others dropdown and if user changes option that that previous selected option should come into that option and currently selected option should hide into other dropdown.
when selected option from dropdown then how to hide that selected option into another dropdown.I tried to find solution of this but no one's code working properly.

答:
Add event handler to the select boxes then find the other select boxes and remove the appropriate option elements. Also, store the selected value as data so we can put it back;

$("select").change(function(){
  var selVal = $(this).val();
  var prevVal = $(this).data("selVal");

  if(selVal !== prevVal)
  {
      //Take out the new select
      $("select").not(this).find("option[value='" + selVal + "']").remove();

      //Store selcted val so we can put it back
      $(this).data("selVal", selVal);

      //Get the previously selected option... clone it and append it to the others
      var newOption = $(this).find("option[value='" + prevVal + "']").clone();
      $("select").not(this).append(newOption);
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<select>
  <option value = "volvo" > Volvo </option>
  <option value = "saab" > Saab </option>
  <option value = "vw" > VW </option>
  <option value = "audi"> Audi </option>
</select>

<select>
  <option value = "volvo" > Volvo </option>
  <option value = "saab" > Saab </option>
  <option value = "vw" > VW </option>
  <option value = "audi"> Audi </option>
</select>
<select>
  <option value = "volvo" > Volvo </option>
  <option value = "saab" > Saab </option>
  <option value = "vw" > VW </option>
  <option value = "audi"> Audi </option>
</select>
<select>
  <option value = "volvo" > Volvo </option>
  <option value = "saab" > Saab </option>
  <option value = "vw" > VW </option>
  <option value = "audi"> Audi </option>
</select></code>```

Body:
<select>
  <option value = "volvo" > Volvo < /option>
  <option value = "saab" > Saab < /option>
  <option value = "vw" > VW < /option>
  <option value = "audi"> Audi < /option>
</select>

I am having many dropdown where all dropdown having same option value but when user select option then that selected value should hide or remove in others dropdown and if user changes option that that previous selected option should come into that option and currently selected option should hide into other dropdown.
when selected option from dropdown then how to hide that selected option into another dropdown.I tried to find solution of this but no one's code working properly.

Body:
Add event handler to the select boxes then find the other select boxes and remove the appropriate option elements. Also, store the selected value as data so we can put it back;

$("select").change(function(){
  var selVal = $(this).val();
  var prevVal = $(this).data("selVal");

  if(selVal !== prevVal)
  {
      //Take out the new select
      $("select").not(this).find("option[value='" + selVal + "']").remove();

      //Store selcted val so we can put it back
      $(this).data("selVal", selVal);

      //Get the previously selected option... clone it and append it to the others
      var newOption = $(this).find("option[value='" + prevVal + "']").clone();
      $("select").not(this).append(newOption);
  }
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<select>
  <option value = "volvo" > Volvo </option>
  <option value = "saab" > Saab </option>
  <option value = "vw" > VW </option>
  <option value = "audi"> Audi </option>
</select>

<select>
  <option value = "volvo" > Volvo </option>
  <option value = "saab" > Saab </option>
  <option value = "vw" > VW </option>
  <option value = "audi"> Audi </option>
</select>
<select>
  <option value = "volvo" > Volvo </option>
  <option value = "saab" > Saab </option>
  <option value = "vw" > VW </option>
  <option value = "audi"> Audi </option>
</select>
<select>
  <option value = "volvo" > Volvo </option>
  <option value = "saab" > Saab </option>
  <option value = "vw" > VW </option>
  <option value = "audi"> Audi </option>
</select>


问:
How to throw InvalidArgumentException JavaScript?

Objective

Throw InvalidArgumentException in a JavaScript method like one does in Java or similar languages.

Background

I have been trying to familiarize myself with JavaSctipt error handling, and I know I can throw exceptions using the throw keyword.

To achieve this, I read the throw documentation on MDN and the Error documentation on MDN as well.

Problem

So far this is my code:

```<code>if (mySize >= myArray.length)
    throw new Error("InvalidArgumentExcpetion - BANG!!!!");
</code>```

This code has some problems for me:

I have the text in the exception itself. Right now I have BANG, but tomorrow I may want BONG and if I decide to change it, I have to look everywhere!

I am using an Error, and not really a new object with the type InvalidArgumentExcpetion. Is this the correct way?

Questions

So now I am confused.

Should I create a new object like in the throw documentation, or create an Error Message?

Doesn't JavaScript have a InvalidArgumentException object that I can use?

How should I proceed in order to have a maintainable way to throw errors that uses ECMA6?

答:
I have been trying to familiarize myself with JavaSctipt [sic] error handling, and I know I can throw exceptions [....] but tomorrow I may want BONG [....]

You could throw a TypeError or a SyntaxError if they make more sense. But no need to get too fancy. Simply throw an Error with a message as it looks as though you're already doing:

```<code>if (myArray && myArray.length < mySize) throw new Error('`mySize` must be larger');
</code>```

And if you decide tomorrow you want BONG:

```<code>if (!myBong) throw new Error('Officer, that is not `myBong`');
</code>```

For more info on built-in errors types, read the docs.

Body:
Objective

Throw InvalidArgumentException in a JavaScript method like one does in Java or similar languages.

Background

I have been trying to familiarize myself with JavaSctipt error handling, and I know I can throw exceptions using the throw keyword.

To achieve this, I read the throw documentation on MDN and the Error documentation on MDN as well.

Problem

So far this is my code:

if (mySize >= myArray.length)
    throw new Error("InvalidArgumentExcpetion - BANG!!!!");

This code has some problems for me:

I have the text in the exception itself. Right now I have BANG, but tomorrow I may want BONG and if I decide to change it, I have to look everywhere!

I am using an Error, and not really a new object with the type InvalidArgumentExcpetion. Is this the correct way?

Questions

So now I am confused.

Should I create a new object like in the throw documentation, or create an Error Message?

Doesn't JavaScript have a InvalidArgumentException object that I can use?

How should I proceed in order to have a maintainable way to throw errors that uses ECMA6?

Body:
I have been trying to familiarize myself with JavaSctipt [sic] error handling, and I know I can throw exceptions [....] but tomorrow I may want BONG [....]

You could throw a TypeError or a SyntaxError if they make more sense. But no need to get too fancy. Simply throw an Error with a message as it looks as though you're already doing:

if (myArray && myArray.length < mySize) throw new Error('`mySize` must be larger');

And if you decide tomorrow you want BONG:

if (!myBong) throw new Error('Officer, that is not `myBong`');

For more info on built-in errors types, read the docs.


问:
Using ?: shorthand in laravel
I have a login function that i am using to login users using telephone numbers. I am getting the phone numbers from the user and then using the phone number to fetch the matching email address.

For that i have this code

```<code>public function processLogin(Request $request){
    $phone = $request->get('phone');
    $getEmail = User::where('users_telephone_number', '=',$phone )->first()->email;
    $email = $getEmail;
    $password = $request->get('password');
    //echo $email.$password;
    $data = array(
        'email' => $email,
        'password' => $password
        );

    if (Auth::attempt($data,true)) {
</code>```

When the number is wrong, i get this error

Trying to get property of non-object

To solve the problem i want to have the variable $getEmail to be equal to  none@dont.com which will fail well like all other wrong email and password combos.

How can i make sure i catch errors in this one line i am using to fetch the email

User::where('users_telephone_number', '=',$phone )->first()->email;

答:
Check the $user first, then access the email.</p>

```<code>$user = User::where('users_telephone_number', '=',$phone )->first();
$email = isset($user) ? $user->email : 'default string';
</code>```

Title: Using ?: shorthand in laravel

Body:
I have a login function that i am using to login users using telephone numbers. I am getting the phone numbers from the user and then using the phone number to fetch the matching email address.

For that i have this code

public function processLogin(Request $request){
    $phone = $request->get('phone');
    $getEmail = User::where('users_telephone_number', '=',$phone )->first()->email;
    $email = $getEmail;
    $password = $request->get('password');
    //echo $email.$password;
    $data = array(
        'email' => $email,
        'password' => $password
        );

    if (Auth::attempt($data,true)) {

When the number is wrong, i get this error

Trying to get property of non-object

To solve the problem i want to have the variable $getEmail to be equal to  none@dont.com which will fail well like all other wrong email and password combos.

How can i make sure i catch errors in this one line i am using to fetch the email

User::where('users_telephone_number', '=',$phone )->first()->email;

Body:
Check the $user first, then access the email.

$user = User::where('users_telephone_number', '=',$phone )->first();
$email = isset($user) ? $user->email : 'default string';


问:
Using libcurl on visual c++ to login to a website
I'm using libcurl to open/save a remote file and parse html files and everything is going great.

I was wondering if it's possible to use c++ and curl to login to a website (not a ssl one) and from there maybe manipulate the html that is generated?

I would love to do that within my executable (not to use php).

Thanks in advance.

答:
I figured there is a way if anyone stumbles upon this. there's an example here:
http://www.hackthissite.org/articles/read/1078

the website has a some what black hat approach but the example provided was useful.


问:
cordova cli installation error
I try updating my ionic cordova cli when i started getting issues installing the two package, but now ionic have been successfully installed and i have tried installing the cordova now, all attempt was not successful
This is the error message am getting

```<code>$ npm install -g cordova
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "cordova"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! file C:\Users\Akinsanya Olanrewaju\AppData\Roaming\npm-cache\cordova-js
\3.7.3\package\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token
npm ERR! File: C:\Users\Akinsanya Olanrewaju\AppData\Roaming\npm-cache\cordova-j
s\3.7.3\package\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! Please include the following file with any support request:
npm ERR!     f:\npm-debug.log
</code>```

Please i need you help as am in the middle of a project, maybe any other sources of installing cordova on my machine except from npm will be appreciated or any ways to fix this issues.

Thanks.

答:
Hi Try cleaning you node cache by running

```<code>npm cache clean
</code>```

then delete folder cordova.delete or cordova at the file location

```<code> C:\Users\USER\AppData\Roaming\npm\node_modules
</code>```

and then search for PowerShell in run and open it.and type

```<code>npm install -g cordova
</code>```

worked for me.
and please try disabling your antivirus as well.

Title: cordova cli installation error

Body:
I try updating my ionic cordova cli when i started getting issues installing the two package, but now ionic have been successfully installed and i have tried installing the cordova now, all attempt was not successful
This is the error message am getting

$ npm install -g cordova
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "cordova"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! file C:\Users\Akinsanya Olanrewaju\AppData\Roaming\npm-cache\cordova-js
\3.7.3\package\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token
npm ERR! File: C:\Users\Akinsanya Olanrewaju\AppData\Roaming\npm-cache\cordova-j
s\3.7.3\package\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! Please include the following file with any support request:
npm ERR!     f:\npm-debug.log

Please i need you help as am in the middle of a project, maybe any other sources of installing cordova on my machine except from npm will be appreciated or any ways to fix this issues.

Thanks.

Body:
Hi Try cleaning you node cache by running

npm cache clean

then delete folder cordova.delete or cordova at the file location

 C:\Users\USER\AppData\Roaming\npm\node_modules

and then search for PowerShell in run and open it.and type

npm install -g cordova

worked for me.
and please try disabling your antivirus as well.