问:
Search the mails containing one email id in all inbox subfolders
To find all emails (by folder name i.e. email id) from subfolders of inbox present since last month and copy paste them in respective folders by their subject.

I am stuck at code     NS = OlApp.GetNamespace("MAPIFolder") also with ("MAPI") as well the error of object variable not set is displaying

```<code>Dim OlApp As Outlook.Application
Set OlApp = New Outlook.Application
Set OlApp = CreateObject("Outlook.Application")
Dim fldrpath As String
Dim fldername As String
Dim oMail As Object
fldrpath = "\data\EMAILS\" & fldrname
Dim NS As Namespace
Dim Folder As MAPIFolder
Dim sName As String
Dim dtdate As String
Dim Inbox As MAPIFolder
NS = OlApp.GetNamespace("MAPIFolder")
Set Inbox = NS.GetDefaultFolder(olFolderInbox)
For Each mysubFolders In Inbox.subFolders
Set mysubfolder = Inbox.subFolders("PDI").Folders("OBU").Folders("DND")
For Each mailItems In mysubfolder
If oMail.Body = r Then
Set mailItems = oMail
sName = mailItems.Subject
dtdate = mailItems.ReceivedTime
Debug.Print fldrpath & sName
mailItems.SaveAs fldrpath & sName, olMSG
End If
 Next
Set OlApp = Nothing
Set mailItems = Nothing
Next
End Sub
</code>```

答:
The first problem is this line, missing the Set keyword:

Set NS = OlApp.GetNamespace("MAPIFolder")

Then you are accessing "Inbox.subFolders", but there is no such property on a Folder object; it would be the Folders property collection that you want.

You also aren't using the mysubFolders variable in the loop, so that entire block of code is going to fail.  There is also no explicit set of the mailItems object you are trying to iterate from the mysubfolder object.

I'd continue but frankly the entire method needs to be rewritten.  Focus on ensuring you are declaring and setting the correct variables to the correct properties or objects.

Body:
To find all emails (by folder name i.e. email id) from subfolders of inbox present since last month and copy paste them in respective folders by their subject.

I am stuck at code     NS = OlApp.GetNamespace("MAPIFolder") also with ("MAPI") as well the error of object variable not set is displaying

Dim OlApp As Outlook.Application
Set OlApp = New Outlook.Application
Set OlApp = CreateObject("Outlook.Application")
Dim fldrpath As String
Dim fldername As String
Dim oMail As Object
fldrpath = "\data\EMAILS\" & fldrname
Dim NS As Namespace
Dim Folder As MAPIFolder
Dim sName As String
Dim dtdate As String
Dim Inbox As MAPIFolder
NS = OlApp.GetNamespace("MAPIFolder")
Set Inbox = NS.GetDefaultFolder(olFolderInbox)
For Each mysubFolders In Inbox.subFolders
Set mysubfolder = Inbox.subFolders("PDI").Folders("OBU").Folders("DND")
For Each mailItems In mysubfolder
If oMail.Body = r Then
Set mailItems = oMail
sName = mailItems.Subject
dtdate = mailItems.ReceivedTime
Debug.Print fldrpath & sName
mailItems.SaveAs fldrpath & sName, olMSG
End If
 Next
Set OlApp = Nothing
Set mailItems = Nothing
Next
End Sub


来源: stackexchange

问:
PHP regex pattern match recursive
I have this in a function which is supposed to replace any sequence of parentheses with what is enclosed in it like (abc) becomes abc any where it appears even recursively because parens can be nested.

```<code>$return =   preg_replace_callback(
    '|(\((.+)\))+|',
    function ($matches) {
        return $matches[2];
    },
    $s
);
</code>```

when the above regex is fed this string "a(bcdefghijkl(mno)p)q" as input it returns "ap)onm(lkjihgfedcbq". This shows the regex is matched once. What can I do to make it continue to match even inside already made matches and produce this `abcdefghijklmnopq'"

答:
It is slightly unclear exactly what the postcondition of the algorithm is supposed to be. It seems to me that you are wanting to strip out matching pairs of ( ). The assumption here is that unmatched parentheses are left alone (otherwise you just strip out all of the ('s and )'s).

So I guess this means the input string a(bcdefghijkl(mno)p)q becomes abcdefghijklmnopq but the input string a(bcdefghijkl(mno)pq becomes a(bcdefghijklmnopq. Likewise an input string (a)) would become a).

It may be possible to do this using pcre since it does provide some non-regular features but I'm doubtful about it. The language of the input strings is not regular; it's context-free. What @ArtisticPhoenix's answer does is match complete pairs of matched parentheses. What it does not do is match all nested pairs. This nested matching is inherently non-regular in my humble understanding of language theory.

I suggest writing a parser to strip out the matching pairs of parentheses. It gets a little wordy having to account for productions that fail to match:

```<code><?php

// Parse the punctuator sub-expression (i.e. anything within ( ... ) ).
function parse_punc(array $tokens,&$iter) {
    if (!isset($tokens[$iter])) {
        return;
    }

    $inner = parse_punc_seq($tokens,$iter);
    if (!isset($tokens[$iter]) || $tokens[$iter] != ')') {
        // Leave unmatched open parentheses alone.
        $inner = "($inner";
    }

    $iter += 1;
    return $inner;
}

// Parse a sequence (inside punctuators).
function parse_punc_seq(array $tokens,&$iter) {
    if (!isset($tokens[$iter])) {
        return;
    }

    $tok = $tokens[$iter];
    if ($tok == ')') {
        return;
    }
    $iter += 1;

    if ($tok == '(') {
        $tok = parse_punc($tokens,$iter);
    }

    $tok .= parse_punc_seq($tokens,$iter);
    return $tok;
}

// Parse a sequence (outside punctuators).
function parse_seq(array $tokens,&$iter) {
    if (!isset($tokens[$iter])) {
        return;
    }

    $tok = $tokens[$iter++];
    if ($tok == '(') {
        $tok = parse_punc($tokens,$iter);
    }

    $tok .= parse_seq($tokens,$iter);
    return $tok;
}

// Wrapper for parser.
function parse(array $tokens) {
    $iter = 0;
    return strval(parse_seq($tokens,$iter));
}

