答:
This is normally caused by your LD_LIBRARY_PATH environment variable missing the Oracle libraries. You need to find the folder in which libclntsh.so.12.1 sits and set this environment variable.

Hopefully it's in your Oracle install directory, in which case you can do this:

```<code>find -L /usr/lib/oracle -name libclntsh.so.12.1
</code>```

The -L switch of find follows symlinks. This is not the default behaviour, however, it's possible that libclntsh.so.12.1 is actually a symlink to libclntsh.so.

If you can't find the file then you'll have to traverse your entire directory structure. It might be worth ditching the -L switch for the first time...

```<code>find -L / -name libclntsh.so.12.1
</code>```

Once you've found the file you need to set your LD_LIBRARY_PATH. As just a one off you can use:

```<code> export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/oracle/lib
</code>```

Where /usr/lib/oracle/lib is replaced with the directory.

If you want to make this change permanent then the normal way on Ubuntu is to add a custom .conf file to /etc/ld.so.conf, see the question "Use shared libraries in /usr/local/lib" on Unix & Linux.

Title: running oracle imp / exp in Ubuntu 14.04.3

Body:
After installing the oracle packages

oracle-instantclient12.2-basiclite-12.2.0.1.0-1.x86_64.rpm

and

oracle-instantclient12.2-tools-12.2.0.1.0-1.x86_64.rpm

with alien -i

I want to run the exp utility, but I got an error

root@localhost:/usr/lib/oracle/12.2/client64/bin# ./exp
./exp: error while loading shared libraries: libclntsh.so.12.1: cannot open shared object file: No such file or directory

root@localhost:/usr/lib/oracle/12.2/client64/bin# export
declare -x DERBY_HOME="/usr/lib/jvm/java-8-oracle/db"
declare -x HOME="/root"
declare -x J2REDIR="/usr/lib/jvm/java-8-oracle/jre"
declare -x J2SDKDIR="/usr/lib/jvm/java-8-oracle"
declare -x JAVA_HOME="/usr/lib/jvm/java-8-oracle"
declare -x LANG="en_US.UTF-8"
declare -x LD_LIBRARY_PATH=":/usr/lib/oracle/12.2/client64/lib/libclntsh.so.12.1"
declare -x LESSCLOSE="/usr/bin/lesspipe %s %s"
declare -x LESSOPEN="| /usr/bin/lesspipe %s"
declare -x LOGNAME="root"
declare -x LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:"
declare -x MAIL="/var/mail/root"
declare -x OLDPWD="/root"
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin"
declare -x PWD="/usr/lib/oracle/12.2/client64/bin"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="212.166.58.203 58642 22"
declare -x SSH_CONNECTION="212.166.58.203 58642 139.162.221.107 22"
declare -x SSH_TTY="/dev/pts/0"
declare -x TERM="xterm-256color"
declare -x USER="root"
declare -x XDG_RUNTIME_DIR="/run/user/0"
declare -x XDG_SESSION_ID="10"

root@localhost:/usr/lib/oracle/12.2/client64/bin# find -L /usr/lib/oracle -name libclntsh.so.12.1
/usr/lib/oracle/12.2/client64/lib/libclntsh.so.12.1
root@localhost:/usr/lib/oracle/12.2/client64/bin#

Body:
This is normally caused by your LD_LIBRARY_PATH environment variable missing the Oracle libraries. You need to find the folder in which libclntsh.so.12.1 sits and set this environment variable.

Hopefully it's in your Oracle install directory, in which case you can do this:

find -L /usr/lib/oracle -name libclntsh.so.12.1

The -L switch of find follows symlinks. This is not the default behaviour, however, it's possible that libclntsh.so.12.1 is actually a symlink to libclntsh.so.

If you can't find the file then you'll have to traverse your entire directory structure. It might be worth ditching the -L switch for the first time...

find -L / -name libclntsh.so.12.1

Once you've found the file you need to set your LD_LIBRARY_PATH. As just a one off you can use:

 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/oracle/lib

Where /usr/lib/oracle/lib is replaced with the directory.

If you want to make this change permanent then the normal way on Ubuntu is to add a custom .conf file to /etc/ld.so.conf, see the question "Use shared libraries in /usr/local/lib" on Unix & Linux.


来源: stackexchange

问:
Rails: Has and belongs to many (HABTM) -- create association without creating other records
Spent all day on Google, but can't find an answer. :\

I have a HABTM relationship between Users and Core_Values.

```<code>class CoreValue < ActiveRecord::Base
  has_and_belongs_to_many :users

class User < ActiveRecord::Base
  has_and_belongs_to_many :core_values
</code>```

In my controller, I need to do two separate things:

If a CoreValue does not exist, create a new one and associate it with a given user id, and

Assuming I know a particular CoreValue does exist already, create the association without creating any new CoreValues or Users

For # 1, I've got this to work:

```<code>User.find(current_user.id).core_values.create({:value => v, :created_by => current_user.id})
</code>```

This creates a new CoreValue with :value and :created_by and creates the association.

For # 2, I've tried a few things, but can't quite seem to create the association ONLY.

Thanks for your help!

答:
You can do this in a two-step procedure, using the very useful find_or_create method. find_or_create will first attempt to find a record, and if it doesn't exist, create it. Something like this should do the trick:

```<code>core_value = CoreValue.find_or_create_by_value(v, :created_by => current_user.id)
current_user.core_values << core_value
</code>```

Some notes:

The first line will find or create the value v. If it doesn't exist and is created, it will set the created_by to current_user.id.

There's no need to do User.find(current_user.id), as that would return the same object as current_user.

current_user.core_values is an array, and you can easily add another value to it by using <<.

For brevity, the following would be the same as the code example above:

```<code>current_user.core_values << CoreValue.find_or_create_by_value(v, :created_by => current_user.id)
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Spent all day on Google, but can't find an answer. :\

I have a HABTM relationship between Users and Core_Values.

class CoreValue < ActiveRecord::Base
  has_and_belongs_to_many :users

class User < ActiveRecord::Base
  has_and_belongs_to_many :core_values

In my controller, I need to do two separate things:

If a CoreValue does not exist, create a new one and associate it with a given user id, and

Assuming I know a particular CoreValue does exist already, create the association without creating any new CoreValues or Users

For # 1, I've got this to work:

User.find(current_user.id).core_values.create({:value => v, :created_by => current_user.id})

This creates a new CoreValue with :value and :created_by and creates the association.

For # 2, I've tried a few things, but can't quite seem to create the association ONLY.

Thanks for your help!

Body:
You can do this in a two-step procedure, using the very useful find_or_create method. find_or_create will first attempt to find a record, and if it doesn't exist, create it. Something like this should do the trick:

core_value = CoreValue.find_or_create_by_value(v, :created_by => current_user.id)
current_user.core_values << core_value

Some notes:

The first line will find or create the value v. If it doesn't exist and is created, it will set the created_by to current_user.id.

There's no need to do User.find(current_user.id), as that would return the same object as current_user.

current_user.core_values is an array, and you can easily add another value to it by using <<.

For brevity, the following would be the same as the code example above:

current_user.core_values << CoreValue.find_or_create_by_value(v, :created_by => current_user.id)


问:
Google Real-Time API: How to download real time file larger than 10MB?
We are using Google real-time API for some internal communication. However, some of the files got bigger than 10MB. Now we are getting error "Requested Resource Too Large to Return" when trying to download it via the server (https://www.googleapis.com/drive/v2/files/realtime/ call).

Is there are a way to download this file using server API?

答:
You Can try to download the file in parts/chunks as what suggested in this SO post.

For further reference, you can check this documentation about partial download.

Partial download involves downloading only a specified portion of a
  file. You can specify the portion of the file you want to dowload by
  using a byte range with the Range header. For example:

```<code>Range: bytes=500-999
</code>```

ContentLicense: CC BY-SA 3.0

Body:
You Can try to download the file in parts/chunks as what suggested in this SO post.

For further reference, you can check this documentation about partial download.

Partial download involves downloading only a specified portion of a
  file. You can specify the portion of the file you want to dowload by
  using a byte range with the Range header. For example:

Range: bytes=500-999


问:
Web scraping issue
I am trying to web scrape a page but I keep getting an error message. "raise HTTPError(req.full_url, code, msg, hdrs, fp) HTTPError: Not Found".

Can anyone see why I am getting this issue and how I can fix it?

Here is my code:

```<code>import bs4
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
U="https://llis.nasa.gov/search?organization=arc&page=1"

uClient=uReq(U)
page_html=uClient.read()
uClient.close()
page_soup=soup(page_html,"html.parser")
page_soup.h2
</code>```

答:
Use requests module as the more powerful and flexible for dealing with HTTP requests:

```<code>import bs4, requests

url = "https://llis.nasa.gov/search?organization=arc&page=1"
data = requests.get(url)
soup = bs4.BeautifulSoup(data.content, 'html.parser')

print(soup.body)
</code>```

The output:

```<code><body>
<script src="assets/vendor.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/llis.js"></script>
</body>
</code>```

Title: Web scraping issue

Body:
I am trying to web scrape a page but I keep getting an error message. "raise HTTPError(req.full_url, code, msg, hdrs, fp) HTTPError: Not Found".

Can anyone see why I am getting this issue and how I can fix it?

Here is my code:

import bs4
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
U="https://llis.nasa.gov/search?organization=arc&page=1"

uClient=uReq(U)
page_html=uClient.read()
uClient.close()
page_soup=soup(page_html,"html.parser")
page_soup.h2

Body:
Use requests module as the more powerful and flexible for dealing with HTTP requests:

import bs4, requests

url = "https://llis.nasa.gov/search?organization=arc&page=1"
data = requests.get(url)
soup = bs4.BeautifulSoup(data.content, 'html.parser')

print(soup.body)

The output:

<body>
<script src="assets/vendor.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/llis.js"></script>
</body>


问:
Oracle SQL Count Grouping by without repeating records in previous days
I need to count the distinct WO grouping by day, but not counting the WO that were already in previous days. And sum the LABOR column grouping by day also.

SAMPLE:

```<code>DAY   WO     LABOR
6   379157    3
9   379157    5
10  379404    8
10  379362    8
19  386118    10
24  386547    2
25  388711    8
25  386547    5
30  386547    1
</code>```

RESULTS

```<code>DAY   WO    LABOR
6      1    3
9      0    5
10     2    16
19     1    10
24     1    2
25     1    13
30     0    1
</code>```

Thanks a lot for your help

答:
Try this, if it works</p>

```<code>select COUNT(tbl1.wo), sum(tbl1.labor) FROM Table_Name tbl1
where tbl1.wo not in (SELECT tbl2.wo from Table_Name tbl2 WHERE tbl2.day < tbl1.day)
group by tbl1.day
</code>```

Body:
I need to count the distinct WO grouping by day, but not counting the WO that were already in previous days. And sum the LABOR column grouping by day also.

SAMPLE:

DAY   WO     LABOR
6   379157    3
9   379157    5
10  379404    8
10  379362    8
19  386118    10
24  386547    2
25  388711    8
25  386547    5
30  386547    1

RESULTS

DAY   WO    LABOR
6      1    3
9      0    5
10     2    16
19     1    10
24     1    2
25     1    13
30     0    1

Thanks a lot for your help

Body:
Try this, if it works

select COUNT(tbl1.wo), sum(tbl1.labor) FROM Table_Name tbl1
where tbl1.wo not in (SELECT tbl2.wo from Table_Name tbl2 WHERE tbl2.day < tbl1.day)
group by tbl1.day


问:
Run C# integration tests with a configurable variable locally and as a part of a VSTS build
I have a test project within my solution that can run tests on a live sql database.  The problem is I have to provide the connection string for it to connect to the database.

Is there anyway that I can provide a different connection string specified in the Visual Studio Online Build Parameters/Variables? I've looked into creating an appsettings.json file to but I'm still not sure how to override the value in appsettings.json.

It might be important to note that my test project is testing EF Core SqlServer.

答:
To get this working.  I added an appsettings.json file and changed the property Copy to Output Directory to Copy Always.  I then an abstract class called DbTests with a setup method

appsettings.json

```<code>{
  "ConnectionStrings": {
    "TestDatabase": "YOUR CONNECTION STRING GOES HERE"
  }
}
</code>```

DbTests.cs (snippet)

```<code>// ...

