问:
JSF - Bean injection trouble
As suggested by a user time ago in another question, I need to inject a bean in another bean.

So, i do the following :

```<code>@ManagedBean
@RequestScoped
public class Articles {
    private String selectedMenu;

    @ManagedProperty(value="#{user}")
    private UserManager user;

    @PostConstruct
    public void init() {
        if(selectedMenu==null || selectedMenu.trim().isEmpty()) {
            this.selectedMenu="0";
        }
    }

    // now here i should access to user.methods

    // getter and setter
}
</code>```

In fact, i can't access to UserManager data. I get these error :

BROWSER malformedXML: INVALID_STATE_ERR: Dom Exception 11

SERVER LOG
30-nov-2010 15.36.58 javax.faces.component.UIViewRoot$ViewMap put
AVVERTENZA: Setting non-serializable attribute value into ViewMap: (key: profileSelector, value class: model.ProfileSelector)
30-nov-2010 15.36.59 com.sun.faces.mgbean.BeanManager preProcessBean
GRAVE: JSF will be unable to create managed bean articles when it is requested.  The following problems where found:
     - Property user for managed bean articles does not exist.  Check that appropriate getter and/or setter methods exist.
30-nov-2010 15.36.59 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
GRAVE: com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean articles.  The following problems were found:
     - Property user for managed bean articles does not exist.  Check that appropriate getter and/or setter methods exist.

If i comment @ManagedProperty(value="#{user}") and private UserManager user; than i don't see any error. So that's the problem. What am I wrong?

Cheers

答:
malformedXML: INVALID_STATE_ERR: Dom Exception 11

This XML error indicates an error in your view (the XHTML), not in the bean. I don't understand why this error occurred, but likely you've a pretty complex component tree with several rendered attributes of which one is depending on the user property which caused a wrong state in the XML tree in the client side.

As to the server logs:

AVVERTENZA: Setting non-serializable attribute value into ViewMap: (key: profileSelector, value class: model.ProfileSelector)

This does not necessarily harm, but to fix it, you need to let the class implement java.io.Serializable.

```<code>public class ProfileSelector implements Serializable {}
</code>```

This way the server will be able to transfer the instance over network and/or store the instance on harddisk instead of in memory whenever necessary (when the server reboots or is placed in a server cluster).

30-nov-2010 15.36.59 com.sun.faces.mgbean.BeanManager preProcessBean GRAVE: JSF will be unable to create managed bean articles when it is requested. The following problems where found: - Property user for managed bean articles does not exist. Check that appropriate getter and/or setter methods exist.

This is self-explaining as well. Ensure that there are proper getter/setter methods for the property user of the managed bean with name articles.

```<code>@ManagedBean
@RequestScoped
public class Articles {

    @ManagedProperty(value="#{user}")
    private UserManager user;

    public UserManager getUser() {
        return user;
    }

    public void setUser(UserManager user) {
        this.user = user;
    }

}
</code>```

You can if necessary let your IDE autogenerate them. In Eclipse, check the Source section in rightclick context menu (Alt+Shift+S).

30-nov-2010 15.36.59 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit GRAVE: com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean articles. The following problems were found: - Property user for managed bean articles does not exist. Check that appropriate getter and/or setter methods exist.

This has the same problem cause.

Title: JSF - Bean injection trouble

Body:
As suggested by a user time ago in another question, I need to inject a bean in another bean.

So, i do the following :

@ManagedBean
@RequestScoped
public class Articles {
    private String selectedMenu;

    @ManagedProperty(value="#{user}")
    private UserManager user;

    @PostConstruct
    public void init() {
        if(selectedMenu==null || selectedMenu.trim().isEmpty()) {
            this.selectedMenu="0";
        }
    }

    // now here i should access to user.methods

    // getter and setter
}

In fact, i can't access to UserManager data. I get these error :

BROWSER malformedXML: INVALID_STATE_ERR: Dom Exception 11

SERVER LOG
30-nov-2010 15.36.58 javax.faces.component.UIViewRoot$ViewMap put
AVVERTENZA: Setting non-serializable attribute value into ViewMap: (key: profileSelector, value class: model.ProfileSelector)
30-nov-2010 15.36.59 com.sun.faces.mgbean.BeanManager preProcessBean
GRAVE: JSF will be unable to create managed bean articles when it is requested.  The following problems where found:
     - Property user for managed bean articles does not exist.  Check that appropriate getter and/or setter methods exist.
30-nov-2010 15.36.59 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
GRAVE: com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean articles.  The following problems were found:
     - Property user for managed bean articles does not exist.  Check that appropriate getter and/or setter methods exist.

If i comment @ManagedProperty(value="#{user}") and private UserManager user; than i don't see any error. So that's the problem. What am I wrong?

Cheers

Body:
malformedXML: INVALID_STATE_ERR: Dom Exception 11

This XML error indicates an error in your view (the XHTML), not in the bean. I don't understand why this error occurred, but likely you've a pretty complex component tree with several rendered attributes of which one is depending on the user property which caused a wrong state in the XML tree in the client side.

As to the server logs:

AVVERTENZA: Setting non-serializable attribute value into ViewMap: (key: profileSelector, value class: model.ProfileSelector)

This does not necessarily harm, but to fix it, you need to let the class implement java.io.Serializable.

public class ProfileSelector implements Serializable {}

This way the server will be able to transfer the instance over network and/or store the instance on harddisk instead of in memory whenever necessary (when the server reboots or is placed in a server cluster).

30-nov-2010 15.36.59 com.sun.faces.mgbean.BeanManager preProcessBean GRAVE: JSF will be unable to create managed bean articles when it is requested. The following problems where found: - Property user for managed bean articles does not exist. Check that appropriate getter and/or setter methods exist.

This is self-explaining as well. Ensure that there are proper getter/setter methods for the property user of the managed bean with name articles.

@ManagedBean
@RequestScoped
public class Articles {

    @ManagedProperty(value="#{user}")
    private UserManager user;

    public UserManager getUser() {
        return user;
    }

    public void setUser(UserManager user) {
        this.user = user;
    }

}

You can if necessary let your IDE autogenerate them. In Eclipse, check the Source section in rightclick context menu (Alt+Shift+S).

30-nov-2010 15.36.59 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit GRAVE: com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean articles. The following problems were found: - Property user for managed bean articles does not exist. Check that appropriate getter and/or setter methods exist.

This has the same problem cause.


来源: stackexchange

问:
How to encode/escape unicode text in Python3?
How can I create unicode entities out of python3 string objects?

Having smt _ 1 #, I want to generate smt%20_%201%20%23

答:
Use quote from urllib.parse:

```<code>>>> from urrlib.parse import quote
>>> quote('smt _ 1 #')
'smt%20_%201%20%23'
</code>```

Since you aren't dealing with a url, you don't seem to need to specify any safe characters. If you'd also require / to be escaped, pass safe='' to quote.

ContentLicense: CC BY-SA 3.0

Body:
Use quote from urllib.parse:

>>> from urrlib.parse import quote
>>> quote('smt _ 1 #')
'smt%20_%201%20%23'

Since you aren't dealing with a url, you don't seem to need to specify any safe characters. If you'd also require / to be escaped, pass safe='' to quote.


问:
Protractor - Get array from canvas attribute in Angular2 using ng2-charts/Chart.js
I'm using ng2-charts which is based on chart.js
Using it in my Angular 2 Application I want to check some data with my protractor test in one of the attributes of the <canvas> element.

I can't find a way to access the data. I found solutions with evaluate but I'm not sure if that's for Angular1 or 2.

Following solution with evaluate did not work for me:
Test a Chart.js canvas with Protractor

My canvas setup:

```<code>  <div style="display: block">
    <canvas id="test"
            [datasets]="chartData"
            [labels]="chartLabels"
            [options]="ChartOptions"
            [legend]="showRegions"
            [chartType]="barChartType"
            height="100%"></canvas>
  </div>
</code>```

When the page is loaded the canvas element looks like this (I removed the label attributes for convinience).

```<code><canvas id="test" ng-reflect-datasets="[object Object],[object Object]" ng-reflect-chart-type="bar" ng-reflect-legend="true"></canvas>
</code>```

Now I find my canvas element like this:

```<code>var canvas = element(by.css("canvas#test[ng-reflect-datasets]"));
</code>```

And from here I'm stuck. If I access the ng-reflect-datasets attribute I only get the string "[object Object]..." but I need the values inside these objects.

Is this somehow possible?

答:
Did you try it like this...

```<code>var canvas = element(by.css("canvas#test[datasets]"));
canvas.evaluate("chartData").then(function (datasets) {
    // datasets is an array of objects that each have data, label, etc.
    console.dir(datasets[0].data);
});
</code>```

Note, I just derived this from the SO answer in your question + my knowledge of ng2-charts (I have not used Protractor before).

Body:
I'm using ng2-charts which is based on chart.js
Using it in my Angular 2 Application I want to check some data with my protractor test in one of the attributes of the <canvas> element.