// Grab input from stdin and run it through the parser.
$str = trim(stream_get_contents(STDIN));
$tokens = preg_split('/([\(\)])/',$str,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
var_dump(parse($tokens));
</code>```

I know this is a lot more code than a regex one-liner but it does solve the problem as I understand it. I'd be interested to know if anyone can solve this problem with a regular expression.

ContentLicense: CC BY-SA 3.0

Title: PHP regex pattern match recursive

Body:
I have this in a function which is supposed to replace any sequence of parentheses with what is enclosed in it like (abc) becomes abc any where it appears even recursively because parens can be nested.

$return =   preg_replace_callback(
    '|(\((.+)\))+|',
    function ($matches) {
        return $matches[2];
    },
    $s
);

when the above regex is fed this string "a(bcdefghijkl(mno)p)q" as input it returns "ap)onm(lkjihgfedcbq". This shows the regex is matched once. What can I do to make it continue to match even inside already made matches and produce this `abcdefghijklmnopq'"

Body:
It is slightly unclear exactly what the postcondition of the algorithm is supposed to be. It seems to me that you are wanting to strip out matching pairs of ( ). The assumption here is that unmatched parentheses are left alone (otherwise you just strip out all of the ('s and )'s).

So I guess this means the input string a(bcdefghijkl(mno)p)q becomes abcdefghijklmnopq but the input string a(bcdefghijkl(mno)pq becomes a(bcdefghijklmnopq. Likewise an input string (a)) would become a).

It may be possible to do this using pcre since it does provide some non-regular features but I'm doubtful about it. The language of the input strings is not regular; it's context-free. What @ArtisticPhoenix's answer does is match complete pairs of matched parentheses. What it does not do is match all nested pairs. This nested matching is inherently non-regular in my humble understanding of language theory.

I suggest writing a parser to strip out the matching pairs of parentheses. It gets a little wordy having to account for productions that fail to match:

<?php

// Parse the punctuator sub-expression (i.e. anything within ( ... ) ).
function parse_punc(array $tokens,&$iter) {
    if (!isset($tokens[$iter])) {
        return;
    }

    $inner = parse_punc_seq($tokens,$iter);
    if (!isset($tokens[$iter]) || $tokens[$iter] != ')') {
        // Leave unmatched open parentheses alone.
        $inner = "($inner";
    }

    $iter += 1;
    return $inner;
}

// Parse a sequence (inside punctuators).
function parse_punc_seq(array $tokens,&$iter) {
    if (!isset($tokens[$iter])) {
        return;
    }

    $tok = $tokens[$iter];
    if ($tok == ')') {
        return;
    }
    $iter += 1;

    if ($tok == '(') {
        $tok = parse_punc($tokens,$iter);
    }

    $tok .= parse_punc_seq($tokens,$iter);
    return $tok;
}

// Parse a sequence (outside punctuators).
function parse_seq(array $tokens,&$iter) {
    if (!isset($tokens[$iter])) {
        return;
    }

    $tok = $tokens[$iter++];
    if ($tok == '(') {
        $tok = parse_punc($tokens,$iter);
    }

    $tok .= parse_seq($tokens,$iter);
    return $tok;
}

// Wrapper for parser.
function parse(array $tokens) {
    $iter = 0;
    return strval(parse_seq($tokens,$iter));
}

// Grab input from stdin and run it through the parser.
$str = trim(stream_get_contents(STDIN));
$tokens = preg_split('/([\(\)])/',$str,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
var_dump(parse($tokens));

I know this is a lot more code than a regex one-liner but it does solve the problem as I understand it. I'd be interested to know if anyone can solve this problem with a regular expression.


问:
How to call scanf inside int main(int argc, char *argv[])
I am trying to modify code from MercuryAPI SDK for RFID reader. The program suppose to work by taking some argument from the use and print some message depend on the user's input. However, the program does not allow me to declare new variable inside the main function.

```<code>int main(int argc, char *argv[])
</code>```

So, I tried to declare the variable as a global outside main function.

```<code>char c[1];
int main(int argc, char *argv[])
{
    //Code that already written from MercuryAPI SDK
    printf("\nEnter input: ");
    scanf("%c",c[0]);
    printf("\n%c", c[0]);
    if(*c == 'O'){
        printf("\nThe system is open");
    }
    else if(*c == 'X'){
        printf("\nThe system is unopen");
    }
}
</code>```

The declaration is succeed, but the program terminate write after I input an argument. Are there any solution for this?

答: The scanf("%c",c[0]); should be scanf("%c",c);

Body:
I am trying to modify code from MercuryAPI SDK for RFID reader. The program suppose to work by taking some argument from the use and print some message depend on the user's input. However, the program does not allow me to declare new variable inside the main function.

int main(int argc, char *argv[])

So, I tried to declare the variable as a global outside main function.

char c[1];
int main(int argc, char *argv[])
{
    //Code that already written from MercuryAPI SDK
    printf("\nEnter input: ");
    scanf("%c",c[0]);
    printf("\n%c", c[0]);
    if(*c == 'O'){
        printf("\nThe system is open");
    }
    else if(*c == 'X'){
        printf("\nThe system is unopen");
    }
}

The declaration is succeed, but the program terminate write after I input an argument. Are there any solution for this?


问:
File opening in Google Cloud with append
Generally I opened a file and write contents as

```<code>file_put_contents('data_file.txt', $data, FILE_APPEND | LOCK_EX);
</code>```

And I opened the same file is opened in google cloud local server as

```<code>file_put_contents("gs://${default_bucket}/data_file.txt", $data,);
</code>```

What is the condition to append in google cloud??

答:
As Jeff mentioned, there is no append. GCS does have composite objects which may work for you depending on your use case.

https://cloud.google.com/storage/docs/composite-objects

Body:
Generally I opened a file and write contents as

file_put_contents('data_file.txt', $data, FILE_APPEND | LOCK_EX);

And I opened the same file is opened in google cloud local server as

file_put_contents("gs://${default_bucket}/data_file.txt", $data,);

What is the condition to append in google cloud??


问:
why stderr fails to be redirected using the 2>&1 instruction? and how outputs are expected to work?
this fails stderr redirection:

(echo a >/dev/stdout;echo b >/dev/stderr) 2>&1 >test2.log;ls test2.log;cat test2.log

so, the above will output: "b" at terminal, and will log "a"

this fails to log stderr too:

(echo a >&1;echo b >&2) 2>&1 >test2.log;ls test2.log;cat test2.log

this vanishes with stdout and logs stderr:

(echo a >/dev/stdout;echo b >/dev/stderr) &>test2.log;ls test2.log;cat test2.log

this fully works:

(echo a >&1;echo b >&2) &>test2.log;ls test2.log;cat test2.log

is this some bug related to the way things should be outputted or I am missing some knowledge?

Obs.: I found this problem because I wasnt being able to log strace dosbox, this is NOT a dosbox question, this is just a comment to say that the origin of the problem was found on a non script application (could be any other application...), and I was able to replicate the problem on a command line terminal in a script way.

PS.: ubuntu 16.04.1 , bash 4.3.48(1)

答:
The key is to recognize that the shell first processes the redirections outside the subshell from left to write; the resulting file descriptors are then inherited by the subshell.

With this

```<code>(echo a >/dev/stdout;echo b >/dev/stderr) 2>&1 >test2.log
ls test2.log
cat test2.log
</code>```

The shell starts by processing 2>&1, which sends standard error to the same place as standard output (here, the terminal). The next redirection makes test2.log the standard output, without affecting standard error.

Now, the subshell inherits those file descriptors, so a is written to the inherited standard output (i.e., test2.log) and b is written to the inherited standard error (i.e., the terminal).

Body:
The key is to recognize that the shell first processes the redirections outside the subshell from left to write; the resulting file descriptors are then inherited by the subshell.

With this

(echo a >/dev/stdout;echo b >/dev/stderr) 2>&1 >test2.log
ls test2.log
cat test2.log

The shell starts by processing 2>&1, which sends standard error to the same place as standard output (here, the terminal). The next redirection makes test2.log the standard output, without affecting standard error.

Now, the subshell inherits those file descriptors, so a is written to the inherited standard output (i.e., test2.log) and b is written to the inherited standard error (i.e., the terminal).


问:
Laravel 5.4 - copy data from one table to another table, in same database
Is there any way to copy entire data from one table to another table?

Condition:
without making these data to retrieve from one table and storing to array than saving to another table.

Reason according to me:

running these entire database on localhost

there are nearly avg 100k rows

retrieving to array is costly with respect to memory (don't care) but time (important, as entire db on localhost which process slowly)

答:
To copy data from one table and also all the dependent objects of the table, you use the following statements:

```<code>CREATE TABLE IF NOT EXISTS new_table LIKE existing_table;

INSERT new_table
SELECT * FROM existing_table;
</code>```

From here: MySQL Copy Table With Examples

Body:
To copy data from one table and also all the dependent objects of the table, you use the following statements:

CREATE TABLE IF NOT EXISTS new_table LIKE existing_table;

INSERT new_table
SELECT * FROM existing_table;

From here: MySQL Copy Table With Examples


问:
Getting values from json arrays
I am trying to get data from https://api.kraken.com/0/public/OHLC?pair=XBTUSD&interval=1 to my database, but I'm having issues with the array.
I want to get the last datetime in unix, but it just doesnt work.

here is how I try to get the value, but it just seems to not be working:

```<code>var cur = body.length - 1;
var time = body.result.XXBTZUSD[cur][0];
</code>```

答:
Because </p>

```<code>// this one will return 1 because the length are 'error' and 'result'
var cur = body.length - 1;
</code>```

<p>You need to </p>

```<code>var cur = body.result.XXBTZUSD.length - 1;
var time = body.result.XXBTZUSD[cur][0];
</code>```

Title: Getting values from json arrays

Body:
I am trying to get data from https://api.kraken.com/0/public/OHLC?pair=XBTUSD&interval=1 to my database, but I'm having issues with the array.
I want to get the last datetime in unix, but it just doesnt work.

here is how I try to get the value, but it just seems to not be working:

var cur = body.length - 1;
var time = body.result.XXBTZUSD[cur][0];

Body:
Because

// this one will return 1 because the length are 'error' and 'result'
var cur = body.length - 1;

You need to

var cur = body.result.XXBTZUSD.length - 1;
var time = body.result.XXBTZUSD[cur][0];


问:
Add a div that is "not solid"
I am trying to explain myself as best as possible.

I have a
, in which I add other
s which the user can manipulate by dragging and resizing it (for this it uses JQuery libraries).  The problem comes when I add several divs (using append (html)); Let's say that the user drags the first detail of the position that he wants, then a second
 is added. (From here there is a problem.  If the first is divided into coordination 0, 0 and is 50px in height, the second
 appears in the coordinate 0, 51, which is not passed) and places it anywhere else... the second problem (heavier than the first) is that if you resize the first split, the second
 is affected; I explain, if it makes the first
 sea higher, and the second
 moves down, the same when the div becomes shorter.

I explain it with the following images, the
s are those of the black frame, the colored rectangles are a background image:

As you can see, there are three
s; The
 on the left was the last to join.

If we enlarge that last
 (left), then the other two
s also scroll down, as if the first
 pushed them although visually they are not in a row:

I know this has to do that for DOOM they are aligned one next to the other even if they are manipulated with JavaScript, but I would like to know if there is any way (with CSS or whatever) that the
s will not get in the way, that they will not be "solid", they will collapse or anything that will help me avoid that problem.

答:
Since you didn't include your code, I can only guess.

You should use position: absolute; to position the child divs. The parent div should be styled with position: relative;

Title: Add a div that is "not solid"


问:
Is there any shortcut to select entire code block in Atom similar to Option + Up Arrow in PhpStorm
Is there any shortcut to select entire code block in Atom similar to Option + Up Arrow in PhpStorm?

It helps you select the code block and if you press Option + Up Arrow again, it expands the selection to its parent block.

Is there any shortcut or plugin to have that feature? It makes it faster to work with heavy code.

答:
Yes! You want the expand-region plugin, it's great! Add these to your keymap.cson to expand the region with option-up (alt-up on windows) :

```<code>'atom-text-editor':
  'alt-up': 'expand-region:expand'
  'alt-down': 'expand-region:shrink'
</code>```

Body:
Yes! You want the expand-region plugin, it's great! Add these to your keymap.cson to expand the region with option-up (alt-up on windows) :

'atom-text-editor':
  'alt-up': 'expand-region:expand'
  'alt-down': 'expand-region:shrink'


问:
Error in string index out of range: maf file to fasta file
Context: I am trying to convert a maf file (multiple alignment file) to individual fasta file. I keep running into the same error that I'm not sure how to fix and this may be because I'm relatively new to python. My code is below:

```<code>open_file = open('C:/Users/Danielle/Desktop/Maf_file.maf','r')
for record in open_file:
    print(record[2:7])
    if (record[2] == 'Z'):
        new_file = open(record[2:7]+".fasta",'w')
        header = ">"+record[2:7]+"\n"
        sequence = record[46:len(record)]
        new_file.write(header)
        new_file.write(sequence)
        new_file.close()
    else:
        print("Not correct isolate.")
open_file.close()
</code>```

The error I get is:

```<code>IndexError
Traceback (most recent call last)
      2 for record in open_file:
      3     print(record[2:7])
----> 4     if (record[2] == 'Z'):
      5         new_file = open(record[2:7]+".fasta",'w')
      6         header = ">"+record[2:7]+"\n"
IndexError: string index out of range
</code>```

If I remove the if, else statement it works as I expect but I would like to filter for specific species that start with the character Z.

If anyone could help explain why I can't select for only strings that start with the character Z this way, that would be great! Thanks in advance.

答:
Here's an alternative answer.

The problem you're having is because the record you're reading might not have at least 3 chars. For that reason you have to check the length of the string before checking index 2. As you might have noticed, the line 3 doesn't crash.

Slice operator in short will slice from index 2 to 7 returning anything it finds.

So if you have let look at this:

```<code>"abcd"[1:] == "bcd"
"abcd"[1:3] == "bc"
"abcd"[1:10] == "bcd"
"abcd"[4:] == ""
</code>```

As you can see, it will return anything from index 1 to index 2 excluded. When it doesn't find anything the slice operation stop and return.

So one different way to get the same result as checking for the length would be to do this:

```<code>if (record[2:3] == 'Z'):
</code>```

This way, you're slicing the char at index 2, if the index exists it will return a char otherwise an empty string. That said, I can't say if the slice operation will be faster than checking the length of the string and getting the index then. In some ways, the slice operation does that internally most probably.

Body:
Context: I am trying to convert a maf file (multiple alignment file) to individual fasta file. I keep running into the same error that I'm not sure how to fix and this may be because I'm relatively new to python. My code is below:

open_file = open('C:/Users/Danielle/Desktop/Maf_file.maf','r')
for record in open_file:
    print(record[2:7])
    if (record[2] == 'Z'):
        new_file = open(record[2:7]+".fasta",'w')
        header = ">"+record[2:7]+"\n"
        sequence = record[46:len(record)]
        new_file.write(header)
        new_file.write(sequence)
        new_file.close()
    else:
        print("Not correct isolate.")
open_file.close()

The error I get is:

IndexError
Traceback (most recent call last)
      2 for record in open_file:
      3     print(record[2:7])
----> 4     if (record[2] == 'Z'):
      5         new_file = open(record[2:7]+".fasta",'w')
      6         header = ">"+record[2:7]+"\n"
IndexError: string index out of range

If I remove the if, else statement it works as I expect but I would like to filter for specific species that start with the character Z.

If anyone could help explain why I can't select for only strings that start with the character Z this way, that would be great! Thanks in advance.

Body:
Here's an alternative answer.

The problem you're having is because the record you're reading might not have at least 3 chars. For that reason you have to check the length of the string before checking index 2. As you might have noticed, the line 3 doesn't crash.

Slice operator in short will slice from index 2 to 7 returning anything it finds.

So if you have let look at this:

"abcd"[1:] == "bcd"
"abcd"[1:3] == "bc"
"abcd"[1:10] == "bcd"
"abcd"[4:] == ""

As you can see, it will return anything from index 1 to index 2 excluded. When it doesn't find anything the slice operation stop and return.

So one different way to get the same result as checking for the length would be to do this:

if (record[2:3] == 'Z'):

This way, you're slicing the char at index 2, if the index exists it will return a char otherwise an empty string. That said, I can't say if the slice operation will be faster than checking the length of the string and getting the index then. In some ways, the slice operation does that internally most probably.


问:
Tabindex in AngularJS directive
I have written a directive which produces a table including some rows. Each row has some drop-down list for selection and also some normal text areas to fill information.
The problem is, when I hit the tab key on Keyboard, the drop-down selections are ignored and not focused. The cursor jumps to the next text area. I tried to fix the problem with incremental tabindex attribute inside each column of rows, but still no difference.
Each column of each row is produced inside the directive by looping over an array using ng-repeat. Following produces a drop-down:

```<code><td><ng-select ng-model="oneRow.XItem" ng-options="opt.name as opt.name for opt in selections.XItemList| orderBy:'name'" cs-option-init=""></ng-select></td>
</code>```

Follwing produces a text area which is focused by pressing tab on keyboard.

```<code>  <td><ng-input ng-model="oneRow.YItem" ></ng-input></td>
</code>```

Please note all produced inside a directive NOT a static HTML.
The picture depicts the table. By hitting tab key, cursor jumps to next possible text area either in the same row or next row.

答:
Not precisely sure what behavior you are describing here.  However, by default your HTML will tab through properly formatted for fields from left-to-right before continuing to the next row.

Tab will allow the user to focus on the "next " form field, however, once a drop-down has focus, the arrow-up/down keys are used to select an option.  Once an option is selected, pressing tab again moves to the next form field.

If something is skipped, I would check your HTML syntax.

Even via angular, the DOM is the DOM.  If the syntax for your form fields is correct within the table, it will process correctly using tabs.

Non-anglar example because using angular should have zero effect on tabbing if you didn't force a tabindex:  https://codepen.io/KarsunJason/pen/KqeOYg

```<code><form>
<table style="width:75%">
  <tr>
    <td><select id="tableDropdown-useNgRepeatIndexHere0"><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option>
</select></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere1"><option value="volvo">mr</option><option value="saab">mrs</option><option value="mercedes">Sir</option><option value="audi">Madame</option>
</select></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere2"><option value="volvo">1</option><option value="saab">2</option><option value="mercedes">3</option><option value="audi">4</option>
</select></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere4"></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere5"></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere6"><option value="volvo">5555</option><option value="saab">4444</option><option value="mercedes">3333</option><option value="audi">2222</option>
</select></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere7"></td>
  </tr><tr>
    <td><select id="tableDropdown-useNgRepeatIndexHere8"><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option>
</select></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere9"><option value="volvo">mr</option><option value="saab">mrs</option><option value="mercedes">Sir</option><option value="audi">Madame</option>
</select></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere10"><option value="volvo">1</option><option value="saab">2</option><option value="mercedes">3</option><option value="audi">4</option>
</select></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere11"></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere12"></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere13"><option value="volvo">5555</option><option value="saab">4444</option><option value="mercedes">3333</option><option value="audi">2222</option>
</select></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere14"></td>
  </tr>

</table>
</form>
</code>```

Suggestions:
1) Check your form fields for proper syntax.
2) Either use tabindex="0" in each field (forces a tab stop within the natural order of the page) or remove tabindex entirely.

Title: Tabindex in AngularJS directive

Body:
I have written a directive which produces a table including some rows. Each row has some drop-down list for selection and also some normal text areas to fill information.
The problem is, when I hit the tab key on Keyboard, the drop-down selections are ignored and not focused. The cursor jumps to the next text area. I tried to fix the problem with incremental tabindex attribute inside each column of rows, but still no difference.
Each column of each row is produced inside the directive by looping over an array using ng-repeat. Following produces a drop-down:

<ng-select ng-model="oneRow.XItem" ng-options="opt.name as opt.name for opt in selections.XItemList| orderBy:'name'" cs-option-init=""></ng-select>

Follwing produces a text area which is focused by pressing tab on keyboard.

  <ng-input ng-model="oneRow.YItem" ></ng-input>

Please note all produced inside a directive NOT a static HTML.
The picture depicts the table. By hitting tab key, cursor jumps to next possible text area either in the same row or next row.

Body:
Not precisely sure what behavior you are describing here.  However, by default your HTML will tab through properly formatted for fields from left-to-right before continuing to the next row.

Tab will allow the user to focus on the "next " form field, however, once a drop-down has focus, the arrow-up/down keys are used to select an option.  Once an option is selected, pressing tab again moves to the next form field.

If something is skipped, I would check your HTML syntax.

Even via angular, the DOM is the DOM.  If the syntax for your form fields is correct within the table, it will process correctly using tabs.

Non-anglar example because using angular should have zero effect on tabbing if you didn't force a tabindex:  https://codepen.io/KarsunJason/pen/KqeOYg

<form>
<table style="width:75%">
  <tr>
    <td><select id="tableDropdown-useNgRepeatIndexHere0"><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option>
</select></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere1"><option value="volvo">mr</option><option value="saab">mrs</option><option value="mercedes">Sir</option><option value="audi">Madame</option>
</select></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere2"><option value="volvo">1</option><option value="saab">2</option><option value="mercedes">3</option><option value="audi">4</option>
</select></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere4"></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere5"></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere6"><option value="volvo">5555</option><option value="saab">4444</option><option value="mercedes">3333</option><option value="audi">2222</option>
</select></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere7"></td>
  </tr><tr>
    <td><select id="tableDropdown-useNgRepeatIndexHere8"><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option>
</select></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere9"><option value="volvo">mr</option><option value="saab">mrs</option><option value="mercedes">Sir</option><option value="audi">Madame</option>
</select></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere10"><option value="volvo">1</option><option value="saab">2</option><option value="mercedes">3</option><option value="audi">4</option>
</select></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere11"></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere12"></td>
    <td><select id="tableDropdown-useNgRepeatIndexHere13"><option value="volvo">5555</option><option value="saab">4444</option><option value="mercedes">3333</option><option value="audi">2222</option>
</select></td>
    <td><input id="tableDropdown-useNgRepeatIndexHere14"></td>
  </tr>

</table>
</form>

Suggestions:
1) Check your form fields for proper syntax.
2) Either use tabindex="0" in each field (forces a tab stop within the natural order of the page) or remove tabindex entirely.