IConfigurationRoot configurationRoot = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .AddEnvironmentVariables()  // <== this is important
    .Build();

string connectionString = configurationRoot.GetConnectionString("TestDatabase")

// ...
</code>```

The .AddEnvironmentVariables() allows me to override variables contained in the appsettings.json with environment variables.  I can set environment variables within VSTS

Body:
To get this working.  I added an appsettings.json file and changed the property Copy to Output Directory to Copy Always.  I then an abstract class called DbTests with a setup method

appsettings.json

{
  "ConnectionStrings": {
    "TestDatabase": "YOUR CONNECTION STRING GOES HERE"
  }
}

DbTests.cs (snippet)

// ...

IConfigurationRoot configurationRoot = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .AddEnvironmentVariables()  // <== this is important
    .Build();

string connectionString = configurationRoot.GetConnectionString("TestDatabase")

// ...

The .AddEnvironmentVariables() allows me to override variables contained in the appsettings.json with environment variables.  I can set environment variables within VSTS


问:
Why do I get undefined index while using cookie in PHP?
If I use the following basic code

```<code>if (!defined('NAME_COOKIE') )
 define('NAME_COOKIE', "storedusername");

$cookie_domain = ".".$_SERVER['HTTP_HOST'];

setcookie(NAME_COOKIE, $username,time() + (86400),"/", $cookie_domain);
print $_COOKIE[NAME_COOKIE];
</code>```

The script dies during the print with undefined index error.  What am I doing wrong?

答:
Your lines:

```<code>setcookie(NAME_COOKIE, $username,time() + (86400),"/", $cookie_domain);
print $_COOKIE[NAME_COOKIE];
</code>```

Whats happening here is that your setting the cookie, which means that a string is *added to the headers, ready to send with your content.

think of this like a queue, and the queue goes to the browser only when you send your content.

as your cookie is still in the queue, its not actually been set until the page gets sent and you recall the page, then upon the recall the browser will send the cookie information back to the browser which in turn compiles the $_COOKIE array.

Try think of it like this:

setcookie();

(ADDED TO THE QUEUE)

try $_COOKIE

(NOT FOUND)

send content

(BROWSER SETS COOKIE TO FILE)

refresh

(BROWSER SENDS COOKIE INFO TO SERVER)

php compiles

($_COOKIE LOADED FROM BROWSER DATA)

try $_COOKIE

(FOUND)

Hope this helps.

Body:
If I use the following basic code

if (!defined('NAME_COOKIE') )
 define('NAME_COOKIE', "storedusername");

$cookie_domain = ".".$_SERVER['HTTP_HOST'];

setcookie(NAME_COOKIE, $username,time() + (86400),"/", $cookie_domain);
print $_COOKIE[NAME_COOKIE];

The script dies during the print with undefined index error.  What am I doing wrong?

Body:
Your lines:

setcookie(NAME_COOKIE, $username,time() + (86400),"/", $cookie_domain);
print $_COOKIE[NAME_COOKIE];

Whats happening here is that your setting the cookie, which means that a string is *added to the headers, ready to send with your content.

think of this like a queue, and the queue goes to the browser only when you send your content.

as your cookie is still in the queue, its not actually been set until the page gets sent and you recall the page, then upon the recall the browser will send the cookie information back to the browser which in turn compiles the $_COOKIE array.

Try think of it like this:

setcookie();

(ADDED TO THE QUEUE)

try $_COOKIE

(NOT FOUND)

send content

(BROWSER SETS COOKIE TO FILE)

refresh

(BROWSER SENDS COOKIE INFO TO SERVER)

php compiles

($_COOKIE LOADED FROM BROWSER DATA)

try $_COOKIE

(FOUND)

Hope this helps.


问:
How to query category based product on homepage in woocommerce
I'm learning woocommerce developing. I'm trying to query  specific categories Product on Homepage. But i can't query specific category product as same as product page. Anyone can show me the right way to query specific category product.</p>

答:
You can do it like this:</p>

```<code>$args = array(
        'posts_per_page' => '10',
         // change category
        'product_cat' => 'some-category',
        'post_type' => 'product',
        'orderby' => 'title',
    );

$query = new WP_Query( $args );
if( $query->have_posts()) {
    while( $query->have_posts() ) {
        $query->the_post();
        get_the_title();
    }
}
</code>```

Body:
You can do it like this:

$args = array(
        'posts_per_page' => '10',
         // change category
        'product_cat' => 'some-category',
        'post_type' => 'product',
        'orderby' => 'title',
    );

$query = new WP_Query( $args );
if( $query->have_posts()) {
    while( $query->have_posts() ) {
        $query->the_post();
        get_the_title();
    }
}


问:
Mysql Join table based on column name and field value
I wish to update a table where the value of a cell in tableB is a reference to a column name in tableA. It is a bit difficult to explain so below an example of the existing tables and the desired output:

Existing tables:

```<code>TableA
Dates       |   f1  |   f2  |   f3
1-1-2017    |   0   |   0   |   0
2-1-2017    |   0   |   0   |   0
3-1-2017    |   0   |   0   |   0
4-1-2017    |   0   |   0   |   0