I can't find a way to access the data. I found solutions with evaluate but I'm not sure if that's for Angular1 or 2.

Following solution with evaluate did not work for me:
Test a Chart.js canvas with Protractor

My canvas setup:

    <canvas id="test"
            [datasets]="chartData"
            [labels]="chartLabels"
            [options]="ChartOptions"
            [legend]="showRegions"
            [chartType]="barChartType"
            height="100%"></canvas>

When the page is loaded the canvas element looks like this (I removed the label attributes for convinience).

<canvas id="test" ng-reflect-datasets="[object Object],[object Object]" ng-reflect-chart-type="bar" ng-reflect-legend="true"></canvas>

Now I find my canvas element like this:

var canvas = element(by.css("canvas#test[ng-reflect-datasets]"));

And from here I'm stuck. If I access the ng-reflect-datasets attribute I only get the string "[object Object]..." but I need the values inside these objects.

Is this somehow possible?

Body:
Did you try it like this...

var canvas = element(by.css("canvas#test[datasets]"));
canvas.evaluate("chartData").then(function (datasets) {
    // datasets is an array of objects that each have data, label, etc.
    console.dir(datasets[0].data);
});

Note, I just derived this from the SO answer in your question + my knowledge of ng2-charts (I have not used Protractor before).


问:
Akamai forward caching dynamic content like web services
I have a general question about what Akamai can provide for web services. We are looking to develop a web service and our web service application is hosted in the US, but we would expect that our web service can be accessed from across the globe. I would like to know if 1) Akamai caches dynamic content like web services, and 2) can Akamai provide some better performance if it can cache a web service.</p>

```<code>Such as a .ASMX endpoint where there is nothing static about it. The content is 100% dynamic as it fetches data from the back-end like a database and returns it. I’m wondering if Akamai would apply here.
</code>```

答:
Akamai can definitely be used for web services, it all comes down to your own decisions about how long content should be valid before the server (your service) needs to supply a new version of the content. In simple terms Akamai are only doing what http will do for you anyway, if you set cache control headers for the resources you serve from your API then clients will look at those headers and not request new copies of resources if you've told them that the resource is valid for 10s/10m/10h, etc.

Of course in practice Akamai does a lot more than that, firstly they have over 200k servers globally so your content will sit close to your users wherever they are in the world meaning if that content is still fresh your users will get it very quickly (from a server near them, not from your servers). Secondly, if they do need to request content from you, they do it over a super-optimised network which monitors itself to ensure the quickest route across the globe is taken. If you're concerned about them serving stale content you can even have every request go to your service to check if there's a more up to date copy, eg by using eTags.

The whole thing is highly configurable as well as being extensible from your end using custom headers to instruct their network how you want to deal with different content and endpoints. This is just a quick overview, they can do a lot more as well, definitely worth a look.

Body:
I have a general question about what Akamai can provide for web services. We are looking to develop a web service and our web service application is hosted in the US, but we would expect that our web service can be accessed from across the globe. I would like to know if 1) Akamai caches dynamic content like web services, and 2) can Akamai provide some better performance if it can cache a web service.

Such as a .ASMX endpoint where there is nothing static about it. The content is 100% dynamic as it fetches data from the back-end like a database and returns it. I’m wondering if Akamai would apply here.


问:
How can i add a renderer to gameobject in script?
```<code>GameObject cube = Cube.CreatePrimitive(Cube.CubePivotPoint.UPLEFT);
cube.GetComponent<Renderer>().material.color = Color.blue;
</code>```

When i assign the color i'm getting exception on the line:

```<code>cube.GetComponent<Renderer>().material.color = Color.blue;
</code>```

MissingComponentException: There is no 'Renderer' attached to the "CubeHolder" game object, but a script is trying to access it.
  You probably need to add a Renderer to the game object "CubeHolder". Or your script needs to check if the component is attached before using it.

NOTE:

I am using the CUBE class from this answer to create a cube, not the Unity's GameObject.CreatePrimitive function.

答:
When I wrote the CUBE class, I forgot to mention that the Cubes' renderer is now a child of another Object.

You don't need to add Renderer or MeshRenderer to the cube. It's is already there. The cube is simply a child object and the parent Object is named CubeHolder. You need to use GetComponentInChildren to get its Renderer.

```<code>cube.GetComponent<Renderer>().material.color = Color.blue;
</code>```

should now be:

```<code>cube.GetComponentInChildren<Renderer>().material.color = Color.blue;
</code>```

Body:
GameObject cube = Cube.CreatePrimitive(Cube.CubePivotPoint.UPLEFT);
cube.GetComponent<Renderer>().material.color = Color.blue;

When i assign the color i'm getting exception on the line:

cube.GetComponent<Renderer>().material.color = Color.blue;

MissingComponentException: There is no 'Renderer' attached to the "CubeHolder" game object, but a script is trying to access it.
  You probably need to add a Renderer to the game object "CubeHolder". Or your script needs to check if the component is attached before using it.

NOTE:

I am using the CUBE class from this answer to create a cube, not the Unity's GameObject.CreatePrimitive function.

Body:
When I wrote the CUBE class, I forgot to mention that the Cubes' renderer is now a child of another Object.

You don't need to add Renderer or MeshRenderer to the cube. It's is already there. The cube is simply a child object and the parent Object is named CubeHolder. You need to use GetComponentInChildren to get its Renderer.

cube.GetComponent<Renderer>().material.color = Color.blue;

should now be:

cube.GetComponentInChildren<Renderer>().material.color = Color.blue;