问:
How do I detect CPU and Memory usage on android using Appcelerator?
I'm trying to detect the CPU speed, Usage Percentage, Memory, Memory usage in the Android device while using the app.
The application is being created in Appcelerator Studio.
I have read that I need to parse /proc/cpuinfo but I have no idea how to even detect the file.</p>

答: You could have a look at the JAVA code at https://stackoverflow.com/a/26242139/5193915 and use Hyperloop to access it. The module list at http://gitt.io/search?q=cpu doesn't list any module</p>


问:
Stylecop tells me to add this keyword, but it's redundant - any performance implications?
I use Stylecop for Resharper and whenever I call something in my class, Stylecop tells me to use the this keyword. But the IDE says this is redundant code (which it sure is), so why should I use the this keyword?

Does redundant code mean its not needed (obviously) and the compiler won't even do anything with the this keyword? So I assume the this keyword is just for clarity.

Also, with the CLR, do things like this fall consistently across languages? So if the answer is that the compiler doesn't even touch the this keyword and it is just for presentation and clarity, then the same is true for VB.NET? I assume it is all for clarity as stylecop keeps an eye on this and Fxcop (which I will use later on) keeps an eye on my code's quality from a technical point of view.

Thanks

答:
It's for clarity and to prevent any ambiguity between a class member and a local variable or parameter with the same name.

The IL it compiles to will not be any different.

OwnerDisplayName: GSS

OwnerDisplayName: Andrew Kennan

ContentLicense: CC BY-SA 2.5


问:
Links being acted on -- style in CSS or using JavaScript?
Should you use a:hover, a:active, a:visited and a:link, or similar javascript things (tags??) instead?</p>

答: Highly dependent on what you're trying to do. If a:active/:visited/:link/:hover provide sufficient styling control, use those as they work across browsers with or without JavaScript enabled. If you're trying to do something fancy that can't be accomplished with CSS, then use JavaScript. It's also common to mix the two techniques... Use CSS for the parts where you can and use JavaScript for everything else.</p>


问:
Minimal DFA for whole-words in regex
In creating a DFA for a regex, I have noticed that whole-words add to the number of states, even though analytically, they look similar to regex with fewer states.

For example, to me, (a|b)+ looks the same as (hello|world)+

If I had a matching string, it would be fairly easily to find/replace "hello" with "a" and "world" with "b" and viceversa. So my question is, why aren't "hello" and "world" counted as single states?

答:
Because DFAs are mind-numbingly simple to implement with the simpler definition of states, at the cost of having more states.  What you suggest is fine for describing how you want a DFA to work, and have a straight-forward correspondence to the traditional DFAs.  But it doesn't allow you to say anything more.

It is similar to the use of NFAs: they're easier to design and (maybe) think about, but have no more power, and there is a well-defined algorithm to translate them into DFAs (again, at the cost of introducing states).

Think of DFAs using single-character transitions as the "machine language" of regular expressions (which are NOT the same thing as regex, to get pedantic).

Title: Minimal DFA for whole-words in regex


问:
Regular expression for select unknown text in the line
I have a following strings:

```<code>static name p1SystemSignalAlarm_oid = {4.3.4.2.1}
static name p1SystemKfLinkNet_oid = {3.4.1.5.7}
</code>```

I need to get "Alarm" from first line and "Net" from second line.
I succeeded select SystemSignalAlarm_oid and I can select words that are needed by using strip. But it would be great if I can use one regular expression. How can I should select it?

答:
You seem to need the word between the last uppercase and the underscore. So:

```<code>([A-Z][a-z]*)_
</code>```

And then take group number 1, to ignore the underscore:

```<code>>>> re.search('([A-Z][a-z]*)_', 'p1SystemSignalAlarm_oid').group(1)
'Alarm'
>>> re.search('([A-Z][a-z]*)_', 'p1SystemKfLinkNet_oid).group(1)
'Net'
</code>```

Body:
I have a following strings:

static name p1SystemSignalAlarm_oid = {4.3.4.2.1}
static name p1SystemKfLinkNet_oid = {3.4.1.5.7}

I need to get "Alarm" from first line and "Net" from second line.
I succeeded select SystemSignalAlarm_oid and I can select words that are needed by using strip. But it would be great if I can use one regular expression. How can I should select it?

Body:
You seem to need the word between the last uppercase and the underscore. So:

([A-Z][a-z]*)_

And then take group number 1, to ignore the underscore:

>>> re.search('([A-Z][a-z]*)_', 'p1SystemSignalAlarm_oid').group(1)
'Alarm'
>>> re.search('([A-Z][a-z]*)_', 'p1SystemKfLinkNet_oid).group(1)
'Net'


问:
Assign shortcut to Visual Studio "Find All"
How can I assign a keyboard shortcut to the "Find All" button of the Quick Find function in Visual Studio 2013?

I can't find any command that would match this button next to the Edit.Find... commands:

答:
I found it is easiest to re-assign Edit.FindinFiles to Alt + F then use Alt + A to press Find All on that dialog box:

Highlight the text

Press Alt + F

Press Alt + A


问:
Jenkins JMeter Selenium JUnit test does not display browser
I have created a JMeter JUNIT Selenium test and have used Maven plugin to run that test. When I run my JMeter test from within the Java IDE it opens the browser. However, when I run the same test using Jenkins (running as a service) it does not display the browser. I was wondering if anybody is aware of this issue or have resolved this problem?</p>

答:
You need to run Jenkins service under account of the user which is currently logged in like:

```<code> Start -> Run -> services.msc -> find Jenkins service -> Properties -> Log On -> This account
</code>```

and provide your username along with credentials. This way you will be able to see the browser.

However if you don't experience issues with your test it might be better idea to run Jenkins under Local System Account so your test Selenium test could run headless, in this case you will be able to continue working while tests are running to save time.

Body:
You need to run Jenkins service under account of the user which is currently logged in like:

 Start -> Run -> services.msc -> find Jenkins service -> Properties -> Log On -> This account

and provide your username along with credentials. This way you will be able to see the browser.

However if you don't experience issues with your test it might be better idea to run Jenkins under Local System Account so your test Selenium test could run headless, in this case you will be able to continue working while tests are running to save time.


问:
Notifiy the user in a Thread
Code:

```<code>final ProgressDialog pd = ProgressDialog.show(Main.this,"","Loading. Please wait...", true);
pd.show();

Thread t = new Thread()
           {
               public void run()
               {
                   result = GetData("link", nameValuePairs);
                   pd.dismiss();
                   if(result.contains("Logged IN"))
                   {
                       user=etuser.getText().toString();
                   }
                   else
                   {
                       fail();
                   }
               }
           };
t.start();
</code>```

Fail Function:

```<code>public void  fail ()
{
    final TextView tverror = new TextView(this);
    tverror.setText("FAIL");
    linear_l.addView(tverror);
}
</code>```

Error: It isn't possible to add a view  during the run in the thread.

Is there any workaround?

答: Do not attempt to modify the UI from a background thread. Use onPostExecute() in an AsyncTask. Or, use a Handler. Or, use post() on any View. Or, use runOnUiThread().

Title: Notifiy the user in a Thread

Body:
Code:

final ProgressDialog pd = ProgressDialog.show(Main.this,"","Loading. Please wait...", true);
pd.show();

Thread t = new Thread()
           {
               public void run()
               {
                   result = GetData("link", nameValuePairs);
                   pd.dismiss();
                   if(result.contains("Logged IN"))
                   {
                       user=etuser.getText().toString();
                   }
                   else
                   {
                       fail();
                   }
               }
           };
t.start();

Fail Function:

public void  fail ()
{
    final TextView tverror = new TextView(this);
    tverror.setText("FAIL");
    linear_l.addView(tverror);
}

Error: It isn't possible to add a view  during the run in the thread.

Is there any workaround?


答:
This will find either Alarm or Net from your sample lines:

```<code>for item in lines:
    result = re.findall(r'([A-Z][a-z]+)_oid', item)
    print result[0]
</code>```

Title: Regular expression for select unknown text in the line

Body:
This will find either Alarm or Net from your sample lines:

for item in lines:
    result = re.findall(r'([A-Z][a-z]+)_oid', item)
    print result[0]


问:
How to call scanf inside int main(int argc, char *argv[])
I am trying to modify code from MercuryAPI SDK for RFID reader. The program suppose to work by taking some argument from the use and print some message depend on the user's input. However, the program does not allow me to declare new variable inside the main function.

```<code>int main(int argc, char *argv[])
</code>```

So, I tried to declare the variable as a global outside main function.

```<code>char c[1];
int main(int argc, char *argv[])
{
    //Code that already written from MercuryAPI SDK
    printf("\nEnter input: ");
    scanf("%c",c[0]);
    printf("\n%c", c[0]);
    if(*c == 'O'){
        printf("\nThe system is open");
    }
    else if(*c == 'X'){
        printf("\nThe system is unopen");
    }
}
</code>```

The declaration is succeed, but the program terminate write after I input an argument. Are there any solution for this?

答:
replace

```<code>scanf("%c",c[0]);
</code>```

with

```<code>scanf("%c",c);
</code>```

Also in your code, sometimes you use c[0] and sometimes *c:

```<code>printf("\n%c", c[0]);
if(*c == 'O'){
    printf("\nThe system is open");
}
else if(*c == 'X'){
    printf("\nThe system is unopen");
}
</code>```

I would suggest to be consistent about this and, e.g., replace:

```<code>printf("\n%c", c[0]);
</code>```

with

```<code>printf("\n%c", *c);
</code>```

Body:
replace

scanf("%c",c[0]);

with

scanf("%c",c);

Also in your code, sometimes you use c[0] and sometimes *c:

printf("\n%c", c[0]);
if(*c == 'O'){
    printf("\nThe system is open");
}
else if(*c == 'X'){
    printf("\nThe system is unopen");
}

I would suggest to be consistent about this and, e.g., replace:

printf("\n%c", c[0]);

with

printf("\n%c", *c);


问:
How to merge array inside foreach loop?
How to merge array inside foreach loop in php ? </p>

<p>Here is my Code: </p>

```<code>$subjects = $this->db->order_by('id','desc')->get_where('tbl_class_management', array('status'=>'1','teacher_id'=>$this->teacher->id))->result();
foreach ($subjects as $key => $s) {
   $std = $this->db->get_where('tbl_student', array('batch'=>$s->batch,'semester'=>$s->semester,'faculty'=>$s->faculty))->result();
debug($std);
}
</code>```

答:
The general formula for merging two arrays is as follows (merging $array_m into $array_o):

```<code>foreach($array_m as $key=>$value){
    $array_o[$key] = $value;
}
</code>```

$array_o would now contain all of the elements of $array_m

EDIT: I just noticed in your post that you seem to want to use the array_merge function. You could also do the following:

```<code>$array_o = array_merge($array_o, array_m);
</code>```

Title: How to merge array inside foreach loop?

Body:
How to merge array inside foreach loop in php ?

Here is my Code:

$subjects = $this->db->order_by('id','desc')->get_where('tbl_class_management', array('status'=>'1','teacher_id'=>$this->teacher->id))->result();
foreach ($subjects as $key => $s) {
   $std = $this->db->get_where('tbl_student', array('batch'=>$s->batch,'semester'=>$s->semester,'faculty'=>$s->faculty))->result();
debug($std);
}

Body:
The general formula for merging two arrays is as follows (merging $array_m into $array_o):

foreach($array_m as $key=>$value){
    $array_o[$key] = $value;
}

$array_o would now contain all of the elements of $array_m

EDIT: I just noticed in your post that you seem to want to use the array_merge function. You could also do the following:

$array_o = array_merge($array_o, array_m);


答:
The %c format specifier to scanf expects the address of a char.  You're passing in c[0] which is the value of a char.  Since c is global, all of its elements are initialized with the value 0.  This means you're passing in a NULL pointer to scanf, which it then attempts to dereference.  This invokes undefined behavior.

Change the scanf call to pass in the address of a char.  Also, change c to a single char instead of a single element array:

```<code>char c;
...
scanf("%c",&c);
printf("\n%c", c);
if(c == 'O'){
    printf("\nThe system is open");
}
else if(c == 'X'){
    printf("\nThe system is unopen");
}
</code>```

There's also no reason you shouldn't be able to define c inside of the main function, as long as the definition comes before any other statements.

Title: How to call scanf inside int main(int argc, char *argv[])

Body:
I am trying to modify code from MercuryAPI SDK for RFID reader. The program suppose to work by taking some argument from the use and print some message depend on the user's input. However, the program does not allow me to declare new variable inside the main function.

int main(int argc, char *argv[])

So, I tried to declare the variable as a global outside main function.

char c[1];
int main(int argc, char *argv[])
{
    //Code that already written from MercuryAPI SDK
    printf("\nEnter input: ");
    scanf("%c",c[0]);
    printf("\n%c", c[0]);
    if(*c == 'O'){
        printf("\nThe system is open");
    }
    else if(*c == 'X'){
        printf("\nThe system is unopen");
    }
}

The declaration is succeed, but the program terminate write after I input an argument. Are there any solution for this?

Body:
The %c format specifier to scanf expects the address of a char.  You're passing in c[0] which is the value of a char.  Since c is global, all of its elements are initialized with the value 0.  This means you're passing in a NULL pointer to scanf, which it then attempts to dereference.  This invokes undefined behavior.

Change the scanf call to pass in the address of a char.  Also, change c to a single char instead of a single element array:

char c;
...
scanf("%c",&c);
printf("\n%c", c);
if(c == 'O'){
    printf("\nThe system is open");
}
else if(c == 'X'){
    printf("\nThe system is unopen");
}

There's also no reason you shouldn't be able to define c inside of the main function, as long as the definition comes before any other statements.


问:
What is the glyphicons icon for resetting a form to its original values?
What is the glyphicons icon for resetting a form to its original values? I have looked at the cheat sheet, Bootstrap Glyphicons
The "glyphicon-refresh" icon is the closest one I see. </p>

Body:
You can search for icons here: http://glyphicons.com/

This might be what you're looking for: <span class="glyphicon glyphicon-repeat"></span>


问:
VBA AutoFilter with symbol (*) Not Working
I am trying to filter excel data using AutoFilter, but somehow it is not working.
The data I want to filter represent time and are in format of 00:00 through 23:59.
Specifically, I am trying to filter by the hour, so like "00" through "23", or "00:" through "23:", whichever works.
However, it is not working and none of them gets filtered.

Assuming there is a table like

|ID|Date| time |

| 0 | 7/5 | 00:00|

| 1 | 7/5 | 00:20|

| 2 | 7/5 | 00:35|

| 3 | 7/5 | 00:47|

| 4 | 7/5 | 00:58|

| 5 | 7/5 | 01:03|

| 6 | 7/5 | 01:15|

| 7 | 7/5 | 01:27|

| 8 | 7/5 | 01:48|

I tested the following macro:

```<code>Selection.Autofilter Field:=3, Criteria1:="=00*"
</code>```

hoping that I could get the top 5 rows of the data as their times begin with "00". I looked for information on how to set "start with" in AutoFilter, and I found that star (*) can be used. However, this does not work and none of the rows gets filtered.
Interestingly, if I tried the following:

```<code>Selection.Autofilter Field:=3, Criteria1:="00:20"
</code>```

it worked fine and it filtered the second row only where the time is "00:20".

Why is my first macro with * not working? I tried many different ways to no avail. Can someone tell me why this is not working?

答:
Excel treats time values as decimal numbers. One approach would be is to insert a helper column called "Hour" and put the following formula in D2

```<code>=HOUR(C2)
</code>```

and copy it down.

Now filter the data like below...

```<code>Range("$A$1:$D1").Autofilter Field:=4, Criteria1:="=0"
</code>```

Body:
I am trying to filter excel data using AutoFilter, but somehow it is not working.
The data I want to filter represent time and are in format of 00:00 through 23:59.
Specifically, I am trying to filter by the hour, so like "00" through "23", or "00:" through "23:", whichever works.
However, it is not working and none of them gets filtered.

Assuming there is a table like

|ID|Date| time |

| 0 | 7/5 | 00:00|

| 1 | 7/5 | 00:20|

| 2 | 7/5 | 00:35|

| 3 | 7/5 | 00:47|

| 4 | 7/5 | 00:58|

| 5 | 7/5 | 01:03|

| 6 | 7/5 | 01:15|

| 7 | 7/5 | 01:27|

| 8 | 7/5 | 01:48|

I tested the following macro:

Selection.Autofilter Field:=3, Criteria1:="=00*"

hoping that I could get the top 5 rows of the data as their times begin with "00". I looked for information on how to set "start with" in AutoFilter, and I found that star (*) can be used. However, this does not work and none of the rows gets filtered.
Interestingly, if I tried the following:

Selection.Autofilter Field:=3, Criteria1:="00:20"

it worked fine and it filtered the second row only where the time is "00:20".

Why is my first macro with * not working? I tried many different ways to no avail. Can someone tell me why this is not working?

Body:
Excel treats time values as decimal numbers. One approach would be is to insert a helper column called "Hour" and put the following formula in D2

=HOUR(C2)

and copy it down.

Now filter the data like below...

Range("$A$1:$D1").Autofilter Field:=4, Criteria1:="=0"


问:
Exporting a AWS Postgres RDS Table to AWS S3
I wanted to use AWS Data Pipeline to pipe data from a Postgres RDS to AWS S3. Does anybody know how this is done?

More precisely, I wanted to export a Postgres Table to AWS S3 using data Pipeline. The reason I am using Data Pipeline is I want to automate this process and this export is going to run once every week.

Any other suggestions will also work.

答:
I built a Pipeline from scratch using the MySQL and the documentation as reference.

You need to have the roles on place, DataPipelineDefaultResourceRole && DataPipelineDefaultRole.

I haven't load the parameters, so, you need to get into the architech and put your credentials and folders.

Hope it helps.

```<code>{
  "objects": [
    {
      "failureAndRerunMode": "CASCADE",
      "resourceRole": "DataPipelineDefaultResourceRole",
      "role": "DataPipelineDefaultRole",
      "pipelineLogUri": "#{myS3LogsPath}",
      "scheduleType": "ONDEMAND",
      "name": "Default",
      "id": "Default"
    },
    {
      "database": {
        "ref": "DatabaseId_WC2j5"
      },
      "name": "DefaultSqlDataNode1",
      "id": "SqlDataNodeId_VevnE",
      "type": "SqlDataNode",
      "selectQuery": "#{myRDSSelectQuery}",
      "table": "#{myRDSTable}"
    },
    {
      "*password": "#{*myRDSPassword}",
      "name": "RDS_database",
      "id": "DatabaseId_WC2j5",
      "type": "RdsDatabase",
      "rdsInstanceId": "#{myRDSId}",
      "username": "#{myRDSUsername}"
    },
    {
      "output": {
        "ref": "S3DataNodeId_iYhHx"
      },
      "input": {
        "ref": "SqlDataNodeId_VevnE"
      },
      "name": "DefaultCopyActivity1",
      "runsOn": {
        "ref": "ResourceId_G9GWz"
      },
      "id": "CopyActivityId_CapKO",
      "type": "CopyActivity"
    },
    {
      "dependsOn": {
        "ref": "CopyActivityId_CapKO"
      },
      "filePath": "#{myS3Container}#{format(@scheduledStartTime, 'YYYY-MM-dd-HH-mm-ss')}",
      "name": "DefaultS3DataNode1",
      "id": "S3DataNodeId_iYhHx",
      "type": "S3DataNode"
    },
    {
      "resourceRole": "DataPipelineDefaultResourceRole",
      "role": "DataPipelineDefaultRole",
      "instanceType": "m1.medium",
      "name": "DefaultResource1",
      "id": "ResourceId_G9GWz",
      "type": "Ec2Resource",
      "terminateAfter": "30 Minutes"
    }
  ],
  "parameters": [
  ]
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I built a Pipeline from scratch using the MySQL and the documentation as reference.

You need to have the roles on place, DataPipelineDefaultResourceRole && DataPipelineDefaultRole.

I haven't load the parameters, so, you need to get into the architech and put your credentials and folders.

Hope it helps.

{
  "objects": [
    {
      "failureAndRerunMode": "CASCADE",
      "resourceRole": "DataPipelineDefaultResourceRole",
      "role": "DataPipelineDefaultRole",
      "pipelineLogUri": "#{myS3LogsPath}",
      "scheduleType": "ONDEMAND",
      "name": "Default",
      "id": "Default"
    },
    {
      "database": {
        "ref": "DatabaseId_WC2j5"
      },
      "name": "DefaultSqlDataNode1",
      "id": "SqlDataNodeId_VevnE",
      "type": "SqlDataNode",
      "selectQuery": "#{myRDSSelectQuery}",
      "table": "#{myRDSTable}"
    },
    {
      "*password": "#{*myRDSPassword}",
      "name": "RDS_database",
      "id": "DatabaseId_WC2j5",
      "type": "RdsDatabase",
      "rdsInstanceId": "#{myRDSId}",
      "username": "#{myRDSUsername}"
    },
    {
      "output": {
        "ref": "S3DataNodeId_iYhHx"
      },
      "input": {
        "ref": "SqlDataNodeId_VevnE"
      },
      "name": "DefaultCopyActivity1",
      "runsOn": {
        "ref": "ResourceId_G9GWz"
      },
      "id": "CopyActivityId_CapKO",
      "type": "CopyActivity"
    },
    {
      "dependsOn": {
        "ref": "CopyActivityId_CapKO"
      },
      "filePath": "#{myS3Container}#{format(@scheduledStartTime, 'YYYY-MM-dd-HH-mm-ss')}",
      "name": "DefaultS3DataNode1",
      "id": "S3DataNodeId_iYhHx",
      "type": "S3DataNode"
    },
    {
      "resourceRole": "DataPipelineDefaultResourceRole",
      "role": "DataPipelineDefaultRole",
      "instanceType": "m1.medium",
      "name": "DefaultResource1",
      "id": "ResourceId_G9GWz",
      "type": "Ec2Resource",
      "terminateAfter": "30 Minutes"
    }
  ],
  "parameters": [
  ]
}


问:
[Error: EACCES: permission denied, open '/home/ubuntu/.hfc-key-store/
I am getting following error while running composer rest server. I am using aws ubuntu 16.04 server.

Hyperledger Composer

? Enter your Fabric Connection Profile Name: hlfv1

? Enter your Business Network Identifier : digitalproperty-network

? Enter your Fabric username : admin

? Enter your secret: Xurw3yU9zI0l

? Specify if you want namespaces in the generated REST API: never use namespaces

? Specify if you want the generated REST API to be secured: No

To restart the REST server using the same options, issue the following command:
   composer-rest-server -p hlfv1 -n digitalproperty-network -i admin -s Xurw3yU9zI0l -N never

Discovering types from business network definition ...

Connection fails: Error: error trying login and get user Context.
  Error: error trying to enroll user. Error: Failed to generate key for
  enrollment due to error [Error: EACCES: permission denied, open
  '/home/ubuntu/.hfc-key-store/be8405cef82cc00455de296664ccdcb35e4c707bb0e63a00d0bef76546528e13-priv']
  It will be retried for the next request. Error: error trying login and
  get user Context. Error: error trying to enroll user. Error: Failed to
  generate key for enrollment due to error [Error: EACCES: permission
  denied, open
  '/home/ubuntu/.hfc-key-store/be8405cef82cc00455de296664ccdcb35e4c707bb0e63a00d0bef76546528e13-priv']
      at client.getUserContext.then.then.catch (/home/ubuntu/.nvm/versions/node/v6.11.0/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:293:34)
  ubuntu@ip-172-31-19-220:~/composer-sample-networks/packages/digitalproperty-network$

答:
On the similar set up, I could able to work with following command, basically use PeerAdmin user instead of admin. For example:

```<code>composer-rest-server -p hlfv1 -n my-network -i PeerAdmin -s PeerAdmin -N never
</code>```

If you still face same issue, try with sudo

Body:
On the similar set up, I could able to work with following command, basically use PeerAdmin user instead of admin. For example:

composer-rest-server -p hlfv1 -n my-network -i PeerAdmin -s PeerAdmin -N never

If you still face same issue, try with sudo


问:
Retrieving Root Mean Square Error for each regression model in a dataframe
I have created a model shown here for daily data:

```<code>myts <- ts(data[2], frequency = 7)
fit <- auto.arima(myts)
</code>```

The output looks like this:

```<code>Series: myts
ARIMA(2,1,1)(2,0,0)[7]

Coefficients:
         ar1      ar2      ma1    sar1    sar2
      0.2874  -0.0422  -0.9349  0.0015  0.1397
s.e.  0.0586   0.0598   0.0293  0.0546  0.0812

sigma^2 estimated as 39.71:  log likelihood=-1188.2
AIC=2388.4   AICc=2388.63   BIC=2411.8

Training set error measures:
                     ME     RMSE      MAE       MPE     MAPE      MASE         ACF1
Training set -0.1423045 6.250017 3.605002 -2.910684 11.96048 0.7200852 -0.000295024
</code>```

How do I obtain a dataframe of just the training set error measures.

In the end, let's say I have 5 different models, I want the final output to look like this dataframe:

```<code>                  Model Type         RMSE
      ARIMA(2,1,1)(2,0,0)[7]         6.25
Regression with ARIMA(0,0,1)     6.054298
                  ETS(M,N,M)     6.647029
Regression with ARIMA(1,0,0)     5.993514
Regression with ARIMA(1,1,1)     6.135232
</code>```

答:
Try using the accuracy function. Then extract the value from the RMSE to build your data.frame. Without a working example it's hard to give more of an answer.

```<code>> accuracy(fit)
                    ME     RMSE      MAE       MPE     MAPE      MASE        ACF1
Training set 0.3035616 3.113754 2.405275 0.2805566 1.917463 0.5315228 -0.01715517

> accuracy(fit)[2]
[1] 3.113754
</code>```

Body:
I have created a model shown here for daily data:

myts <- ts(data[2], frequency = 7)
fit <- auto.arima(myts)

The output looks like this:

Series: myts
ARIMA(2,1,1)(2,0,0)[7]

Coefficients:
         ar1      ar2      ma1    sar1    sar2
      0.2874  -0.0422  -0.9349  0.0015  0.1397
s.e.  0.0586   0.0598   0.0293  0.0546  0.0812

sigma^2 estimated as 39.71:  log likelihood=-1188.2
AIC=2388.4   AICc=2388.63   BIC=2411.8

Training set error measures:
                     ME     RMSE      MAE       MPE     MAPE      MASE         ACF1
Training set -0.1423045 6.250017 3.605002 -2.910684 11.96048 0.7200852 -0.000295024

How do I obtain a dataframe of just the training set error measures.

In the end, let's say I have 5 different models, I want the final output to look like this dataframe:

                  Model Type         RMSE
      ARIMA(2,1,1)(2,0,0)[7]         6.25
Regression with ARIMA(0,0,1)     6.054298
                  ETS(M,N,M)     6.647029
Regression with ARIMA(1,0,0)     5.993514
Regression with ARIMA(1,1,1)     6.135232

Body:
Try using the accuracy function. Then extract the value from the RMSE to build your data.frame. Without a working example it's hard to give more of an answer.

> accuracy(fit)
                    ME     RMSE      MAE       MPE     MAPE      MASE        ACF1
Training set 0.3035616 3.113754 2.405275 0.2805566 1.917463 0.5315228 -0.01715517

> accuracy(fit)[2]
[1] 3.113754


问:
Angular 4 + Jest-Preset-Angular : testing animation on host with trigger imported from file
I am having an issue issue when running tests with Jest-Preset-Angular on a component that has an animation on host element imported from a seperate file (so it can be reused in another component).

example.animation.ts

import { trigger } from '@angular/animations';

export const ExampleAnimationHost = { '[@example]': '' };
export const ExampleAnimationTrigger = trigger('example', []);
```

<p><strong>example.component.ts</strong></p>

<pre class="lang-js prettyprint-override"><code>import { Component } from '@angular/core';
import { ExampleAnimationHost, ExampleAnimationTrigger } from './example.animation';

@Component({
  selector: 'app-example',
  templateUrl: './example.component.html',
  styleUrls: ['./example.component.scss'],
  animations: [ExampleAnimationTrigger],
  host: ExampleAnimationHost,
})
export class ExampleComponent { }
</code>```

The fact is that if I copy-paste the trigger into the animations property of the @Component decorator my test pass ... otherwise it fails as it doesn't seems to find the animation declaration.

Any ideas?

答:
I will answer my own question if any body ever have the same problem.

There is an issue here specifying that you need to put the animations property before the styleUrls property in the @Component decorator.

import { Component } from '@angular/core';
import { ExampleAnimationHost, ExampleAnimationTrigger } from './example.animation';

@Component({
  animations: [ExampleAnimationTrigger], // must be place before styleUrls
  host: ExampleAnimationHost,
  selector: 'app-example',
  templateUrl: './example.component.html',
  styleUrls: ['./example.component.scss'],
})
export class ExampleComponent { }
```

And voila!

Body:
I am having an issue issue when running tests with Jest-Preset-Angular on a component that has an animation on host element imported from a seperate file (so it can be reused in another component).

example.animation.ts

import { trigger } from '@angular/animations';

export const ExampleAnimationHost = { '[@example]': '' };
export const ExampleAnimationTrigger = trigger('example', []);

example.component.ts

import { Component } from '@angular/core';
import { ExampleAnimationHost, ExampleAnimationTrigger } from './example.animation';

@Component({
  selector: 'app-example',
  templateUrl: './example.component.html',
  styleUrls: ['./example.component.scss'],
  animations: [ExampleAnimationTrigger],
  host: ExampleAnimationHost,
})
export class ExampleComponent { }

The fact is that if I copy-paste the trigger into the animations property of the @Component decorator my test pass ... otherwise it fails as it doesn't seems to find the animation declaration.

Any ideas?

Body:
I will answer my own question if any body ever have the same problem.

There is an issue here specifying that you need to put the animations property before the styleUrls property in the @Component decorator.

import { Component } from '@angular/core';
import { ExampleAnimationHost, ExampleAnimationTrigger } from './example.animation';

@Component({
  animations: [ExampleAnimationTrigger], // must be place before styleUrls
  host: ExampleAnimationHost,
  selector: 'app-example',
  templateUrl: './example.component.html',
  styleUrls: ['./example.component.scss'],
})
export class ExampleComponent { }

And voila!


问:
Running a linux subprocess in python script
I need to show coloured diff of two text files on linux from my python script, for which I am using vimdiff. I am able to run vimdiff using subprocess but I cant get control back to python script. It stays in the vimdiff mode forever until I do Ctrl+Z.
What i want to do is that open vimdiff and get back to python script after receiving some kind of input from the keyboard. I tried signal module too but couldnt solve the problem.

I am a beginner in python so far what I tried is here:

```<code>import subprocess
p = subprocess.Popen(["vimdiff","test1.txt", "test2.txt"])
try:
 p.wait()
except KeyboardInterrupt:
 p.kill()
</code>```

Any help will be appreciated

答:
As I known vim uses ncurses library.
For run ncurses based application use module pexpect:</p>

```<code>import pexpect
child = pexpect.spawn("vim")
child.interact()
</code>```

Body:
I need to show coloured diff of two text files on linux from my python script, for which I am using vimdiff. I am able to run vimdiff using subprocess but I cant get control back to python script. It stays in the vimdiff mode forever until I do Ctrl+Z.
What i want to do is that open vimdiff and get back to python script after receiving some kind of input from the keyboard. I tried signal module too but couldnt solve the problem.

I am a beginner in python so far what I tried is here:

import subprocess
p = subprocess.Popen(["vimdiff","test1.txt", "test2.txt"])
try:
 p.wait()
except KeyboardInterrupt:
 p.kill()

Any help will be appreciated

Body:
As I known vim uses ncurses library.
For run ncurses based application use module pexpect:

import pexpect
child = pexpect.spawn("vim")
child.interact()


问:
How to display "Registered Successfull" Message in android
Any one can tell me how to display this Message in Android.
Registered Successfully
Click To view Image</p>

答:
I believe you should use a custom Toast.

Create a layout resource file. My resource file is named toast.xml, but name it whatever you want. Find an image of the green check, and save it to your app's drawable folder.

toast.xml

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="#FFF" >

<ImageView android:id="@+id/image"
    android:contentDescription="Green check mark"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/green_check_mark"/>

<TextView android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:textColor="#FF8B8B8B"
    android:text="Registered Successfully"/>
</code>```

In your MainActivity.java

```<code>public void showCustomToast(String message) {
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.toast,
            (ViewGroup) findViewById(R.id.toast_layout));
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(message);
    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);
    toast.show();
}
</code>```

Just call showCustomToast("Registered Successfully) to show the Toast. Hope this helps.

Body:
I believe you should use a custom Toast.

Create a layout resource file. My resource file is named toast.xml, but name it whatever you want. Find an image of the green check, and save it to your app's drawable folder.

toast.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="#FFF" >

<ImageView android:id="@+id/image"
    android:contentDescription="Green check mark"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/green_check_mark"/>

<TextView android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:textColor="#FF8B8B8B"
    android:text="Registered Successfully"/>

In your MainActivity.java

public void showCustomToast(String message) {
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.toast,
            (ViewGroup) findViewById(R.id.toast_layout));
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(message);
    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);
    toast.show();
}

Just call showCustomToast("Registered Successfully) to show the Toast. Hope this helps.


问:
Managing Azure Search 503
Is there a well-known pattern to manage the ServiceUnavailable ?
I'm NOT so happy with something like this

```<code>catch (CloudException e) when (System.Net.HttpStatusCode.ServiceUnavailable.Equals(e.Response?.StatusCode))
{
    var howMuchWait = TimeSpan.FromMinutes(1);
    if (e.Response.Headers.TryGetValue("Retry-After", out var hValue))
    {
        if(RetryConditionHeaderValue.TryParse(hValue.FirstOrDefault(), out var time) && time.Delta.HasValue)
        {
            howMuchWait = time.Delta.Value;
        }
    }
    logger.LogWarning(() => $"Service Unavailable... Let him rest a bit, I will wait for {howMuchWait}.");
    await Task.Delay(howMuchWait);
    return indexEntities.Select(x => (string)x[indexKeyFieldName]).ToList();
}
</code>```

This code simply delay the current call to it but does not prevent calls from other threads.
Now I'm implementing something different using a Stopwatch and I would like to know if there is a well-known pattern.
NOTE: everything using the SDK.

答:
When managing for 503's, it is best to implement more of an incremental back-off mechanism as opposed to a fixed time delay.  For example, start with 1 second, then 2, then 4, then 8, etc...  The key reason for this, is if you are sending a lot of work to Azure Search, it is best to let it catch up as opposed to continually trying to send more work to it.

By the way, for others reading this, sometimes you might think that is a good idea to add partitions while you are seeing these 503's (typically for mass uploads) to give more resources, when in fact, this can cause more 503's as this is more work the service needs to do to configure the partitions.  If you do think you need more partitions it would be best to do this before you do the work and then scale down afterwards, if needed.

Also, another side note is that if you leveraged the Azure Search .NET SDK, retry is already integrated.  Bruce, has some good information on this here: Azure Search RetryPolicy

Title: Managing Azure Search 503

Body:
Is there a well-known pattern to manage the ServiceUnavailable ?
I'm NOT so happy with something like this

catch (CloudException e) when (System.Net.HttpStatusCode.ServiceUnavailable.Equals(e.Response?.StatusCode))
{
    var howMuchWait = TimeSpan.FromMinutes(1);
    if (e.Response.Headers.TryGetValue("Retry-After", out var hValue))
    {
        if(RetryConditionHeaderValue.TryParse(hValue.FirstOrDefault(), out var time) && time.Delta.HasValue)
        {
            howMuchWait = time.Delta.Value;
        }
    }
    logger.LogWarning(() => $"Service Unavailable... Let him rest a bit, I will wait for {howMuchWait}.");
    await Task.Delay(howMuchWait);
    return indexEntities.Select(x => (string)x[indexKeyFieldName]).ToList();
}

This code simply delay the current call to it but does not prevent calls from other threads.
Now I'm implementing something different using a Stopwatch and I would like to know if there is a well-known pattern.
NOTE: everything using the SDK.


问:
Read mnist images into Tensorflow
I was looking at this Tensorflow tutorial.

In the tutorial the images are magically read like this:

```<code>mnist = learn.datasets.load_dataset("mnist")
train_data = mnist.train.images
</code>```

My images are placed in two directories:

```<code>../input/test/
../input/train/
</code>```

They all have a *.jpg ending.

So how can read them into my program?

I don't think I can use learn.datasets.load_dataset because this seems to take in a specialized dataset structure, while I only have folders with images.

答:
mnist.train.images is essentially a numpy array of shape [55000, 784]. Where, 55000 is the number of images and 784 is the number of pixels in each image (each image is 28x28)

You need to create a similar numpy array from your data in case you want to run this exact code. So, you'll need to iterate over all your images, read image as a numpy array, flatten it and create a matrix of size [num_examples, image_size]

The following code snippet should do it:

```<code>import os
import cv2
import numpy as np
def load_data(img_dir):
    return np.array([cv2.imread(os.path.join(img_dir, img)).flatten() for img in os.listdir(img_dir) if img.endswith(".jpg")])