TableB
Dates       |   Label   |   Counter
1-1-2017    |   f1      |   1
1-1-2017    |   f2      |   2
2-1-2017    |   f1      |   1
2-1-2017    |   f2      |   3
2-1-2017    |   f3      |   2
3-1-2017    |   f2      |   4
4-1-2017    |   f3      |   2
4-1-2017    |   f2      |   1
</code>```

Desired output

```<code>TableA
Dates       |   f1  |   f2  |   f3
1-1-2017    |   1   |   2   |   0
2-1-2017    |   1   |   3   |   2
3-1-2017    |   0   |   0   |   4
4-1-2017    |   0   |   1   |   2
</code>```

Is something like this possible in mysql?

答:
This code will produce a result similar to your output, but it is a result and you cannot update it directly (you update TableB as normal)
Also if there are no count for a specific date, no record will show for that date, and you might want to cross join your date table for this.</p>

```<code>SELECT A.Dates
,SUM(CASE WHEN Label = 'f1' THEN Counter ELSE 0 END) AS f1
,SUM(CASE WHEN Label = 'f2' THEN Counter ELSE 0 END) AS f2
,SUM(CASE WHEN Label = 'f3' THEN Counter ELSE 0 END) AS f3
FROM TableA A
LEFT JOIN TableB B ON B.Dates = A.Dates
GROUP BY A.Dates
</code>```

Body:
I wish to update a table where the value of a cell in tableB is a reference to a column name in tableA. It is a bit difficult to explain so below an example of the existing tables and the desired output:

Existing tables:

TableA
Dates       |   f1  |   f2  |   f3
1-1-2017    |   0   |   0   |   0
2-1-2017    |   0   |   0   |   0
3-1-2017    |   0   |   0   |   0
4-1-2017    |   0   |   0   |   0

TableB
Dates       |   Label   |   Counter
1-1-2017    |   f1      |   1
1-1-2017    |   f2      |   2
2-1-2017    |   f1      |   1
2-1-2017    |   f2      |   3
2-1-2017    |   f3      |   2
3-1-2017    |   f2      |   4
4-1-2017    |   f3      |   2
4-1-2017    |   f2      |   1

Desired output

TableA
Dates       |   f1  |   f2  |   f3
1-1-2017    |   1   |   2   |   0
2-1-2017    |   1   |   3   |   2
3-1-2017    |   0   |   0   |   4
4-1-2017    |   0   |   1   |   2

Is something like this possible in mysql?

Body:
This code will produce a result similar to your output, but it is a result and you cannot update it directly (you update TableB as normal)
Also if there are no count for a specific date, no record will show for that date, and you might want to cross join your date table for this.

SELECT A.Dates
,SUM(CASE WHEN Label = 'f1' THEN Counter ELSE 0 END) AS f1
,SUM(CASE WHEN Label = 'f2' THEN Counter ELSE 0 END) AS f2
,SUM(CASE WHEN Label = 'f3' THEN Counter ELSE 0 END) AS f3
FROM TableA A
LEFT JOIN TableB B ON B.Dates = A.Dates
GROUP BY A.Dates


问:
SQL query to get min, max rows
I have following sample data, I want to get min and max time of every consecutive status.

```<code>cat     subcat  status  logtime
fruits  apple   0   30-10-2017 06:00
fruits  apple   0   30-10-2017 06:03
fruits  apple   0   30-10-2017 06:06
fruits  apple   0   30-10-2017 06:09
fruits  apple   0   30-10-2017 06:12
fruits  apple   0   30-10-2017 06:15
fruits  apple   0   30-10-2017 06:18
fruits  apple   0   30-10-2017 06:21
fruits  apple   0   30-10-2017 06:24
fruits  apple   0   30-10-2017 06:27
fruits  apple   0   30-10-2017 06:30
fruits  apple   0   30-10-2017 06:33
fruits  apple   0   30-10-2017 06:36
fruits  apple   0   30-10-2017 06:39
fruits  apple   0   30-10-2017 06:42
fruits  apple   0   30-10-2017 06:45
fruits  apple   0   30-10-2017 06:48
fruits  apple   0   30-10-2017 06:51
fruits  apple   0   30-10-2017 06:54
fruits  apple   0   30-10-2017 06:57
fruits  strawberry  1   30-10-2017 06:00
fruits  strawberry  1   30-10-2017 06:03
fruits  strawberry  1   30-10-2017 06:06
fruits  strawberry  2   30-10-2017 06:09
fruits  strawberry  1   30-10-2017 06:12
fruits  strawberry  1   30-10-2017 06:15
fruits  strawberry  1   30-10-2017 06:18
fruits  strawberry  1   30-10-2017 06:21
fruits  strawberry  1   30-10-2017 06:24
fruits  strawberry  1   30-10-2017 06:27
fruits  strawberry  1   30-10-2017 06:30
fruits  strawberry  1   30-10-2017 06:33
fruits  strawberry  1   30-10-2017 06:36
fruits  strawberry  1   30-10-2017 06:39
fruits  strawberry  2   30-10-2017 06:42
fruits  strawberry  1   30-10-2017 06:45
fruits  strawberry  1   30-10-2017 06:48
fruits  strawberry  1   30-10-2017 06:51
fruits  strawberry  1   30-10-2017 06:54
fruits  strawberry  1   30-10-2017 06:57
fruits  blueberry   0   30-10-2017 06:00
fruits  blueberry   0   30-10-2017 06:03
fruits  blueberry   0   30-10-2017 06:06
fruits  blueberry   2   30-10-2017 06:09
fruits  blueberry   0   30-10-2017 06:12
fruits  blueberry   0   30-10-2017 06:15
fruits  blueberry   0   30-10-2017 06:18
fruits  blueberry   0   30-10-2017 06:21
fruits  blueberry   0   30-10-2017 06:24
fruits  blueberry   0   30-10-2017 06:27
fruits  blueberry   0   30-10-2017 06:30
fruits  blueberry   0   30-10-2017 06:33
fruits  blueberry   0   30-10-2017 06:36
fruits  blueberry   0   30-10-2017 06:39
fruits  blueberry   2   30-10-2017 06:42
fruits  blueberry   0   30-10-2017 06:45
fruits  blueberry   0   30-10-2017 06:48
fruits  blueberry   0   30-10-2017 06:51
fruits  blueberry   0   30-10-2017 06:54
fruits  blueberry   0   30-10-2017 06:57
fruits  guaua   1   30-10-2017 06:00
fruits  guaua   1   30-10-2017 06:03
fruits  guaua   1   30-10-2017 06:06
fruits  guaua   2   30-10-2017 06:09
fruits  guaua   1   30-10-2017 06:12
fruits  guaua   1   30-10-2017 06:15
fruits  guaua   1   30-10-2017 06:18
fruits  guaua   1   30-10-2017 06:21
fruits  guaua   1   30-10-2017 06:24
fruits  guaua   1   30-10-2017 06:27
fruits  guaua   1   30-10-2017 06:30
fruits  guaua   1   30-10-2017 06:33
fruits  guaua   1   30-10-2017 06:36
fruits  guaua   1   30-10-2017 06:39
fruits  guaua   2   30-10-2017 06:42
fruits  guaua   1   30-10-2017 06:45
fruits  guaua   1   30-10-2017 06:48
fruits  guaua   1   30-10-2017 06:51
fruits  guaua   1   30-10-2017 06:54
fruits  guaua   1   30-10-2017 06:57
</code>```

I'm trying get min, max time of each status for cat and subcat status.

Output result should be following:

```<code>cat     subcat      status  mintime maxtime
fruits  apple       0   30-10-2017 06:00    30-10-2017 06:57
fruits  strawberry  1   30-10-2017 06:00    30-10-2017 06:06
fruits  strawberry  2   30-10-2017 06:09    30-10-2017 06:09
fruits  strawberry  1   30-10-2017 06:12    30-10-2017 06:39
fruits  strawberry  2   30-10-2017 06:42    30-10-2017 06:42
fruits  strawberry  1   30-10-2017 06:45    30-10-2017 06:57
fruits  blueberry   0   30-10-2017 06:00    30-10-2017 06:06
fruits  blueberry   2   30-10-2017 06:09    30-10-2017 06:09
fruits  blueberry   0   30-10-2017 06:12    30-10-2017 06:39
fruits  blueberry   2   30-10-2017 06:42    30-10-2017 06:42
fruits  blueberry   0   30-10-2017 06:45    30-10-2017 06:57
fruits  guaua       1   30-10-2017 06:00    30-10-2017 06:06
fruits  guaua       2   30-10-2017 06:09    30-10-2017 06:09
fruits  guaua       1   30-10-2017 06:12    30-10-2017 06:39
fruits  guaua       2   30-10-2017 06:42    30-10-2017 06:42
fruits  guaua       1   30-10-2017 06:45    30-10-2017 06:57
</code>```

tried with following sql query but unable to get above output instead its giving min, max total hour.

```<code>SELECT cat,
        subcat,
        status,
        min(logtime) as minlog,
        max(logtime) as maxlog