问:
Git: How to maintain two branches of a project and merge only shared data?
Suppose I have two branches of a project IMClient-MacOS and IMClient-Windows, and their code only differs by (let's say) one directory main/.  All the other directories contain system-independent code and are interchangeable.

Some workers work on the Windows version, and some work on the MacOS version.  How do they prevent overwriting changing into the main/ directory when they merge from their counterparts' branch?  Is there a way to merge in Git that will always ignore the OS-dependent directory?

答:
There's an option for ignore the whole file or directory structure, but then those file won't get added to the repo at all. I think you already know that, by using .gitignore file

What I think is having a separate branch for Windows and OS X's code, as you said. Then you'll merge the change by cherry-picking the code from the other branch (the syntax is git cherry-pick refspec) However, those developers should always watch for a 'change' on other os's branch.

I would also suggest that always make a separate commit for files in main, so that it won't be mix-up when you're cherry-picking the branch.

OwnerDisplayName: Jake

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Sikachu


问:
$.Ajax POST, accessing return data
I'm currently working on a ASP.NET Webforms site and I've run in to a small problem. Been searching around for 2 hours now and I got a deadline, so hoping someone here can assist.

On my .cs file I have the following Webmethod

```<code>[WebMethod]
   public static string IsJobEditable(int jobid)
   {
       try
       {
           string isEditable = "false";

           JobsBLL jbl = new JobsBLL();

           int jobStatusId = jbl.GetJobStatusId(jobid);

           if(jobStatusId == Convert.ToInt32(ConstantsUtil.JobStatus.Waiting) || jobStatusId == Convert.ToInt32(ConstantsUtil.JobStatus.Edit))
           {
               isEditable = "true";
           }

           return isEditable;

       }
       catch (Exception ex)
       {

           throw ex;
       }
   }
</code>```

This function in this case will ALWAYS return TRUE as a string.

On Aspx page I have the following

```<code>$(function () {

           $.ajax({

               type: "POST",
               url: "Coordination.aspx/IsJobEditable",
               data: "{jobid:" + jobid + "}",
               contentType: "application/json; charset=utf-8",
               dataType: "text",
               success: function (result) {

                   alert(result);

                   // This is written out in the alert {"d":"true"}
                   // I want this in a variable as a string
                   // so I can do a check on it before I do some other actions
                   // The format is not a String so i cannot split on it to
                   // retrieve the "true" part.

               },
               error: function (err, result) { alert(err); }

           });
       });
</code>```

As you can see in the comments the value I get back in the Callback method is in to me a weird format. The type is unknown and I need this value to be able to proceed with my entire method surrounding the small portion of the Javascript.

So can anyone point me into the direction where I can access the result variable / data as a var or anything else that will let me put it into a var (as a string).

答: According to two articles I found, I think you want to specify "DataType" as json not as text (since you're expecting a content-type of json to be returned). That may be your issue, though i don't have a sample project in front of me to test on. Your result is also probably result.d as outlined in those same articles.

Title: $.Ajax POST, accessing return data

Body:
I'm currently working on a ASP.NET Webforms site and I've run in to a small problem. Been searching around for 2 hours now and I got a deadline, so hoping someone here can assist.

On my .cs file I have the following Webmethod

[WebMethod]
   public static string IsJobEditable(int jobid)
   {
       try
       {
           string isEditable = "false";

           JobsBLL jbl = new JobsBLL();

           int jobStatusId = jbl.GetJobStatusId(jobid);

           if(jobStatusId == Convert.ToInt32(ConstantsUtil.JobStatus.Waiting) || jobStatusId == Convert.ToInt32(ConstantsUtil.JobStatus.Edit))
           {
               isEditable = "true";
           }

           return isEditable;

       }
       catch (Exception ex)
       {

           throw ex;
       }
   }

This function in this case will ALWAYS return TRUE as a string.

On Aspx page I have the following

$(function () {

           $.ajax({

               type: "POST",
               url: "Coordination.aspx/IsJobEditable",
               data: "{jobid:" + jobid + "}",
               contentType: "application/json; charset=utf-8",
               dataType: "text",
               success: function (result) {

                   alert(result);

                   // This is written out in the alert {"d":"true"}
                   // I want this in a variable as a string
                   // so I can do a check on it before I do some other actions
                   // The format is not a String so i cannot split on it to
                   // retrieve the "true" part.

               },
               error: function (err, result) { alert(err); }

           });
       });

As you can see in the comments the value I get back in the Callback method is in to me a weird format. The type is unknown and I need this value to be able to proceed with my entire method surrounding the small portion of the Javascript.

So can anyone point me into the direction where I can access the result variable / data as a var or anything else that will let me put it into a var (as a string).


问:
Replacing a lambda command in a Tkinter button but giving wrong answer
In my code I have a custom frame class which contains multiple entries and a button that should be able to remove itself from the overall frame. There is a second button that adds a section to a list that manages all of the different sections:

```<code>def addSection():
    sectionNumber = len(sections)
    if sectionNumber <= 25:
        sections.append(sectionFrame(SectionsFrame.interior,sectionNumber))
        sections[sectionNumber].pack(side=TOP)
        sections[sectionNumber].getButton().config(command = lambda: removeSpecificSection(sections[sectionNumber].getSectionNumber()))
</code>```

Now when I remove a section I want to give each section below the one removed the proper place in the list. this is the section button method:

```<code>def removeSpecificSection(index):
    sections[index].pack_forget()
    del(sections[index])
    for section in sections[index:]:
        section.getButton().deletecommand(section.getButton().cget("command"))
         section.moveDownIndex()
         section.getButton().config(command = lambda: removeSpecificSection(section.getSectionNumber()))
</code>```

section.moveDownIndex() is only self.sectionNumber=self.sectionNumber-1 in its own class.

The problem that I'm getting is that if I try to remove any of the sections that were touched by the remove function it will just remove the last section and the index that is coming into the second call confirms that's it always the last index.

Maybe I don't understand the lambda function, why each button is not taking the its own section for when it calls the remove function ?

答:
This is a very common beginners trap. lambda is late binding, which means it uses the value from sectionNumber when it's called, not from when it was defined. To get the behavior you want you need to use functools.partial:

```<code>from functools import partial
...
sections[sectionNumber].getButton().config(command = partial(removeSpecificSection, sections[sectionNumber])))
</code>```

and then call the getSectionNumber in the removeSpecificSection method.

Body:
In my code I have a custom frame class which contains multiple entries and a button that should be able to remove itself from the overall frame. There is a second button that adds a section to a list that manages all of the different sections:

def addSection():
    sectionNumber = len(sections)
    if sectionNumber <= 25:
        sections.append(sectionFrame(SectionsFrame.interior,sectionNumber))
        sections[sectionNumber].pack(side=TOP)
        sections[sectionNumber].getButton().config(command = lambda: removeSpecificSection(sections[sectionNumber].getSectionNumber()))

Now when I remove a section I want to give each section below the one removed the proper place in the list. this is the section button method:

def removeSpecificSection(index):
    sections[index].pack_forget()
    del(sections[index])
    for section in sections[index:]:
        section.getButton().deletecommand(section.getButton().cget("command"))
         section.moveDownIndex()
         section.getButton().config(command = lambda: removeSpecificSection(section.getSectionNumber()))

section.moveDownIndex() is only self.sectionNumber=self.sectionNumber-1 in its own class.

The problem that I'm getting is that if I try to remove any of the sections that were touched by the remove function it will just remove the last section and the index that is coming into the second call confirms that's it always the last index.

Maybe I don't understand the lambda function, why each button is not taking the its own section for when it calls the remove function ?

Body:
This is a very common beginners trap. lambda is late binding, which means it uses the value from sectionNumber when it's called, not from when it was defined. To get the behavior you want you need to use functools.partial:

from functools import partial
...
sections[sectionNumber].getButton().config(command = partial(removeSpecificSection, sections[sectionNumber])))

and then call the getSectionNumber in the removeSpecificSection method.


问:
How to ask perforce for a list of changes with both description and files
I want to get a list of changes for a perforce branch like:

p4 -t -L //mydepot/library1/v1.0/...@2017/03/27,@now

That is, a list of all changes this week with description. But I also want a list of the files, as in
files in one changelist:

p4 files @=123456

This seems like it needs script, but anyone know of a perforce method?
If the returned changeset collection is large, will the server be adversely impacted by querying every changeset afterwards?

答:
You asked a bunch of questions in one question, so here's a bunch of answers in one answer.

Use the p4 changes command to get a list of changes of interest.

Use p4 describe -s or p4 files @= to get a list of the files in each change.

Yes, to combine these two sets of data you need a script, but it can be a remarkably short script. You can use the p4 command-line aliases feature to write such a script, or you can use your favorite scripting language. There are lots of examples of such scripts on the web.

The server will end up have to perform multiple commands, but these particular commands are ones that the server does very efficiently. I suspect that it won't be so much that the server will have a problem computing the output, but that you will have a problem reading all that output. In other words, don't run a script that produces more output than you want to read.


问:
Ways to speed up code with multiple IF statements
I've been working on this code all day and have finally gotten everything to work perfectly. The only problem, is that the code does run pretty slow. Considering that it will be used on a workbook with thousands of rows I would like to change that. I am extremely new to vba so there is probably stuff in here that is wrong or seems like a bad shortcut. I think I added a couple of ways that could speed it up but i didnt know if anything else could be done. </p>

```<code> Sub Degree_Workboook_Names_major1()

 Application.ScreenUpdating = False
 Application.DisplayStatusBar = False
 Application.EnableEvents = False

'Inserts a new column after column H named department names
 range("I1").EntireColumn.Insert
 range("I1").Value = "DeptName"

 Dim abbrRange As range              'range to hold the columns with the department names
 Set abbrRange = range("H:H")

'Writes the department name in the the department name column next to the associated abbr

 For Each cell In abbrRange

            If cell.Value = "ACC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Accounting"
            End If

            If cell.Value = "ACS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Adolescent, Career and Special Education"
            End If

            If cell.Value = "AES" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Animal and Equine Science"
            End If

            If cell.Value = "AGR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Agricultural Science"
            End If

            If cell.Value = "AHS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Applied Health Sciences"
            End If

            If cell.Value = "AHT" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Veterinary Technology and Pre-Veterinary Medicine"
            End If

            If cell.Value = "Art" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Art and Design"
            End If

            If cell.Value = "BIO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Biology"
            End If

            If cell.Value = "BPA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Management, Marketing and Business Administration"
            End If

            If cell.Value = "CCD" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Center for Communication Disorders"
            End If

            If cell.Value = "CEAO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Bachelor of Integrated Studies Program"
            End If

            If cell.Value = "CHE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Chemistry"
            End If

            If cell.Value = "CLH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Community Leadership and Human Services"
            End If

            If cell.Value = "COM" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Organizational Communication"
            End If

            If cell.Value = "CSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Computer Science and Information Systems"
            End If

            If cell.Value = "ECO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Economics and Finance"
            End If

            If cell.Value = "ELE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Early Childhood and Elementary Education"
            End If

            If cell.Value = "ENPH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of English and Philosophy"
            End If

            If cell.Value = "ELSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Educational Studies, Leadership and Counseling"
            End If

            If cell.Value = "GSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Geosciences"
            End If

            If cell.Value = "HFA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Liberal Arts"
            End If

            If cell.Value = "HIS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of History"
            End If

            If cell.Value = "INDC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Institute of Engineering"
            End If

            If cell.Value = "IOE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Institute of Engineering"
            End If

            If cell.Value = "JMC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Journalism and Mass Communications"
            End If

            If cell.Value = "MAT" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Mathematics and Statistics"
            End If

            If cell.Value = "MLA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Modern Languages"
            End If

            If cell.Value = "MMB" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Management, Marketing and Business Administration"
            End If

            If cell.Value = "MSP" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Military Science Program"
            End If

            If cell.Value = "MUS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Music"
            End If

            If cell.Value = "NUR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Nursing"
            End If

            If cell.Value = "OSH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Occupational Safety and Health"
            End If

            If cell.Value = "POL" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Political Science and Sociology"
            End If

            If cell.Value = "PSY" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Psychology"
            End If

            If cell.Value = "THR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Theatre"
            End If

 Next

 'Inserts a new column after column H named department names
range("M1").EntireColumn.Insert
range("M1").Value = "DeptName"

'Dim abbrRange As range              'range to hold the columns with the   dpeartment names
Set abbrRange = range("L:L")

'Writes the department name in the the department name column next to the associated abbr

For Each cell In abbrRange

            If cell.Value = "ACC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Accounting"
            End If

            If cell.Value = "ACS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Adolescent, Career and Special Education"
            End If

            If cell.Value = "AES" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Animal and Equine Science"
            End If

            If cell.Value = "AGR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Agricultural Science"
            End If

            If cell.Value = "AHS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Applied Health Sciences"
            End If

            If cell.Value = "AHT" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Veterinary Technology and Pre-Veterinary Medicine"
            End If

            If cell.Value = "Art" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Art and Design"
            End If

            If cell.Value = "BIO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Biology"
            End If

            If cell.Value = "BPA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Management, Marketing and Business Administration"
            End If

            If cell.Value = "CCD" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Center for Communication Disorders"
            End If

            If cell.Value = "CEAO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Bachelor of Integrated Studies Program"
            End If

            If cell.Value = "CHE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Chemistry"
            End If

            If cell.Value = "CLH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Community Leadership and Human Services"
            End If

            If cell.Value = "COM" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Organizational Communication"
            End If

            If cell.Value = "CSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Computer Science and Information Systems"
            End If

            If cell.Value = "ECO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Economics and Finance"
            End If

            If cell.Value = "ELE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Early Childhood and Elementary Education"
            End If

            If cell.Value = "ENPH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of English and Philosophy"
            End If

            If cell.Value = "ELSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Educational Studies, Leadership and Counseling"
            End If

            If cell.Value = "GSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Geosciences"
            End If

            If cell.Value = "HFA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Liberal Arts"
            End If

            If cell.Value = "HIS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of History"
            End If

            If cell.Value = "INDC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Institute of Engineering"
            End If

            If cell.Value = "IOE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Institute of Engineering"
            End If

            If cell.Value = "JMC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Journalism and Mass Communications"
            End If

            If cell.Value = "MAT" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Mathematics and Statistics"
            End If

            If cell.Value = "MLA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Modern Languages"
            End If

            If cell.Value = "MMB" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Management, Marketing and Business Administration"
            End If

            If cell.Value = "MSP" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Military Science Program"
            End If

            If cell.Value = "MUS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Music"
            End If

            If cell.Value = "NUR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Nursing"
            End If

            If cell.Value = "OSH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Occupational Safety and Health"
            End If

            If cell.Value = "POL" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Political Science and Sociology"
            End If

            If cell.Value = "PSY" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Psychology"
            End If

            If cell.Value = "THR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Theatre"
            End If

Next

range("I:I").HorizontalAlignment = xlLeft
range("M:M").HorizontalAlignment = xlLeft

Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True

End Sub
</code>```

答:
Every single condition is executing every time, irrespective of Cell.Value.

Working with cells and ranges in a loop is certainly the single slowest thing you can do in Excel VBA, but doing it for a dozen of conditions when you only need to check a single one... is even slower.

Replace it with If...Else If...Else If... ...End If, or use a Select Case block:

```<code>Select Case cell.Value
    Case "ABC"
       'handle 'ABC'
    Case "DEF"
       'handle 'DEF'
    '...
    Case "XYZ"
       'handle 'XYZ'
    Case Else
       'handle default
End Select
</code>```

But that still makes "XYZ" be evaluated only after every single other case has been evaluated.

A better alternative could be to setup a Dictionary. Reference the Microsoft Scripting Runtime library.

```<code>Static map As Scripting.Dictionary
If map Is Nothing Then
    Set map = New Scripting.Dictionary
    With map
        .Add "ACC", "Department of Accounting"
        .Add "ACS", "Department of Adolescent, Career and Special Education"
        '...add every possible ABC -> Description map
    End With
End If

cell.Activate
ActiveCell.Offset(0, 1).Activate
If map.Exists(cell.Value) Then ActiveCell.Value = map(cell.Value)
</code>```

The Static dictionary will only be populated the first time the procedure runs. Then the ActiveCell.Value is simply fetched with a lightning-fast dictionary lookup.

Now, that's likely still going to be very slow. You don't need 2 loops: iterate rows (only the ones you know you need to check), and then do H and L in one single pass. Just that is slicing execution time by half. Avoid .Activate, too; you don't need to work off ActiveCell at all.

Body:
I've been working on this code all day and have finally gotten everything to work perfectly. The only problem, is that the code does run pretty slow. Considering that it will be used on a workbook with thousands of rows I would like to change that. I am extremely new to vba so there is probably stuff in here that is wrong or seems like a bad shortcut. I think I added a couple of ways that could speed it up but i didnt know if anything else could be done.

 Sub Degree_Workboook_Names_major1()

 Application.ScreenUpdating = False
 Application.DisplayStatusBar = False
 Application.EnableEvents = False

'Inserts a new column after column H named department names
 range("I1").EntireColumn.Insert
 range("I1").Value = "DeptName"

 Dim abbrRange As range              'range to hold the columns with the department names
 Set abbrRange = range("H:H")

'Writes the department name in the the department name column next to the associated abbr

 For Each cell In abbrRange

            If cell.Value = "ACC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Accounting"
            End If

            If cell.Value = "ACS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Adolescent, Career and Special Education"
            End If

            If cell.Value = "AES" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Animal and Equine Science"
            End If

            If cell.Value = "AGR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Agricultural Science"
            End If

            If cell.Value = "AHS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Applied Health Sciences"
            End If

            If cell.Value = "AHT" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Veterinary Technology and Pre-Veterinary Medicine"
            End If

            If cell.Value = "Art" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Art and Design"
            End If

            If cell.Value = "BIO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Biology"
            End If

            If cell.Value = "BPA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Management, Marketing and Business Administration"
            End If

            If cell.Value = "CCD" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Center for Communication Disorders"
            End If

            If cell.Value = "CEAO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Bachelor of Integrated Studies Program"
            End If

            If cell.Value = "CHE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Chemistry"
            End If

            If cell.Value = "CLH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Community Leadership and Human Services"
            End If

            If cell.Value = "COM" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Organizational Communication"
            End If

            If cell.Value = "CSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Computer Science and Information Systems"
            End If

            If cell.Value = "ECO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Economics and Finance"
            End If

            If cell.Value = "ELE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Early Childhood and Elementary Education"
            End If

            If cell.Value = "ENPH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of English and Philosophy"
            End If

            If cell.Value = "ELSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Educational Studies, Leadership and Counseling"
            End If

            If cell.Value = "GSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Geosciences"
            End If

            If cell.Value = "HFA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Liberal Arts"
            End If

            If cell.Value = "HIS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of History"
            End If

            If cell.Value = "INDC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Institute of Engineering"
            End If

            If cell.Value = "IOE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Institute of Engineering"
            End If

            If cell.Value = "JMC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Journalism and Mass Communications"
            End If

            If cell.Value = "MAT" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Mathematics and Statistics"
            End If

            If cell.Value = "MLA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Modern Languages"
            End If

            If cell.Value = "MMB" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Management, Marketing and Business Administration"
            End If

            If cell.Value = "MSP" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Military Science Program"
            End If

            If cell.Value = "MUS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Music"
            End If

            If cell.Value = "NUR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Nursing"
            End If

            If cell.Value = "OSH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Occupational Safety and Health"
            End If

            If cell.Value = "POL" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Political Science and Sociology"
            End If

            If cell.Value = "PSY" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Psychology"
            End If

            If cell.Value = "THR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Theatre"
            End If

 Next

 'Inserts a new column after column H named department names
range("M1").EntireColumn.Insert
range("M1").Value = "DeptName"

'Dim abbrRange As range              'range to hold the columns with the   dpeartment names
Set abbrRange = range("L:L")

'Writes the department name in the the department name column next to the associated abbr

For Each cell In abbrRange

            If cell.Value = "ACC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Accounting"
            End If

            If cell.Value = "ACS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Adolescent, Career and Special Education"
            End If

            If cell.Value = "AES" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Animal and Equine Science"
            End If

            If cell.Value = "AGR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Agricultural Science"
            End If

            If cell.Value = "AHS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Applied Health Sciences"
            End If

            If cell.Value = "AHT" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Veterinary Technology and Pre-Veterinary Medicine"
            End If

            If cell.Value = "Art" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Art and Design"
            End If

            If cell.Value = "BIO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Biology"
            End If

            If cell.Value = "BPA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Management, Marketing and Business Administration"
            End If

            If cell.Value = "CCD" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Center for Communication Disorders"
            End If

            If cell.Value = "CEAO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Bachelor of Integrated Studies Program"
            End If

            If cell.Value = "CHE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Chemistry"
            End If

            If cell.Value = "CLH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Community Leadership and Human Services"
            End If

            If cell.Value = "COM" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Organizational Communication"
            End If

            If cell.Value = "CSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Computer Science and Information Systems"
            End If

            If cell.Value = "ECO" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Economics and Finance"
            End If

            If cell.Value = "ELE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Early Childhood and Elementary Education"
            End If

            If cell.Value = "ENPH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of English and Philosophy"
            End If

            If cell.Value = "ELSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Educational Studies, Leadership and Counseling"
            End If

            If cell.Value = "GSC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Geosciences"
            End If

            If cell.Value = "HFA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Liberal Arts"
            End If

            If cell.Value = "HIS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of History"
            End If

            If cell.Value = "INDC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Institute of Engineering"
            End If

            If cell.Value = "IOE" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Institute of Engineering"
            End If

            If cell.Value = "JMC" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Journalism and Mass Communications"
            End If

            If cell.Value = "MAT" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Mathematics and Statistics"
            End If

            If cell.Value = "MLA" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Modern Languages"
            End If

            If cell.Value = "MMB" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Management, Marketing and Business Administration"
            End If

            If cell.Value = "MSP" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Military Science Program"
            End If

            If cell.Value = "MUS" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Music"
            End If

            If cell.Value = "NUR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Nursing"
            End If

            If cell.Value = "OSH" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Occupational Safety and Health"
            End If

            If cell.Value = "POL" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Political Science and Sociology"
            End If

            If cell.Value = "PSY" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Psychology"
            End If

            If cell.Value = "THR" Then
            cell.Activate
            ActiveCell.Offset(0, 1).Activate
            ActiveCell.Value = "Department of Theatre"
            End If

Next

range("I:I").HorizontalAlignment = xlLeft
range("M:M").HorizontalAlignment = xlLeft

Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True

End Sub

Body:
Every single condition is executing every time, irrespective of Cell.Value.

Working with cells and ranges in a loop is certainly the single slowest thing you can do in Excel VBA, but doing it for a dozen of conditions when you only need to check a single one... is even slower.

Replace it with If...Else If...Else If... ...End If, or use a Select Case block:

Select Case cell.Value
    Case "ABC"
       'handle 'ABC'
    Case "DEF"
       'handle 'DEF'
    '...
    Case "XYZ"
       'handle 'XYZ'
    Case Else
       'handle default
End Select

But that still makes "XYZ" be evaluated only after every single other case has been evaluated.

A better alternative could be to setup a Dictionary. Reference the Microsoft Scripting Runtime library.

Static map As Scripting.Dictionary
If map Is Nothing Then
    Set map = New Scripting.Dictionary
    With map
        .Add "ACC", "Department of Accounting"
        .Add "ACS", "Department of Adolescent, Career and Special Education"
        '...add every possible ABC -> Description map
    End With
End If

cell.Activate
ActiveCell.Offset(0, 1).Activate
If map.Exists(cell.Value) Then ActiveCell.Value = map(cell.Value)

The Static dictionary will only be populated the first time the procedure runs. Then the ActiveCell.Value is simply fetched with a lightning-fast dictionary lookup.

Now, that's likely still going to be very slow. You don't need 2 loops: iterate rows (only the ones you know you need to check), and then do H and L in one single pass. Just that is slicing execution time by half. Avoid .Activate, too; you don't need to work off ActiveCell at all.


问:
Migrating from AWS Kinesis
My team and I have a streaming system based on the Kinesis service from Amazon, that delivers tracking information to other teams using Java standalone consumers and the KCL. We've decided to migrate this system to  Google Cloud Platform.

We understand that the natural replacement of Amazon Kinesis in the Google Platform is the Google Cloud Dataflow service. Is that right?

Other concern is about data partition, because we use the user-id as a partition key in Kinesis. Is it posible to do the same partition on Google Dataflow?

And of course, has anyone done a migration like this o a similar migration from AWS to the Google Platform before? Any advise?

答:
Yes, Cloud Dataflow would be the correct alternative, and you probably also want to consider Cloud Pub/Sub as your messaging middleware if you want to use topics and subscriptions.

Partitioning data by keys is totally possible in Dataflow, but you don't need to decide on a single partition key for your entire pipeline. Instead, when you are ready to do aggregation operations, you just define a GroupByKey transform and Dataflow will correctly shard your data into buckets and process them in a distributed fashion over many workers in parallel. Each worker will own a subrange of your keys.

You can have multiple GroupByKeys in a sequence and they can use different keys to do sharding and aggregations.

A recent example of a former AWS user migrating to GCP (specifically, Dataflow) would be Brightcove. Here is a recording of their GCP Next session https://www.youtube.com/watch?v=3BrcmUqWNm0&feature=youtu.be&t=29m30s

Title: Migrating from AWS Kinesis


问:
jQuery - Variable Scope Problem
I have the following javascript:

```<code>      $.getJSON('/calculate_quote/' + moulding_1_id, function(data) {
        moulding_1_cost = data.moulding.cost;
        moulding_1_width = data.moulding.width;
      });
      cost_of_moulding = ( ( 2 * ( width + ( 2 * moulding_1_width ) ) + 2 * ( height + ( 2 * moulding_1_width ) ) ) / 1000 ) * moulding_1_cost;
      $('#item_total').html( cost_of_moulding );
</code>```

The problem is that the two variables moulding_1_cost and moulding_1_width are undefined outside of the getJSON call.  How do I make these two variables available outside the getJSON call?

答:
Infact they are not undefined (after the code was executed). By skipping the var keyword those names go directly into the global scope (which in most instances.. is window). So you can access window.moulding_1_cost from anywhere of your script once this piece of script has executed.

And that most likely is your problem here, timing. Since this is the success handler of an ajax request this code runs asynchronously and therefore, is not executed instantly.

To solve this it's a good practice to use a callback function on your own. Nick Craver's answer has a pretty good demonstration on this.

Title: jQuery - Variable Scope Problem

Body:
I have the following javascript:

      $.getJSON('/calculate_quote/' + moulding_1_id, function(data) {
        moulding_1_cost = data.moulding.cost;
        moulding_1_width = data.moulding.width;
      });
      cost_of_moulding = ( ( 2 * ( width + ( 2 * moulding_1_width ) ) + 2 * ( height + ( 2 * moulding_1_width ) ) ) / 1000 ) * moulding_1_cost;
      $('#item_total').html( cost_of_moulding );

The problem is that the two variables moulding_1_cost and moulding_1_width are undefined outside of the getJSON call.  How do I make these two variables available outside the getJSON call?


问:
Perl6: Match elements in a list with another list
I have a list of numbers L. There is another list of numbers M. I need to return a list L' of numbers found in both L and M.

Edit: Mathematically, I am looking for Multiset intersection.

Example:

L  = 3, 1, 4, 1, 5, 9, 2, 6

  M  = 9, 7, 1, 2, 1, 1

  L' = 9, 1, 2, 1

I wrote the following code for that:

```<code>my @some-numbers = 3, 1, 4, 1, 5, 9, 2, 6;
my @to-match     = 9, 7, 1, 2, 1, 1;
my @matched;

my %histogram;
for @some-numbers -> $n { %histogram{$n}++ };

for @to-match -> $n {
    next if not defined %histogram{$n};
    if %histogram{$n} > 0 {
        push @matched, $n;
        %histogram{$n}--;
    }
};

say @matched;
</code>```

While it achieves the purpose, I was wondering whether there was an idiomatic Perl6 way of doing this?

Some background: I have been trying to learn Perl6 and Python together, and solve the same puzzles in both the languages. Python offered a particularly pleasing solution for the above problem. To my beginner eyes at least :)