</code>```

A more comprehensive code to enable debugging:

```<code>import os
list_of_imgs = []
img_dir = "../input/train/"
for img in os.listdir("."):
    img = os.path.join(img_dir, img)
    if not img.endswith(".jpg"):
        continue
    a = cv2.imread(img)
    if a is None:
        print "Unable to read image", img
        continue
    list_of_imgs.append(a.flatten())
train_data = np.array(list_of_imgs)
</code>```

Note:
If your images are not 28x28x1 (B/W images), you will need to change the neural network architecture (defined in cnn_model_fn). The architecture in the tutorial is a toy architecture which only works for simple images like MNIST. Alexnet may be a good place to start for RGB images.

Title: Read mnist images into Tensorflow

Body:
I was looking at this Tensorflow tutorial.

In the tutorial the images are magically read like this:

mnist = learn.datasets.load_dataset("mnist")
train_data = mnist.train.images

My images are placed in two directories:

../input/test/
../input/train/

They all have a *.jpg ending.

So how can read them into my program?

I don't think I can use learn.datasets.load_dataset because this seems to take in a specialized dataset structure, while I only have folders with images.

Body:
mnist.train.images is essentially a numpy array of shape [55000, 784]. Where, 55000 is the number of images and 784 is the number of pixels in each image (each image is 28x28)

You need to create a similar numpy array from your data in case you want to run this exact code. So, you'll need to iterate over all your images, read image as a numpy array, flatten it and create a matrix of size [num_examples, image_size]

The following code snippet should do it:

import os
import cv2
import numpy as np
def load_data(img_dir):
    return np.array([cv2.imread(os.path.join(img_dir, img)).flatten() for img in os.listdir(img_dir) if img.endswith(".jpg")])

A more comprehensive code to enable debugging:

import os
list_of_imgs = []
img_dir = "../input/train/"
for img in os.listdir("."):
    img = os.path.join(img_dir, img)
    if not img.endswith(".jpg"):
        continue
    a = cv2.imread(img)
    if a is None:
        print "Unable to read image", img
        continue
    list_of_imgs.append(a.flatten())
train_data = np.array(list_of_imgs)

Note:
If your images are not 28x28x1 (B/W images), you will need to change the neural network architecture (defined in cnn_model_fn). The architecture in the tutorial is a toy architecture which only works for simple images like MNIST. Alexnet may be a good place to start for RGB images.


问:
How do you combine two arrays in such a way that the two are equally distributed?
It is way easier to give an example than to explain it with words.
Starting with 2 arrays:

{a,a,a,a,a,a,a} and {b,b,b}

I would like the output to be:

{a,a,b,a,a,b,a,a,b,a}

With a little help I found the following:

```<code>    let result = [];
    let ratio = array1.length / array2.length;
    let pushA = 0;
    while (array2.length >0) {
        pushA+= ratio;
        while (pushA >= 1){
            result.push(array1.pop());
            pushA--;
        }
        result.push(array2.pop());

    }

    return result;
