问:
group selection & checkbox in ag-Grid
In my Angular application I have a grid that is almost identical to the Group Selection example in the ag-Grid docs: https://www.ag-grid.com/javascript-grid-selection/#gsc.tab=0

My requirement is slightly different in that my expand button needs to both expand the row and select the row.  As you see in the plunker example selection and expansion are two separate click events, but I am looking to select the row and expand that same row in one click, without having the user click on the checkbox and the expand button.  I have tried doing this with css by making the checkbox transparent and placing it over the expand icon, but the click is highjacked so only one event will fire...

Is this possible in ag-Grid?

In my component by columnDefs for the column that has my checkbox and expand icon looks like so:

```<code>...
       this.gridOptions.columnDefs = [

            {
                headerName: '', width: 100, cellRenderer: 'group',
                // for parent row selection - checkboxes for parent rows
                checkboxSelection: function(params) {
                    return params.node.canFlower;
                },
                cellRendererParams: { value: ' ' }, colId: 'PlusIcon', pinned: 'left', cellClass: 'center'

            },
...
</code>```

答:
Listen to the rowGroupOpened event and set the row to selected:

```<code>// inside the ag-grid tag
    (gridReady)="onGridReady($event)"

// inside the AppComponent class
  onGroupOpened(event){
    event.node.setSelected(true)
    console.log(event)

  }
</code>```

plnkr example

Title: group selection & checkbox in ag-Grid

Body:
In my Angular application I have a grid that is almost identical to the Group Selection example in the ag-Grid docs: https://www.ag-grid.com/javascript-grid-selection/#gsc.tab=0

My requirement is slightly different in that my expand button needs to both expand the row and select the row.  As you see in the plunker example selection and expansion are two separate click events, but I am looking to select the row and expand that same row in one click, without having the user click on the checkbox and the expand button.  I have tried doing this with css by making the checkbox transparent and placing it over the expand icon, but the click is highjacked so only one event will fire...

Is this possible in ag-Grid?

In my component by columnDefs for the column that has my checkbox and expand icon looks like so:

...
       this.gridOptions.columnDefs = [

            {
                headerName: '', width: 100, cellRenderer: 'group',
                // for parent row selection - checkboxes for parent rows
                checkboxSelection: function(params) {
                    return params.node.canFlower;
                },
                cellRendererParams: { value: ' ' }, colId: 'PlusIcon', pinned: 'left', cellClass: 'center'

            },
...

Body:
Listen to the rowGroupOpened event and set the row to selected:

// inside the ag-grid tag
    (gridReady)="onGridReady($event)"

// inside the AppComponent class
  onGroupOpened(event){
    event.node.setSelected(true)
    console.log(event)

  }

plnkr example


来源: stackexchange

问:
Bar button item not shown in navigationBar
I'm working on an app where my initial view controller is embedded in a Navigation Controller and Tab bar controller.

In my app I have 3 different tabs, one tab is the settings view. This is a tableview with 5 buttons. every button will show the same view controller when it's touched.

When I touch on one of the buttons, I still have a nice green navigation bar, but my buttons do not work.

I tried dragging a Navigation Item into the view in my storyboard and then put a bar button item in it. I can see the button in my storyboard, but it won't show up in my app when I run it.

I also added the following code to my viewDidLoad():

```<code>let leftItem = UIBarButtonItem(title: "< Back", style: .Done, target: self, action: Selector("Save"))
let rightItem = UIBarButtonItem(title: "Save", style: .Plain, target: self, action: Selector("Save"))

//self.parentViewController?.navigationItem.leftBarButtonItem = leftItem // also doesn't work

navigationController?.navigationItem.leftBarButtonItem = leftItem
navigationController?.navigationItem.rightBarButtonItem = rightItem
</code>```

But it won't have any effect.

I checked if the correct UIViewController was assigned to my view in the storyboard, did several Clean builds (CMD + Shift + K) and Rebuilds (CMD + B).

The following images are a screenshot of a part of my storyboard and a screenshot of my app at the view where the buttons won't show up.

EDIT

Added a new screenshot about the controls in the view. These do not work with or without the additional code in my viewDidLoad.

答:
I had two segues: one via a storyboard segue, and one programmatic. The storyboard segue showed the buttons as expected. The progammatic segue, however, showed the view without the buttons.

For the programmatic segue, I was using:

```<code>present(theNewVC, animated: true)
</code>```

The buttons appeared and functioned correctly when I changed that to:

```<code>show(theNewVC, sender: self)
</code>```

Per the documentation, present(...) presents the view controller modally. Apparently a modal view controller doesn't get the nav bar buttons. I further confirmed this by changing my storyboard segue to Present Modally - and the buttons disappeared there as well.

(Using Xcode 9, Swift 4)

ContentLicense: CC BY-SA 3.0

Body:
I'm working on an app where my initial view controller is embedded in a Navigation Controller and Tab bar controller.

In my app I have 3 different tabs, one tab is the settings view. This is a tableview with 5 buttons. every button will show the same view controller when it's touched.

When I touch on one of the buttons, I still have a nice green navigation bar, but my buttons do not work.

I tried dragging a Navigation Item into the view in my storyboard and then put a bar button item in it. I can see the button in my storyboard, but it won't show up in my app when I run it.

I also added the following code to my viewDidLoad():

let leftItem = UIBarButtonItem(title: "< Back", style: .Done, target: self, action: Selector("Save"))
let rightItem = UIBarButtonItem(title: "Save", style: .Plain, target: self, action: Selector("Save"))

//self.parentViewController?.navigationItem.leftBarButtonItem = leftItem // also doesn't work

navigationController?.navigationItem.leftBarButtonItem = leftItem
navigationController?.navigationItem.rightBarButtonItem = rightItem

But it won't have any effect.

I checked if the correct UIViewController was assigned to my view in the storyboard, did several Clean builds (CMD + Shift + K) and Rebuilds (CMD + B).

The following images are a screenshot of a part of my storyboard and a screenshot of my app at the view where the buttons won't show up.

EDIT

Added a new screenshot about the controls in the view. These do not work with or without the additional code in my viewDidLoad.

Body:
I had two segues: one via a storyboard segue, and one programmatic. The storyboard segue showed the buttons as expected. The progammatic segue, however, showed the view without the buttons.

For the programmatic segue, I was using:

present(theNewVC, animated: true)

The buttons appeared and functioned correctly when I changed that to:

show(theNewVC, sender: self)

Per the documentation, present(...) presents the view controller modally. Apparently a modal view controller doesn't get the nav bar buttons. I further confirmed this by changing my storyboard segue to Present Modally - and the buttons disappeared there as well.

(Using Xcode 9, Swift 4)


问:
Bind address in Docker macvlan

I am trying to building a macvlan with N containers binded to the same ip. Each container will expose one service.
To do that:

```<code>sudo docker network create -d macvlan \
    --subnet=192.168.4.0/24 \
    --ip-range=192.168.4.0/24 \
    --gateway=192.168.4.201 \
    -o macvlan_mode=bridge \
    -o parent=eth0 macvlan70
</code>```

Running containers:

```<code>sudo docker run --net=macvlan70 -P -d --name test_sshd1 eg_ssh
sudo docker run --net=macvlan70 -P -d --name test_sshd2 eg_ssh
</code>```

Bridge:

```<code>sudo ip link add mymacvlan90 link eth0 type macvlan mode bridge
sudo ip addr add 192.168.4.10/24 dev mymacvlan90
sudo ifconfig mymacvlan90 up
</code>```

At this point I can ping and nmap each container from host. I used inspect to check "IPAddress" of each container.

Result of macvlan inspect:

```<code>"Containers": {
            "89ed3de20801bf096b389379bb546da03f3452e80dbabad89c5457bdc4dcc5fc": {
                "Name": "test_sshd1",
                "EndpointID": "6a7d774ae7e3ce3aac877523968b2ce5a026ae740c059b61162ceb170d53a0c4",
                "MacAddress": "02:42:c0:a8:04:01",
                "IPv4Address": "192.168.4.1/24",
                "IPv6Address": ""
            },
            "ca13b48ccbc267859f406084357dadcd3592cb678502b7086908d6d895728632": {
                "Name": "test_sshd2",
                "EndpointID": "98ce081e94a209838bb4281613055b32967ea85c40c2e3814fe73a88bc9cb380",
                "MacAddress": "02:42:c0:a8:04:02",
                "IPv4Address": "192.168.4.2/24",
                "IPv6Address": ""
            }
</code>```

Now I am creating another container, like this:

```<code>sudo docker run --net=macvlan70 -p 192.168.4.1:66:22 -d --name test_sshd4 eg_ssh
</code>```

My goal is to expose 2 generic services under the same ip and mac (trying to emulate a real machine with N services). The container is created with success. But if I run this command:

```<code>$ nmap 192.168.4.1 -p 66

Starting Nmap 7.01 ( https://nmap.org ) at 2017-12-06 16:57 WET
Nmap scan report for 192.168.4.1
Host is up (0.00021s latency).
PORT   STATE  SERVICE
66/tcp closed sqlnet
</code>```

I was expecting open port at 66. But it's not.

答:
You can't use -p to bind to an address of another container.  That is for exposing containers on a host interface.

You could just start your new container in the same network namespace as the existing container:

```<code>docker run --net=container:test_sshd1 -d --name test_sshd4 eg_ssh
</code>```

Re: your comment:

Well, sure, you can't have two things bound to the same port on the same address.

One options is to configure ssh in the second container to listen on something other than port 22.  Set up your image so that you can pass the listen port in as an environment variable (so you can do docker run -e SSHD_LISTEN_PORT=66 ... or something).

A second option is to instead bind them both to a host address (such as your bridge address @ 192.168.4.10).  You would start the first with -p 192.168.4.10:22:22 and the second with -p 192.168.4.10:66:22.  This would expose both services on 192.168.4.10, one on port 22 and one on port 66.

Title: Bind address in Docker macvlan

Body:
I am trying to building a macvlan with N containers binded to the same ip. Each container will expose one service.
To do that:

sudo docker network create -d macvlan \
    --subnet=192.168.4.0/24 \
    --ip-range=192.168.4.0/24 \
    --gateway=192.168.4.201 \
    -o macvlan_mode=bridge \
    -o parent=eth0 macvlan70

Running containers:

sudo docker run --net=macvlan70 -P -d --name test_sshd1 eg_ssh
sudo docker run --net=macvlan70 -P -d --name test_sshd2 eg_ssh

Bridge:

sudo ip link add mymacvlan90 link eth0 type macvlan mode bridge
sudo ip addr add 192.168.4.10/24 dev mymacvlan90
sudo ifconfig mymacvlan90 up

At this point I can ping and nmap each container from host. I used inspect to check "IPAddress" of each container.

Result of macvlan inspect:

"Containers": {
            "89ed3de20801bf096b389379bb546da03f3452e80dbabad89c5457bdc4dcc5fc": {
                "Name": "test_sshd1",
                "EndpointID": "6a7d774ae7e3ce3aac877523968b2ce5a026ae740c059b61162ceb170d53a0c4",
                "MacAddress": "02:42:c0:a8:04:01",
                "IPv4Address": "192.168.4.1/24",
                "IPv6Address": ""
            },
            "ca13b48ccbc267859f406084357dadcd3592cb678502b7086908d6d895728632": {
                "Name": "test_sshd2",
                "EndpointID": "98ce081e94a209838bb4281613055b32967ea85c40c2e3814fe73a88bc9cb380",
                "MacAddress": "02:42:c0:a8:04:02",
                "IPv4Address": "192.168.4.2/24",
                "IPv6Address": ""
            }

Now I am creating another container, like this:

sudo docker run --net=macvlan70 -p 192.168.4.1:66:22 -d --name test_sshd4 eg_ssh

My goal is to expose 2 generic services under the same ip and mac (trying to emulate a real machine with N services). The container is created with success. But if I run this command:

$ nmap 192.168.4.1 -p 66

Starting Nmap 7.01 ( https://nmap.org ) at 2017-12-06 16:57 WET
Nmap scan report for 192.168.4.1
Host is up (0.00021s latency).
PORT   STATE  SERVICE
66/tcp closed sqlnet

I was expecting open port at 66. But it's not.

Body:
You can't use -p to bind to an address of another container.  That is for exposing containers on a host interface.

You could just start your new container in the same network namespace as the existing container:

docker run --net=container:test_sshd1 -d --name test_sshd4 eg_ssh

Re: your comment:

Well, sure, you can't have two things bound to the same port on the same address.

One options is to configure ssh in the second container to listen on something other than port 22.  Set up your image so that you can pass the listen port in as an environment variable (so you can do docker run -e SSHD_LISTEN_PORT=66 ... or something).

A second option is to instead bind them both to a host address (such as your bridge address @ 192.168.4.10).  You would start the first with -p 192.168.4.10:22:22 and the second with -p 192.168.4.10:66:22.  This would expose both services on 192.168.4.10, one on port 22 and one on port 66.


问:
HmacSHA256 algorithm in Android API 23
I am trying to generate hash value in my Android app (API 23). I followed this link- https://developer.android.com/reference/javax/crypto/Mac.html and below code should work as per it.

```<code>Mac hmacSha256 = Mac.getInstance("HmacSHA1");
</code>```

But this gives compile time error-

java.security.NoSuchAlgorithmException

I searched and tried few solutions from across other Stackoverflow posts but they didn't work.

Tried this- MessageDigest digest = MessageDigest.getInstance("SHA-256"); got same error.

My overall intention is to convert the below C# code in Java so I can use it in my Android app-

```<code>string GenerateAuthToken(string verb, string resourceType, string resourceId, string date, string key, string keyType, string tokenVersion)
{
    var hmacSha256 = new System.Security.Cryptography.HMACSHA256 { Key = Convert.FromBase64String(key) };

    verb = verb ?? "";
    resourceType = resourceType ?? "";
    resourceId = resourceId ?? "";

    string payLoad = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}\n{1}\n{2}\n{3}\n{4}\n",
            verb.ToLowerInvariant(),
            resourceType.ToLowerInvariant(),
            resourceId,
            date.ToLowerInvariant(),
            ""
    );

    byte[] hashPayLoad = hmacSha256.ComputeHash(System.Text.Encoding.UTF8.GetBytes(payLoad));
    string signature = Convert.ToBase64String(hashPayLoad);

    return System.Web.HttpUtility.UrlEncode(String.Format(System.Globalization.CultureInfo.InvariantCulture, "type={0}&ver={1}&sig={2}",
        keyType,
        tokenVersion,
        signature));
}
</code>```

So I am just going and converting each line manually step by step and stuck at this point. Any ideas I can make this work?

答:
You typed the algorithm incorrectly
It's HmacSHA256 not hmacSHA256

You need to be careful when choosing the algorithms because they're case sensitive.

From your snapshot I can see that you used

```<code>Mac hmacSHA256 = Mac.getInstance("hmacSHA256");
</code>```

It's incorrect because you're trying to get the instance of hmacSHA256 witch does not exists!

The correct one would be

```<code>Mac hmacSHA256 = Mac.getInstance("HmacSHA245");
</code>```

The first H should be on caps

Title: HmacSHA256 algorithm in Android API 23

Body:
I am trying to generate hash value in my Android app (API 23). I followed this link- https://developer.android.com/reference/javax/crypto/Mac.html and below code should work as per it.

Mac hmacSha256 = Mac.getInstance("HmacSHA1");

But this gives compile time error-

java.security.NoSuchAlgorithmException

I searched and tried few solutions from across other Stackoverflow posts but they didn't work.

Tried this- MessageDigest digest = MessageDigest.getInstance("SHA-256"); got same error.

My overall intention is to convert the below C# code in Java so I can use it in my Android app-

string GenerateAuthToken(string verb, string resourceType, string resourceId, string date, string key, string keyType, string tokenVersion)
{
    var hmacSha256 = new System.Security.Cryptography.HMACSHA256 { Key = Convert.FromBase64String(key) };

    verb = verb ?? "";
    resourceType = resourceType ?? "";
    resourceId = resourceId ?? "";

    string payLoad = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}\n{1}\n{2}\n{3}\n{4}\n",
            verb.ToLowerInvariant(),
            resourceType.ToLowerInvariant(),
            resourceId,
            date.ToLowerInvariant(),
            ""
    );

    byte[] hashPayLoad = hmacSha256.ComputeHash(System.Text.Encoding.UTF8.GetBytes(payLoad));
    string signature = Convert.ToBase64String(hashPayLoad);

    return System.Web.HttpUtility.UrlEncode(String.Format(System.Globalization.CultureInfo.InvariantCulture, "type={0}&ver={1}&sig={2}",
        keyType,
        tokenVersion,
        signature));
}

So I am just going and converting each line manually step by step and stuck at this point. Any ideas I can make this work?

Body:
You typed the algorithm incorrectly
It's HmacSHA256 not hmacSHA256

You need to be careful when choosing the algorithms because they're case sensitive.

From your snapshot I can see that you used

Mac hmacSHA256 = Mac.getInstance("hmacSHA256");

It's incorrect because you're trying to get the instance of hmacSHA256 witch does not exists!

The correct one would be

Mac hmacSHA256 = Mac.getInstance("HmacSHA245");

The first H should be on caps


问:
How to update MySQL(MyISAM) table in parallel?
I have a parallel bash script with several threads. Each thread checks if record is exists then update value otherwise insert new row.
Should I care about  thread concurrency?
Should I lock unlock tables or mysql takes care about it?

my update goes over the command line:

```<code>#get.sh script...
# set status Downloading
mysql -uroot -pmypass -ss -e "use filestatus; call changeStatus(\"$1/$2\", 1)"
rsync  -ar  rsync://user@server/$2/ $1/$2/
if [ $? -eq 0 ];
then
# set status OK
mysql -uroot -pmypass -ss -e "use filestatus; call changeStatus(\"$1/$2\", 0)"
else
# set status ERROR
mysql -uroot -pmypass -ss -e "use filestatus; call changeStatus(\"$1/$2\", 2)"
fi
</code>```

I call several get.sh with different parameters.

Thank you beforehand

 Arman.

答:
You could implement locking, but that's going to defeat the purpose of having multiple threads. MyISAM only supports table level locking, so only 1 thread will be able to modify the table at a time.

If you can, put a unique index or primary key on a field(s). The do an INSERT ... ON DUPLICATE KEY UPDATE ...  MySql will then make sure the action is atomic.

What I usually do with multi-threading/processing, is have the first thread/process get a "list" of all the jobs that need to be perform, then create a thread/fork to handle each job or batch of jobs. The parent thread/process will assure the children aren't trying to do the same thing. I'm not sure if this will work in your case.

ContentLicense: CC BY-SA 2.5

Body:
I have a parallel bash script with several threads. Each thread checks if record is exists then update value otherwise insert new row.
Should I care about  thread concurrency?
Should I lock unlock tables or mysql takes care about it?

my update goes over the command line:

#get.sh script...
# set status Downloading
mysql -uroot -pmypass -ss -e "use filestatus; call changeStatus(\"$1/$2\", 1)"
rsync  -ar  rsync://user@server/$2/ $1/$2/
if [ $? -eq 0 ];
then
# set status OK
mysql -uroot -pmypass -ss -e "use filestatus; call changeStatus(\"$1/$2\", 0)"
else
# set status ERROR
mysql -uroot -pmypass -ss -e "use filestatus; call changeStatus(\"$1/$2\", 2)"
fi

I call several get.sh with different parameters.

Thank you beforehand

 Arman.


问:
Trying to do an array within an array in animate CC (html5 canvas)
```<code>var Home = this;
creategame();
var beasts = [];
function creategame() {
for (i=0;i<4;i++)
{

beasts[i][0] = "lib.ojb"+i.toString()+"()";
beasts[i][1] = 150+(i*125);
}

for (i=0;i<4;i++)
{
var n = new beasts[0][0][0];
    n.x = beasts[i][1];
    n.y = 350;
    n.name = "animal"+i.toString();
    stage.addChild(n);
    n.addEventListener("pressmove", dragFunc);
    n.addEventListener("pressup",release);

}
}
</code>```

Is it impossible to write the array as 'var beasts' and then expect the software to create the subarrays when told 'beasts[i][0]=something' resulting in it putting beasts = [[something,[]]] basically? the console keeps telling me 'cannot read property of undefined'

答:
You need to create an array for the beasts items. You can't assign property values to something that doesn't exist.

```<code>for (i=0;i<4;i++){
    beasts[i] = [];
    beasts[i][0] = "lib.ojb"+i.toString()+"()";
    beasts[i][1] = 150+(i*125);
}
</code>```

Edit: here is another way to write it.

```<code>for (i=0;i<4;i++){
    beasts[i] = [
        "lib.ojb"+i.toString()+"()",
        150+(i*125)
    ];
}
</code>```

Body:
var Home = this;
creategame();
var beasts = [];
function creategame() {
for (i=0;i<4;i++)
{

beasts[i][0] = "lib.ojb"+i.toString()+"()";
beasts[i][1] = 150+(i*125);
}

for (i=0;i<4;i++)
{
var n = new beasts[0][0][0];
    n.x = beasts[i][1];
    n.y = 350;
    n.name = "animal"+i.toString();
    stage.addChild(n);
    n.addEventListener("pressmove", dragFunc);
    n.addEventListener("pressup",release);

}
}

Is it impossible to write the array as 'var beasts' and then expect the software to create the subarrays when told 'beasts[i][0]=something' resulting in it putting beasts = [[something,[]]] basically? the console keeps telling me 'cannot read property of undefined'

Body:
You need to create an array for the beasts items. You can't assign property values to something that doesn't exist.

for (i=0;i<4;i++){
    beasts[i] = [];
    beasts[i][0] = "lib.ojb"+i.toString()+"()";
    beasts[i][1] = 150+(i*125);
}

Edit: here is another way to write it.

for (i=0;i<4;i++){
    beasts[i] = [
        "lib.ojb"+i.toString()+"()",
        150+(i*125)
    ];
}


问:
How a middleware is deployed for a distributed system?
I studied about distributed systems but I'm still not understanding how a middleware is deployed in order to install a distributed system.

I practiced sockets, but didn't anything about middleware and distributed system development and administration.

I'm confused about how the middleware can be deployed - must it be installed on a proxy machine, or must be installed on every machine (as part of the distributed system)? How client machines make use of middleware, is there a client part of the middleware?

答:
I could tell this from a developer perspective.
If you are working on a middleware integration project:

(1). You will be using a IDE like IBM Websphere Integration Designer(from IBM & built on top of eclipse).

(2). In this you will develop your flow, and suppose your flow has to connect to a System say A & System B, and you are sending some request to them and expecting some result to come back to your flow.

(3). You will use Web services(like SOAP) and hit to the port through which the Systems from another server are exposed and you will get back the result.

(4). You will have this inbuilt WAS server you will have in your IDE where you will deploy your integrated module. In this way, everything is connected via ports, urls and you are able to setup a distributed environment.

My answer not directly talks about distributed systems, I am much sharing my experience working in the Middleware Integration domain which is much of distributed computing.


问:
spring boot Cannot add foreign key constraint
when I running my project with spring boot 1.3.3,I get this ERROR:

```<code>.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.3.RELEASE)

2017-08-21 15:59:45.538 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000388: Unsuccessful: alter table qa_business_account add constraint FK_kr5ew7lgiv482tmmv3q0n0ny3 foreign key (business_id) references qa_shared_business (id)
2017-08-21 15:59:45.540 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : Cannot add foreign key constraint
2017-08-21 15:59:45.765 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000388: Unsuccessful: alter table qa_business_partner add constraint FK_on7gqlbhqdqsfgel0tuebc82h foreign key (business_id) references qa_shared_business (id)
2017-08-21 15:59:45.765 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : Cannot add foreign key constraint
2017-08-21 15:59:45.977 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000388: Unsuccessful: alter table qa_business_partner add constraint FK_o5bkc0vxbgebjkg34o2ccd6au foreign key (social_id) references qa_business_social_connection (id)
2017-08-21 15:59:45.978 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : Cannot add foreign key constraint
</code>```

but the project is working. No effect on function
now I want use spring boot 1.5.6
when I running the same code,I get an Execption:
like this

```<code>Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    ... 21 common frames omitted
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table qa_business_account add constraint FK963742xi8os0e9gd45ftfh8a5 foreign key (business_id) references qa_shared_business (id)]
    at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:59)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:431)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:420)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applyForeignKeys(SchemaMigratorImpl.java:386)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:214)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:60)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:134)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:472)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
    ... 27 common frames omitted
Caused by: java.sql.SQLException: Cannot add foreign key constraint
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2490)
    at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1552)
    at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2607)
    at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1480)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
    at com.sun.proxy.$Proxy87.executeUpdate(Unknown Source)
    at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:56)
    ... 37 common frames omitted
</code>```

I cannot modify the tables,add the foreign key.

So,what should I do to make it right

答:
Its due to foreign key reference error(Foreign key record not found).
After resolving it should function properly.</p>

Body:
when I running my project with spring boot 1.3.3,I get this ERROR:

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.3.RELEASE)