答:
You can do it with bags:

```<code>my $some-numbers = bag 3, 1, 4, 1, 5, 9, 2, 6;
my $to-match     = bag 9, 7, 1, 2, 1, 1;
my $matched      = $some-numbers ∩ $to-match;
say $matched;
</code>```

Output:

```<code>bag(9, 1(2), 2)
</code>```

You can turn the bag back into an array with .kxxv.

```<code>my @match-list = $matched.kxxv;
say @match-list;
</code>```

Output:

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

(If you don't care about duplicates, use sets instead of bags.)

Body:
I have a list of numbers L. There is another list of numbers M. I need to return a list L' of numbers found in both L and M.

Edit: Mathematically, I am looking for Multiset intersection.

Example:

L  = 3, 1, 4, 1, 5, 9, 2, 6

  M  = 9, 7, 1, 2, 1, 1

  L' = 9, 1, 2, 1

I wrote the following code for that:

my @some-numbers = 3, 1, 4, 1, 5, 9, 2, 6;
my @to-match     = 9, 7, 1, 2, 1, 1;
my @matched;

my %histogram;
for @some-numbers -> $n { %histogram{$n}++ };

for @to-match -> $n {
    next if not defined %histogram{$n};
    if %histogram{$n} > 0 {
        push @matched, $n;
        %histogram{$n}--;
    }
};

say @matched;

While it achieves the purpose, I was wondering whether there was an idiomatic Perl6 way of doing this?

Some background: I have been trying to learn Perl6 and Python together, and solve the same puzzles in both the languages. Python offered a particularly pleasing solution for the above problem. To my beginner eyes at least :)