</code>```

答:
For simple application, you may find size of both arrays. For example suppose size of fist array is M and size of second array is N. Also suppose M>=N ( If not you may interchange both arrays ).

Now, you may easily find total elements of First array to be inserted before inserting one element from Second array , which is equal to: M/N ( = K,say ).

So, while merging, you may insert K elements from First array then one element from Second array and so on untill elements exists in both arrays.

Body:
It is way easier to give an example than to explain it with words.
Starting with 2 arrays:

{a,a,a,a,a,a,a} and {b,b,b}

I would like the output to be:

{a,a,b,a,a,b,a,a,b,a}

With a little help I found the following:

    let result = [];
    let ratio = array1.length / array2.length;
    let pushA = 0;
    while (array2.length >0) {
        pushA+= ratio;
        while (pushA >= 1){
            result.push(array1.pop());
            pushA--;
        }
        result.push(array2.pop());

    }

    return result;


问:
What CSS selector do I need here?
I'm trying to center the title text on my Alert control. I'm using the following CSS right now:

```<code>mx|Alert{
  text-align: center;
}
</code>```

The problem is that the above code centers my alert content as well, not just the title text. What selector do I need to access just the title of the alert control?

Edit:

I'm using the 4.x SDK and Spark.

Code:

Alert.Show();

答: Take a look at titleStyleName.  </p>

Title: What CSS selector do I need here?

Body:
I'm trying to center the title text on my Alert control. I'm using the following CSS right now:

mx|Alert{
  text-align: center;
}

The problem is that the above code centers my alert content as well, not just the title text. What selector do I need to access just the title of the alert control?

Edit:

I'm using the 4.x SDK and Spark.

Code:

Alert.Show();

Body: Take a look at titleStyleName.


问:
Optaplanner select only entities in conflict
In the change and swap move selector, I would like to only consider moves that involve entities in conflict as they are more likely to improve the heuristic score.

How should this be done? What classes and interfaces do I have to reuse/extend? I looked at ScoreDirector and PhaseLifecycleListener.

答:
A MoveFilter might do that (if it's not in phase or solver cached as it changes ever step). See the course scheduling example and docs for how to use a filter.

I wouldn't recommend it though, as you still want to move non-conflicting entities at times. You might just want to focus more on those conflicting lectures. So I would keep a vanilla move selector in the mix.

The move filter isn't perfect either - the Guided Local Search feature (not yet available) is a better way to deal with this.

However, given the other question about the model and similar cases I 've seen, I 'd say moves are not your problem. A better model will make all these kinds of move tweaking obsolete.


问:
Laravel 5.4 - copy data from one table to another table, in same database
Is there any way to copy entire data from one table to another table?

Condition:
without making these data to retrieve from one table and storing to array than saving to another table.

Reason according to me:

running these entire database on localhost

there are nearly avg 100k rows

retrieving to array is costly with respect to memory (don't care) but time (important, as entire db on localhost which process slowly)

答:
```<code>$results = DB::select( DB::raw("CREATE TABLE tbl_new AS SELECT * FROM tbl_old;'") );
</code>```

I believe you will get what you want.

comment on this answer if you need more info

Body:
$results = DB::select( DB::raw("CREATE TABLE tbl_new AS SELECT * FROM tbl_old;'") );

I believe you will get what you want.

comment on this answer if you need more info


问:
Access Ribbon in PowerPoint using interop
I'm wondering is it possible to access the ribbon and it buttons(elements) in PowerPoint using interop. I've searched online and all I can find is answers for if it's your own addin.

I thought I may have been able to access it like this but it's not what I'm looking for

```<code>foreach (Microsoft.Office.Core.CommandBar bar in pptApp.CommandBars)
        {
            Console.WriteLine(bar.Name + "   " + bar.Id);
        }