2017-08-21 15:59:45.538 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000388: Unsuccessful: alter table qa_business_account add constraint FK_kr5ew7lgiv482tmmv3q0n0ny3 foreign key (business_id) references qa_shared_business (id)
2017-08-21 15:59:45.540 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : Cannot add foreign key constraint
2017-08-21 15:59:45.765 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000388: Unsuccessful: alter table qa_business_partner add constraint FK_on7gqlbhqdqsfgel0tuebc82h foreign key (business_id) references qa_shared_business (id)
2017-08-21 15:59:45.765 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : Cannot add foreign key constraint
2017-08-21 15:59:45.977 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000388: Unsuccessful: alter table qa_business_partner add constraint FK_o5bkc0vxbgebjkg34o2ccd6au foreign key (social_id) references qa_business_social_connection (id)
2017-08-21 15:59:45.978 ERROR 5564 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : Cannot add foreign key constraint

but the project is working. No effect on function
now I want use spring boot 1.5.6
when I running the same code,I get an Execption:
like this

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    ... 21 common frames omitted
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table qa_business_account add constraint FK963742xi8os0e9gd45ftfh8a5 foreign key (business_id) references qa_shared_business (id)]
    at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:59)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:431)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:420)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applyForeignKeys(SchemaMigratorImpl.java:386)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:214)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:60)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:134)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:472)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
    ... 27 common frames omitted
Caused by: java.sql.SQLException: Cannot add foreign key constraint
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2490)
    at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1552)
    at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2607)
    at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1480)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
    at com.sun.proxy.$Proxy87.executeUpdate(Unknown Source)
    at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:56)
    ... 37 common frames omitted

I cannot modify the tables,add the foreign key.

So,what should I do to make it right


问:
Ionic 2 is loading the stale component
This is my footer component.  I am calling few pages from the footer bar as follows.  When i click on the footer, it is loading the stale component. i debugged it and found out it is not calling the constructor of the component (where i have the loading logic to refresh the data). i have to click twice from the footer to call the component to get the correct data

```<code>tab-footer.component.html

  <ion-tabs>
    <ion-tab [root]="home" tabIcon="md-home"
   [rootParams]="homeparams"></ion-tab>
     <ion-tab [root]="alertsPage" tabIcon="md-notifications-outline">
    </iontab>
   <ion-tab [root]="flagged" tabIcon="flag"></ion-tab>
  </ion-tabs>

  @Component({
   selector: 'app-tab-footer',
   templateUrl: './tab-footer.component.html',
  styleUrls: ['./tab-footer.component.scss']
  })
  export class TabFooterComponent {

  home = HomeComponent;
  alertsPage = AlertsComponent;
  flagged = FlaggedComponent;
  homeparams: any;

  constructor(public navparam: NavParams) {
    this.homeparams = navparam;
   }

 }
</code>```

Here is my one of the components that is called from footer

```<code>  @Component({
 selector: 'app-flagged',
 templateUrl: './flagged.component.html',
  styleUrls: ['./flagged.component.scss']
})
export class FlaggedComponent {

    someData1: any;
    someData:any[] = [];

    someObj = {}

 constructor(public someService: SomeServiceService,
     public exampleService: ExampleService,
     public navParams: NavParams,
     public navCtrl: NavController) {

   // some loading logic
   }
</code>```

Can anyone help finding out why it is not calling constructor every time?
Do I have specify some property to load it fresh?
Thank you

答:
Add the lifecycle event ionViewDidEnter or ionViewWillEnter to your FlaggedComponent class and move your update or loading logic from the constructor into one of those methods.

ionViewDidEnter() {
  console.log('the page has entered');
}