Body:
You can do it with bags:

my $some-numbers = bag 3, 1, 4, 1, 5, 9, 2, 6;
my $to-match     = bag 9, 7, 1, 2, 1, 1;
my $matched      = $some-numbers ∩ $to-match;
say $matched;

Output:

bag(9, 1(2), 2)

You can turn the bag back into an array with .kxxv.

my @match-list = $matched.kxxv;
say @match-list;

Output:

[9 1 1 2]

(If you don't care about duplicates, use sets instead of bags.)


问:
Routing is not working for web api with realtions
I am creating web api using asp.net core. The api end point is logically mapped to resource's relations based on guidelines here
So my API looks like

```<code>      http://tax.mydomain.com/api/v1/clients/1/batches/12/start
</code>```

Where Client is parent of Batch,  1 is clientid and 12 is batchid, and Start is POST action method.

Here is the corresponding controller

```<code>public class TaxController : Controller
{
    [HttpPost]
    [Route("clients/{clientid}/batches/{batchid}/start")]
    public void Start([FromRoute]string clientId, [FromRoute]string batchId,
                      [FromBody]IEnumerable<string> urls)
    {
       // do something
    }
}
</code>```

since api/v1 is common to all controllers i configured that in startup's Configure method. Also i want Home as default controller.

```<code>    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
      app.UseMvc(routes =>
      {
        routes.MapRoute("default","api/v1/{controller=Home}/{action=Index}/{id?}");
      });
    }
</code>```

However client is getting not found error for api http://tax.mydomain.com/api/v1/clients/1/batches/12/start

答:
There are two things wrong with your setup

You call http://tax.mydomain.com/clients/1/batches/12/start but you don't have specified the controller name within it. This route looks for a controller named ClientsController. So the correct url would have to be http://tax.mydomain.com/tax/clients/1/batches/12/start instead

You seem to be using default MVC/Viewbased route, but your url suggest you use WebAPI.

When you use WebAPI to create a Rest service, you don't have any actions. Instead, actions map to the Http Verbs (GET (Read), PUT (update/replace), POST (insert), DELETE).

So for REST Services your default route should look like this instead:  api/v1/{controller=Home}/{id?}

Body:
I am creating web api using asp.net core. The api end point is logically mapped to resource's relations based on guidelines here
So my API looks like

      http://tax.mydomain.com/api/v1/clients/1/batches/12/start

Where Client is parent of Batch,  1 is clientid and 12 is batchid, and Start is POST action method.

Here is the corresponding controller

public class TaxController : Controller
{
    [HttpPost]
    [Route("clients/{clientid}/batches/{batchid}/start")]
    public void Start([FromRoute]string clientId, [FromRoute]string batchId,
                      [FromBody]IEnumerable<string> urls)
    {
       // do something
    }
}

since api/v1 is common to all controllers i configured that in startup's Configure method. Also i want Home as default controller.

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
      app.UseMvc(routes =>
      {
        routes.MapRoute("default","api/v1/{controller=Home}/{action=Index}/{id?}");
      });
    }