FROM fruits_log
WHERE
    cat = 'fruits'
    AND date_format(logtime,'%Y-%m-%d %H) = '2017-10-30 06'
    AND status IN ('0','1','2')
GROUP BY cat,subcat,date_format(logtime,'%Y-%m-%d %H),status
ORDER BY cat,subcat,minlog ;
</code>```

Please help what i'm missing in above query

答:
```<code>Select cat,subcat,minlog,maxlog from ( SELECT cat,
            subcat,
            status,
            min(logtime) as minlog,
            max(logtime) as maxlog
    FROM fruits_log
    WHERE
        cat = 'fruits'
        AND date_format(logtime,'%Y-%m-%d %H') = '2017-10-30 06'
        AND status IN ('0','1','2')
    GROUP BY cat,subcat,date_format(logtime,"%Y-%m-%d %H-%i"),status) t1 order by cat,subcat,status;
</code>```

try this...

Title: SQL query to get min, max rows

Body:
I have following sample data, I want to get min and max time of every consecutive status.

cat     subcat  status  logtime
fruits  apple   0   30-10-2017 06:00
fruits  apple   0   30-10-2017 06:03
fruits  apple   0   30-10-2017 06:06
fruits  apple   0   30-10-2017 06:09
fruits  apple   0   30-10-2017 06:12
fruits  apple   0   30-10-2017 06:15
fruits  apple   0   30-10-2017 06:18
fruits  apple   0   30-10-2017 06:21
fruits  apple   0   30-10-2017 06:24
fruits  apple   0   30-10-2017 06:27
fruits  apple   0   30-10-2017 06:30
fruits  apple   0   30-10-2017 06:33
fruits  apple   0   30-10-2017 06:36
fruits  apple   0   30-10-2017 06:39
fruits  apple   0   30-10-2017 06:42
fruits  apple   0   30-10-2017 06:45
fruits  apple   0   30-10-2017 06:48
fruits  apple   0   30-10-2017 06:51
fruits  apple   0   30-10-2017 06:54
fruits  apple   0   30-10-2017 06:57
fruits  strawberry  1   30-10-2017 06:00
fruits  strawberry  1   30-10-2017 06:03
fruits  strawberry  1   30-10-2017 06:06
fruits  strawberry  2   30-10-2017 06:09
fruits  strawberry  1   30-10-2017 06:12
fruits  strawberry  1   30-10-2017 06:15
fruits  strawberry  1   30-10-2017 06:18
fruits  strawberry  1   30-10-2017 06:21
fruits  strawberry  1   30-10-2017 06:24
fruits  strawberry  1   30-10-2017 06:27
fruits  strawberry  1   30-10-2017 06:30
fruits  strawberry  1   30-10-2017 06:33
fruits  strawberry  1   30-10-2017 06:36
fruits  strawberry  1   30-10-2017 06:39
fruits  strawberry  2   30-10-2017 06:42
fruits  strawberry  1   30-10-2017 06:45
fruits  strawberry  1   30-10-2017 06:48
fruits  strawberry  1   30-10-2017 06:51
fruits  strawberry  1   30-10-2017 06:54
fruits  strawberry  1   30-10-2017 06:57
fruits  blueberry   0   30-10-2017 06:00
fruits  blueberry   0   30-10-2017 06:03
fruits  blueberry   0   30-10-2017 06:06
fruits  blueberry   2   30-10-2017 06:09
fruits  blueberry   0   30-10-2017 06:12
fruits  blueberry   0   30-10-2017 06:15
fruits  blueberry   0   30-10-2017 06:18
fruits  blueberry   0   30-10-2017 06:21
fruits  blueberry   0   30-10-2017 06:24
fruits  blueberry   0   30-10-2017 06:27
fruits  blueberry   0   30-10-2017 06:30
fruits  blueberry   0   30-10-2017 06:33
fruits  blueberry   0   30-10-2017 06:36
fruits  blueberry   0   30-10-2017 06:39
fruits  blueberry   2   30-10-2017 06:42
fruits  blueberry   0   30-10-2017 06:45
fruits  blueberry   0   30-10-2017 06:48
fruits  blueberry   0   30-10-2017 06:51
fruits  blueberry   0   30-10-2017 06:54
fruits  blueberry   0   30-10-2017 06:57
fruits  guaua   1   30-10-2017 06:00
fruits  guaua   1   30-10-2017 06:03
fruits  guaua   1   30-10-2017 06:06
fruits  guaua   2   30-10-2017 06:09
fruits  guaua   1   30-10-2017 06:12
fruits  guaua   1   30-10-2017 06:15
fruits  guaua   1   30-10-2017 06:18
fruits  guaua   1   30-10-2017 06:21
fruits  guaua   1   30-10-2017 06:24
fruits  guaua   1   30-10-2017 06:27
fruits  guaua   1   30-10-2017 06:30
fruits  guaua   1   30-10-2017 06:33
fruits  guaua   1   30-10-2017 06:36
fruits  guaua   1   30-10-2017 06:39
fruits  guaua   2   30-10-2017 06:42
fruits  guaua   1   30-10-2017 06:45
fruits  guaua   1   30-10-2017 06:48
fruits  guaua   1   30-10-2017 06:51
fruits  guaua   1   30-10-2017 06:54
fruits  guaua   1   30-10-2017 06:57

I'm trying get min, max time of each status for cat and subcat status.

Output result should be following:

cat     subcat      status  mintime maxtime
fruits  apple       0   30-10-2017 06:00    30-10-2017 06:57
fruits  strawberry  1   30-10-2017 06:00    30-10-2017 06:06
fruits  strawberry  2   30-10-2017 06:09    30-10-2017 06:09
fruits  strawberry  1   30-10-2017 06:12    30-10-2017 06:39
fruits  strawberry  2   30-10-2017 06:42    30-10-2017 06:42
fruits  strawberry  1   30-10-2017 06:45    30-10-2017 06:57
fruits  blueberry   0   30-10-2017 06:00    30-10-2017 06:06
fruits  blueberry   2   30-10-2017 06:09    30-10-2017 06:09
fruits  blueberry   0   30-10-2017 06:12    30-10-2017 06:39
fruits  blueberry   2   30-10-2017 06:42    30-10-2017 06:42
fruits  blueberry   0   30-10-2017 06:45    30-10-2017 06:57
fruits  guaua       1   30-10-2017 06:00    30-10-2017 06:06
fruits  guaua       2   30-10-2017 06:09    30-10-2017 06:09
fruits  guaua       1   30-10-2017 06:12    30-10-2017 06:39
fruits  guaua       2   30-10-2017 06:42    30-10-2017 06:42
fruits  guaua       1   30-10-2017 06:45    30-10-2017 06:57

tried with following sql query but unable to get above output instead its giving min, max total hour.

SELECT cat,
        subcat,
        status,
        min(logtime) as minlog,
        max(logtime) as maxlog
FROM fruits_log
WHERE
    cat = 'fruits'
    AND date_format(logtime,'%Y-%m-%d %H) = '2017-10-30 06'
    AND status IN ('0','1','2')
GROUP BY cat,subcat,date_format(logtime,'%Y-%m-%d %H),status
ORDER BY cat,subcat,minlog ;

Please help what i'm missing in above query

Body:
Select cat,subcat,minlog,maxlog from ( SELECT cat,
            subcat,
            status,
            min(logtime) as minlog,
            max(logtime) as maxlog
    FROM fruits_log
    WHERE
        cat = 'fruits'
        AND date_format(logtime,'%Y-%m-%d %H') = '2017-10-30 06'
        AND status IN ('0','1','2')
    GROUP BY cat,subcat,date_format(logtime,"%Y-%m-%d %H-%i"),status) t1 order by cat,subcat,status;

try this...


问:
cordapp-example on a VM does not appear to start correctly
I'm attempting to deploy cordapp-example to a Google Compute Engine VM (Ubuntu 16.04). I am using OpenJDK (I know but I'm not able to use the Oracle JDK). I've attempted to follow the pre-reqs.

However, I think at least one problem results from the advice to "Do not click while 8 additional terminal windows start up." (this isn't going to occur through ssh'ing to a remote VM).

runnodes never results in Webserver started up in XX.X sec or Node for “NodeC” started up and registered in XX.XX sec and (therefore) does not result in a process listening on :10007.

Console output:

```<code>Starting nodes in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes
Starting corda.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyB on debug port 5005
Starting corda-webserver.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyB on debug port 5006
Starting corda.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/Controller on debug port 5007
Starting corda.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyC on debug port 5008
Starting corda-webserver.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyC on debug port 5009
Starting corda.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyA on debug port 5010
Starting corda-webserver.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyA on debug port 5011
Started 7 processes
Finished starting nodes
Listening for transport dt_socket at address: 5011
Listening for transport dt_socket at address: 5009
Listening for transport dt_socket at address: 5006
Listening for transport dt_socket at address: 5005
Listening for transport dt_socket at address: 5008
Listening for transport dt_socket at address: 5010
Listening for transport dt_socket at address: 5007
Unknown command line arguments: no-local-shell is not a recognized option
Unknown command line arguments: no-local-shell is not a recognized option
Unknown command line arguments: no-local-shell is not a recognized option

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         I had an account with a bank in the
/ /___  /_/ / /  / /_/ / /_/ /          North Pole, but they froze all my assets
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 1.0.0 (31be2a4) -----------------------------------------------

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         I had an account with a bank in the
/ /___  /_/ / /  / /_/ / /_/ /          North Pole, but they froze all my assets
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 1.0.0 (31be2a4) -----------------------------------------------

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         What you can buy for a dollar these
/ /___  /_/ / /  / /_/ / /_/ /          days is absolute non-cents!
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 1.0.0 (31be2a4) -----------------------------------------------

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         It's not who you know, it's who you know
/ /___  /_/ / /  / /_/ / /_/ /          knows what you know you know.
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 1.0.0 (31be2a4) -----------------------------------------------

Logs can be found in                    : /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyA/logs
Logs can be found in                    : /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyB/logs
Logs can be found in                    : /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/Controller/logs
Logs can be found in                    : /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyC/logs
Database connection url is              : jdbc:h2:tcp://10.138.0.5:33219/node
Database connection url is              : jdbc:h2:tcp://10.138.0.5:41313/node
Database connection url is              : jdbc:h2:tcp://10.138.0.5:36079/node
Database connection url is              : jdbc:h2:tcp://10.138.0.5:38015/node
Incoming connection address             : localhost:10002
Incoming connection address             : localhost:10008
Incoming connection address             : localhost:10005
Incoming connection address             : localhost:10011
Listening on port                       : 10002
RPC service listening on port           : 10003
Providing network services              : corda.notary.validating
Loaded CorDapps                         : kotlin-source-0.1, corda-finance-1.0.0, corda-core-1.0.0
Node for "Controller" started up and registered in 46.26 sec
Listening on port                       : 10008
RPC service listening on port           : 10009
Listening on port                       : 10011
RPC service listening on port           : 10012
Listening on port                       : 10005
RPC service listening on port           : 10006
Loaded CorDapps                         : kotlin-source-0.1, corda-finance-1.0.0, corda-core-1.0.0
Node for "PartyB" started up and registered in 51.99 sec
Loaded CorDapps                         : kotlin-source-0.1, corda-finance-1.0.0, corda-core-1.0.0
Node for "PartyC" started up and registered in 52.75 sec
Loaded CorDapps                         : kotlin-source-0.1, corda-finance-1.0.0, corda-core-1.0.0
Node for "PartyA" started up and registered in 53.48 sec
</code>```

and ss --tcp --listening filtered and sorted results in:

```<code> *:5005
 *:5007
 *:5008
 *:5010
 *:ssh
:::10002
:::10003
:::10005
:::10006
:::10008
:::10009
:::10011
:::10012
:::33219
:::36079
:::38015
:::41313
:::ssh
</code>```

For what it's worth:

the debug ports aren't reported by ss: 5006, 5009, 5011

there's no reference by ss to 10007 being used; can't browse to it

this error looks not good no-local-shell is not a recognized option

It's unclear to me what I can debug. runnodes is opaque and I don't see obvious errors suggesting nodes are missing.

Any pointers would be appreciated.

P.S. There do appear to be 8 java processes running 4 of which include a flag --no-local-shell so perhaps that's a difference with OpenJDK and perhaps a|the problem?

答:
I have also experienced this issue. It's something I'm looking into but in the meantime, a simple workaround is to run the webservers manually by running the following in the nodes directory (kotlin-source/build/nodes I think?):

```<code>find . -name corda-webserver.jar -execdir sh -c 'java -jar {} &' \;
</code>```

As an aside, Corda is tested against the Azul build of OpenJDK in addition to Oracle JDK. I don't believe the problem is related to OpenJDK, I think it's a timing issue in the runnodes.jar.

Body:
I'm attempting to deploy cordapp-example to a Google Compute Engine VM (Ubuntu 16.04). I am using OpenJDK (I know but I'm not able to use the Oracle JDK). I've attempted to follow the pre-reqs.

However, I think at least one problem results from the advice to "Do not click while 8 additional terminal windows start up." (this isn't going to occur through ssh'ing to a remote VM).

runnodes never results in Webserver started up in XX.X sec or Node for “NodeC” started up and registered in XX.XX sec and (therefore) does not result in a process listening on :10007.

Console output:

Starting nodes in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes
Starting corda.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyB on debug port 5005
Starting corda-webserver.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyB on debug port 5006
Starting corda.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/Controller on debug port 5007
Starting corda.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyC on debug port 5008
Starting corda-webserver.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyC on debug port 5009
Starting corda.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyA on debug port 5010
Starting corda-webserver.jar in /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyA on debug port 5011
Started 7 processes
Finished starting nodes
Listening for transport dt_socket at address: 5011
Listening for transport dt_socket at address: 5009
Listening for transport dt_socket at address: 5006
Listening for transport dt_socket at address: 5005
Listening for transport dt_socket at address: 5008
Listening for transport dt_socket at address: 5010
Listening for transport dt_socket at address: 5007
Unknown command line arguments: no-local-shell is not a recognized option
Unknown command line arguments: no-local-shell is not a recognized option
Unknown command line arguments: no-local-shell is not a recognized option

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         I had an account with a bank in the
/ /___  /_/ / /  / /_/ / /_/ /          North Pole, but they froze all my assets
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 1.0.0 (31be2a4) -----------------------------------------------

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         I had an account with a bank in the
/ /___  /_/ / /  / /_/ / /_/ /          North Pole, but they froze all my assets
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 1.0.0 (31be2a4) -----------------------------------------------

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         What you can buy for a dollar these
/ /___  /_/ / /  / /_/ / /_/ /          days is absolute non-cents!
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 1.0.0 (31be2a4) -----------------------------------------------

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         It's not who you know, it's who you know
/ /___  /_/ / /  / /_/ / /_/ /          knows what you know you know.
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 1.0.0 (31be2a4) -----------------------------------------------

Logs can be found in                    : /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyA/logs
Logs can be found in                    : /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyB/logs
Logs can be found in                    : /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/Controller/logs
Logs can be found in                    : /home/dazwilkin/cordapp-example/kotlin-source/build/nodes/PartyC/logs
Database connection url is              : jdbc:h2:tcp://10.138.0.5:33219/node
Database connection url is              : jdbc:h2:tcp://10.138.0.5:41313/node
Database connection url is              : jdbc:h2:tcp://10.138.0.5:36079/node
Database connection url is              : jdbc:h2:tcp://10.138.0.5:38015/node
Incoming connection address             : localhost:10002
Incoming connection address             : localhost:10008
Incoming connection address             : localhost:10005
Incoming connection address             : localhost:10011
Listening on port                       : 10002
RPC service listening on port           : 10003
Providing network services              : corda.notary.validating
Loaded CorDapps                         : kotlin-source-0.1, corda-finance-1.0.0, corda-core-1.0.0
Node for "Controller" started up and registered in 46.26 sec
Listening on port                       : 10008
RPC service listening on port           : 10009
Listening on port                       : 10011
RPC service listening on port           : 10012
Listening on port                       : 10005
RPC service listening on port           : 10006
Loaded CorDapps                         : kotlin-source-0.1, corda-finance-1.0.0, corda-core-1.0.0
Node for "PartyB" started up and registered in 51.99 sec
Loaded CorDapps                         : kotlin-source-0.1, corda-finance-1.0.0, corda-core-1.0.0
Node for "PartyC" started up and registered in 52.75 sec
Loaded CorDapps                         : kotlin-source-0.1, corda-finance-1.0.0, corda-core-1.0.0
Node for "PartyA" started up and registered in 53.48 sec

and ss --tcp --listening filtered and sorted results in:

 *:5005
 *:5007
 *:5008
 *:5010
 *:ssh
:::10002
:::10003
:::10005
:::10006
:::10008
:::10009
:::10011
:::10012
:::33219
:::36079
:::38015
:::41313
:::ssh

For what it's worth:

the debug ports aren't reported by ss: 5006, 5009, 5011

there's no reference by ss to 10007 being used; can't browse to it

this error looks not good no-local-shell is not a recognized option

It's unclear to me what I can debug. runnodes is opaque and I don't see obvious errors suggesting nodes are missing.

Any pointers would be appreciated.

P.S. There do appear to be 8 java processes running 4 of which include a flag --no-local-shell so perhaps that's a difference with OpenJDK and perhaps a|the problem?

Body:
I have also experienced this issue. It's something I'm looking into but in the meantime, a simple workaround is to run the webservers manually by running the following in the nodes directory (kotlin-source/build/nodes I think?):

find . -name corda-webserver.jar -execdir sh -c 'java -jar {} &' \;

As an aside, Corda is tested against the Azul build of OpenJDK in addition to Oracle JDK. I don't believe the problem is related to OpenJDK, I think it's a timing issue in the runnodes.jar.


问:
SuiteCRM Install on Minikube/K8s
I am brand new to suiteCRM and I am trying to deploy into Minikube.   I am using the helm charts in the K8s repo:

https://github.com/kubernetes/charts/tree/master/stable/suitecrm

I am using the command:

```<code>helm install --name red-falcon-crm -f values.yaml stable/suitecrm
</code>```

I modified the values.yaml to have some custom values (e.g. email, username, password).   The install is not successful even though I don't get very usable errors.  I do get errors about not having a resolvable host but I was hoping to proxy.

```<code>craig@craigs-laptop:~/redfalcon/gitlab/platform-setup/modules/suitecrm$ helm install --name red-falcon-crm -f values.yaml stable/suitecrm
NAME:   red-falcon-crm
LAST DEPLOYED: Tue Oct 31 19:13:03 2017
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Pod(related)
NAME                                     READY  STATUS             RESTARTS  AGE
red-falcon-crm-mariadb-7fb6774f5c-b5w7t  0/1    ContainerCreating  0         0s

==> v1/Secret
NAME                     TYPE    DATA  AGE
red-falcon-crm-mariadb   Opaque  2     1s
red-falcon-crm-suitecrm  Opaque  2     1s

==> v1/ConfigMap
NAME                    DATA  AGE
red-falcon-crm-mariadb  1     1s

==> v1/PersistentVolumeClaim
NAME                              STATUS   VOLUME                                    CAPACITY  ACCESS MODES  STORAGECLASS  AGE
red-falcon-crm-mariadb            Bound    pvc-cf72d52d-bea1-11e7-b8a4-080027c951c6  8Gi       RWO           standard      1s
red-falcon-crm-suitecrm-apache    Pending  standard                                  1s
red-falcon-crm-suitecrm-suitecrm  Pending  standard                                  1s

==> v1/Service
NAME                     TYPE          CLUSTER-IP  EXTERNAL-IP  PORT(S)                     AGE
red-falcon-crm-mariadb   ClusterIP     10.0.0.104  <none>       3306/TCP                    1s
red-falcon-crm-suitecrm  LoadBalancer  10.0.0.89   <pending>    80:32750/TCP,443:31973/TCP  1s

==> v1beta1/Deployment
NAME                    DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
red-falcon-crm-mariadb  1        1        1           0          1s

NOTES:
###############################################################################
### ERROR: You did not provide an external host in your 'helm install' call ###
###############################################################################

This deployment will be incomplete until you configure SuiteCRM with a resolvable
host. To configure SuiteCRM with the URL of your service:

1. Get the SuiteCRM URL by running:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w red-falcon-crm-suitecrm'

  export APP_HOST=$(kubectl get svc --namespace default red-falcon-crm-suitecrm --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
  export APP_PASSWORD=$(kubectl get secret --namespace default red-falcon-crm-suitecrm -o jsonpath="{.data.suitecrm-password}" | base64 --decode)
  export APP_DATABASE_PASSWORD=$(kubectl get secret --namespace default red-falcon-crm-mariadb -o jsonpath="{.data.mariadb-root-password}" | base64 --decode)

2. Complete your SuiteCRM deployment by running:

  helm upgrade red-falcon-crm \
    --set suitecrmHost=$APP_HOST,suitecrmPassword=$APP_PASSWORD,mariadb.mariadbRootPassword=$APP_DATABASE_PASSWORD stable/suitecrm

craig@craigs-laptop:~/redfalcon/gitlab/platform-setup/modules/suitecrm$ kubectl get svc --namespace default -w red-falcon-crm-suitecrm
NAME                      TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)                      AGE
red-falcon-crm-suitecrm   LoadBalancer   10.0.0.89    <pending>     80:32750/TCP,443:31973/TCP   3m
^Ccraig@craigs-laptop:~/redfalcon/gitlab/platform-setup/modules/suitecrm$ minikube service red-falcon-crm-suitecrm
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
</code>```

My Values.yaml:

```<code>## Bitnami SuiteCRM image version
## ref: https://hub.docker.com/r/bitnami/suitecrm/tags/
##
image: bitnami/suitecrm:7.9.7-r0

## Specify a imagePullPolicy
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
imagePullPolicy: IfNotPresent

## SuiteCRM host to create application URLs
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
# suitecrmHost:

## loadBalancerIP for the SuiteCRM Service (optional, cloud specific)
## ref: http://kubernetes.io/docs/user-guide/services/#type-loadbalancer
##
# suitecrmLoadBalancerIP:

## User of the application
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
suitecrmUsername: craig

## Application password
## Defaults to a random 10-character alphanumeric string if not set
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
suitecrmPassword: <hadmypasswordhere>

## Admin email
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
suitecrmEmail: <hadmyemail>@gmail.com

## Lastname
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
suitecrmLastName: <hadmylastname>

## SMTP mail delivery configuration
## ref: https://github.com/bitnami/bitnami-docker-suitecrm/#smtp-configuration
##
# suitecrmSmtpHost:
# suitecrmSmtpPort:
# suitecrmSmtpUser:
# suitecrmSmtpPassword:
# suitecrmSmtpProtocol:

##
## MariaDB chart configuration
##
mariadb:
  ## MariaDB admin password
  ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#setting-the-root-password-on-first-run
  ##
  mariadbRootPassword: <hadMyPasswordHere>

  ## Enable persistence using Persistent Volume Claims
  ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
  ##
  persistence:
    enabled: true
    ## mariadb data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessMode: ReadWriteOnce
    size: 8Gi

## Kubernetes configuration
## For minikube, set this to NodePort, elsewhere use LoadBalancer
##
serviceType: LoadBalancer

## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
  enabled: true
  apache:
    ## apache data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessMode: ReadWriteOnce
    size: 1Gi
  suitecrm:
    ## suitecrm data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessMode: ReadWriteOnce
    size: 8Gi

## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
resources: {}
  # requests:
  #   memory: 512Mi
  #   cpu: 300m
</code>```

I did look at the logs of the running service (through minikube dashboard).  Really not much use there but it seems to hang on preparing CRM Environment.   It never gets beyond that...

```<code>     nami    INFO  Initializing apache
apache  INFO  ==> Patching httpoxy...
nami    INFO  apache successfully initialized
nami    INFO  Initializing php
nami    INFO  php successfully initialized
nami    INFO  Initializing suitecrm
suitecr INFO  Preparing webserver environment...
suitecr INFO  Preparing PHP environment...
suitecr INFO  Preparing suitecrm environment...
</code>```

The service endpoint is never ready and never appears to complete deployment.   Any help would be appreciated.

答:
I think the issue has to do with not setting the suitecrm host correctly. It is configured to use LoadBalancer but as you are using minikube you need to manually set the APP_HOST variable with a different command than that displayed by helm. This is what I did to make it work:</p>

```<code>helm install --name red-falcon-crm -f values.yaml stable/suitecrm
export APP_HOST=$(minikube ip):$(kubectl get svc red-falcon-crm-suitecrm --template "{{ (index .spec.ports 0).nodePort }}")
helm upgrade red-falcon-crm --set suitecrmHost=$APP_HOST -f values.yaml stable/suitecrm
</code>```

Title: SuiteCRM Install on Minikube/K8s

Body:
I am brand new to suiteCRM and I am trying to deploy into Minikube.   I am using the helm charts in the K8s repo:

https://github.com/kubernetes/charts/tree/master/stable/suitecrm

I am using the command:

helm install --name red-falcon-crm -f values.yaml stable/suitecrm

I modified the values.yaml to have some custom values (e.g. email, username, password).   The install is not successful even though I don't get very usable errors.  I do get errors about not having a resolvable host but I was hoping to proxy.

craig@craigs-laptop:~/redfalcon/gitlab/platform-setup/modules/suitecrm$ helm install --name red-falcon-crm -f values.yaml stable/suitecrm
NAME:   red-falcon-crm
LAST DEPLOYED: Tue Oct 31 19:13:03 2017
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Pod(related)
NAME                                     READY  STATUS             RESTARTS  AGE
red-falcon-crm-mariadb-7fb6774f5c-b5w7t  0/1    ContainerCreating  0         0s

==> v1/Secret
NAME                     TYPE    DATA  AGE
red-falcon-crm-mariadb   Opaque  2     1s
red-falcon-crm-suitecrm  Opaque  2     1s

==> v1/ConfigMap
NAME                    DATA  AGE
red-falcon-crm-mariadb  1     1s

==> v1/PersistentVolumeClaim
NAME                              STATUS   VOLUME                                    CAPACITY  ACCESS MODES  STORAGECLASS  AGE
red-falcon-crm-mariadb            Bound    pvc-cf72d52d-bea1-11e7-b8a4-080027c951c6  8Gi       RWO           standard      1s
red-falcon-crm-suitecrm-apache    Pending  standard                                  1s
red-falcon-crm-suitecrm-suitecrm  Pending  standard                                  1s

==> v1/Service
NAME                     TYPE          CLUSTER-IP  EXTERNAL-IP  PORT(S)                     AGE
red-falcon-crm-mariadb   ClusterIP     10.0.0.104  <none>       3306/TCP                    1s
red-falcon-crm-suitecrm  LoadBalancer  10.0.0.89   <pending>    80:32750/TCP,443:31973/TCP  1s

==> v1beta1/Deployment
NAME                    DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
red-falcon-crm-mariadb  1        1        1           0          1s

NOTES:
###############################################################################
### ERROR: You did not provide an external host in your 'helm install' call ###
###############################################################################

This deployment will be incomplete until you configure SuiteCRM with a resolvable
host. To configure SuiteCRM with the URL of your service:

1. Get the SuiteCRM URL by running:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w red-falcon-crm-suitecrm'

  export APP_HOST=$(kubectl get svc --namespace default red-falcon-crm-suitecrm --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
  export APP_PASSWORD=$(kubectl get secret --namespace default red-falcon-crm-suitecrm -o jsonpath="{.data.suitecrm-password}" | base64 --decode)
  export APP_DATABASE_PASSWORD=$(kubectl get secret --namespace default red-falcon-crm-mariadb -o jsonpath="{.data.mariadb-root-password}" | base64 --decode)

2. Complete your SuiteCRM deployment by running:

  helm upgrade red-falcon-crm \
    --set suitecrmHost=$APP_HOST,suitecrmPassword=$APP_PASSWORD,mariadb.mariadbRootPassword=$APP_DATABASE_PASSWORD stable/suitecrm

craig@craigs-laptop:~/redfalcon/gitlab/platform-setup/modules/suitecrm$ kubectl get svc --namespace default -w red-falcon-crm-suitecrm
NAME                      TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)                      AGE
red-falcon-crm-suitecrm   LoadBalancer   10.0.0.89    <pending>     80:32750/TCP,443:31973/TCP   3m
^Ccraig@craigs-laptop:~/redfalcon/gitlab/platform-setup/modules/suitecrm$ minikube service red-falcon-crm-suitecrm
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...
Waiting, endpoint for service is not ready yet...

My Values.yaml:

## Bitnami SuiteCRM image version
## ref: https://hub.docker.com/r/bitnami/suitecrm/tags/
##
image: bitnami/suitecrm:7.9.7-r0

## Specify a imagePullPolicy
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
imagePullPolicy: IfNotPresent

## SuiteCRM host to create application URLs
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
# suitecrmHost:

## loadBalancerIP for the SuiteCRM Service (optional, cloud specific)
## ref: http://kubernetes.io/docs/user-guide/services/#type-loadbalancer
##
# suitecrmLoadBalancerIP:

## User of the application
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
suitecrmUsername: craig

## Application password
## Defaults to a random 10-character alphanumeric string if not set
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
suitecrmPassword: <hadmypasswordhere>

## Admin email
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
suitecrmEmail: <hadmyemail>@gmail.com

## Lastname
## ref: https://github.com/bitnami/bitnami-docker-suitecrm#configuration
##
suitecrmLastName: <hadmylastname>

## SMTP mail delivery configuration
## ref: https://github.com/bitnami/bitnami-docker-suitecrm/#smtp-configuration
##
# suitecrmSmtpHost:
# suitecrmSmtpPort:
# suitecrmSmtpUser:
# suitecrmSmtpPassword:
# suitecrmSmtpProtocol:

##
## MariaDB chart configuration
##
mariadb:
  ## MariaDB admin password
  ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#setting-the-root-password-on-first-run
  ##
  mariadbRootPassword: <hadMyPasswordHere>

  ## Enable persistence using Persistent Volume Claims
  ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
  ##
  persistence:
    enabled: true
    ## mariadb data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessMode: ReadWriteOnce
    size: 8Gi

## Kubernetes configuration
## For minikube, set this to NodePort, elsewhere use LoadBalancer
##
serviceType: LoadBalancer

## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
  enabled: true
  apache:
    ## apache data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessMode: ReadWriteOnce
    size: 1Gi
  suitecrm:
    ## suitecrm data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessMode: ReadWriteOnce
    size: 8Gi

## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
resources: {}
  # requests:
  #   memory: 512Mi
  #   cpu: 300m

I did look at the logs of the running service (through minikube dashboard).  Really not much use there but it seems to hang on preparing CRM Environment.   It never gets beyond that...

     nami    INFO  Initializing apache
apache  INFO  ==> Patching httpoxy...
nami    INFO  apache successfully initialized
nami    INFO  Initializing php
nami    INFO  php successfully initialized
nami    INFO  Initializing suitecrm
suitecr INFO  Preparing webserver environment...
suitecr INFO  Preparing PHP environment...
suitecr INFO  Preparing suitecrm environment...

The service endpoint is never ready and never appears to complete deployment.   Any help would be appreciated.

Body:
I think the issue has to do with not setting the suitecrm host correctly. It is configured to use LoadBalancer but as you are using minikube you need to manually set the APP_HOST variable with a different command than that displayed by helm. This is what I did to make it work:

helm install --name red-falcon-crm -f values.yaml stable/suitecrm
export APP_HOST=$(minikube ip):$(kubectl get svc red-falcon-crm-suitecrm --template "{{ (index .spec.ports 0).nodePort }}")
helm upgrade red-falcon-crm --set suitecrmHost=$APP_HOST -f values.yaml stable/suitecrm


问:
AJAX POST data not being sent
On button click, i want to post the contents of the email text box. When i click the login button nothing happens.

My File dir:

Model/                <-- configuration.php is inside Model dir.

View/

Controller/

index.php             <-- calls the header, body, and footer php classes that are in the view dir

```<code>                    <!-- Modal body -->
                <div class="modal-body" style="padding:40px 50px;">
                    <form>
                        <div class="form-group">
                            <label for="usrname"><span class="glyphicon glyphicon-user"></span> Username</label>
                            <input type="text" class="form-control" name="email" id="email" placeholder="Enter email">
                        </div>
                        <div class="form-group">
                            <label for="psw"><span class="glyphicon glyphicon-eye-open"></span> Password</label>
                            <input type="text" class="form-control" id="password" placeholder="Enter password">
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" value="" checked>Remember me</label>
                        </div>
                        <button type="button" name="loginButton" id="loginButton" name="loginButton" class="btn btn-success btn-block">Login</button>
                    </form>
                </div>

                <!-- Modal footer -->
                <div class="modal-footer">
                    <p>Not a member? <a href="View/registration.php">Sign Up</a></p>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function() {
        $("#loginButton").click(function() {
            $.ajax({
                type: "POST",
                url: "Model/configuration.php?action=login",
                data: "email=" + $("#email").val(),
                success: function (result) {
                    alert("result");
                }
            })
        })
    })
</script>
</code>```

PHP file

```<code><?php

if($_GET['action'] == "login") {
    print_r($_POST);
}

?>
</code>```

答:
You should serialize your form and pass to data.

```<code>data: $("#FormId").serialize()
</code>```

See also https://api.jquery.com/serialize/

Title: AJAX POST data not being sent

Body:
On button click, i want to post the contents of the email text box. When i click the login button nothing happens.

My File dir:

Model/                <-- configuration.php is inside Model dir.

View/

Controller/

index.php             <-- calls the header, body, and footer php classes that are in the view dir

                    <form>

                             Username
                            <input type="text" class="form-control" name="email" id="email" placeholder="Enter email">

                             Password
                            <input type="text" class="form-control" id="password" placeholder="Enter password">

                            <input type="checkbox" value="" checked>Remember me

                        <button type="button" name="loginButton" id="loginButton" name="loginButton" class="btn btn-success btn-block">Login</button>
                    </form>

Not a member? Sign Up

PHP file

<?php

if($_GET['action'] == "login") {
    print_r($_POST);
}

?>

Body:
You should serialize your form and pass to data.

data: $("#FormId").serialize()

See also https://api.jquery.com/serialize/


问:
Is it possible to convert a Database Access 97 to Access 2003 using VB6?
I have a project in VB6 with a DB Access 97.

I need to convert the format to Access 2003 or newer.

Is this possible using VB6 code?

答:
Using DAO in VB6, create a new database in JET 4.0 format:

```<code>DBEngine.CreateDatabase "c:\test\db4.mdb", dbLangGeneral, dbVersion40
</code>```

Then copy all objects from the old database to the new database.

More info here.

Body:
Using DAO in VB6, create a new database in JET 4.0 format:

DBEngine.CreateDatabase "c:\test\db4.mdb", dbLangGeneral, dbVersion40

Then copy all objects from the old database to the new database.

More info here.


问:
Adding buttons to bot framework application
I am trying to implement a bot using the bot framework from Microsoft. I followed the documentation but it doesn't seem to be adding the buttons properly. On skype it shows a sort of a thumbnail which opens into the skype download page. On facebook messenger it doesn't show anything.

Any advice?
Thank you!

答:
Yes you can achieve to add a custom button which will work on every channel of bot framework.

There are two approach to achieve that:
1) Use Cards feature of Bot to get buttons. (Quick and Easy)
2) Use direct Line Channel and Add your custom button. (Complex)

Lets start with approach 1

You need to create a hero card and call it in your dialog. Hero card contains your text response from bot and Thumbnail image url. (You can remove thumbnail if not required). Below is the running code for your help.

```<code>public async Task StartAsync(IDialogContext context)
        {
            context.Wait(ImgCardResponse);
        }

        private async Task ImgCardResponse(IDialogContext context, IAwaitable<IMessageActivity> argument)
        {
            var message = await argument;

            //responseMsgOnly is used to pass bot reply message
            //responseImage is used to pass thumbnail image
            var attachment = BotButtonCard(responseMsgOnly, responseImage);
            cardMsg.Attachments.Add(attachment);
            await context.PostAsync(cardMsg);

        }
        private static Attachment BotButtonCard(string responseMsgOnly, string responseImage)
        {
            var heroCard = new HeroCard
            {
                Title = "Here we go with the response",
                Subtitle = "Subtitle goes here",
                Text = responseMsgOnly,
                Images = new List<CardImage>
                {
                    new CardImage(responseImage)
                }
                Buttons = new List<CardAction>
                {
                    new CardAction(ActionTypes.OpenUrl, "Your Button Label", value: "https://www.google.com")
                }
            };

            return heroCard.ToAttachment();
        }
        private async Task ResumeAfterAction(IDialogContext context, IAwaitable<object> result)
        {
            context.Done(new object());
        }
</code>```

Lets start with approach 2

The Direct Line API is a simple REST API for connecting directly to a single bot. This API is intended for developers writing their own client applications, web chat controls, or mobile apps that will talk to their bot. The Direct Line v3.0 Nuget package simplifies access to the underlying REST API.

You need to create an html page and put the below code

in head part

```<code><link href="../botchat.css" rel="stylesheet"/>
    <script src="../js/botchat.js"></script>
</code>```

in body part

```<code><div id="bot"></div>
<script>

    var FirstName;
    var emailaddress;
    var Environment;
    try{

        FirstName =  _spPageContextInfo.userDisplayName;
        emailaddress = "manoj.resources@resources.in";
        Environment= _spPageContextInfo.webAbsoluteUrl ;
    }
    catch(ex)
    {
        spCOntext = 'You';
        Environment = 'Local System';

    }

    BotChat.App({

        directLine: { secret: 'Your direct line secret' },

        user: { id: FirstName,Name: Environment},
        name: spCOntext,
        value: FirstName,
        From: '',
        bot: { id: 'Bot ID' },
        resize: 'detect'
    }, document.getElementById("bot"));

</script>
</code>```

do let me know in case you need any help

Body:
Yes you can achieve to add a custom button which will work on every channel of bot framework.

There are two approach to achieve that:
1) Use Cards feature of Bot to get buttons. (Quick and Easy)
2) Use direct Line Channel and Add your custom button. (Complex)

Lets start with approach 1

You need to create a hero card and call it in your dialog. Hero card contains your text response from bot and Thumbnail image url. (You can remove thumbnail if not required). Below is the running code for your help.

public async Task StartAsync(IDialogContext context)
        {
            context.Wait(ImgCardResponse);
        }

        private async Task ImgCardResponse(IDialogContext context, IAwaitable<IMessageActivity> argument)
        {
            var message = await argument;

            //responseMsgOnly is used to pass bot reply message
            //responseImage is used to pass thumbnail image
            var attachment = BotButtonCard(responseMsgOnly, responseImage);
            cardMsg.Attachments.Add(attachment);
            await context.PostAsync(cardMsg);

        }
        private static Attachment BotButtonCard(string responseMsgOnly, string responseImage)
        {
            var heroCard = new HeroCard
            {
                Title = "Here we go with the response",
                Subtitle = "Subtitle goes here",
                Text = responseMsgOnly,
                Images = new List<CardImage>
                {
                    new CardImage(responseImage)
                }
                Buttons = new List<CardAction>
                {
                    new CardAction(ActionTypes.OpenUrl, "Your Button Label", value: "https://www.google.com")
                }
            };

            return heroCard.ToAttachment();
        }
        private async Task ResumeAfterAction(IDialogContext context, IAwaitable<object> result)
        {
            context.Done(new object());
        }

Lets start with approach 2

The Direct Line API is a simple REST API for connecting directly to a single bot. This API is intended for developers writing their own client applications, web chat controls, or mobile apps that will talk to their bot. The Direct Line v3.0 Nuget package simplifies access to the underlying REST API.

You need to create an html page and put the below code

in head part

<link href="../botchat.css" rel="stylesheet"/>
    <script src="../js/botchat.js"></script>

in body part

<div id="bot"></div>
<script>

    var FirstName;
    var emailaddress;
    var Environment;
    try{

        FirstName =  _spPageContextInfo.userDisplayName;
        emailaddress = "manoj.resources@resources.in";
        Environment= _spPageContextInfo.webAbsoluteUrl ;
    }
    catch(ex)
    {
        spCOntext = 'You';
        Environment = 'Local System';

    }

    BotChat.App({

        directLine: { secret: 'Your direct line secret' },

        user: { id: FirstName,Name: Environment},
        name: spCOntext,
        value: FirstName,
        From: '',
        bot: { id: 'Bot ID' },
        resize: 'detect'
    }, document.getElementById("bot"));

</script>

do let me know in case you need any help


问:
How to get the status of parallel port printer under Linux？
How to get the status of parallel port printer under Linux, such as paper missing, the device is not installed.
Or
How to get through the CUPS printer status etc.</p>

答:
```<code>int fd = open("/dev/lp0", O_RDWR);
if (fd < 0)
{
    printf("can't open lp0\n");
}
else
{
    int status = 0;
    if (ioctl(fd, LPGETSTATUS, &status) == 0)
    {

        fprintf(stderr, "DEBUG: LPGETSTATUS returned a port status of %02X...\n", status);
          if (status & LP_NOPA)
        {
            RET = T;
            fputs("WARNING: Media tray empty!\n", stderr);
        }
        else if (status & LP_ERR)
        {
            RET = F;
            fputs("WARNING: Printer fault!\n", stderr);

        }
        else if (status & LP_OFFL)
        {
            RET = F;
            fputs("WARNING: Printer off-line.\n", stderr);
        }
    close(fd);
</code>```

<p>}
  }</p>

Body:
int fd = open("/dev/lp0", O_RDWR);
if (fd < 0)
{
    printf("can't open lp0\n");
}
else
{
    int status = 0;
    if (ioctl(fd, LPGETSTATUS, &status) == 0)
    {

        fprintf(stderr, "DEBUG: LPGETSTATUS returned a port status of %02X...\n", status);
          if (status & LP_NOPA)
        {
            RET = T;
            fputs("WARNING: Media tray empty!\n", stderr);
        }
        else if (status & LP_ERR)
        {
            RET = F;
            fputs("WARNING: Printer fault!\n", stderr);

        }
        else if (status & LP_OFFL)
        {
            RET = F;
            fputs("WARNING: Printer off-line.\n", stderr);
        }
    close(fd);

}
  }


问:
Javascript sort array by context
Looking to sort a array based on context, that contains the following sample data

```<code> ["1 Bob Smith", "12 Foo Bar", "112 Mary Jane", "122 Fizz Buzz"]
</code>```

When I search by 12 it returns

```<code>["12 Foo Bar", "112 Mary Jane", "122 Fizz Buzz"]
</code>```

This seems to be the default sort behaviour of react-select the library I am currently using

What I need it to return is the following

```<code>["12 Foo Bar", "122 Fizz Buzz", "112 Mary Jane"]
</code>```

答:
You could use the index position of the wanted search string and sort it first and then by string.

var array = ["1 Bob Smith", "12 Foo Bar", "112 Mary Jane", "122 Fizz Buzz" ,"12312 something"],
    value = '12',
    result = array.filter(a => a.includes(value));

result.sort(function (a, b) {
    return a.lastIndexOf(value) - b.lastIndexOf(value) || +(a > b) || -(a < b);
});

console.log(result);```
</div>
</div>
</p>

<p>An approach with using the indices of the search number and use it as string by sorting with <code>String#localeCompare</code> with options.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var array = ["1 Bob Smith", "12 Foo Bar", "112 Mary Jane", "122 Fizz Buzz", "12312 something", "12101 bar"],
    value = '12',
    result = array.filter(a => a.includes(value));

result.sort(function (a, b) {
    function getPos(s) {
        var p = 0, h, r = [];

        s = s.match(/^\S+/)[0];
        while (p < s.length) {
            p = s.indexOf(value, p)
            r.push((p + 1) || 99999);
            if (p === -1) {
                break;
            }
            p += value.length;
        }
        return r.join(' ');
    }

    var aa = getPos(a), bb = getPos(b);

    return aa.localeCompare(bb, undefined, { numeric: true, sensitivity: 'base' }) || a.localeCompare(b);
});

console.log(result);</code>```

.as-console-wrapper { max-height: 100% !important; top: 0; }```

Title: Javascript sort array by context

Body:
Looking to sort a array based on context, that contains the following sample data

 ["1 Bob Smith", "12 Foo Bar", "112 Mary Jane", "122 Fizz Buzz"]

When I search by 12 it returns

["12 Foo Bar", "112 Mary Jane", "122 Fizz Buzz"]

This seems to be the default sort behaviour of react-select the library I am currently using

What I need it to return is the following

["12 Foo Bar", "122 Fizz Buzz", "112 Mary Jane"]

Body:
You could use the index position of the wanted search string and sort it first and then by string.

var array = ["1 Bob Smith", "12 Foo Bar", "112 Mary Jane", "122 Fizz Buzz" ,"12312 something"],
    value = '12',
    result = array.filter(a => a.includes(value));

result.sort(function (a, b) {
    return a.lastIndexOf(value) - b.lastIndexOf(value) || +(a > b) || -(a < b);
});

console.log(result);

An approach with using the indices of the search number and use it as string by sorting with String#localeCompare with options.

var array = ["1 Bob Smith", "12 Foo Bar", "112 Mary Jane", "122 Fizz Buzz", "12312 something", "12101 bar"],
    value = '12',
    result = array.filter(a => a.includes(value));

result.sort(function (a, b) {
    function getPos(s) {
        var p = 0, h, r = [];

        s = s.match(/^\S+/)[0];
        while (p < s.length) {
            p = s.indexOf(value, p)
            r.push((p + 1) || 99999);
            if (p === -1) {
                break;
            }
            p += value.length;
        }
        return r.join(' ');
    }

    var aa = getPos(a), bb = getPos(b);

    return aa.localeCompare(bb, undefined, { numeric: true, sensitivity: 'base' }) || a.localeCompare(b);
});

console.log(result);

.as-console-wrapper { max-height: 100% !important; top: 0; }


问:
Don’t mock value objects: too generic rule without explanation
Here is a quote from Mockito unit testing framework:

Don't mock value objects

Why one would even want to do that?

Because instantiating the object is too painful !? => not a valid
  reason. If it's too difficult to create new fixtures, it is a sign the
  code may need some serious refactoring. An alternative is to create
  builders for your value objects -- there are tools for that, including
  IDE plugins, Lombok, and others. One can also create meaningful
  factory methods in the test classpath.

And another quote from here:

There isn't much point in writing mocks for simple value objects
  (which should be immutable anyway), just create an instance and use
  it.  It's not worth creating an interface / implementation pair to control which time values are returned, just create instances with the appropriate values and use them. There are a couple of heuristics for when a class is not worth mocking. First, it has only accessors or simple methods that act on values it holds, it doesn't have any interesting behaviour. Second, you can't think of a meaningful name for the class other than VideoImpl or some such vague term.

This seems to be a valid reason for dumb value objects holding just the values and nothing more, but things getting more complicated when you have a ValueObject referencing the entities and other value objects.

Let's say I have Person and Pet objects which are entities and Relationship (owner, doctor, etc) which is a ValueObject between two persons and has a RelationshipType which is also a Value Object. So, relationship is basically:

```<code>class Relationship {
    private Person person;
    private Pet pet;
    private RelationshipType type;
}
</code>```

Now, let's say I have a class with the predicate like isOwnerRelationship, isDoctorRelationship, whatever. Basically predicate is as simple as

relationship -> relationship.isOwner(); //delegates to relationshipType.isOwner()

Now, I want to test the predicates and I have two options:

Mock Relationship

```<code>public void testIsOwner() {
   Relationship rel = mock(Relationship.class);
   when(rel.isOwner()).thenReturn(true);

   assertTrue(RelationshipPredicates.isOwner(rel));
}
</code>```

Don't mock Relationship

```<code>public void testIsOwner() {
   Person person = PersonBuilder.newPerson();
   Pet pet = PetBuilder.newDogPet();
   RelationshipType type = RelationshipTypes.ownerType();

   Relationship rel = new Relationship(person, pet, type);

   assertTrue(RelationshipPredicates.isOwner(rel));
}
</code>```

Of course the example is over simplified because for a person you may be required to provide address, for Pet you may have to provide BreedType, whatever, i.e. transitive graph of entities and value objects you may need to provide can be very huge. Of course you can mock Entities, but assume you have more ValueObjects of ValueObjects inside of Relationship. Even if you have fancy builders, you will have to provide each and every part of the original ValueObject even though unit test is going to test only single aspect of it.

In the predicates test, why should I care about full object construction if the predicate cares about calling one particular method of the object or combination of them?

Or is such value object can't be considered as a simple and rule doesn't apply?

答: UnitTests should test individual units. So, if your ValueObject is simple enough then it should not influence the testing of SUT (subject under test). If, however, the ValueObject has complex behavior then you should mock it. This simplifies the test and isolate testing to only the SUT.

Body:
Here is a quote from Mockito unit testing framework:

Don't mock value objects

Why one would even want to do that?

Because instantiating the object is too painful !? => not a valid
  reason. If it's too difficult to create new fixtures, it is a sign the
  code may need some serious refactoring. An alternative is to create
  builders for your value objects -- there are tools for that, including
  IDE plugins, Lombok, and others. One can also create meaningful
  factory methods in the test classpath.

And another quote from here:

There isn't much point in writing mocks for simple value objects
  (which should be immutable anyway), just create an instance and use
  it.  It's not worth creating an interface / implementation pair to control which time values are returned, just create instances with the appropriate values and use them. There are a couple of heuristics for when a class is not worth mocking. First, it has only accessors or simple methods that act on values it holds, it doesn't have any interesting behaviour. Second, you can't think of a meaningful name for the class other than VideoImpl or some such vague term.

This seems to be a valid reason for dumb value objects holding just the values and nothing more, but things getting more complicated when you have a ValueObject referencing the entities and other value objects.

Let's say I have Person and Pet objects which are entities and Relationship (owner, doctor, etc) which is a ValueObject between two persons and has a RelationshipType which is also a Value Object. So, relationship is basically:

class Relationship {
    private Person person;
    private Pet pet;
    private RelationshipType type;
}

Now, let's say I have a class with the predicate like isOwnerRelationship, isDoctorRelationship, whatever. Basically predicate is as simple as

relationship -> relationship.isOwner(); //delegates to relationshipType.isOwner()

Now, I want to test the predicates and I have two options:

Mock Relationship

public void testIsOwner() {
   Relationship rel = mock(Relationship.class);
   when(rel.isOwner()).thenReturn(true);

   assertTrue(RelationshipPredicates.isOwner(rel));
}

Don't mock Relationship

public void testIsOwner() {
   Person person = PersonBuilder.newPerson();
   Pet pet = PetBuilder.newDogPet();
   RelationshipType type = RelationshipTypes.ownerType();

   Relationship rel = new Relationship(person, pet, type);

   assertTrue(RelationshipPredicates.isOwner(rel));
}

Of course the example is over simplified because for a person you may be required to provide address, for Pet you may have to provide BreedType, whatever, i.e. transitive graph of entities and value objects you may need to provide can be very huge. Of course you can mock Entities, but assume you have more ValueObjects of ValueObjects inside of Relationship. Even if you have fancy builders, you will have to provide each and every part of the original ValueObject even though unit test is going to test only single aspect of it.

In the predicates test, why should I care about full object construction if the predicate cares about calling one particular method of the object or combination of them?

Or is such value object can't be considered as a simple and rule doesn't apply?


问:
ng-Show and ng-Hide Divisions on ng-repeat values
```<code><html>
    <span ng-init="hideTableDiv = false;"></span>
    <div ng-repeat="schedule in allschedules" ng-if="(schedule.faculty_id==row.faculty_id) && (schedule.start_time)=='09:30:00'">
       <span ng-init="hideTableDiv = true;"></span>
       <span id="{{schedule.schedule_id}}" style="font-size: 88%">

           <span class="label spanlabel" style="font-weight:100">{{schedule.classroom}} {{schedule.module_name}} {{schedule.cohort_name}}</span>
           <a id="delete_0-{{$index}}" class="" ng-click="deleteschedule(schedule.start_time,schedule.module_id,schedule.schedule_id);"><i class="fa fa-trash-o" style="color:red"></i></a>

       </span>
   </div>
   <div ng-if="!hideTableDiv">ALL DROPDOWN BOXES</div>
</html>
</code>```

Glimpse of my code i am working on. Need to check if labeldiv is shown hide table div and vice versa.

How that can be achieved?

答:
do it like this:</p>

```<code><html>
<span ng-init="hideTableDiv = false;"></span>
<div id="labeldiv" ng-repeat="schedules in allschedules" ng-if="schedules.facultyis==row.facultyid">
<span ng-init="hideTableDiv = true;"></span>
<span>id Matches</span>
</div>

<div id="tablediv"  ng-if="!hideTableDiv">
</div>
</html>
</code>```

Body:
           {{schedule.classroom}} {{schedule.module_name}} {{schedule.cohort_name}}

ALL DROPDOWN BOXES

Glimpse of my code i am working on. Need to check if labeldiv is shown hide table div and vice versa.

How that can be achieved?

Body:
do it like this:

<html>
<span ng-init="hideTableDiv = false;"></span>
<div id="labeldiv" ng-repeat="schedules in allschedules" ng-if="schedules.facultyis==row.facultyid">
<span ng-init="hideTableDiv = true;"></span>
<span>id Matches</span>
</div>

<div id="tablediv"  ng-if="!hideTableDiv">
</div>
</html>


问:
Android disable screen timeout while app is running
Is there a way to disable the screensaver while my app is running?

The dimming of the screen is what I mean.

答:
```<code>android:keepScreenOn="true"
</code>```

is the better way to handle this if we want to make any particular screen awake all the time otherwise we have to handle yourself when to enable it and to disable  it

https://developer.android.com/training/scheduling/wakelock.html

Body:
android:keepScreenOn="true"

is the better way to handle this if we want to make any particular screen awake all the time otherwise we have to handle yourself when to enable it and to disable  it

https://developer.android.com/training/scheduling/wakelock.html


问:
how to replace char with other in hexdecimal
I'm a new user who using mainframe, I have a file and I need to change all dots '.' in file with space, I was trying to write this statement on command </p>

```<code>change X'05' X'40' all
</code>```

<p>after I converted the file to hexdecimal, but It doesn't work.
How can I change all the dots with space in file, in simple way please? </p>

答:
Hans answer above will certainly change any non-displayable character to a space.  However you need to make sure you really want to change all non displayable characters to a space.  Turn HEX ON to look at the actual data. You can then do a F p'.' to find the non-displayable character(s) prior to changing it.  Browse shows non-displayable characters as a dot.  However Edit would replace the value with an attribute for display purposes and this keeps you from typing over the data.  You have to turn on HEX mode to manually modify the non-displayable value or use the Change command as you were trying.   Typically any hex value from x'00' - x'3F' would be non-displayable.  So a

C P'.' X'40' ALL

would modify every one of those values to a space.  This may or may not be desirable depending on the file.

Body:
I'm a new user who using mainframe, I have a file and I need to change all dots '.' in file with space, I was trying to write this statement on command

change X'05' X'40' all

after I converted the file to hexdecimal, but It doesn't work.
How can I change all the dots with space in file, in simple way please?


问:
POST versus Ajax call
Now that most modern browsers support AJAX and client-side requests without performing a POST, what is the role of POST (form post)?

Are there situations or general rules when a POST will always be preferred to a XmlHttpRequest?

All that POST is doing is placing variable key value pairs inside the server head. The advantages of POST I can think of are large amounts of data and mobile browsers. Are there many others I'm missing?

N.B. I know you can perform POSTs with AJAX calls, I'm talking primarily about with a <form> tag

答: The key differentiator is that the POST of a form sends data and can navigate to a new URL in a single round trip to the server.  Ajax can send data but can't navigate to new page.</p>

OwnerDisplayName: Chris

Title: POST versus Ajax call

OwnerDisplayName: AnthonyWJones


问:
Facebook javascript SDK works with one app id but not another
I have been working on creating a publish to stream dialog box with the javascript sdk. I couldn't get it to work, so in frustration I tried replacing the app id with the app id of another app I had previously worked on. Somehow this worked perfectly! There is no difference in the code, only the app id changed.

This is the code. What could be the difference between the two app settings that would cause the sdk to work with one id and not the other? In fact, no new facebook application which I create will work with the javascript sdk. Only my original app.

```<code><div id="fb-root"></div>
<script>
    (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    }());
    window.fbAsyncInit = function()
    {
        FB.init({ appId: '696969696969', status: true, cookie: true, channelUrl: 'http://example.com/channel.html' });

        FB.getLoginStatus(function(response)
        {
            console.log(response.session);
        });

        var publish = {
            method     : 'stream.publish',
            message    : '',
            attachment : {
                name        : 'name',
                caption     : 'caption',
                description : 'description',
                href        : 'http://www.fjdjdj.com'
            },
            action_links : [ { text : 'action link', href : 'http://www.cnn.com' } ],
            user_message_prompt  : 'user prompt'
        };

        FB.ui(publish, function(response) { console.log(response); });
    };
</script>
</code>```

答:
I suppose it's your application settings, most likely the Site URL. If this does not match your domain that you are running the SDK on, it won't work.

A bonus tip, it's a good idea to remove the application from your user's added applications and re-install it!


问:
Injecting data into  via server side rendering
Here is the demo:

```<code><script>
    var temp = {{{$data}}}
</script>
</code>```

I like inject the $data into the

答:
use like this:

```<code><script>
    window.data = <?=$data?>
</script>
</code>```

in vue:

```<code>var data  = window.data
</code>```

Title: Injecting data into <script>var t = {{{$data}}}</script> via server side rendering

Body:
Here is the demo:

I like inject the $data into the

Body:
use like this:

<script>
    window.data = <?=$data?>
</script>

in vue:

var data  = window.data


问:
How to access named url arguments in permissions with Django REST Framework?
I have an url config like

url(r'^user/(?P<id>[0-9]+)/$', UserView.as_view())

And a view class like

```<code>class UserView(GenericAPIView):
    serializer_class = UserSerializer
    permission_classes = [MyCustomPermission]

    def get(self, request, id):
        # code...
</code>```

The permission is like

```<code>class MyCustomPermission(BasePermission):
    def has_permission(self, request, view, *args, **kwargs):
    # code
</code>```

How do I access id in MyCustomPermission? I can't find it from the request or from *args or *kwargs. Documentation doesn't say anything about this. I've tried to look the source code but can't find how to access those named url arguments. Is it even possible?

答: you can access from the view.kwargs.</p>

Body:
I have an url config like

url(r'^user/(?P<id>[0-9]+)/$', UserView.as_view())

And a view class like

class UserView(GenericAPIView):
    serializer_class = UserSerializer
    permission_classes = [MyCustomPermission]

    def get(self, request, id):
        # code...

The permission is like

class MyCustomPermission(BasePermission):
    def has_permission(self, request, view, *args, **kwargs):
    # code

How do I access id in MyCustomPermission? I can't find it from the request or from *args or *kwargs. Documentation doesn't say anything about this. I've tried to look the source code but can't find how to access those named url arguments. Is it even possible?

Body: you can access from the view.kwargs.


答:
The problem seems to be that your if condition had an extra parentheses.

Try this:

```<code><?php

if($_GET['action'] == "login") {
    print_r($_POST);
}

?>
</code>```

Title: AJAX POST data not being sent

Body:
The problem seems to be that your if condition had an extra parentheses.

Try this:

<?php

if($_GET['action'] == "login") {
    print_r($_POST);
}

?>