ionViewWillEnter() {
  console.log('the page is about to enter');
}
```

ionViewDidEnter is called when the page has fully entered and is now the active page.
This event will fire, whether it was the first load or a cached page.

ionViewWillEnter is called when the page is about to enter and become the active page.

reference: https://ionicframework.com/docs/api/navigation/NavController/#lifecycle-events

Title: Ionic 2 is loading the stale component

Body:
This is my footer component.  I am calling few pages from the footer bar as follows.  When i click on the footer, it is loading the stale component. i debugged it and found out it is not calling the constructor of the component (where i have the loading logic to refresh the data). i have to click twice from the footer to call the component to get the correct data

tab-footer.component.html

  <ion-tabs>
    <ion-tab [root]="home" tabIcon="md-home"
   [rootParams]="homeparams"></ion-tab>
     <ion-tab [root]="alertsPage" tabIcon="md-notifications-outline">
    </iontab>
   <ion-tab [root]="flagged" tabIcon="flag"></ion-tab>
  </ion-tabs>

  @Component({
   selector: 'app-tab-footer',
   templateUrl: './tab-footer.component.html',
  styleUrls: ['./tab-footer.component.scss']
  })
  export class TabFooterComponent {

  home = HomeComponent;
  alertsPage = AlertsComponent;
  flagged = FlaggedComponent;
  homeparams: any;

  constructor(public navparam: NavParams) {
    this.homeparams = navparam;
   }

 }

Here is my one of the components that is called from footer

  @Component({
 selector: 'app-flagged',
 templateUrl: './flagged.component.html',
  styleUrls: ['./flagged.component.scss']
})
export class FlaggedComponent {

    someData1: any;
    someData:any[] = [];

    someObj = {}

 constructor(public someService: SomeServiceService,
     public exampleService: ExampleService,
     public navParams: NavParams,
     public navCtrl: NavController) {

   // some loading logic
   }

Can anyone help finding out why it is not calling constructor every time?
Do I have specify some property to load it fresh?
Thank you

Body:
Add the lifecycle event ionViewDidEnter or ionViewWillEnter to your FlaggedComponent class and move your update or loading logic from the constructor into one of those methods.

ionViewDidEnter() {
  console.log('the page has entered');
}

ionViewWillEnter() {
  console.log('the page is about to enter');
}

ionViewDidEnter is called when the page has fully entered and is now the active page.
This event will fire, whether it was the first load or a cached page.

ionViewWillEnter is called when the page is about to enter and become the active page.

reference: https://ionicframework.com/docs/api/navigation/NavController/#lifecycle-events


问:
Querying customer change log for earliest record to determine the user that created the record
I am trying to report on which users created a given record in our customer table. Unfortunately it only shows the last user to modify the record. There is a change log though so I need to pull the earliest record for a given customer and pull the id of the change user.

So I have this:

```<code>SELECT min(ca.archive_date),
ca.cust_no,
ca.change_user
FROM mi_masdb.dbo.customer_archive ca
GROUP BY ca.cust_no
</code>```

but it won't pull the change user because there are multiple change users for each cust_no. I just need it to pull the change user associated with the earliest archive date for each cust_no.

Thoughts?

答:
Add change_user column in group by clause. refer below</p>

```<code>SELECT min(ca.archive_date),
ca.cust_no,
ca.change_user
FROM mi_masdb.dbo.customer_archive ca
GROUP BY ca.cust_no, ca.change_user
</code>```

Body:
I am trying to report on which users created a given record in our customer table. Unfortunately it only shows the last user to modify the record. There is a change log though so I need to pull the earliest record for a given customer and pull the id of the change user.

So I have this:

SELECT min(ca.archive_date),
ca.cust_no,
ca.change_user
FROM mi_masdb.dbo.customer_archive ca
GROUP BY ca.cust_no

but it won't pull the change user because there are multiple change users for each cust_no. I just need it to pull the change user associated with the earliest archive date for each cust_no.

Thoughts?

Body:
Add change_user column in group by clause. refer below

SELECT min(ca.archive_date),
ca.cust_no,
ca.change_user
FROM mi_masdb.dbo.customer_archive ca
GROUP BY ca.cust_no, ca.change_user


问:
Using Xming X Window Server over a VPN
I have the Xming X Window Server installed on a laptop running Windows XP to connect to some UNIX development servers.

It works fine when I connect directly to the company network in the office. However, it does not work when I connect to the network remotely over a VPN.

When I start Xming when connected remotely none of my terminal Windows are displayed.

I think it may have something to do with the DISPLAY environment variable not being set correctly to the IP address of the laptop when it is connected.

I've noticed that when I do an ipconfig whilst connected remotely that my laptop has two IP addresses, the one assigned to it from the company network and the local IP address I've set up for it on my "local network" from my modem/router.

Are there some configuration changes I need to make in Xming to support its use through the VPN?

答:
You may have better luck doing X11 Forwarding through SSH rather than fiddling with your DISPLAY variable directly.  X11 Forwarding with SSH is secure and uses the existing SSH connection to tunnel, so working through a VPN should be no problem.

Fortunately this is fairly straightforward with Xming.  If you open your connection from within Xming (e.g. the plink option) I believe it sets up X11 forwarding by default.  If you connect using another SSH client (e.g. PuTTY) then you simply need to enable X11 forwarding (e.g. 'ssh -X user@host').  In PuTTY the option is under Connection -> SSH -> X11 -> click on 'Enable X11 Forwarding'.

Make sure Xming is running in the background on your laptop and do the standard X test, 'xclock'.  If you get a message like 'X connection to localhost:19.0 broken (explicit kill or server shutdown).' then Xming is most likely not running.

Also, make sure you're not explicitly setting your DISPLAY variable in any startup scripts; SSH will set up an alias (something like localhost:10 or in the example above localhost:19) for the X11 tunnel and automatically set DISPLAY to that value.  Overwriting DISPLAY will obviously mean you will no longer be pointing to the correct X11 tunnel.  The flip side of this is that other terminals that don't have SSH X11 Forwarding set can use the same DISPLAY value and take advantage of the tunnel.

I tend to prefer the PuTTY option but several of my coworkers use plink from within Xming.

Title: Using Xming X Window Server over a VPN

LastEditorDisplayName: Gaius

LastEditorDisplayName: Greg Case


问:
How do I do full-text searching in Ruby on Rails?
I would like to do full-text searching of data in my Ruby on Rails application.  What options exist?</p>

答:
There are several options available and each have different strengths and weaknesses. If you would like to add full-text searching, it would be prudent to investigate each a little bit and try them out to see how well it works for you in your environment.

MySQL has built-in support for full-text searching.  It has online support meaning that when new records are added to the database, they are automatically indexed and will be available in the search results. The documentation has more details.

acts_as_tsearch offers a wrapper for similar built-in functionality for recent versions of PostgreSQL

For other databases you will have to use other software.

Lucene is a popular search provider written in Java. You can use Lucene through its search server Solr with Rails using acts_as_solr.

If you don't want to use Java, there is a port of Lucene to Ruby called Ferret. Support for Rails is added using the acts_as_ferret plugin.

Xapian is another good option and is supported in Rails using the acts_as_xapian plugin.

Finally, my preferred choice is Sphinx using the Ultrasphinx plugin. It is extremely fast and has many options on how to index and search your databases, but is no longer being actively maintained.

Another plugin for Sphinx is Thinking Sphinx which has a lot of positive feedback. It is a little easier to get started using Thinking Sphinx than Ultrasphinx. I would suggest investigating both plugins to determine which fits better with your project.

OwnerDisplayName: sock

LastEditorDisplayName: sock


问:
Rounding Numbers in XML Using Ruby
Task Goal: I am pulling data from a column in Excel and converting this information into the XML format.

I want to round numbers which have been extracted from an excel sheet using ruby and I want these to be 0 decimal places instead of 1 decimal places for example 24 instead of 24.0

```<code>xml.PLZ "#{row[7]}" is the code which produces:
<PLZ>74544.0</PLZ> in XML
</code>```

I have looked at the .round function but this does not work for me as I am pulling the PLZ value from column 7 of an excel sheet. This PLZ value changes as the program works its way down the excel sheet. What could I do to remove the decimal point in the output?

Thanks

答:
To round to nearest integer:

```<code>#{row[7].round}
</code>```

To round to specific decimal place use:

```<code>#{row[7].round(no_of_decimal_place)}
</code>```

example lets say I have a = 2.3456. If I do

```<code>#{row[7].round(2)} this will give me 2.35
</code>```

Title: Rounding Numbers in XML Using Ruby

Body:
Task Goal: I am pulling data from a column in Excel and converting this information into the XML format.

I want to round numbers which have been extracted from an excel sheet using ruby and I want these to be 0 decimal places instead of 1 decimal places for example 24 instead of 24.0

xml.PLZ "#{row[7]}" is the code which produces:
<PLZ>74544.0</PLZ> in XML

I have looked at the .round function but this does not work for me as I am pulling the PLZ value from column 7 of an excel sheet. This PLZ value changes as the program works its way down the excel sheet. What could I do to remove the decimal point in the output?

Thanks

Body:
To round to nearest integer:

#{row[7].round}

To round to specific decimal place use:

#{row[7].round(no_of_decimal_place)}

example lets say I have a = 2.3456. If I do

#{row[7].round(2)} this will give me 2.35


问:
Updating trigger (how)
can someone help with updating a trigger? I know I am supposed to use the alter clause but after that I am stuck. I would like to alter this trigger:

```<code>CREATE OR REPLACE TRIGGER  "CR_SURGERY_AUDIT"
before insert or delete or update on CR_SURGERY
for each row
declare
V_user varchar2 (30);
V_date varchar2 (30);
begin
select user, to_char(sysdate, 'dd/mon/yyyy hh24:mi:SS') INTO v_user, v_date
from dual;
IF inserting THEN
insert into CR_SURGERY_AUDIT (new_name, old_name, user_name, entry_date, operation)
VALUES (:NEW.CR_SURGERY, NULL, v_user, v_date, 'insert');
ELSIF DELETING THEN
insert into CR_SURGERY_AUDIT (new_name, old_name, user_name, entry_date, operation)
VALUES (null, :OLD.CR_SURGERY, v_user, v_date, 'delete');
ELSIF UPDATING THEN
insert into CR_SURGERY_AUDIT (new_name, old_name, user_name, entry_date, operation)
VALUES (:NEW.CR_SURGERY, :OLD.CR_SURGERY, v_user, v_date, 'Update');
END IF;
END;
</code>```

I know it's simple but I cannot find a way to compose it. I want to add FK_SOCRD_ID so it updates to:

```<code>select user, to_char(sysdate, 'dd/mon/yyyy') INTO v_user, v_date from dual;
IF inserting THEN
insert into CR_SURGERY_AUDIT (new_name, old_name, user_name, entry_date,
operation, FK_SOCRD_ID)
VALUES (:NEW.CR_SURGERY, NULL, v_user, v_date, 'insert');
</code>```

答:
There is no syntax to modify triggers, you just modify your create or replace trigger code and rerun it.

With your proposed change, I make it something like this:

```<code>create or replace trigger cr_surgery_audit
before insert or delete or update on cr_surgery
for each row
declare
    k_user constant cr_surgery_audit.user_name%type := sys_context('userenv','os_user');
    k_date constant cr_surgery_audit.entry_date%type := sysdate;
begin
    if inserting then
        insert into cr_surgery_audit (new_name, old_name, user_name, entry_date, operation, fk_socrd_id)
        values (:new.cr_surgery, null, k_user, k_date, 'insert', 12345);
    elsif deleting then
        insert into cr_surgery_audit (new_name, old_name, user_name, entry_date, operation)
        values (null, :old.cr_surgery, k_user, k_date, 'delete');
    elsif updating then
        insert into cr_surgery_audit (new_name, old_name, user_name, entry_date, operation)
        values (:new.cr_surgery, :old.cr_surgery, k_user, k_date, 'update');
    end if;