However client is getting not found error for api http://tax.mydomain.com/api/v1/clients/1/batches/12/start


问:
remove double quotes from Json return data using Jquery
I use JQuery to get Json data, but the data it display has double quotes. It there a function to remove it?

```<code>$('div#ListingData').text(JSON.stringify(data.data.items[0].links[1].caption))
</code>```

it returns:

```<code>"House"
</code>```

How can I remove the double quote? Cheers.

答:
I also had this question, but in my case I didn't want to use a regex, because my JSON value may contain quotation marks. Hopefully my answer will help others in the future.

I solved this issue by using a standard string slice to remove the first and last characters. This works for me, because I used JSON.stringify() on the textarea that produced it and as a result, I know that I'm always going to have the "s at each end of the string.

In this generalized example, response is the JSON object my AJAX returns, and key is the name of my JSON key.

```<code>response.key.slice(1, response.key.length-1)
</code>```

I used it like this with a regex replace to preserve the line breaks and write the content of that key to a paragraph block in my HTML:

```<code>$('#description').html(studyData.description.slice(1, studyData.description.length-1).replace(/\\n/g, '<br/>'));
</code>```

In this case, $('#description') is the paragraph tag I'm writing to. studyData is my JSON object, and description is my key with a multi-line value.

Body:
I use JQuery to get Json data, but the data it display has double quotes. It there a function to remove it?

$('div#ListingData').text(JSON.stringify(data.data.items[0].links[1].caption))

it returns:

"House"

How can I remove the double quote? Cheers.

Body:
I also had this question, but in my case I didn't want to use a regex, because my JSON value may contain quotation marks. Hopefully my answer will help others in the future.

I solved this issue by using a standard string slice to remove the first and last characters. This works for me, because I used JSON.stringify() on the textarea that produced it and as a result, I know that I'm always going to have the "s at each end of the string.

In this generalized example, response is the JSON object my AJAX returns, and key is the name of my JSON key.

response.key.slice(1, response.key.length-1)

I used it like this with a regex replace to preserve the line breaks and write the content of that key to a paragraph block in my HTML:

$('#description').html(studyData.description.slice(1, studyData.description.length-1).replace(/\\n/g, '<br/>'));

In this case, $('#description') is the paragraph tag I'm writing to. studyData is my JSON object, and description is my key with a multi-line value.


问:
mongodb pipeline aggregation pipeline replacing values
If I have documents and I'm aggregating and I want to sub a field like:

```<code>{data: {'date_created': '2011-01-01', 'title': 'abc'}, 'owner': 'Jim'}
{data: {'date_created': '2011-05-01', 'title': 'def'}, 'owner': 'Bob'}
{data: {'date_created': '2011-03-01', 'title': 'ghi'}, 'owner': 'Jim'}
{data: {'date_created': '2011-03-01', 'title': ''}, 'owner': 'Sam'}
</code>```

and I want to aggregate so that I only take titles created before a certain date or return an empty list, how would I structure the aggregate pipeline?

So desired output would be:

```<code>{owner: "Jim", titles: ["abc", "def"],
 owner: "Bob", titles: [],
 owner: "Sam", titles: []}
</code>```

I have an aggregate pipeline that goes something like:

```<code>lookup => unwind =>
        {'$match':
            {'$or': [{'data.date_created': {'$lte': requested_date}}, {'data.title': {'$exists': False}}]}}}
</code>```

but I can't figure out how to cast the data where the date created is after the required time to be blank so it'll be grouped with the blank titles.

答:
If you didn't strictly require the empty arrays when there are no items matching your criteria, that would make it much simpler. If that were the case you could simply do a $match and a $group with either $push or $addToSet.

For example:

```<code>db.foo.aggregate([
    { $match : {'data.date_created': {'$lte': "2011-03-01"}}},
    { $group: {
       _id: "$owner",
       titles : {$push : "$data.title"}
    }}
])
</code>```

Results:

```<code>{ "_id" : "Sam", "titles" : [ "" ] }
{ "_id" : "Jim", "titles" : [ "abc", "ghi" ] }
</code>```

Another option would be to do your $group / $push first, then filter the array elements using $filter (requires MongoDB 3.2+).

For example:

```<code>db.foo.aggregate([
    { $group: {
       _id: "$owner",
       data : {$push : "$data"}
    }},
    {
      $project: {
         titles: {
            $filter: {
               input: "$data",
               as: "item",
               cond: { $lte: [ "$$item.date_created", "2011-03-01" ] }
            }
         }
    }}
])
</code>```

Results:

```<code>{ "_id" : "Sam", "titles" : [ { "date_created" : "2011-03-01", "title" : "" } ] }
{ "_id" : "Bob", "titles" : [ ] }
{ "_id" : "Jim", "titles" : [ { "date_created" : "2011-01-01", "title" : "abc" }, { "date_created" : "2011-03-01", "title" : "ghi" } ] }
</code>```

Body:
If I have documents and I'm aggregating and I want to sub a field like:

{data: {'date_created': '2011-01-01', 'title': 'abc'}, 'owner': 'Jim'}
{data: {'date_created': '2011-05-01', 'title': 'def'}, 'owner': 'Bob'}
{data: {'date_created': '2011-03-01', 'title': 'ghi'}, 'owner': 'Jim'}
{data: {'date_created': '2011-03-01', 'title': ''}, 'owner': 'Sam'}

and I want to aggregate so that I only take titles created before a certain date or return an empty list, how would I structure the aggregate pipeline?

So desired output would be:

{owner: "Jim", titles: ["abc", "def"],
 owner: "Bob", titles: [],
 owner: "Sam", titles: []}

I have an aggregate pipeline that goes something like:

lookup => unwind =>
        {'$match':
            {'$or': [{'data.date_created': {'$lte': requested_date}}, {'data.title': {'$exists': False}}]}}}

but I can't figure out how to cast the data where the date created is after the required time to be blank so it'll be grouped with the blank titles.

Body:
If you didn't strictly require the empty arrays when there are no items matching your criteria, that would make it much simpler. If that were the case you could simply do a $match and a $group with either $push or $addToSet.

For example:

db.foo.aggregate([
    { $match : {'data.date_created': {'$lte': "2011-03-01"}}},
    { $group: {
       _id: "$owner",
       titles : {$push : "$data.title"}
    }}
])

Results:

{ "_id" : "Sam", "titles" : [ "" ] }
{ "_id" : "Jim", "titles" : [ "abc", "ghi" ] }

Another option would be to do your $group / $push first, then filter the array elements using $filter (requires MongoDB 3.2+).

For example:

db.foo.aggregate([
    { $group: {
       _id: "$owner",
       data : {$push : "$data"}
    }},
    {
      $project: {
         titles: {
            $filter: {
               input: "$data",
               as: "item",
               cond: { $lte: [ "$$item.date_created", "2011-03-01" ] }
            }
         }
    }}
])

Results:

{ "_id" : "Sam", "titles" : [ { "date_created" : "2011-03-01", "title" : "" } ] }
{ "_id" : "Bob", "titles" : [ ] }
{ "_id" : "Jim", "titles" : [ { "date_created" : "2011-01-01", "title" : "abc" }, { "date_created" : "2011-03-01", "title" : "ghi" } ] }


问:
Angularjs UI Grid switch column icon
I am use UI Grid to draw a table.

Here is UI Grid offical webiste:
http://ui-grid.info/docs/#/tutorial/215_treeView

Now, I want to switch collapse icon and selectAll icon.

By default UI Grid, the collapse is first element, selectAll Icon is second element.
I want to switch of them.

Here is the sample

http://embed.plnkr.co/DODIxKaQ5nrqNO9eUObe/

Anyone can help with this ? Thanks a lot.

答:
I don't believe it's possible, yet...  you might want to add your vote here...

https://github.com/angular-ui/ui-grid/issues/4862

I just added my two cents worth.

Title: Angularjs UI Grid switch column icon


答:
Hope this helps. You can do conditional push on the basis of date and then filter out the blank items from the titles array.

```<code>db.collection.aggregate([
  {"$group":{
     _id:"$owner",titles:{
         $push: { $cond:[
         { $lte: [ "$data.date_created", "2011-03-01" ]},"$data.title",""
          ]
        }
      }
    }
  },
  {
  $project: {
       _id:0,
       owner : "$_id",
       titles: {
        $filter: {
           input: "$titles",
           as: "titles",
           cond: { $ne: [ "$$titles", "" ] }
        }
      }
    }
  }
])
</code>```

Result :

```<code>{ "titles" : [ ], "owner" : "Bob" }
{ "titles" : [ "abc", "ghi" ], "owner" : "Jim" }
{ "titles" : [ ], "owner" : "Sam" }
</code>```

Title: mongodb pipeline aggregation pipeline replacing values

Body:
Hope this helps. You can do conditional push on the basis of date and then filter out the blank items from the titles array.

db.collection.aggregate([
  {"$group":{
     _id:"$owner",titles:{
         $push: { $cond:[
         { $lte: [ "$data.date_created", "2011-03-01" ]},"$data.title",""
          ]
        }
      }
    }
  },
  {
  $project: {
       _id:0,
       owner : "$_id",
       titles: {
        $filter: {
           input: "$titles",
           as: "titles",
           cond: { $ne: [ "$$titles", "" ] }
        }
      }
    }
  }
])

Result :

{ "titles" : [ ], "owner" : "Bob" }
{ "titles" : [ "abc", "ghi" ], "owner" : "Jim" }
{ "titles" : [ ], "owner" : "Sam" }


问:
Compiling React Native for Windows (on Windows)
Has anyone successfully compiled and run a Windows (UWP) app on a Windows (10) machine using React Native?

I've built an app, it's working in the Android emulator. I ran through the instructions from Microsoft here and here.

I am using VS Code for my editor... should I be using Visual Studio?

I ran these commands to convert existing project to a 'Windows' project which adds the Windows file structure. That works.

```<code>npm install --save-dev rnpm-plugin-windows
react-native windows
</code>```

I ran:

```<code>react-native run-windows
</code>```

Which basically works but fails at the end.

At this point in the loading I get an error:

```<code>Building C:/Users/..../MyApp/windows/MyApp.sln
ERROR: The system was unable to find the specified registry key or value.
</code>```

The rest of it seems to install fine but at the end...

```<code>Press Enter to continue...:
Failed to deploy: Command failed: CheckNetIsolation LoopbackExempt -a -n=
</code>```

I Googled this error and got literally zero results. Anyone have something that could help me get over this hump?

Am I supposed to have a Windows Emulator on my machine like the Android emulator or does it just run like any other program?

Also, I'm not 'allowed' to create a new tag unless I have 1500 magic unicorn points so could someone please create react-native-windows tag for future users?

答:
Solution:

```<code>CheckNetIsolation LoopbackExempt -a -n=MyApp
</code>```

Where 'MyApp' is the name of your project folder.

Thanks @Onorio Catenacci for the link that had the clues to put it together.

Body:
Has anyone successfully compiled and run a Windows (UWP) app on a Windows (10) machine using React Native?

I've built an app, it's working in the Android emulator. I ran through the instructions from Microsoft here and here.

I am using VS Code for my editor... should I be using Visual Studio?

I ran these commands to convert existing project to a 'Windows' project which adds the Windows file structure. That works.

npm install --save-dev rnpm-plugin-windows
react-native windows

I ran:

react-native run-windows

Which basically works but fails at the end.

At this point in the loading I get an error:

Building C:/Users/..../MyApp/windows/MyApp.sln
ERROR: The system was unable to find the specified registry key or value.

The rest of it seems to install fine but at the end...

Press Enter to continue...:
Failed to deploy: Command failed: CheckNetIsolation LoopbackExempt -a -n=

I Googled this error and got literally zero results. Anyone have something that could help me get over this hump?

Am I supposed to have a Windows Emulator on my machine like the Android emulator or does it just run like any other program?

Also, I'm not 'allowed' to create a new tag unless I have 1500 magic unicorn points so could someone please create react-native-windows tag for future users?

Body:
Solution:

CheckNetIsolation LoopbackExempt -a -n=MyApp

Where 'MyApp' is the name of your project folder.

Thanks @Onorio Catenacci for the link that had the clues to put it together.


问:
Mysql select first then limit
How can i select the newest 5 rows from mysql (newest by id for example) then order them asc or desc ??

the problem is i have 1,2,3,4,5,6,7 , i want to select the newest 2 for example (6,7) then order them asc or desc (6,7 or 7,6) , but if i use the orderby then the limit it would be (1,2) or (7,6) , is there anyway to do it from ONE sql statement ?

thank you

答:
ok i found the solution , thank you all for your efforts and answers ,

i made 2 columns , ID and TSTAMP (for timestamp) , just made it like order by id asc , tstamp asc/desc ... limit x , so it orders always by the id then orders by the tstamp and limits the right thing .

and nested queries are a pain for the engine ...

thanks

Title: Mysql select first then limit


问:
Appcelerator not detecting android sdk api
When I attempt building a android distribution of my app through the appcelerator CLI, I get the following error: [ERROR] Target Android SDK API 23 is not installed.

I have installed android sdk api 23 but when I run appc ti info -t android it appears that Titanium is not recognizing the installed targets.

```
Appcelerator Command-Line Interface, version 6.0.0
Copyright (c) 2014-2017, Appcelerator, Inc.  All Rights Reserved.
Android SDK
  Android Executable          = /Users/Shared/Jenkins/Library/Android/sdk/tools/android
  ADB Executable              = /Users/Shared/Jenkins/Library/Android/sdk/platform-tools/adb
  SDK Path                    = /Users/Shared/Jenkins/Library/Android/sdk
Android NDK
  NDK Path                    = /Users/Shared/Jenkins/Library/Android/sdk/ndk-bundle
  NDK Version                 = 14.1.3816874
Android Platforms
  None
Android Add-Ons
  None
Android Emulators
  None
Genymotion Emulators
  None
Connected Android Devices
  None
Issues
  No issues detected! Your development environment should be working perfectly!
```

Output of sdkmanager --list