</code>```

答:
Yes, it is possible!

Here is a MSDN walkthough: https://msdn.microsoft.com/en-us/library/bb608593.aspx

Here is the list of all the existing Office controls (is also found in the MSDN walkthough): https://www.microsoft.com/en-us/download/details.aspx?id=6627

Body:
I'm wondering is it possible to access the ribbon and it buttons(elements) in PowerPoint using interop. I've searched online and all I can find is answers for if it's your own addin.

I thought I may have been able to access it like this but it's not what I'm looking for

foreach (Microsoft.Office.Core.CommandBar bar in pptApp.CommandBars)
        {
            Console.WriteLine(bar.Name + "   " + bar.Id);
        }


问:
Allow only letters, numbers, and hyphen in input?
I want to accept only letters, numbers, and hyphen (dash) in the input. in php, i do this:

```<code>if(!preg_match("/^[A-Za-z0-9-]+$/", $input)) {
    echo "Only letters, numbers, and hyphens are allowed.";
}
</code>```

how can I achieve this same thing in vanilla javascript? if its not possible in pure javascript, how can i do it in jquery? thanks

答:
You can start a new regex using /{criteria}/{flags}. Your regex would translate to something like this:

```<code>/^[aA-zZ0-9-]+$/g.test(/* value to test here*/)
</code>```

Body:
I want to accept only letters, numbers, and hyphen (dash) in the input. in php, i do this:

if(!preg_match("/^[A-Za-z0-9-]+$/", $input)) {
    echo "Only letters, numbers, and hyphens are allowed.";
}

how can I achieve this same thing in vanilla javascript? if its not possible in pure javascript, how can i do it in jquery? thanks

Body:
You can start a new regex using /{criteria}/{flags}. Your regex would translate to something like this:

/^[aA-zZ0-9-]+$/g.test(/* value to test here*/)


问:
LdapFilter not accepting Parentheses
I need to match an AD contact using an email address pulled from a csv.  I am currently having an issue getting the ldapfilter to accept parenthesis.

Currently this works:

```<code>Get-ADObject -LDAPFilter "objectClass=contact" -SearchBase "OU=PLACE,OU=CONTACTS,DC=WORK,DC=COM"
</code>```

But this does not

```<code>Get-ADObject -LDAPFilter (objectClass=contact) -SearchBase "OU=PLACE,OU=CONTACTS,DC=WORK,DC=COM"
</code>```

And I don't know why

答:
LDAPFilter requires a string value; just enclose the filter you want in quotes so that PowerShell knows to parse it as a string and doesn't try to evaluate it as additional script content:</p>

```<code>Get-ADObject -LDAPFilter "(objectClass=contact)" -SearchBase "OU=PLACE,OU=CONTACTS,DC=WORK,DC=COM"
</code>```

Title: LdapFilter not accepting Parentheses

Body:
I need to match an AD contact using an email address pulled from a csv.  I am currently having an issue getting the ldapfilter to accept parenthesis.

Currently this works:

Get-ADObject -LDAPFilter "objectClass=contact" -SearchBase "OU=PLACE,OU=CONTACTS,DC=WORK,DC=COM"

But this does not

Get-ADObject -LDAPFilter (objectClass=contact) -SearchBase "OU=PLACE,OU=CONTACTS,DC=WORK,DC=COM"

And I don't know why

Body:
LDAPFilter requires a string value; just enclose the filter you want in quotes so that PowerShell knows to parse it as a string and doesn't try to evaluate it as additional script content:

Get-ADObject -LDAPFilter "(objectClass=contact)" -SearchBase "OU=PLACE,OU=CONTACTS,DC=WORK,DC=COM"


问:
huawei ascend (m860) not recognized by adb on mac
I am trying to use a Huawei Ascend (m860) (this particular model from Cricket Mobile) as a low-end Android test device. I've already turned USB Debugging on from the device. I plug it into my Mac, run "./adb devices" from terminal and there are no devices listed.

Has anyone successfully connected this device to a Mac for Android development?

My setup:

Mac OSX 10.6.5

Eclipse 3.5.2 with the Android ADT plugin 0.9.9

Android Debug Bridge version 1.0.26

Thanks!

答:
According to the thread at XDA-Developers forum and another thread at androidforums, you can't use adb with it because of some sort of lock.

You are probably better off rooting your phone first then installing Wireless ADB.

Also, for further questions on this you would probably want to ask on those forums (XDA-Developers and androidforums).


问:
How to limit class animations to clicked elements and their content
I know this question has been asked and answered, but here is a slightly more complicated situation. I have a list of cards, all set to animate once clicked. Of course the animation is created by using the toggleClass() command and the initial problem was that if i Clicked one card, all of them animated. This was easily fixed by using the $(this) statement. However, I then decided to add content to the cards, that would display only once the card is clicked. I thought this would be affected by the $(this) statement too, but it is not and now when I click a card, that card animates but the content of other cards is displayed too.

$(".card").click(function() {
  $(this).toggleClass("transform-active");
  $(".disappear").toggleClass("appear");
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>/* CARDS SECTION */

.cards {
  display: block;
  position: absolute;
  width: 100%;
  top: 60px;
  list-style: none;
  text-decoration: none;
  z-index: -1;
}

.cards li {
  display: block;
  position: relative;
  width: 100%;
  padding-bottom: 10px;
}

.card {
  position: relative;
  background-color: #ffffff;
  height: 150px;
  width: 100%;
  left: -5%;
  border-radius: 8px;
  box-shadow: 2px 2px 2px #686868;
  cursor: pointer;
}

/* CARDS CONTENT SECTION */

#containText {
  position: absolute;
  width: 76%;
  color: #58a7dd;
  top: -2px;
  left: 90px;
  text-align: justify;
}

#containText p {
  position: absolute;
  top: 30px;
}

.face {
  position: relative;
  height: 70px;
  width: 70px;
  top: 10px;
  left: 10px;
  border: solid #58a7dd;
  background-color: white;
  border-radius: 50%;
  color: #58a7dd;
}

.face h2 {
  position: relative;
  left: 3px;
  top: 20px;
  transform: rotate(90deg);
}

.extra {
  position: relative;
  width: 90%;
  top: 7px;
  margin: auto;
  color: #2f4f4f;
}

.disappear {
  position: relative;
  width: 90%;
  height: 40%;
  top: 5px;
  margin: auto;
  color: #2f4f4f;
  opacity: 0;
}

.appear {
  animation: appear 1.2s ease;
  animation-fill-mode: forwards;
}

@keyframes appear {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.transform {
  -webkit-transition: all 0.2s ease;
  -moz-transition: all 0.2s ease;
  -o-transition: all 0.2s ease;
  -ms-transition: all 0.2s ease;
  transition: all 0.2s ease;
}

.transform-active {
  background-color: #ffffff;
  height: 300px;
  width: 100%;
  box-shadow: 6px 6px 6px #888888;
}</code>```