end;
</code>```

I've assumed cr_surgery_audit.entry_date is actually a date and not a varchar2.

You need a value to populate fk_socrd_id with, so I put in 123456 as a dummy value.

Title: Updating trigger (how)

Body:
can someone help with updating a trigger? I know I am supposed to use the alter clause but after that I am stuck. I would like to alter this trigger:

CREATE OR REPLACE TRIGGER  "CR_SURGERY_AUDIT"
before insert or delete or update on CR_SURGERY
for each row
declare
V_user varchar2 (30);
V_date varchar2 (30);
begin
select user, to_char(sysdate, 'dd/mon/yyyy hh24:mi:SS') INTO v_user, v_date
from dual;
IF inserting THEN
insert into CR_SURGERY_AUDIT (new_name, old_name, user_name, entry_date, operation)
VALUES (:NEW.CR_SURGERY, NULL, v_user, v_date, 'insert');
ELSIF DELETING THEN
insert into CR_SURGERY_AUDIT (new_name, old_name, user_name, entry_date, operation)
VALUES (null, :OLD.CR_SURGERY, v_user, v_date, 'delete');
ELSIF UPDATING THEN
insert into CR_SURGERY_AUDIT (new_name, old_name, user_name, entry_date, operation)
VALUES (:NEW.CR_SURGERY, :OLD.CR_SURGERY, v_user, v_date, 'Update');
END IF;
END;

I know it's simple but I cannot find a way to compose it. I want to add FK_SOCRD_ID so it updates to:

select user, to_char(sysdate, 'dd/mon/yyyy') INTO v_user, v_date from dual;
IF inserting THEN
insert into CR_SURGERY_AUDIT (new_name, old_name, user_name, entry_date,
operation, FK_SOCRD_ID)
VALUES (:NEW.CR_SURGERY, NULL, v_user, v_date, 'insert');

Body:
There is no syntax to modify triggers, you just modify your create or replace trigger code and rerun it.

With your proposed change, I make it something like this:

create or replace trigger cr_surgery_audit
before insert or delete or update on cr_surgery
for each row
declare
    k_user constant cr_surgery_audit.user_name%type := sys_context('userenv','os_user');
    k_date constant cr_surgery_audit.entry_date%type := sysdate;
begin
    if inserting then
        insert into cr_surgery_audit (new_name, old_name, user_name, entry_date, operation, fk_socrd_id)
        values (:new.cr_surgery, null, k_user, k_date, 'insert', 12345);
    elsif deleting then
        insert into cr_surgery_audit (new_name, old_name, user_name, entry_date, operation)
        values (null, :old.cr_surgery, k_user, k_date, 'delete');
    elsif updating then
        insert into cr_surgery_audit (new_name, old_name, user_name, entry_date, operation)
        values (:new.cr_surgery, :old.cr_surgery, k_user, k_date, 'update');
    end if;
end;

I've assumed cr_surgery_audit.entry_date is actually a date and not a varchar2.

You need a value to populate fk_socrd_id with, so I put in 123456 as a dummy value.


问:
How to join multiple tables with one table?
I'm working on an SQL project, but I found a problem while retrieving data from the database. There are four tables as you can see in the following screenshot:

So my query is about calculating the sum of the units from the tables transac_EUR_M10_17 and transac_EUR_M09_17.

I tried the following SQL Server query but the results are false:

```<code>SELECT cntry.cod_country
    , rg.nom_region
    , SUM(tr.unite) as [sum units M09]
    , SUM(tr1.unite) as [sum units M10]
FROM [Backup].[dbo].[transac_EUR_M09_17] as tr
INNER JOIN [Backup].[dbo].[COUNTRY] as cntry ON tr.[cod_country] = cntry.[cod_country]
INNER JOIN [Backup].[dbo].Region as rg   ON rg.[cod_country] = cntry.[cod_country]
INNER JOIN [Backup].[dbo].[transac_EUR_M10_17] AS tr1  ON tr1.[cod_country] = cntry.[cod_country]
where tr.cod_region = rg.cod_region
    AND tr1.cod_region = rg.cod_region
Group BY cntry.cod_country
    , rg.nom_region
ORDER BY SUM(tr.unite)
    , SUM(tr1.unite) DESC
</code>```

Do you have any advice about how to join two tables with one permanent table?

答:
Unless cod_country is a unique column, those joins are bound to cause duplicate columns.

If you have 2 rows with the same country in 09_17 and the same thing in 10_17 it is going to duplicate both rows in the first table to duplicate, hence messing up your sums.

EDIT: And the same applies to any other table you're joining with

Body:
I'm working on an SQL project, but I found a problem while retrieving data from the database. There are four tables as you can see in the following screenshot:

So my query is about calculating the sum of the units from the tables transac_EUR_M10_17 and transac_EUR_M09_17.

I tried the following SQL Server query but the results are false:

SELECT cntry.cod_country
    , rg.nom_region
    , SUM(tr.unite) as [sum units M09]
    , SUM(tr1.unite) as [sum units M10]
FROM [Backup].[dbo].[transac_EUR_M09_17] as tr
INNER JOIN [Backup].[dbo].[COUNTRY] as cntry ON tr.[cod_country] = cntry.[cod_country]
INNER JOIN [Backup].[dbo].Region as rg   ON rg.[cod_country] = cntry.[cod_country]
INNER JOIN [Backup].[dbo].[transac_EUR_M10_17] AS tr1  ON tr1.[cod_country] = cntry.[cod_country]
where tr.cod_region = rg.cod_region
    AND tr1.cod_region = rg.cod_region
Group BY cntry.cod_country
    , rg.nom_region
ORDER BY SUM(tr.unite)
    , SUM(tr1.unite) DESC

Do you have any advice about how to join two tables with one permanent table?


问:
Webpack.config how to just copy the index.html to the dist folder
I am  trying to automate assets going into /dist. I have the following config.js:

```<code>module.exports = {
  context: __dirname + "/lib",
  entry: {
    main: [
      "./baa.ts"
    ]
  },
  output: {
    path: __dirname + "/dist",
    filename: "foo.js"
  },
  devtool: "source-map",
  module: {
    loaders: [
      {
        test: /\.ts$/,
        loader: 'awesome-typescript-loader'
      },
      { test: /\.css$/, loader: "style-loader!css-loader" }
    ]
  },
  resolve: {
    // you can now require('file') instead of require('file.js')
    extensions: ['', '.js', '.json']
  }
}
</code>```

I also want to include main.html from the directory that sits next to /lib, into the /dist folder when running webpack. How can I do this?

UPDATE 1 2017_____________

My favourite way to do this now is to use the html-webpack-plugin with a template file. Thanks to the accepted answer too! The advantage of this way is that the index file will also have the cachbusted js link added out of the box!

答:
You can add the index directly to your entry config and using a file-loader to load it</p>

```<code>module.exports = {

  entry: [
    __dirname + "/index.html",
    .. other js files here
  ],

  module: {
    rules: [
      {
        test: /\.html/,
        loader: 'file-loader?name=[name].[ext]',
      },
      .. other loaders
    ]
  }

}
</code>```

Body:
I am  trying to automate assets going into /dist. I have the following config.js:

module.exports = {
  context: __dirname + "/lib",
  entry: {
    main: [
      "./baa.ts"
    ]
  },
  output: {
    path: __dirname + "/dist",
    filename: "foo.js"
  },
  devtool: "source-map",
  module: {
    loaders: [
      {
        test: /\.ts$/,
        loader: 'awesome-typescript-loader'
      },
      { test: /\.css$/, loader: "style-loader!css-loader" }
    ]
  },
  resolve: {
    // you can now require('file') instead of require('file.js')
    extensions: ['', '.js', '.json']
  }
}

I also want to include main.html from the directory that sits next to /lib, into the /dist folder when running webpack. How can I do this?

UPDATE 1 2017_____________

My favourite way to do this now is to use the html-webpack-plugin with a template file. Thanks to the accepted answer too! The advantage of this way is that the index file will also have the cachbusted js link added out of the box!

Body:
You can add the index directly to your entry config and using a file-loader to load it

module.exports = {

  entry: [
    __dirname + "/index.html",
    .. other js files here
  ],

  module: {
    rules: [
      {
        test: /\.html/,
        loader: 'file-loader?name=[name].[ext]',
      },
      .. other loaders
    ]
  }

}


问:
Yarn install command error No such file or directory: 'install'
I am installing sylius bundle and while install sylius I need to run yarn install So
While I run the command:

```<code>yarn install
</code>```

I get the error:

ERROR: [Errno 2] No such file or directory: 'install'
```

答:
I had the same issue on Ubuntu 17.04.

This solution worked for me:

```<code>sudo apt remove cmdtest
sudo apt remove yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn -y
</code>```

then

```<code>yarn install
</code>```

result:

```<code>yarn install v1.3.2
warning You are using Node "6.0.0" which is not supported and may encounter bugs or unexpected behaviour. Yarn supports the following server range: "^4.8.0 || ^5.7.0 || ^6.2.2 || >=8.0.0"
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

info Lockfile not saved, no dependencies.
Done in 0.20s.
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am installing sylius bundle and while install sylius I need to run yarn install So
While I run the command:

yarn install

I get the error:

ERROR: [Errno 2] No such file or directory: 'install'

Body:
I had the same issue on Ubuntu 17.04.

This solution worked for me:

sudo apt remove cmdtest
sudo apt remove yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn -y

then

yarn install

result:

yarn install v1.3.2
warning You are using Node "6.0.0" which is not supported and may encounter bugs or unexpected behaviour. Yarn supports the following server range: "^4.8.0 || ^5.7.0 || ^6.2.2 || >=8.0.0"
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

info Lockfile not saved, no dependencies.
Done in 0.20s.


问:
Angular2 observable timeout
I have a ASP.NET core web application with angular2 for client-facing.For specific reasons I want to increase the timeout of Http calls from angular2 to back-end server from default to 8 minutes.I have tried the timeout operator as such but still ending up with default timeout(2 minutes)

```<code>getSystemDetailsBySystemTypeAndOwnershipCode(systemType: string, ownershipCode: string): Observable<any> {
    let productUrl: string = `/api/systemdetails/systemtypes/${systemType}/systems/ownershipcode/${ownershipCode}`;
    return this.http.get(productUrl).timeout(480000)
        .catch((error: any) => {
            return Observable.throw(error);
        });
}
</code>```

Any suggestions to increase timeout? Thanks in advance !!

答:
Found a fix .Increasing the requestTimeout of the http calls in the web.config file of the project solves this issue

```<code><system.webServer>
<handlers>
  <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore requestTimeout="00:10:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</code>```