```
devbuild1:bin jenkins$ ./sdkmanager --list
Warning: File /Users/Shared/Jenkins/.android/repositories.cfg could not be loaded.
Installed packages:
  Path                              | Version      | Description                    | Location
  -------                           | -------      | -------                        | -------
  add-ons;addon-g..._apis-google-15 | 3            | Google APIs                    | add-ons/addon-g...apis-google-15/
  add-ons;addon-g..._apis-google-16 | 4            | Google APIs                    | add-ons/addon-g...apis-google-16/
  add-ons;addon-g..._apis-google-17 | 4            | Google APIs                    | add-ons/addon-g...apis-google-17/
  add-ons;addon-g..._apis-google-18 | 4            | Google APIs                    | add-ons/addon-g...apis-google-18/
  add-ons;addon-g..._apis-google-19 | 20           | Google APIs                    | add-ons/addon-g...apis-google-19/
  add-ons;addon-g..._apis-google-21 | 1            | Google APIs                    | add-ons/addon-g...apis-google-21/
  add-ons;addon-g..._apis-google-22 | 1            | Google APIs                    | add-ons/addon-g...apis-google-22/
  add-ons;addon-g..._apis-google-23 | 1            | Google APIs                    | add-ons/addon-g...apis-google-23/
  add-ons;addon-g..._apis-google-24 | 1            | Google APIs                    | add-ons/addon-g...apis-google-24/
  build-tools;25.0.2                | 25.0.2       | Android SDK Build-Tools 25.0.2 | build-tools/25.0.2/
  emulator                          | 26.0.0       | Android Emulator               | emulator/
  extras;android;m2repository       | 47.0.0       | Android Support Repository     | extras/android/m2repository/
  extras;google;m2repository        | 46           | Google Repository              | extras/google/m2repository/
  ndk-bundle                        | 14.1.3816874 | NDK                            | ndk-bundle/
  patcher;v4                        | 1            | SDK Patch Applier v4           | patcher/v4/
  platform-tools                    | 25.0.4       | Android SDK Platform-Tools     | platform-tools/
  platforms;android-14              | 4            | Android SDK Platform 14        | platforms/android-14/
  platforms;android-15              | 5            | Android SDK Platform 15        | platforms/android-15/
  platforms;android-16              | 5            | Android SDK Platform 16        | platforms/android-16/
  platforms;android-17              | 3            | Android SDK Platform 17        | platforms/android-17/
  platforms;android-18              | 3            | Android SDK Platform 18        | platforms/android-18/
  platforms;android-19              | 4            | Android SDK Platform 19        | platforms/android-19/
  platforms;android-20              | 2            | Android SDK Platform 20        | platforms/android-20/
  platforms;android-21              | 2            | Android SDK Platform 21        | platforms/android-21/
  platforms;android-22              | 2            | Android SDK Platform 22        | platforms/android-22/
  platforms;android-23              | 3            | Android SDK Platform 23        | platforms/android-23/
  platforms;android-24              | 2            | Android SDK Platform 24        | platforms/android-24/
  platforms;android-25              | 3            | Android SDK Platform 25        | platforms/android-25/
  sources;android-15                | 2            | Sources for Android 15         | sources/android-15/
  sources;android-16                | 2            | Sources for Android 16         | sources/android-16/
  sources;android-17                | 1            | Sources for Android 17         | sources/android-17/
  sources;android-18                | 1            | Sources for Android 18         | sources/android-18/
  sources;android-19                | 2            | Sources for Android 19         | sources/android-19/
  sources;android-20                | 1            | Sources for Android 20         | sources/android-20/
  sources;android-21                | 1            | Sources for Android 21         | sources/android-21/
  sources;android-22                | 1            | Sources for Android 22         | sources/android-22/
  sources;android-23                | 1            | Sources for Android 23         | sources/android-23/
  sources;android-24                | 1            | Sources for Android 24         | sources/android-24/
  sources;android-25                | 1            | Sources for Android 25         | sources/android-25/
  tools                             | 26.0.0       | Android SDK Tools              | tools/
```

答:
I have been wrestling with this issue for about 2 days and thanks to Mauro's solution (which I would mark as correct) above posted solution was finally able to resolve it.  Here is what I have speculated happened.  Prior to March 1, 2017, I was able to successfully use appc on the command to build and run Appcelerator apps using the SDK downloaded via Android Studio.  About 3 days ago, I did an overdue update to Android Studio (and probably the SDK) and could no longer build on the command line.

Apparently, on March 1, Google updated the Android SDK such to "deprecate" the android CLI tool, i.e. break it completely, which apparently affected a bunch of build tools that depend on it such as Unity, Ionic, etc and my guess Appcelerator.

https://code.google.com/p/android/issues/detail?id=235455&sort=-id&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened

The only remedy I've found so far is now using the Android SDK provided by the Appcelerator Studio, and not one installed by either Android Studio or brew as the android command like tool no longer works as expected before the update.

Body:
When I attempt building a android distribution of my app through the appcelerator CLI, I get the following error: [ERROR] Target Android SDK API 23 is not installed.

I have installed android sdk api 23 but when I run appc ti info -t android it appears that Titanium is not recognizing the installed targets.

Appcelerator Command-Line Interface, version 6.0.0
Copyright (c) 2014-2017, Appcelerator, Inc.  All Rights Reserved.
Android SDK
  Android Executable          = /Users/Shared/Jenkins/Library/Android/sdk/tools/android
  ADB Executable              = /Users/Shared/Jenkins/Library/Android/sdk/platform-tools/adb
  SDK Path                    = /Users/Shared/Jenkins/Library/Android/sdk
Android NDK
  NDK Path                    = /Users/Shared/Jenkins/Library/Android/sdk/ndk-bundle
  NDK Version                 = 14.1.3816874
Android Platforms
  None
Android Add-Ons
  None
Android Emulators
  None
Genymotion Emulators
  None
Connected Android Devices
  None
Issues
  No issues detected! Your development environment should be working perfectly!

Output of sdkmanager --list

devbuild1:bin jenkins$ ./sdkmanager --list
Warning: File /Users/Shared/Jenkins/.android/repositories.cfg could not be loaded.
Installed packages:
  Path                              | Version      | Description                    | Location
  -------                           | -------      | -------                        | -------
  add-ons;addon-g..._apis-google-15 | 3            | Google APIs                    | add-ons/addon-g...apis-google-15/
  add-ons;addon-g..._apis-google-16 | 4            | Google APIs                    | add-ons/addon-g...apis-google-16/
  add-ons;addon-g..._apis-google-17 | 4            | Google APIs                    | add-ons/addon-g...apis-google-17/
  add-ons;addon-g..._apis-google-18 | 4            | Google APIs                    | add-ons/addon-g...apis-google-18/
  add-ons;addon-g..._apis-google-19 | 20           | Google APIs                    | add-ons/addon-g...apis-google-19/
  add-ons;addon-g..._apis-google-21 | 1            | Google APIs                    | add-ons/addon-g...apis-google-21/
  add-ons;addon-g..._apis-google-22 | 1            | Google APIs                    | add-ons/addon-g...apis-google-22/
  add-ons;addon-g..._apis-google-23 | 1            | Google APIs                    | add-ons/addon-g...apis-google-23/
  add-ons;addon-g..._apis-google-24 | 1            | Google APIs                    | add-ons/addon-g...apis-google-24/
  build-tools;25.0.2                | 25.0.2       | Android SDK Build-Tools 25.0.2 | build-tools/25.0.2/
  emulator                          | 26.0.0       | Android Emulator               | emulator/
  extras;android;m2repository       | 47.0.0       | Android Support Repository     | extras/android/m2repository/
  extras;google;m2repository        | 46           | Google Repository              | extras/google/m2repository/
  ndk-bundle                        | 14.1.3816874 | NDK                            | ndk-bundle/
  patcher;v4                        | 1            | SDK Patch Applier v4           | patcher/v4/
  platform-tools                    | 25.0.4       | Android SDK Platform-Tools     | platform-tools/
  platforms;android-14              | 4            | Android SDK Platform 14        | platforms/android-14/
  platforms;android-15              | 5            | Android SDK Platform 15        | platforms/android-15/
  platforms;android-16              | 5            | Android SDK Platform 16        | platforms/android-16/
  platforms;android-17              | 3            | Android SDK Platform 17        | platforms/android-17/
  platforms;android-18              | 3            | Android SDK Platform 18        | platforms/android-18/
  platforms;android-19              | 4            | Android SDK Platform 19        | platforms/android-19/
  platforms;android-20              | 2            | Android SDK Platform 20        | platforms/android-20/
  platforms;android-21              | 2            | Android SDK Platform 21        | platforms/android-21/
  platforms;android-22              | 2            | Android SDK Platform 22        | platforms/android-22/
  platforms;android-23              | 3            | Android SDK Platform 23        | platforms/android-23/
  platforms;android-24              | 2            | Android SDK Platform 24        | platforms/android-24/
  platforms;android-25              | 3            | Android SDK Platform 25        | platforms/android-25/
  sources;android-15                | 2            | Sources for Android 15         | sources/android-15/
  sources;android-16                | 2            | Sources for Android 16         | sources/android-16/
  sources;android-17                | 1            | Sources for Android 17         | sources/android-17/
  sources;android-18                | 1            | Sources for Android 18         | sources/android-18/
  sources;android-19                | 2            | Sources for Android 19         | sources/android-19/
  sources;android-20                | 1            | Sources for Android 20         | sources/android-20/
  sources;android-21                | 1            | Sources for Android 21         | sources/android-21/
  sources;android-22                | 1            | Sources for Android 22         | sources/android-22/
  sources;android-23                | 1            | Sources for Android 23         | sources/android-23/
  sources;android-24                | 1            | Sources for Android 24         | sources/android-24/
  sources;android-25                | 1            | Sources for Android 25         | sources/android-25/
  tools                             | 26.0.0       | Android SDK Tools              | tools/