: )

HI! I am a card.

Click me to trigger the animation.

Here is some extra info about the items on this card, such as stuff, things and blah.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

TWO

THREE

FOUR

FIVE

SIX

```

CodePen with working example: https://codepen.io/BGGrieco/pen/PjOevR

答:
You need to change:

```<code>$(".card").click(function() {
  $(this).toggleClass("transform-active");
  $(".disappear").toggleClass("appear");
});
</code>```

to:

```<code>$(".card").click(function()
{
  $(this).toggleClass("transform-active");
  $(this).find(".disappear").toggleClass("appear");
});
</code>```

That way you will only target the
 element with a class of .disappear in the current clicked element.

$(".card").click(function() {
  $(this).toggleClass("transform-active");
  $(this).find(".disappear").toggleClass("appear");
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.cards
{

  margin: 0;
  padding: 0;
  list-style: none;
  text-decoration: none;
}

.cards li
{
  width: 100%;
  padding-bottom: 10px;
}

.card
{
  background-color: #ffffff;
  height: 150px;
  width: 100%;
  padding: 6px 12px;
  border-radius: 8px;
  box-shadow: 2px 2px 2px #686868;
  cursor: pointer;
}

/* CARDS CONTENT SECTION */
#containText
{
  position: absolute;
  width: 76%;
  color: #58a7dd;
  top: -2px;
  left: 120px;
  text-align: justify;
}

#containText p
{
  position: absolute;
  top: 30px;
}

.face
{
  height: 70px;
  width: 70px;
  border: solid #58a7dd;
  background-color: white;
  border-radius: 50%;
  color: #58a7dd;
}

.face h2
{
  position: relative;
  left: 3px;
  top: 20px;
  transform: rotate(90deg);
}

.extra
{
  position: relative;
  width: 90%;
  top: 7px;
  margin: auto;
  color: #2f4f4f;
}

.disappear
{
  position: relative;
  width: 90%;
  height: 40%;
  top: 5px;
  margin: auto;
  color: #2f4f4f;
  opacity: 0;
}

.appear
{
  animation: appear 1.2s ease;
  animation-fill-mode: forwards;
}

@keyframes appear
{
  0%
  {
    opacity: 0;
  }
  100%
  {
    opacity: 1;
  }
}

.transform
{
  -webkit-transition: all 0.2s ease;
  -moz-transition: all 0.2s ease;
  -o-transition: all 0.2s ease;
  -ms-transition: all 0.2s ease;
  transition: all 0.2s ease;
}

.transform-active
{
  background-color: #ffffff;
  height: 300px;
  width: 100%;
  box-shadow: 6px 6px 6px #888888;
}</code>```

: )

HI! I am a card.

Click me to trigger the animation.

Here is some extra info about the items on this card, such as stuff,                    things and blah.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim                    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea                commodo consequat.

TWO

THREE

FOUR

FIVE

SIX

```

Body:
I know this question has been asked and answered, but here is a slightly more complicated situation. I have a list of cards, all set to animate once clicked. Of course the animation is created by using the toggleClass() command and the initial problem was that if i Clicked one card, all of them animated. This was easily fixed by using the $(this) statement. However, I then decided to add content to the cards, that would display only once the card is clicked. I thought this would be affected by the $(this) statement too, but it is not and now when I click a card, that card animates but the content of other cards is displayed too.

$(".card").click(function() {
  $(this).toggleClass("transform-active");
  $(".disappear").toggleClass("appear");
});

/* CARDS SECTION */

.cards {
  display: block;
  position: absolute;
  width: 100%;
  top: 60px;
  list-style: none;
  text-decoration: none;
  z-index: -1;
}

.cards li {
  display: block;
  position: relative;
  width: 100%;
  padding-bottom: 10px;
}

.card {
  position: relative;
  background-color: #ffffff;
  height: 150px;
  width: 100%;
  left: -5%;
  border-radius: 8px;
  box-shadow: 2px 2px 2px #686868;
  cursor: pointer;
}

/* CARDS CONTENT SECTION */

#containText {
  position: absolute;
  width: 76%;
  color: #58a7dd;
  top: -2px;
  left: 90px;
  text-align: justify;
}

#containText p {
  position: absolute;
  top: 30px;
}

.face {
  position: relative;
  height: 70px;
  width: 70px;
  top: 10px;
  left: 10px;
  border: solid #58a7dd;
  background-color: white;
  border-radius: 50%;
  color: #58a7dd;
}

.face h2 {
  position: relative;
  left: 3px;
  top: 20px;
  transform: rotate(90deg);
}

.extra {
  position: relative;
  width: 90%;
  top: 7px;
  margin: auto;
  color: #2f4f4f;
}

.disappear {
  position: relative;
  width: 90%;
  height: 40%;
  top: 5px;
  margin: auto;
  color: #2f4f4f;
  opacity: 0;
}

.appear {
  animation: appear 1.2s ease;
  animation-fill-mode: forwards;
}

@keyframes appear {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.transform {
  -webkit-transition: all 0.2s ease;
  -moz-transition: all 0.2s ease;
  -o-transition: all 0.2s ease;
  -ms-transition: all 0.2s ease;
  transition: all 0.2s ease;
}

.transform-active {
  background-color: #ffffff;
  height: 300px;
  width: 100%;
  box-shadow: 6px 6px 6px #888888;
}

: )

HI! I am a card.

Click me to trigger the animation.

Here is some extra info about the items on this card, such as stuff, things and blah.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

TWO

THREE

FOUR

FIVE

SIX

CodePen with working example: https://codepen.io/BGGrieco/pen/PjOevR

Body:
You need to change:

$(".card").click(function() {
  $(this).toggleClass("transform-active");
  $(".disappear").toggleClass("appear");
});

to:

$(".card").click(function()
{
  $(this).toggleClass("transform-active");
  $(this).find(".disappear").toggleClass("appear");
});

That way you will only target the <div> element with a class of .disappear in the current clicked element.

$(".card").click(function() {
  $(this).toggleClass("transform-active");
  $(this).find(".disappear").toggleClass("appear");
});

.cards
{

  margin: 0;
  padding: 0;
  list-style: none;
  text-decoration: none;
}

.cards li
{
  width: 100%;
  padding-bottom: 10px;
}

.card
{
  background-color: #ffffff;
  height: 150px;
  width: 100%;
  padding: 6px 12px;
  border-radius: 8px;
  box-shadow: 2px 2px 2px #686868;
  cursor: pointer;
}

/* CARDS CONTENT SECTION */
#containText
{
  position: absolute;
  width: 76%;
  color: #58a7dd;
  top: -2px;
  left: 120px;
  text-align: justify;
}

#containText p
{
  position: absolute;
  top: 30px;
}

.face
{
  height: 70px;
  width: 70px;
  border: solid #58a7dd;
  background-color: white;
  border-radius: 50%;
  color: #58a7dd;
}

.face h2
{
  position: relative;
  left: 3px;
  top: 20px;
  transform: rotate(90deg);
}

.extra
{
  position: relative;
  width: 90%;
  top: 7px;
  margin: auto;
  color: #2f4f4f;
}

.disappear
{
  position: relative;
  width: 90%;
  height: 40%;
  top: 5px;
  margin: auto;
  color: #2f4f4f;
  opacity: 0;
}

.appear
{
  animation: appear 1.2s ease;
  animation-fill-mode: forwards;
}

@keyframes appear
{
  0%
  {
    opacity: 0;
  }
  100%
  {
    opacity: 1;
  }
}

.transform
{
  -webkit-transition: all 0.2s ease;
  -moz-transition: all 0.2s ease;
  -o-transition: all 0.2s ease;
  -ms-transition: all 0.2s ease;
  transition: all 0.2s ease;
}

.transform-active
{
  background-color: #ffffff;
  height: 300px;
  width: 100%;
  box-shadow: 6px 6px 6px #888888;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul id="cardList" class="cards">
    <li><div class="card transform">
      <div class="face"><h2>: )</h2></div>
        <div id="containText">
          <h3>HI! I am a card.</h3><br>
          <p>Click me to trigger the animation.</p>
        </div>
        <div class="extra">
          <p>Here is some extra info about the items on this card, such as stuff,                    things and blah.</p>
        </div>
        <div class="disappear">
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim                    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea                commodo consequat.</p>
        </div>
        </div>
    </li>
    <li><div class="card transform">TWO</div></li>
    <li><div class="card transform">THREE</div></li>
    <li><div class="card transform">FOUR</div></li>
    <li><div class="card transform">FIVE</div></li>
    <li><div class="card transform">SIX</div></li>
  </ul>


问:
Netbeans 8.2 execution not stopping at the break point
I am using a Netbeans 8.2 for a Netbeans module application in java.
Netbeans debugging was working fine until now. But currently I am facing problem in debugging the application. The set break point is not getting displayed in the breakpoint window and the execution also does not stop at the break point.

My netbeans breakpoint window :

答: Try to install Netbeans version 8.0.2, I've encountered a similar problem and problems of freezing on startup, opening projects whilst using Netbeans 8.2 , but after I installed the version I mentioned, I have no problem till now.</p>


问:
What event is triggered when a e-mail is opened in preview pane?
I'm using code like this to catch the open event from an e-mail, but this only fires when you actually double click on an e-mail. Is there a way to also run the code when the e-mail is opened in the preview pane?

```<code>Public WithEvents myItem As Outlook.MailItem
Public EventsDisable As Boolean

Private Sub Application_ItemLoad(ByVal Item As Object)
    If EventsDisable = True Then Exit Sub
    If Item.Class = olMail Then
        Set myItem = Item
    End If
End Sub

Private Sub myItem_Open(Cancel As Boolean)
    EventsDisable = True
    'do something
    EventsDisable = False
End Sub
</code>```

Thanks.

答: That would be the Explorer.SelectionChange event: https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/explorer-selectionchange-event-outlook.</p>

Body:
I'm using code like this to catch the open event from an e-mail, but this only fires when you actually double click on an e-mail. Is there a way to also run the code when the e-mail is opened in the preview pane?

Public WithEvents myItem As Outlook.MailItem
Public EventsDisable As Boolean

Private Sub Application_ItemLoad(ByVal Item As Object)
    If EventsDisable = True Then Exit Sub
    If Item.Class = olMail Then
        Set myItem = Item
    End If
End Sub

Private Sub myItem_Open(Cancel As Boolean)
    EventsDisable = True
    'do something
    EventsDisable = False
End Sub

Thanks.