Title: Angular2 observable timeout

Body:
I have a ASP.NET core web application with angular2 for client-facing.For specific reasons I want to increase the timeout of Http calls from angular2 to back-end server from default to 8 minutes.I have tried the timeout operator as such but still ending up with default timeout(2 minutes)

getSystemDetailsBySystemTypeAndOwnershipCode(systemType: string, ownershipCode: string): Observable<any> {
    let productUrl: string = `/api/systemdetails/systemtypes/${systemType}/systems/ownershipcode/${ownershipCode}`;
    return this.http.get(productUrl).timeout(480000)
        .catch((error: any) => {
            return Observable.throw(error);
        });
}

Any suggestions to increase timeout? Thanks in advance !!

Body:
Found a fix .Increasing the requestTimeout of the http calls in the web.config file of the project solves this issue

<system.webServer>
<handlers>
  <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore requestTimeout="00:10:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>


答: I think this is something that you can expect from any Rest API. You should just always verify the data that comes back from the API.</p>

Title: GDAX api - Get Historic Rates returning inconsistent results

Body:
While using GDAX api for calling historic prices using the following:

https://api.gdax.com/products/ETH-EUR/candles?start=2017-07-02T15:25:00.00000Z&end=2017-07-02T16:12:00.00000Z&granularity=30

I always get a 200 code responde, but sometimes it returns :

[]

and other times :

[[1499011890,234.98,235,234.98,235,7.582868079999999],[1499011830,234.4,235,234.4,235,17.7272481],[1499011680,233.71,233.71,233.71,233.71,1.61151688],[1499011650,233.71,233.71,233.71,233.71,0.85362734],[1499011350,233.71,233.71,233.71,233.71,1.5],[1499011320,233.48,233.67,233.48,233.67,5.22588745],[1499011290,233.48,233.48,233.48,233.48,1.11358574],[1499011200,233.48,233.48,233.48,233.48,1.70893649],[1499010990,233.44,233.47,233.44,233.47,8.34642375],[1499010270,230.11,233,231,233,9.30791793],[1499010240,231,231,231,231,10],[1499009850,233.02,233.02,233.02,233.02,0.0000428],[1499009640,230.26,231.64,231.64,230.26,10.81225691],[1499009250,231,231.55,231.55,231,15],
[1499009100,231,231.92,231.92,231,20]]

Can anyone explain this behavior?

I was expecting "429 Too Many Requests" if it was a situation where limits were reached, which I'm pretty sure this isn't the case.


问:
Can't run Xamarin project after installing SkiaSharp?
I installed SkiaSharp and SkiaSharp.Views.Forms
and when I used them in my code:

```<code>public MainPage()
        {
            InitializeComponent();

            SKCanvasView canvasView = new SKCanvasView();
            canvasView.PaintSurface += OnCanvasViewPaintSurface;
            Content = canvasView;

        }

void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
    {
        SKImageInfo info = args.Info;
        SKSurface surface = args.Surface;
        SKCanvas canvas = surface.Canvas;

        canvas.Clear();

        SKPaint paint = new SKPaint
        {
            Style = SKPaintStyle.Stroke,
            Color = Color.Red.ToSKColor(),
            StrokeWidth = 25
        };
        canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, paint);

        paint.Style = SKPaintStyle.Fill;
        paint.Color = SKColors.Blue;
        canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, paint);
    }
</code>```

The project can't run, (the orange color of the debugging mode just disappear immediately), and there're no errors.

when I commented out the code above, the project run normally!
I'm using Visual Studio 2017 version 15.4.5

I tried opening the project in VS 2015, I got this exception in MainActivity of the Android project at:

```<code>LoadApplication(new App());
</code>```

Message:

Specified cast is not valid.

StackTrace:

System.InvalidCastException: Specified cast is not valid. at (wrapper
  castclass) System.Object:__castclass_with_cache (object,intptr,intptr)
  at Xamarin.Forms.Internals.Registrar1[TRegistrable].GetHandler
  (System.Type type) [0x0001b] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Registrar.cs:37
  at Xamarin.Forms.Internals.Registrar1[TRegistrable].GetHandler[TOut]
  (System.Type type) [0x00000] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Registrar.cs:42
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer
  (Xamarin.Forms.VisualElement element) [0x00006] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:284
  at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild
  (Xamarin.Forms.VisualElement view,
  Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer,
  Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean
  sameChildren) [0x00023] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:86
  at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement
  (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement
  newElement) [0x00104] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:219
  at Xamarin.Forms.Platform.Android.VisualElementPackager.Load ()
  [0x00000] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:70
  at
  Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].SetPackager
  (Xamarin.Forms.Platform.Android.VisualElementPackager packager)
  [0x00007] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:371
  at
  Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].SetElement
  (TElement element) [0x000ce] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:174
  at
  Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement
  (Xamarin.Forms.VisualElement element) [0x00027] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:120
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer
  (Xamarin.Forms.VisualElement element) [0x0001f] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:285
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.AddChild
  (Xamarin.Forms.Page page, System.Boolean layout) [0x00015] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:268
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage
  (Xamarin.Forms.Page newRoot) [0x0007a] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:245
  at
  Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage
  (Xamarin.Forms.Page page) [0x0009b] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:337
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.SetMainPage
  () [0x00000] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:407
  at
  Xamarin.Forms.Platform.Android.FormsAppCompatActivity.LoadApplication
  (Xamarin.Forms.Application application) [0x00229] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:152
  at XamApp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle)
  [0x00028] in D :\P\XamApp\XamApp\XamApp.Android\MainActivity.cs:25

答:
To work, I have to install SkiaSharp, SkiaSharp.Views, and SkiaSharp.Views.Forms via nuget to the Android and iOS projects, PCL only requires SkiaSharp and SkiaSharp.Views.Forms.

original answer here:
https://forums.xamarin.com/discussion/comment/310695/#Comment_310695

Body:
I installed SkiaSharp and SkiaSharp.Views.Forms
and when I used them in my code:

public MainPage()
        {
            InitializeComponent();

            SKCanvasView canvasView = new SKCanvasView();
            canvasView.PaintSurface += OnCanvasViewPaintSurface;
            Content = canvasView;

        }

void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
    {
        SKImageInfo info = args.Info;
        SKSurface surface = args.Surface;
        SKCanvas canvas = surface.Canvas;

        canvas.Clear();

        SKPaint paint = new SKPaint
        {
            Style = SKPaintStyle.Stroke,
            Color = Color.Red.ToSKColor(),
            StrokeWidth = 25
        };
        canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, paint);

        paint.Style = SKPaintStyle.Fill;
        paint.Color = SKColors.Blue;
        canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, paint);
    }

The project can't run, (the orange color of the debugging mode just disappear immediately), and there're no errors.

when I commented out the code above, the project run normally!
I'm using Visual Studio 2017 version 15.4.5

I tried opening the project in VS 2015, I got this exception in MainActivity of the Android project at:

LoadApplication(new App());

Message:

Specified cast is not valid.

StackTrace:

System.InvalidCastException: Specified cast is not valid. at (wrapper
  castclass) System.Object:__castclass_with_cache (object,intptr,intptr)
  at Xamarin.Forms.Internals.Registrar1[TRegistrable].GetHandler
  (System.Type type) [0x0001b] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Registrar.cs:37
  at Xamarin.Forms.Internals.Registrar1[TRegistrable].GetHandler[TOut]
  (System.Type type) [0x00000] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Registrar.cs:42
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer
  (Xamarin.Forms.VisualElement element) [0x00006] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:284
  at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild
  (Xamarin.Forms.VisualElement view,
  Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer,
  Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean
  sameChildren) [0x00023] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:86
  at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement
  (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement
  newElement) [0x00104] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:219
  at Xamarin.Forms.Platform.Android.VisualElementPackager.Load ()
  [0x00000] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:70
  at
  Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].SetPackager
  (Xamarin.Forms.Platform.Android.VisualElementPackager packager)
  [0x00007] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:371
  at
  Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].SetElement
  (TElement element) [0x000ce] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:174
  at
  Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement
  (Xamarin.Forms.VisualElement element) [0x00027] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:120
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer
  (Xamarin.Forms.VisualElement element) [0x0001f] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:285
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.AddChild
  (Xamarin.Forms.Page page, System.Boolean layout) [0x00015] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:268
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage
  (Xamarin.Forms.Page newRoot) [0x0007a] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:245
  at
  Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage
  (Xamarin.Forms.Page page) [0x0009b] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:337
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.SetMainPage
  () [0x00000] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:407
  at
  Xamarin.Forms.Platform.Android.FormsAppCompatActivity.LoadApplication
  (Xamarin.Forms.Application application) [0x00229] in
  C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:152
  at XamApp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle)
  [0x00028] in D :\P\XamApp\XamApp\XamApp.Android\MainActivity.cs:25


问:
create a temporary variable in db2/400 (v5R4) within a RUNSQLSTM source file member?
Can I create a temporary variable in db2/400 (v5R4) within a RUNSQLSTM source file member?  Maybe something like this?

```<code>CREATE VARIABLE myVar1 INT DEFAULT (RAND() *100)
CREATE VARIABLE myVar2 INT DEFAULT (RAND() *100)
CREATE VARIABLE myVar3 INT DEFAULT (RAND() *100)

INSERT INTO file1 VALUES(myVar1, myVar2, myVar3)
INSERT INTO file1 VALUES(myVar1, myVar2, myVar3)
etc...
</code>```

The goal is to quickly generate some random test data. Example above is simplified.

答:
Yes. You might want to add or replace to the create command so you can run it over if necessary. Also note the semi-colons;, they are important. This actually creates a global variable in the schema. Here is what I tested.

```<code>CREATE or replace VARIABLE myVar1 INT DEFAULT (RAND() *100);
CREATE or replace VARIABLE myVar2 INT DEFAULT (RAND() *100);
CREATE or replace VARIABLE myVar3 INT DEFAULT (RAND() *100);

create or replace table file1 (
  field1 integer,
  field2 integer,
  field3 integer);

INSERT INTO file1 VALUES(myVar1, myVar2, myVar3);
INSERT INTO file1 VALUES(myVar1, myVar2, myVar3);
</code>```

My results looked like this:

```<code>select * from file1;

field1  field2  field3
19      69      60
19      69      60
</code>```

Body:
Can I create a temporary variable in db2/400 (v5R4) within a RUNSQLSTM source file member?  Maybe something like this?

CREATE VARIABLE myVar1 INT DEFAULT (RAND() *100)
CREATE VARIABLE myVar2 INT DEFAULT (RAND() *100)
CREATE VARIABLE myVar3 INT DEFAULT (RAND() *100)

INSERT INTO file1 VALUES(myVar1, myVar2, myVar3)
INSERT INTO file1 VALUES(myVar1, myVar2, myVar3)
etc...

The goal is to quickly generate some random test data. Example above is simplified.

Body:
Yes. You might want to add or replace to the create command so you can run it over if necessary. Also note the semi-colons;, they are important. This actually creates a global variable in the schema. Here is what I tested.

CREATE or replace VARIABLE myVar1 INT DEFAULT (RAND() *100);
CREATE or replace VARIABLE myVar2 INT DEFAULT (RAND() *100);
CREATE or replace VARIABLE myVar3 INT DEFAULT (RAND() *100);

create or replace table file1 (
  field1 integer,
  field2 integer,
  field3 integer);

INSERT INTO file1 VALUES(myVar1, myVar2, myVar3);
INSERT INTO file1 VALUES(myVar1, myVar2, myVar3);

My results looked like this:

select * from file1;

field1  field2  field3
19      69      60
19      69      60


问:
excel vba macro: copy and paste the specific column to another workbook
i am new in macro and VBA coding.
I have two workbooks. one is report.xls, another one is AT.xlsm.

In report.xls, there has the sheet called "Service".

In AT.xlsm, there has the sheet called "Worksheet".

I want to auto copy the column B,C,F,J,E,D expect first row of report to the column A,C,D,E,F,H of AT.
So, i try to record a macro and revise the code, it can copy and paste but it saved to same location.

Would you please tell me how to paste to new row?

Thank you very much.

Code:

```<code>Sub Module1()
'Hot key: Ctrl+Shift+G

Windows("report.xls").Activate
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("AT.xlsm").Activate
ActiveSheet.Paste
Windows("report.xls").Activate
Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("C5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("F2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("D5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("J2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("E5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("E2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("F5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("D2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("H5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("G2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("J5380").Select
ActiveSheet.Paste
Range("F5380").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:="[S]", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

End Sub
</code>```

答:
You should not be activating and selecting anything to copy over to another worksheet.  wss and wsw are explicit references to your worksheets.

```<code>Sub Tester546()
Set wb = Workbook("report.xls")
Set wb2 = Workbook("AT.xlsm")
Set wss = wb.Sheets("Service")
Set wsw = wb.Sheets("Worksheet")
wss.Range(wss.Cells(2, 2), wss.Cells(wss.Range("B" & wss.Rows.Count).End(xlUp).Row, 2)).Copy wsw.Cells(1, 1)
wss.Range(wss.Cells(2, 3), wss.Cells(wss.Range("C" & wss.Rows.Count).End(xlUp).Row, 3)).Copy wsw.Cells(5380, 3)
wss.Range(wss.Cells(2, 6), wss.Cells(wss.Range("F" & ws.Rows.Count).End(xlUp).Row, 6)).Copy wsw.Cells(5380, 4)
wss.Range(wss.Cells(2, 10), wss.Cells(wss.Range("J" & wss.Rows.Count).End(xlUp).Row, 10)).Copy wsw.Cells(5380, 5)
wss.Range(wss.Cells(2, 5), wss.Cells(wss.Range("E" & wss.Rows.Count).End(xlUp).Row, 5)).Copy wsw.Cells(5380, 6)
wss.Range(wss.Cells(2, 4), wss.Cells(wss.Range("D" & wss.Rows.Count).End(xlUp).Row, 4)).Copy wsw.Cells(5380, 8)
wsw.Range(wsw.Cells(5380, 6), wsw.Cells(wsw.Range("F" & wsw.Rows.Count).End(xlUp).Row, 6)).Replace What:="[S]", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

End Sub
</code>```

You should be able to replace the 5380 on the destination worksheet (wsw) with

```<code>wsW.Range("D" & wss.Rows.Count).End(xlUp).Row +1
</code>```

Changing the Column (here it's "D", to the columns you need.

Body:
i am new in macro and VBA coding.
I have two workbooks. one is report.xls, another one is AT.xlsm.

In report.xls, there has the sheet called "Service".

In AT.xlsm, there has the sheet called "Worksheet".

I want to auto copy the column B,C,F,J,E,D expect first row of report to the column A,C,D,E,F,H of AT.
So, i try to record a macro and revise the code, it can copy and paste but it saved to same location.

Would you please tell me how to paste to new row?

Thank you very much.

Code:

Sub Module1()
'Hot key: Ctrl+Shift+G

Windows("report.xls").Activate
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("AT.xlsm").Activate
ActiveSheet.Paste
Windows("report.xls").Activate
Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("C5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("F2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("D5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("J2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("E5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("E2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("F5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("D2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("H5380").Select
ActiveSheet.Paste
Windows("report.xls").Activate
Range("G2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("AT.xlsm").Activate
Range("J5380").Select
ActiveSheet.Paste
Range("F5380").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:="[S]", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

End Sub

Body:
You should not be activating and selecting anything to copy over to another worksheet.  wss and wsw are explicit references to your worksheets.

Sub Tester546()
Set wb = Workbook("report.xls")
Set wb2 = Workbook("AT.xlsm")
Set wss = wb.Sheets("Service")
Set wsw = wb.Sheets("Worksheet")
wss.Range(wss.Cells(2, 2), wss.Cells(wss.Range("B" & wss.Rows.Count).End(xlUp).Row, 2)).Copy wsw.Cells(1, 1)
wss.Range(wss.Cells(2, 3), wss.Cells(wss.Range("C" & wss.Rows.Count).End(xlUp).Row, 3)).Copy wsw.Cells(5380, 3)
wss.Range(wss.Cells(2, 6), wss.Cells(wss.Range("F" & ws.Rows.Count).End(xlUp).Row, 6)).Copy wsw.Cells(5380, 4)
wss.Range(wss.Cells(2, 10), wss.Cells(wss.Range("J" & wss.Rows.Count).End(xlUp).Row, 10)).Copy wsw.Cells(5380, 5)
wss.Range(wss.Cells(2, 5), wss.Cells(wss.Range("E" & wss.Rows.Count).End(xlUp).Row, 5)).Copy wsw.Cells(5380, 6)
wss.Range(wss.Cells(2, 4), wss.Cells(wss.Range("D" & wss.Rows.Count).End(xlUp).Row, 4)).Copy wsw.Cells(5380, 8)
wsw.Range(wsw.Cells(5380, 6), wsw.Cells(wsw.Range("F" & wsw.Rows.Count).End(xlUp).Row, 6)).Replace What:="[S]", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

End Sub

You should be able to replace the 5380 on the destination worksheet (wsw) with

wsW.Range("D" & wss.Rows.Count).End(xlUp).Row +1

Changing the Column (here it's "D", to the columns you need.


问:
Can't execute Ruby file using Powershell
I want to execute a ruby file using windows 10 powershell. In my powershell terminal, when I type

```<code>ruby test.rb
</code>```

I receive

```<code>ruby: The term 'ruby' is not recognized as the name of the cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ ruby test.rb
    +Category Info        :ObjectNotFound: (ruby:String) [],
    CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
</code>```

These commands don't work either

```<code>ruby.exe test.rb
rb.exe test.rb
</code>```

I'm in the right directory. I suspect the problem has to do with PATHs, but I don't understand PATHs yet. I have been trying to execute .rb files in both Powershell and my beginner IDE, Visual Studio Code.

Thanks

答:
In powershell, navigate to the directory where your ruby file is stored. It will look something like this C:\Users\Joe\Desktop\Ruby_Practice_folder>

Type

```<code>#!/usr/bin/env ruby
</code>```

Hit enter. Type

```<code>ruby your_ruby_file.rb
</code>```

Body:
I want to execute a ruby file using windows 10 powershell. In my powershell terminal, when I type

ruby test.rb

I receive

ruby: The term 'ruby' is not recognized as the name of the cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ ruby test.rb
    +Category Info        :ObjectNotFound: (ruby:String) [],
    CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

These commands don't work either

ruby.exe test.rb
rb.exe test.rb

I'm in the right directory. I suspect the problem has to do with PATHs, but I don't understand PATHs yet. I have been trying to execute .rb files in both Powershell and my beginner IDE, Visual Studio Code.

Thanks

Body:
In powershell, navigate to the directory where your ruby file is stored. It will look something like this C:\Users\Joe\Desktop\Ruby_Practice_folder>

Type

#!/usr/bin/env ruby

Hit enter. Type

ruby your_ruby_file.rb


问:
How to trim extra space from ggplot
I am trying to make an extremely single heatmap of percentages using ggplot2 which ideally will just be two single thin columns. I tried the following code, believing that the width option in aes would solve the problem.

```<code>p_prev_tg <- ggplot(tg_melt, aes(x = variable , y = OTU, fill = value,
                    width=.3)) + geom_tile() +
                    scale_fill_gradientn(colours = hm.palette2(10)) +
                    xlab(NULL) + ylab(NULL) +
                    theme(axis.text=element_text(size=7))
p_prev_tg
</code>```

Unfortunately, this returns a plot with lots of empty space as shown. The plot I would like is those two bars side by side, how can I do this in ggplot?

thanks

答:
What about this solution ?

```<code>set.seed(1234)
tg_melt <- data.frame(variable=rep(c("Prevalence_T","Prevalence_NT"), each=10),
                      OTU=rep(paste0("OTU_",1:10),2),
                      value=rnorm(20))

library(RColorBrewer)
library(ggplot2)
hm.palette2 <- colorRampPalette(rev(brewer.pal(11, 'Spectral')))

p_prev_tg <- ggplot(tg_melt, aes(x = as.numeric(variable), y = OTU, fill = value)) +
                    geom_tile() +
                    scale_fill_gradientn(colours = hm.palette2(10)) +
                    xlab(NULL) + ylab(NULL) +
                    theme(axis.text=element_text(size=7)) +
                    scale_x_continuous(breaks=c(1,2),
                      limits=c(0,3),
                      labels=levels(tg_melt$variable))+
                    theme_bw()

p_prev_tg
</code>```

Title: How to trim extra space from ggplot

Body:
I am trying to make an extremely single heatmap of percentages using ggplot2 which ideally will just be two single thin columns. I tried the following code, believing that the width option in aes would solve the problem.

p_prev_tg <- ggplot(tg_melt, aes(x = variable , y = OTU, fill = value,
                    width=.3)) + geom_tile() +
                    scale_fill_gradientn(colours = hm.palette2(10)) +
                    xlab(NULL) + ylab(NULL) +
                    theme(axis.text=element_text(size=7))
p_prev_tg

Unfortunately, this returns a plot with lots of empty space as shown. The plot I would like is those two bars side by side, how can I do this in ggplot?

thanks

Body:
What about this solution ?

set.seed(1234)
tg_melt <- data.frame(variable=rep(c("Prevalence_T","Prevalence_NT"), each=10),
                      OTU=rep(paste0("OTU_",1:10),2),
                      value=rnorm(20))

library(RColorBrewer)
library(ggplot2)
hm.palette2 <- colorRampPalette(rev(brewer.pal(11, 'Spectral')))

p_prev_tg <- ggplot(tg_melt, aes(x = as.numeric(variable), y = OTU, fill = value)) +
                    geom_tile() +
                    scale_fill_gradientn(colours = hm.palette2(10)) +
                    xlab(NULL) + ylab(NULL) +
                    theme(axis.text=element_text(size=7)) +
                    scale_x_continuous(breaks=c(1,2),
                      limits=c(0,3),
                      labels=levels(tg_melt$variable))+
                    theme_bw()

p_prev_tg


问:
600 + rows of Excel data to create Outlook Appointment...but only creates a single appointment

Background:

I have a task tracking spread sheet and would like to create a calendar "appointment" everytime a new row is added to the table. There are many instances of different versions of this code floating around out there, so I pieced this together with little true knowledge of VBA.

The Data:

Data is stored in a table (Table1) in Sheet1, which I have renamed "Tracker". It's currently ~600 rows, and ~16 columns. The table is constantly updated with new rows of data.

The Problem:

The macro runs, and loops through the 600+ rows of data, creating an appointment for a row, then overwriting that appointment with the data from the next row. I know it's creating + overwriting b/c I set my calendar view to "list view", and ran the macro...and I can see it cycling through all the different rows, so I know it's looping. So I THINK I need assistance modifying the Private Function's subjectFilter. That said, if I remove the Private Function, it does the same thing.

Right now, the .Subject code is this:

```<code>.Subject = Cells(r, 9).Value & " (" & Cells(r, 13).Value & " " & Cells(r, 14).Value & ")"
</code>```

Although I could simplify it to this if it makes it easier to incorp into the subjectFilter:

```<code>.Subject = Cells(r, 9).Value
</code>```

Questions:

How can I adjust the code so it creates all 600+ appointments?

How do I incorporate my .Subject string into the Private Function's
subjectFilter?

Current Code:

```<code>Sub SetAppt()

Dim olApp As Outlook.Application
Dim olApt As AppointmentItem
Dim MySheet As Worksheet

Set MySheet = Worksheets("Tracker")
Set olApp = New Outlook.Application
Set olApt = olApp.CreateItem(olAppointmentItem)

For r = 2 To Cells(Rows.Count,1).End(xlUp).Row

With olApt
       .Start = Cells(r, 2).Value + TimeValue("10:30")
       .Duration = "1"
       .Subject = Cells(r, 9).Value & " (" & Cells(r, 13).Value & " " & Cells(r, 14).Value & ")"
       .Location = Cells(r, 5).Value
       .Body = "Follow up with task lead"
       .BusyStatus = olBusy
       .ReminderMinutesBeforeStart = 60
       .Categories = "Task Reminder"
       .ReminderSet = True
       .Save

End With
Next

Set olApt = Nothing
Set olApp = Nothing

End Sub

Private Function Get_Appointment(subject As String) As Outlook.AppointmentItem
'Private Function grabbed from here https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwis6IGw7vXXAhXBneAKHWJ9A7kQFggpMAA&url=https%3A%2F%2Fwww.mrexcel.com%2Fforum%2Fexcel-questions%2F686519-using-vba-macro-post-new-appointments-outlook-but-dont-want-duplicates.html&usg=AOvVaw0vUdR7HN9USe52hrOU2M1V

Dim olCalendarItems As Outlook.Items
Dim subjectFilter As String

'Get calendar items with the specified subject

subjectFilter = "[Subject] = '" & subject & "'"
Set olCalendarItems = olCalendarFolder.Items.Restrict(subjectFilter)

If olCalendarItems.Count > 0 Then
    Set Get_Appointment = olCalendarItems.Item(1)
Else
    Set Get_Appointment = Nothing
End If
End Function
</code>```

答:
Use a new appointment object for each row - otherwise you're just creating a single appointment and then updating it repeatedly</p>

```<code>Const COL_FLAG As Long = 20 '<< "flag" column
'...
'...
For r = 2 To Cells(Rows.Count, 1).End(xlUp).Row
    'Only create an appointment if not already created....
    If Len(Cells(r, COL_FLAG ).Value)= 0 Then
    With olApp.CreateItem(olAppointmentItem) '<<< use a new object for each iteration
           .Start = Cells(r, 2).Value + TimeValue("10:30")
           .Duration = "1"
           .Subject = Cells(r, 9).Value & " (" & Cells(r, 13).Value & _
                      " " & Cells(r, 14).Value & ")"
           .Location = Cells(r, 5).Value
           .Body = "Follow up with task lead"
           .BusyStatus = olBusy
           .ReminderMinutesBeforeStart = 60
           .Categories = "Task Reminder"
           .ReminderSet = True
           .Save
           Cells(r, COL_FLAG ).Value = "Created"
    End With
    End If '<< appt not already created
Next
</code>```

Body:
Background:

I have a task tracking spread sheet and would like to create a calendar "appointment" everytime a new row is added to the table. There are many instances of different versions of this code floating around out there, so I pieced this together with little true knowledge of VBA.

The Data:

Data is stored in a table (Table1) in Sheet1, which I have renamed "Tracker". It's currently ~600 rows, and ~16 columns. The table is constantly updated with new rows of data.

The Problem:

The macro runs, and loops through the 600+ rows of data, creating an appointment for a row, then overwriting that appointment with the data from the next row. I know it's creating + overwriting b/c I set my calendar view to "list view", and ran the macro...and I can see it cycling through all the different rows, so I know it's looping. So I THINK I need assistance modifying the Private Function's subjectFilter. That said, if I remove the Private Function, it does the same thing.

Right now, the .Subject code is this:

.Subject = Cells(r, 9).Value & " (" & Cells(r, 13).Value & " " & Cells(r, 14).Value & ")"

Although I could simplify it to this if it makes it easier to incorp into the subjectFilter:

.Subject = Cells(r, 9).Value

Questions:

How can I adjust the code so it creates all 600+ appointments?

How do I incorporate my .Subject string into the Private Function's
subjectFilter?

Current Code:

Sub SetAppt()

Dim olApp As Outlook.Application
Dim olApt As AppointmentItem
Dim MySheet As Worksheet

Set MySheet = Worksheets("Tracker")
Set olApp = New Outlook.Application
Set olApt = olApp.CreateItem(olAppointmentItem)

For r = 2 To Cells(Rows.Count,1).End(xlUp).Row

With olApt
       .Start = Cells(r, 2).Value + TimeValue("10:30")
       .Duration = "1"
       .Subject = Cells(r, 9).Value & " (" & Cells(r, 13).Value & " " & Cells(r, 14).Value & ")"
       .Location = Cells(r, 5).Value
       .Body = "Follow up with task lead"
       .BusyStatus = olBusy
       .ReminderMinutesBeforeStart = 60
       .Categories = "Task Reminder"
       .ReminderSet = True
       .Save

End With
Next

Set olApt = Nothing
Set olApp = Nothing

End Sub

Private Function Get_Appointment(subject As String) As Outlook.AppointmentItem
'Private Function grabbed from here https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwis6IGw7vXXAhXBneAKHWJ9A7kQFggpMAA&url=https%3A%2F%2Fwww.mrexcel.com%2Fforum%2Fexcel-questions%2F686519-using-vba-macro-post-new-appointments-outlook-but-dont-want-duplicates.html&usg=AOvVaw0vUdR7HN9USe52hrOU2M1V

Dim olCalendarItems As Outlook.Items
Dim subjectFilter As String

'Get calendar items with the specified subject

subjectFilter = "[Subject] = '" & subject & "'"
Set olCalendarItems = olCalendarFolder.Items.Restrict(subjectFilter)

If olCalendarItems.Count > 0 Then
    Set Get_Appointment = olCalendarItems.Item(1)
Else
    Set Get_Appointment = Nothing
End If
End Function

Body:
Use a new appointment object for each row - otherwise you're just creating a single appointment and then updating it repeatedly

Const COL_FLAG As Long = 20 '<< "flag" column
'...
'...
For r = 2 To Cells(Rows.Count, 1).End(xlUp).Row
    'Only create an appointment if not already created....
    If Len(Cells(r, COL_FLAG ).Value)= 0 Then
    With olApp.CreateItem(olAppointmentItem) '<<< use a new object for each iteration
           .Start = Cells(r, 2).Value + TimeValue("10:30")
           .Duration = "1"
           .Subject = Cells(r, 9).Value & " (" & Cells(r, 13).Value & _
                      " " & Cells(r, 14).Value & ")"
           .Location = Cells(r, 5).Value
           .Body = "Follow up with task lead"
           .BusyStatus = olBusy
           .ReminderMinutesBeforeStart = 60
           .Categories = "Task Reminder"
           .ReminderSet = True
           .Save
           Cells(r, COL_FLAG ).Value = "Created"
    End With
    End If '<< appt not already created
Next