问:
Unity Resources.Load <Sprite> return null
Yes, I have read all the topics with similar problems.
However mine is not solved yet :(

So could you please take a look into it?

Like everyone else, I'm trying to change a sprite of an object via code.
The sprite file itself is in "Assets/Resourses" folder.
The import settings state the texture type of the imported file is "Sprite(2D and UI)".

I've tried the following methods:

```<code>gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("1");
</code>```

and

```<code>gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load("1") as Sprite;
</code>```

and

```<code>Sprite s = Resources.Load("1") as Sprite;
gameObject.GetComponent<SpriteRenderer>().sprite = s;
</code>```

and

```<code>Sprite s = Resources.Load<Sprite>("1");
gameObject.GetComponent<SpriteRenderer>().sprite = s;
</code>```

All of them replace existing object sprite with "None(Sprite)", which I guess, means "null".

Any help would be really appreciated!

答:
The sprite file itself is in "Assets/Resourses" folder.

That's the problem. The folder must be named Resources not Resourses. It's not Resource too.

It has to be named named Resources. Once you fix the folder name, you can use the snippet below to read the Sprite.

```<code>Sprite sprite = Resources.Load("1", typeof(Sprite)) as Sprite;
</code>```

if the sprite is set to multiple mode then use this;

```<code>Sprite[] sprite = Resources.LoadAll<Sprite>("1") as Sprite[];
</code>```

You can find other ways to load Sprites here.

Body:
Yes, I have read all the topics with similar problems.
However mine is not solved yet :(

So could you please take a look into it?

Like everyone else, I'm trying to change a sprite of an object via code.
The sprite file itself is in "Assets/Resourses" folder.
The import settings state the texture type of the imported file is "Sprite(2D and UI)".

I've tried the following methods:

gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("1");

and

gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load("1") as Sprite;

and

Sprite s = Resources.Load("1") as Sprite;
gameObject.GetComponent<SpriteRenderer>().sprite = s;

and

Sprite s = Resources.Load<Sprite>("1");
gameObject.GetComponent<SpriteRenderer>().sprite = s;

All of them replace existing object sprite with "None(Sprite)", which I guess, means "null".

Any help would be really appreciated!

Body:
The sprite file itself is in "Assets/Resourses" folder.

That's the problem. The folder must be named Resources not Resourses. It's not Resource too.

It has to be named named Resources. Once you fix the folder name, you can use the snippet below to read the Sprite.

Sprite sprite = Resources.Load("1", typeof(Sprite)) as Sprite;

if the sprite is set to multiple mode then use this;

Sprite[] sprite = Resources.LoadAll<Sprite>("1") as Sprite[];

You can find other ways to load Sprites here.


来源: stackexchange

问:
amout of write line instaces vary depending on YVAL variable
I have a mesurement that could be any random value, just for fun well make that 2440mm i need to divde that by the industry standard of 610mm which comes out at 2440 / 610 = 4

Programicaly written NEWVAL = YVAL / STDVAL

NEWVAL (4) gives me refrence to how many instances I want to append a new line in a txt file I know that I want the first line to say 0,0,0 and the second line to say 0,610,0 the third 0,1220,0 the fourth 0,1830,0 and the last 0,2440,0, though this is easily achived with addition how can I automate vb.net to produce a new write line for each each instace of 610 if the YVAL is user defind.

Put in simple terms half would be missing if the YVAL variable  is double in length at 4880mm

答:
You mean something like this?</p>

```<code>    Dim YVAL = 2440                                     ''Measurement
    Dim STDVAL = 610                                    ''Standard value
    Dim NEWVAL = YVAL \ STDVAL                          ''Force integer division
    For I = 0 To YVAL Step STDVAL                       ''Loop through each item
        Trace.WriteLine(String.Format("0,{0},0", I))    ''Output
    Next
</code>```

ContentLicense: CC BY-SA 2.5

Body:
You mean something like this?

    Dim YVAL = 2440                                     ''Measurement
    Dim STDVAL = 610                                    ''Standard value
    Dim NEWVAL = YVAL \ STDVAL                          ''Force integer division
    For I = 0 To YVAL Step STDVAL                       ''Loop through each item
        Trace.WriteLine(String.Format("0,{0},0", I))    ''Output
    Next


问:
Avoid <> with default template class/struct in C++
Suppose

```<code>template<class T>
struct S{
    T x;
    a(T xx){x=xx;}
};
</code>```

and that we wish to ease the most common use by more than just a default specialization wishing to omit the empty angle brackets. One could reach for typedef

```<code>typedef S<int> defaut_S;
default_S(1);
</code>```

but here the consistency is broken in a way, as default_S has a different name than S, and can cause confusion with the user. Not to mention that it won't work for member functions.

Is there a better way to accomplish this?

答:
Use the instantiator function pattern.</p>

```<code>template <class T>
struct S
{
  T x;
  void a(T xx) { x = xx; }
};

template <class T=int>
S<T> make_s() { return S<T>(); }

int main()
{
  auto s = make_s();
  auto t = make_s<double>();
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Suppose

template<class T>
struct S{
    T x;
    a(T xx){x=xx;}
};

and that we wish to ease the most common use by more than just a default specialization wishing to omit the empty angle brackets. One could reach for typedef

typedef S<int> defaut_S;
default_S(1);

but here the consistency is broken in a way, as default_S has a different name than S, and can cause confusion with the user. Not to mention that it won't work for member functions.

Is there a better way to accomplish this?

Body:
Use the instantiator function pattern.

template <class T>
struct S
{
  T x;
  void a(T xx) { x = xx; }
};

template <class T=int>
S<T> make_s() { return S<T>(); }

int main()
{
  auto s = make_s();
  auto t = make_s<double>();
}


问:
How to read a csv file as series instead of dataframe in pandas?
When I try to use  x = pandas.Series.from_csv('File_name.csv', header = None)
It throws an error saying IndexError: single positional indexer is out-of-bounds.

However, If I read it as dataframe and then extract series, it works fine.
x = pandas.read_csv('File_name.csv', header = None)[0]

What could be wrong with first method?

答:
Add index_col=None parameter, seems it is reading entire file in one column and default first column is treated as index.

Pandas documentation says Series.from_csv is discouraged. read_csv is much more powerful alternative you should use that.


问:
BST nodes are not saving when trying to create a preorder traversal of a previous tree in c
I am trying to see if tree A is the preorder traversal of tree B and to do so, I created two trees which during a transversal were supposed to save the values. However, after hours of debugging I found out that the trees values were ALWAYS 0. I am confused as to why the trees values are 0. I've done a multitude of print statements (some of which I've left in the code posted below) and I just cannot seem to pinpoint why this is happening. Can someone please nudge me in the correct direction? I thought maybe the function was deleting variables as it exited and in effort to get to the bottom of the issue I had the preorder function return the tree ( as seen below), however, the output is ALWAYS 0 for the tree.

Code:

```<code>typedef struct node
{
    // Each node holds a single integer.
    int data;

    // Pointers to the node's left and right children.
    struct node *left, *right;
} node;
int tree_diff(node *a, node *b)
{
    if (a == NULL && b == NULL)
        return 0;

    else if (a == NULL || b == NULL)
        return 1;

    else if (a->data != b->data)
        return 1;
    printf("A %d , B %d", a->data, b->data);

        return tree_diff(a->left, b->left) || tree_diff(a->right, b->right);
}

node *preorder_recursive(node *root, node *A)
{
    if (root == NULL)
        return A;

    printf("root %d ", root->data);
    A = root;
    printf("= data %d\n", A->data);
    preorder_recursive(root->left, A->left);
    preorder_recursive(root->right, A->right);
}

void postorder_recursive(node *root, node *B)
{
    if (root == NULL)
        return;
    B = root;
    postorder_recursive(root->left, B->left);
    postorder_recursive(root->right, B->right);
    printf("root %d ", root->data);
    printf("= data %d\n", B->data);
}

int kindredSpirits(node *a, node *b)
{

  // Get the preorder of a
  node *A = malloc(sizeof(node));
  A = preorder_recursive(a, A);

  // Get the postorder of b
  printf("\n\n");
  node *B = malloc(sizeof(node));
  postorder_recursive(b, B);

if(tree_diff(A,B) == 1)
  return 0;
else
  return 1;
}
</code>```

The test case:

```<code>#include <stdio.h>
#include <stdlib.h>
#include "KindredSpirits.h"
  node *create_node(int data)
{
    node *n = malloc(sizeof(node));

    n->data = data;
    n->left = n->right = NULL;

    return n;
}

node *forest_fire(node *root)
{
    if (root == NULL)
        return NULL;

    forest_fire(root->left);
    forest_fire(root->right);
    free(root);
}

int main(void)
{
    node *root;

    root = create_node(23);
    root->left = create_node(12);
    root->left->left = create_node(5);
    root->left->right = create_node(18);
    root->right = create_node(71);
    root->right->right = create_node(56);

    printf("%s\n", !kindredSpirits(root, root) ? "Success!" : "fail whale :(");

    forest_fire(root);

    return 0;
}
</code>```

答:
I'm trying to write a function that figures out if tree a's preorder is equal to tree b's postorder without altering a or b.

I use arrays to save the traversals and then compare the value of the two arrays.

```<code>#define MAX_TREE_SIZE 100

void preorder_recursive(node *root, int* arr, int *len) {
  if (root != NULL){
    arr[(*len)++] = root->data;
    preorder_recursive(root->left, arr, len);
    preorder_recursive(root->right, arr, len);
  }
}

void postorder_recursive(node *root, int *arr, int *len) {
  if (root != NULL){
   postorder_recursive(root->left, arr, len);
   postorder_recursive(root->right, arr, len);
   arr[(*len)++] = root->data;
  }
}

int kindredSpirits(node *a, node *b){

 // Get the preorder of a
 int *arr1 = malloc(MAX_TREE_SIZE * sizeof(int));
 int len1 = 0;
 preorder_recursive(a, arr1, &len1);

 // Get the postorder of b
 int *arr2 = malloc(MAX_TREE_SIZE * sizeof(int));
 int len2 = 0;
 postorder_recursive(b, arr2, &len2);

 int ret = 0; // 2 traversals are equal
 if (len1 != len2) {
    ret = 1;
 } else {
   for (int i = 0; i < len1; i++){
     if (arr1[i] != arr2[i]){
       ret = 1;
       break;
     }
   }
 }

 free(arr1);
 free(arr2);
 return ret;
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am trying to see if tree A is the preorder traversal of tree B and to do so, I created two trees which during a transversal were supposed to save the values. However, after hours of debugging I found out that the trees values were ALWAYS 0. I am confused as to why the trees values are 0. I've done a multitude of print statements (some of which I've left in the code posted below) and I just cannot seem to pinpoint why this is happening. Can someone please nudge me in the correct direction? I thought maybe the function was deleting variables as it exited and in effort to get to the bottom of the issue I had the preorder function return the tree ( as seen below), however, the output is ALWAYS 0 for the tree.

Code:

typedef struct node
{
    // Each node holds a single integer.
    int data;

    // Pointers to the node's left and right children.
    struct node *left, *right;
} node;
int tree_diff(node *a, node *b)
{
    if (a == NULL && b == NULL)
        return 0;

    else if (a == NULL || b == NULL)
        return 1;

    else if (a->data != b->data)
        return 1;
    printf("A %d , B %d", a->data, b->data);

        return tree_diff(a->left, b->left) || tree_diff(a->right, b->right);
}

node *preorder_recursive(node *root, node *A)
{
    if (root == NULL)
        return A;

    printf("root %d ", root->data);
    A = root;
    printf("= data %d\n", A->data);
    preorder_recursive(root->left, A->left);
    preorder_recursive(root->right, A->right);
}

void postorder_recursive(node *root, node *B)
{
    if (root == NULL)
        return;
    B = root;
    postorder_recursive(root->left, B->left);
    postorder_recursive(root->right, B->right);
    printf("root %d ", root->data);
    printf("= data %d\n", B->data);
}

int kindredSpirits(node *a, node *b)
{

  // Get the preorder of a
  node *A = malloc(sizeof(node));
  A = preorder_recursive(a, A);

  // Get the postorder of b
  printf("\n\n");
  node *B = malloc(sizeof(node));
  postorder_recursive(b, B);

if(tree_diff(A,B) == 1)
  return 0;
else
  return 1;
}

The test case:

#include <stdio.h>
#include <stdlib.h>
#include "KindredSpirits.h"
  node *create_node(int data)
{
    node *n = malloc(sizeof(node));

    n->data = data;
    n->left = n->right = NULL;

    return n;
}

node *forest_fire(node *root)
{
    if (root == NULL)
        return NULL;

    forest_fire(root->left);
    forest_fire(root->right);
    free(root);
}

int main(void)
{
    node *root;

    root = create_node(23);
    root->left = create_node(12);
    root->left->left = create_node(5);
    root->left->right = create_node(18);
    root->right = create_node(71);
    root->right->right = create_node(56);

    printf("%s\n", !kindredSpirits(root, root) ? "Success!" : "fail whale :(");

    forest_fire(root);

    return 0;
}

Body:
I'm trying to write a function that figures out if tree a's preorder is equal to tree b's postorder without altering a or b.

I use arrays to save the traversals and then compare the value of the two arrays.

#define MAX_TREE_SIZE 100

void preorder_recursive(node *root, int* arr, int *len) {
  if (root != NULL){
    arr[(*len)++] = root->data;
    preorder_recursive(root->left, arr, len);
    preorder_recursive(root->right, arr, len);
  }
}

void postorder_recursive(node *root, int *arr, int *len) {
  if (root != NULL){
   postorder_recursive(root->left, arr, len);
   postorder_recursive(root->right, arr, len);
   arr[(*len)++] = root->data;
  }
}

int kindredSpirits(node *a, node *b){

 // Get the preorder of a
 int *arr1 = malloc(MAX_TREE_SIZE * sizeof(int));
 int len1 = 0;
 preorder_recursive(a, arr1, &len1);

 // Get the postorder of b
 int *arr2 = malloc(MAX_TREE_SIZE * sizeof(int));
 int len2 = 0;
 postorder_recursive(b, arr2, &len2);

 int ret = 0; // 2 traversals are equal
 if (len1 != len2) {
    ret = 1;
 } else {
   for (int i = 0; i < len1; i++){
     if (arr1[i] != arr2[i]){
       ret = 1;
       break;
     }
   }
 }

 free(arr1);
 free(arr2);
 return ret;
}


问:
Mobile live geolocation
Im trying to get my Iphones live location to show on a map on my website.

Is there a way to acomplish this easily using HTML5 Geolocation or is it better to use  Google Maps Geolocation API, or some other library?

Thanks.

答:
At HyperTrack we have an SDK which you can plugin to your app in as little as 3 lines of code and automatically enable location tracking in your application and view (for free) on our Dashboard. In our Sandbox mode (read: Test Mode) you can track and assign actions for up to 20 users for free as well. This mode also gives you an Action Widget that you can embed anywhere to see the activity of your user(s)/device(s).

For iOS you can visit our iOS Integration Guide.

Title: Mobile live geolocation


问:
Use PowerShell to stop 'Default Web Site' in IIS6
I've done several Google searches and can't find a good sample to stop/start the 'Default Web Site' (in II6) using PowerShell.

This...

```<code>$server = "localhost"
$siteName = "default web site"
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer"
        -AND $_.ServerComment -eq $siteName }
</code>```

from here got me started, but I can't get the 'start'/'stop' syntax right.

答:
Check the serverState property. A value of 2 means running and a value of 3 means stopped, you can set them this way:

start the website

$site.serverState = 2

$site.setInfo()

stop the website

$site.serverState = 3

$site.setInfo()

OwnerDisplayName: MattH

Body:
I've done several Google searches and can't find a good sample to stop/start the 'Default Web Site' (in II6) using PowerShell.

This...

$server = "localhost"
$siteName = "default web site"
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer"
        -AND $_.ServerComment -eq $siteName }

from here got me started, but I can't get the 'start'/'stop' syntax right.

LastEditorDisplayName: MattH

OwnerDisplayName: Shay Levy


问:
electron, after browserify, fs.existsSync is not a function
i read a lot about browserify and electron and the gui browser issue
yet there is still a problem with  browserify, saying "fs.existsSync is not a function", and "required is not defined"

* The full story*
i created simple gui with electron   ,
there are the package.json file, the main.js and the index.html file + 3,4 html files, where there i want to create simple "load show save window" that work with require

That feature worked in the index.html file yet doesn't work properly in the load.html file, so i browserify the main.js with the commands

var  fs = require('electron')
//console.log(require('fs').existsSync);
var remote = require('electron').remote;
//  var remote = require('remote');
var dialog = require('electron').remote ```
</div>
</div>
 </p>

<p>into main.bundle3.js, with, (in the cmd)</p>

```browserify main.js > main.bundle3.js
```

<p>yet then the load.html file shouted that require is not define and    </p>

```> main.bundle3.js:6945 Uncaught TypeError: fs.existsSync is not a function
    at Object.<anonymous> (main.bundle3.js:6945)
    at Object.require.36.fs (main.bundle3.js:6951)
    at s (main.bundle3.js:1)
    at main.bundle3.js:1
    at Object.<anonymous> (main.bundle3.js:6794)
    at Object.require.35._process (main.bundle3.js:6937)
    at s (main.bundle3.js:1)
    at e (main.bundle3.js:1)
    at main.bundle3.js:1
(anonymous) @   main.bundle3.js:6945
require.36.fs   @   main.bundle3.js:6951
s   @   main.bundle3.js:1
(anonymous) @   main.bundle3.js:1
(anonymous) @   main.bundle3.js:6794
require.35._process @   main.bundle3.js:6937
s   @   main.bundle3.js:1
e   @   main.bundle3.js:1
(anonymous) @   main.bundle3.js:1
```

<p>The package.json</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>{
  "name": "RDF",
  "version": "0.1.0",
  "main": "main.js",
  "scripts": {
    "test": "mocha -u exports -R spec test/index"
  },
  "devDependencies": {
    "electron": "^1.6.2",
    "electron-packager": "^8.6.0",
    "html-browserify": "0.0.6",
    "jquery": "^3.2.1"
  }
}</code>```

 and load.html file

<!DOCTYPE html>

    <meta charset="UTF-8">

LOAD

load the data

            <input type="text" placeholder="just select a file" id="actual-file" disabled="disabled"/>
            <input type="button" value="Choose a file" id="select-file"/>

        <textarea id="content-editor" rows="5"></textarea>

        <input type="button" id="save-changes" value="Save changes"/>
        <input type="button" id="delete-file" value="Delete file"/>

  he file content will be the same as the editor.

        <input type="button" value="Choose a file" id="create-new-file"/>

```
</div>
</div>
</p>

<p>the the main.js file in full</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>//console.log(require('fs'));
console.log(require('module').globalPaths);
const {
  electron
} = require('electron');
const {
  BrowserWindow
} = require('electron')
const {
  app
} = require('electron');
//  @show(app)
const path = require('path')
//console.log( process.env.PATH);
// (D:\electron-v1.6.1-win32-x64\resources\default_app.asr\main.js:325:5)
 //const BrowserWindow = require('browser-window')
const url = require('url')
var html = require('html-browserify');
var fs = require('electron')
//console.log(require('fs').existsSync);
var remote = require('electron').remote;
//  var remote = require('remote');
var dialog = require('electron').remote
//dialog = require('electron').dialog
//dialog =remote.require('dialog')

//var load_=require('./load_.js')
// broserify html
var through = require('through');
var htmlclean = require('htmlclean');

module.exports = function(file, options) {

  options = options || {};
  options.htmlclean =
   typeof options.htmlclean !== 'undefined'
      ?      options.htmlclean : true;

  var buffer = '';

  if (!/\.(tpl|html)/.test(file)) {

    return through();

  } else {

    return through(function(chunk) {

      return buffer += chunk.toString();

    }, function() {

      var jst = buffer.toString();

      if (options.htmlclean) {
        //options.htmlclean is truthy

        if (typeof options.htmlclean === 'object') {
          //options.htmlclean is an options object for the htmlclean module
          jst = htmlclean(jst, options.htmlclean);
        } else {
          //otherwise, clean using default options
          jst = htmlclean(jst);
        }
      }

      var compiled = 'module.exports = ';
      compiled += JSON.stringify(jst);
      compiled += ';\n';

      this.queue(compiled);
      return this.queue(null);

    });

  }

}
//requirejs.config({
//By default load any module IDs from js/lib
//  baseUrl: 'js/lib',
//except, if the module ID starts with "app",
//load it from the js/app directory. paths
//config is relative to the baseUrl, and
//never includes a ".js" extension since
//the paths config could be for a directory.
//paths: {
//  app: '  '
//}
//});

// Start the main app logic.
//requirejs(['jquery', 'canvas', 'app/sub'],
//function   ($,        canvas,   sub) {
//jQuery, canvas and the app/sub module are all
//loaded and can be used here now.
//});
//const fs = require('fs');
//const app = require('electron').app.
//const remote = require('electron').remote;

// be closed automatically when the JavaScript object is garbage collected.
let win

function createWindow() {
  // Create the browser window.
  win = new BrowserWindow({
    width: 1050,
    height: 814
  })

  // and load the index.html of the app.
  win.loadURL(url.format({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file:',
    slashes: true
  }))

  // Open the DevTools.
  win.webContents.openDevTools()

  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null
  })
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // On macOS it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  // On macOS it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (win === null) {
    createWindow()
  }
})

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.</code>```

答:
The conceptual solution for this problem:
 in "electron",

"{dialog}=require(electron)" (e.g.,)
in tabs, will not work

This is how they built electron.
probably to increase stability or just part of the issue that's based on chrome

in the main process, we can require(electron), where in tabs, we are to require npm modules with browserify
*** check for example
what modules work where in electron

Body:
i read a lot about browserify and electron and the gui browser issue
yet there is still a problem with  browserify, saying "fs.existsSync is not a function", and "required is not defined"

* The full story*
i created simple gui with electron   ,
there are the package.json file, the main.js and the index.html file + 3,4 html files, where there i want to create simple "load show save window" that work with require

That feature worked in the index.html file yet doesn't work properly in the load.html file, so i browserify the main.js with the commands

var  fs = require('electron')
//console.log(require('fs').existsSync);
var remote = require('electron').remote;
//  var remote = require('remote');
var dialog = require('electron').remote

into main.bundle3.js, with, (in the cmd)

browserify main.js > main.bundle3.js

yet then the load.html file shouted that require is not define and

> main.bundle3.js:6945 Uncaught TypeError: fs.existsSync is not a function
    at Object.<anonymous> (main.bundle3.js:6945)
    at Object.require.36.fs (main.bundle3.js:6951)
    at s (main.bundle3.js:1)
    at main.bundle3.js:1
    at Object.<anonymous> (main.bundle3.js:6794)
    at Object.require.35._process (main.bundle3.js:6937)
    at s (main.bundle3.js:1)
    at e (main.bundle3.js:1)
    at main.bundle3.js:1
(anonymous) @   main.bundle3.js:6945
require.36.fs   @   main.bundle3.js:6951
s   @   main.bundle3.js:1
(anonymous) @   main.bundle3.js:1
(anonymous) @   main.bundle3.js:6794
require.35._process @   main.bundle3.js:6937
s   @   main.bundle3.js:1
e   @   main.bundle3.js:1
(anonymous) @   main.bundle3.js:1

The package.json

{
  "name": "RDF",
  "version": "0.1.0",
  "main": "main.js",
  "scripts": {
    "test": "mocha -u exports -R spec test/index"
  },
  "devDependencies": {
    "electron": "^1.6.2",
    "electron-packager": "^8.6.0",
    "html-browserify": "0.0.6",
    "jquery": "^3.2.1"
  }
}

 and load.html file

<!DOCTYPE html>

    <meta charset="UTF-8">

LOAD

load the data

            <input type="text" placeholder="just select a file" id="actual-file" disabled="disabled"/>
            <input type="button" value="Choose a file" id="select-file"/>

        <textarea id="content-editor" rows="5"></textarea>

        <input type="button" id="save-changes" value="Save changes"/>
        <input type="button" id="delete-file" value="Delete file"/>

  he file content will be the same as the editor.

        <input type="button" value="Choose a file" id="create-new-file"/>

the the main.js file in full

//console.log(require('fs'));
console.log(require('module').globalPaths);
const {
  electron
} = require('electron');
const {
  BrowserWindow
} = require('electron')
const {
  app
} = require('electron');
//  @show(app)
const path = require('path')
//console.log( process.env.PATH);
// (D:\electron-v1.6.1-win32-x64\resources\default_app.asr\main.js:325:5)
 //const BrowserWindow = require('browser-window')
const url = require('url')
var html = require('html-browserify');
var fs = require('electron')
//console.log(require('fs').existsSync);
var remote = require('electron').remote;
//  var remote = require('remote');
var dialog = require('electron').remote
//dialog = require('electron').dialog
//dialog =remote.require('dialog')

//var load_=require('./load_.js')
// broserify html
var through = require('through');
var htmlclean = require('htmlclean');

module.exports = function(file, options) {

  options = options || {};
  options.htmlclean =
   typeof options.htmlclean !== 'undefined'
      ?      options.htmlclean : true;

  var buffer = '';

  if (!/\.(tpl|html)/.test(file)) {

    return through();

  } else {

    return through(function(chunk) {

      return buffer += chunk.toString();

    }, function() {

      var jst = buffer.toString();

      if (options.htmlclean) {
        //options.htmlclean is truthy

        if (typeof options.htmlclean === 'object') {
          //options.htmlclean is an options object for the htmlclean module
          jst = htmlclean(jst, options.htmlclean);
        } else {
          //otherwise, clean using default options
          jst = htmlclean(jst);
        }
      }

      var compiled = 'module.exports = ';
      compiled += JSON.stringify(jst);
      compiled += ';\n';

      this.queue(compiled);
      return this.queue(null);

    });

  }

}
//requirejs.config({
//By default load any module IDs from js/lib
//  baseUrl: 'js/lib',
//except, if the module ID starts with "app",
//load it from the js/app directory. paths
//config is relative to the baseUrl, and
//never includes a ".js" extension since
//the paths config could be for a directory.
//paths: {
//  app: '  '
//}
//});

// Start the main app logic.
//requirejs(['jquery', 'canvas', 'app/sub'],
//function   ($,        canvas,   sub) {
//jQuery, canvas and the app/sub module are all
//loaded and can be used here now.
//});
//const fs = require('fs');
//const app = require('electron').app.
//const remote = require('electron').remote;

// be closed automatically when the JavaScript object is garbage collected.
let win

function createWindow() {
  // Create the browser window.
  win = new BrowserWindow({
    width: 1050,
    height: 814
  })

  // and load the index.html of the app.
  win.loadURL(url.format({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file:',
    slashes: true
  }))

  // Open the DevTools.
  win.webContents.openDevTools()

  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null
  })
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // On macOS it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  // On macOS it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (win === null) {
    createWindow()
  }
})

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.


问:
reading commodities into python with yahoo finance
I am reading stock data into python using the yahoo finance.  It works with stocks, however, it giving errors with commodities.

The code below works perfectly:

```<code>import pandas as pd
import numpy as np
import pandas.io.data as web
import datetime

# We will look at stock prices over the past year, starting at January 1, 2016
start = datetime.datetime(2016,1,1)
end = datetime.date.today()

stock = "AAPL"

# get stock data, from yahoo finance within the dates specified
stock = web.DataReader(stock, "yahoo", start, end)

stock.head(n=3)
</code>```

However, if you change the handle to a commodity instead of a stock you get this error:

```<code>import pandas as pd
import numpy as np
import pandas.io.data as web
import datetime

# We will look at stock prices over the past year, starting at January 1, 2016
start = datetime.datetime(2016,1,1)
end = datetime.date.today()

stock = "GCG17.CMX"

# get stock data, from yahoo finance within the dates specified
stock = web.DataReader(stock, "yahoo", start, end)

stock.head(n=3)

OSError: after 3 tries, Yahoo! did not return a 200 for url 'http://ichart.finance.yahoo.com/table.csv?s=GCG17.CMX&a=0&b=1&c=1970&d=0&e=22&f=2017&g=d&ignore=.csv'
</code>```

Can anyone help me?

答: You are getting an error because Yahoo Finance doesn't save historical commodity prices.</p>

Body:
I am reading stock data into python using the yahoo finance.  It works with stocks, however, it giving errors with commodities.

The code below works perfectly:

import pandas as pd
import numpy as np
import pandas.io.data as web
import datetime

# We will look at stock prices over the past year, starting at January 1, 2016
start = datetime.datetime(2016,1,1)
end = datetime.date.today()

stock = "AAPL"

# get stock data, from yahoo finance within the dates specified
stock = web.DataReader(stock, "yahoo", start, end)

stock.head(n=3)

However, if you change the handle to a commodity instead of a stock you get this error:

import pandas as pd
import numpy as np
import pandas.io.data as web
import datetime

# We will look at stock prices over the past year, starting at January 1, 2016
start = datetime.datetime(2016,1,1)
end = datetime.date.today()

stock = "GCG17.CMX"

# get stock data, from yahoo finance within the dates specified
stock = web.DataReader(stock, "yahoo", start, end)

stock.head(n=3)

OSError: after 3 tries, Yahoo! did not return a 200 for url 'http://ichart.finance.yahoo.com/table.csv?s=GCG17.CMX&a=0&b=1&c=1970&d=0&e=22&f=2017&g=d&ignore=.csv'

Can anyone help me?


问:
Restoring MySQL database from physical files
Is it possible to restore a MySQL database from the physical database files. I have a directory that has the following file types:

client.frm

client.MYD

client.MYI

but for about 20 more tables.

I usually use mysqldump or a similar tool to get everything in 1 SQL file so what is the way to deal with these types of files?

答:
From the answer of @Vicent, I already restore MySQL database as below:

Step 1. Shutdown Mysql server

Step 2. Copy database in your database folder (in linux, the default location is /var/lib/mysql). Keep same name of the database, and same name of database in mysql mode.

```<code>sudo cp -rf   /mnt/ubuntu_426/var/lib/mysql/database1 /var/lib/mysql/
</code>```

Step 3:  Change own and change mode the folder:

```<code>sudo chown -R mysql:mysql /var/lib/mysql/database1
sudo chmod -R 660 /var/lib/mysql/database1
sudo chown  mysql:mysql /var/lib/mysql/database1
sudo chmod 700 /var/lib/mysql/database1
</code>```

Step 4: Copy ibdata1 in your database folder

```<code>sudo cp /mnt/ubuntu_426/var/lib/mysql/ibdata1 /var/lib/mysql/

sudo chown mysql:mysql /var/lib/mysql/ibdata1
</code>```

Step 5: copy  ib_logfile0 and  ib_logfile1 files in your database folder.

```<code>sudo cp /mnt/ubuntu_426/var/lib/mysql/ib_logfile0 /var/lib/mysql/

sudo cp /mnt/ubuntu_426/var/lib/mysql/ib_logfile1 /var/lib/mysql/
</code>```

Remember change own and change root of those files:

```<code>sudo chown -R mysql:mysql /var/lib/mysql/ib_logfile0

sudo chown -R mysql:mysql /var/lib/mysql/ib_logfile1
</code>```

or

```<code>sudo chown -R mysql:mysql /var/lib/mysql
</code>```

Step 6 (Optional): My site has configuration to store files in a specific location, then I copy those to corresponding location, exactly.

Step 7: Start your Mysql server. Everything come back and enjoy it.

That is it.

See more info at: https://biolinh.wordpress.com/2017/04/01/restoring-mysql-database-from-physical-files-debianubuntu/

OwnerDisplayName: Abdullah Jibaly

LastEditorDisplayName: Vincent

Body:
From the answer of @Vicent, I already restore MySQL database as below:

Step 1. Shutdown Mysql server

Step 2. Copy database in your database folder (in linux, the default location is /var/lib/mysql). Keep same name of the database, and same name of database in mysql mode.

sudo cp -rf   /mnt/ubuntu_426/var/lib/mysql/database1 /var/lib/mysql/

Step 3:  Change own and change mode the folder:

sudo chown -R mysql:mysql /var/lib/mysql/database1
sudo chmod -R 660 /var/lib/mysql/database1
sudo chown  mysql:mysql /var/lib/mysql/database1
sudo chmod 700 /var/lib/mysql/database1

Step 4: Copy ibdata1 in your database folder

sudo cp /mnt/ubuntu_426/var/lib/mysql/ibdata1 /var/lib/mysql/

sudo chown mysql:mysql /var/lib/mysql/ibdata1

Step 5: copy  ib_logfile0 and  ib_logfile1 files in your database folder.

sudo cp /mnt/ubuntu_426/var/lib/mysql/ib_logfile0 /var/lib/mysql/

sudo cp /mnt/ubuntu_426/var/lib/mysql/ib_logfile1 /var/lib/mysql/

Remember change own and change root of those files:

sudo chown -R mysql:mysql /var/lib/mysql/ib_logfile0

sudo chown -R mysql:mysql /var/lib/mysql/ib_logfile1

or

sudo chown -R mysql:mysql /var/lib/mysql

Step 6 (Optional): My site has configuration to store files in a specific location, then I copy those to corresponding location, exactly.

Step 7: Start your Mysql server. Everything come back and enjoy it.

That is it.

See more info at: https://biolinh.wordpress.com/2017/04/01/restoring-mysql-database-from-physical-files-debianubuntu/


问:
optimizer always full scans table eben though fething only 3 rows
I have a table foo which was created like this.

```<code>CREATE TABLE foo AS SELECT * FROM all_objects;

CREATE INDEX foo_I1 ON foo(owner,object_type,status);
exec dbms_stats.gather_table_stats('hr','foo',method_opt=>'FOR ALL COLUMNS size AUTO');
</code>```

I created an index  on 3 columns and firing a query which looks like below.

```<code>select  * from foo where status='INVALID';
select  * from foo where status='VALID';
</code>```

status='VALID' fetches near about 71000 rows in a table of 71780 rows. it does a full table scan. it's understandable. but in case of status='INVALID' which fetches only 3 rows , it's doing full table scan.  It's also getting A rows and E rows very different.

PLAN: same for both queries.

SQL_ID  gdhy9j91gu9sm, child number 0

select /*+gather_plan_statistics */ * from foo where status='VALID'

```<code>Plan hash value: 1245013993

------------------------------------------------------------------------------------
| Id  | Operation         | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |      1 |        |     50 |00:00:00.01 |       4 |
|*  1 |  TABLE ACCESS FULL| FOO  |      1 |  71773 |     50 |00:00:00.01 |       4 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("STATUS"='VALID')
</code>```

Please explan this behaviour. Database Version: 11.2g oracle.

答:
A missing histogram is probably causing the full table scan.  Histograms are usually only created if the data is skewed and if the column has been used in a relevant predicate.

Sometimes you need to run a query before gathering statistics, to let Oracle know that this column is important enough to deserve a histogram.

```<code>select * from foo where status='INVALID';
exec dbms_stats.gather_table_stats('hr','foo',method_opt=>'FOR ALL COLUMNS size AUTO');
</code>```

Re-run the SELECT and now it can use the histogram.  With the histogram Oracle knows that INVALID returns a small number of rows, and an index would be useful:

```<code>explain plan for select * from foo where status='INVALID';
select * from table(dbms_xplan.display);

Plan hash value: 1520589999

---------------------------------------------------------------------------------------------
| Id  | Operation                           | Name   | Rows  | Bytes | Cost (%CPU)| Time    |
---------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                    |        |     1 |   134 |   217   (0)| 00:00:01|
|   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| FOO    |     1 |   134 |   217   (0)| 00:00:01|
|*  2 |   INDEX SKIP SCAN                   | FOO_I1 |     1 |       |   216   (0)| 00:00:01|
---------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("STATUS"='INVALID')
       filter("STATUS"='INVALID')
</code>```

Body:
I have a table foo which was created like this.

CREATE TABLE foo AS SELECT * FROM all_objects;

CREATE INDEX foo_I1 ON foo(owner,object_type,status);
exec dbms_stats.gather_table_stats('hr','foo',method_opt=>'FOR ALL COLUMNS size AUTO');

I created an index  on 3 columns and firing a query which looks like below.

select  * from foo where status='INVALID';
select  * from foo where status='VALID';

status='VALID' fetches near about 71000 rows in a table of 71780 rows. it does a full table scan. it's understandable. but in case of status='INVALID' which fetches only 3 rows , it's doing full table scan.  It's also getting A rows and E rows very different.

PLAN: same for both queries.

SQL_ID  gdhy9j91gu9sm, child number 0

select /*+gather_plan_statistics */ * from foo where status='VALID'

Plan hash value: 1245013993

------------------------------------------------------------------------------------
| Id  | Operation         | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |      1 |        |     50 |00:00:00.01 |       4 |
|*  1 |  TABLE ACCESS FULL| FOO  |      1 |  71773 |     50 |00:00:00.01 |       4 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("STATUS"='VALID')

Please explan this behaviour. Database Version: 11.2g oracle.

Body:
A missing histogram is probably causing the full table scan.  Histograms are usually only created if the data is skewed and if the column has been used in a relevant predicate.

Sometimes you need to run a query before gathering statistics, to let Oracle know that this column is important enough to deserve a histogram.

select * from foo where status='INVALID';
exec dbms_stats.gather_table_stats('hr','foo',method_opt=>'FOR ALL COLUMNS size AUTO');

Re-run the SELECT and now it can use the histogram.  With the histogram Oracle knows that INVALID returns a small number of rows, and an index would be useful:

explain plan for select * from foo where status='INVALID';
select * from table(dbms_xplan.display);

Plan hash value: 1520589999

---------------------------------------------------------------------------------------------
| Id  | Operation                           | Name   | Rows  | Bytes | Cost (%CPU)| Time    |
---------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                    |        |     1 |   134 |   217   (0)| 00:00:01|
|   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| FOO    |     1 |   134 |   217   (0)| 00:00:01|
|*  2 |   INDEX SKIP SCAN                   | FOO_I1 |     1 |       |   216   (0)| 00:00:01|
---------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("STATUS"='INVALID')
       filter("STATUS"='INVALID')


问:
DyanamoDB SCAN with nested attribute
Can I scan DynamoDB by 'order.shortCode', in the given example.  The console is indicating I can't with dot notation, and I can't find any documentation on it.</p>

```<code>{
  "key2": "cj11b1ygp0000jcgubpe5mso3",
  "order": {
    "amount": 74.22,
    "dateCreated": "2017-04-02T19:15:33-04:00",
    "orderNumber": "cj11b1ygp0000jcgubpe5mso3",
    "shortCode": "SJLLDE"
  },
  "skey2": "SJLLDE"
}
</code>```

答:
To scan by a nested attribute, you should use ExpressionAttributeNames parameter to pass each path component (i.e. order and shortCode) separately into FilterExpression like shown below:

```<code>var params = {
    TableName: 'YOUR_TABLE_NAME',
    FilterExpression: "#order.#shortCode = :shortCodeValue",
    ExpressionAttributeNames: {
        '#order': 'order',
        "#shortCode": "shortCode"
    },
    ExpressionAttributeValues: {
        ':shortCodeValue': 'SJLLDE'
    }
};

dynamodbDoc.scan(params, function(err, data) {
});
</code>```

Here is a link to documentation explaining this:

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html#Expressions.ExpressionAttributeNames.NestedAttributes

Title: DyanamoDB SCAN with nested attribute

Body:
Can I scan DynamoDB by 'order.shortCode', in the given example.  The console is indicating I can't with dot notation, and I can't find any documentation on it.

{
  "key2": "cj11b1ygp0000jcgubpe5mso3",
  "order": {
    "amount": 74.22,
    "dateCreated": "2017-04-02T19:15:33-04:00",
    "orderNumber": "cj11b1ygp0000jcgubpe5mso3",
    "shortCode": "SJLLDE"
  },
  "skey2": "SJLLDE"
}

Body:
To scan by a nested attribute, you should use ExpressionAttributeNames parameter to pass each path component (i.e. order and shortCode) separately into FilterExpression like shown below:

var params = {
    TableName: 'YOUR_TABLE_NAME',
    FilterExpression: "#order.#shortCode = :shortCodeValue",
    ExpressionAttributeNames: {
        '#order': 'order',
        "#shortCode": "shortCode"
    },
    ExpressionAttributeValues: {
        ':shortCodeValue': 'SJLLDE'
    }
};

dynamodbDoc.scan(params, function(err, data) {
});

Here is a link to documentation explaining this:

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html#Expressions.ExpressionAttributeNames.NestedAttributes


问:
AngularJS ng-repeat directives is not working on my EventController.js
I was trying to add session details under address and date. But ng-repeat is working but its not displaying any details under sessions section. Its not giving me any error. Can anyone please check my codes and let me know what`s missing.

.....app.js.....

'use strict';

var eventsApp = angular.module('eventsApp', []);

'use strict';

eventsApp.controller('EventController',

    function EventController($scope){
   $scope.event = {
       name: 'Angular Event App',
       date: '04/02/2017',
       time: '3.09 am',
       location: {
           address: 'Google Headquaters',
           city: 'Mountain View',
           Province: 'CA'
       },
       imageUrl: '/img/angularjs-logo.png',
       sessions: [
           {
               name: 'Directive Masterclass'
           },
           {
               name: 'Scope for fun and profit'
           },
           {
               name: 'well Behaved Controllers'
           }
       ]
   };
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <!DOCTYPE html>
    <html lang="en" ng-app="eventsApp">

    <head>
        <meta charset="utf-8">
        <title>Event Registration</title>
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/app.css">
        <script src="lib/jquery.min.js"></script>
        <script src="lib/underscore-1.4.4.min.js"></script>
        <script src="lib/bootstrap.min.js"></script>
        <script src="lib/angular/angular.js"></script>
        <script src="js/app.js"></script>
        <script src="js/controllers/EventController.js"></script>

    </head>

    <body>
        <div class="container">
            <div class="navbar-inner">
                <ul class="nav">

                </ul>

            </div>
            <div ng-controller="EventController" style="padding-left:20px; padding-right:20px">
                <img ng-src="{{event.imageUrl}}" alt="{{event.name}}" />
                <div class="row">
                    <div class="span1">
                        <h2> {{event.name}}</h2>
                    </div>

                </div>
                <div class="row">
                    <div class="span2">
                        <div><strong>Date: </strong> {{event.date}}</div>
                        <div><strong>Time: </strong> {{event.time}}</div>
                    </div>
                    <div class="span3">
                        <address>
                    <strong> Address: </strong><br>
                        {{event.location.address}}<br>
                        {{event.location.city}}, {{event.location.province}}
                    </address>
                    </div>
                </div>

                <h3>Sessions</h3>
                <ul class="thumbnails">
                    <li ng-repeat="session in event.sessions" ></li>
                    <div class="row session">
                    <div class="well span9">
                        <h4 class="well-title">{{session.name}}</h4>
                        </div>
                    </div>

                </ul>
            </div>

        </div>

    </body>

    </html></code>```

答:
The ending tag for the li element is before where you are referencing the item from the Ng-repeat (likely a typo). I'd update the HTML to the following:</p>

```<code><li ng-repeat="session in event.sessions">
    <div class="row session">
        <div class="well span9">
            <h4 class="well-title">{{session.name}}</h4>
       </div>
   </div>
</li>
</code>```

Body:
I was trying to add session details under address and date. But ng-repeat is working but its not displaying any details under sessions section. Its not giving me any error. Can anyone please check my codes and let me know what`s missing.

.....app.js.....

'use strict';

var eventsApp = angular.module('eventsApp', []);

'use strict';

eventsApp.controller('EventController',

    function EventController($scope){
   $scope.event = {
       name: 'Angular Event App',
       date: '04/02/2017',
       time: '3.09 am',
       location: {
           address: 'Google Headquaters',
           city: 'Mountain View',
           Province: 'CA'
       },
       imageUrl: '/img/angularjs-logo.png',
       sessions: [
           {
               name: 'Directive Masterclass'
           },
           {
               name: 'Scope for fun and profit'
           },
           {
               name: 'well Behaved Controllers'
           }
       ]
   };
});

    <!DOCTYPE html>

        <meta charset="utf-8">
        <title>Event Registration</title>
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/app.css">

 {{event.name}}

Date:  {{event.date}}

Time:  {{event.time}}

                        <address>
                     Address:

                        {{event.location.address}}

                        {{event.location.city}}, {{event.location.province}}
                    </address>

Sessions

{{session.name}}

Body:
The ending tag for the li element is before where you are referencing the item from the Ng-repeat (likely a typo). I'd update the HTML to the following:

<li ng-repeat="session in event.sessions">
    <div class="row session">
        <div class="well span9">
            <h4 class="well-title">{{session.name}}</h4>
       </div>
   </div>
</li>


问:
How can I get string from Textbox in java
I'm having a problem with the textbox. I'm trying to copy a file inside the arraylist and transfer it to another folder.

When I'm using this: String strSource = "D:\\New folder\\";

                   String strDestination = "D:\\New folder\\Another Folder\\";

It copies the file inside but when i change it to String strSource = txtSource.getText(); and same with the destination there is no error but only catch but the destination folder is empty. If you guys confuse on my question i'll try to explain to you.

Copy Method

```<code> public void copyFiles(String source, String destination){
        try {
            File fileFrom = new File(source);
            File fileTo = new File(destination);
            Files.copy( fileFrom.toPath(), fileTo.toPath());

        } catch (IOException e) {
//          e.printStackTrace();
            MessageBox msgBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
            msgBox.setText("Error");
            msgBox.setMessage("File is AlreadyExist."); //where this is the one catching..
            msgBox.open();
        }
    }
</code>```

Copy Button

```<code>String strSource = new String(txtSource.getText());
String strDestination = new String (txtDestination.getText());
                try {
                    ArrayList<String> list = readConfigFileList(ConstantVariables.SPECIFIC_FILE_LIST);

                    for (String strList : list) {
                        copyFiles(strSource + strList, strDestination + strList);
                    }

                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
</code>```

答:
This one is the solution to me i just add \\.

String strSource = txtSource.getText() + "\\;

Body:
I'm having a problem with the textbox. I'm trying to copy a file inside the arraylist and transfer it to another folder.

When I'm using this: String strSource = "D:\\New folder\\";

                   String strDestination = "D:\\New folder\\Another Folder\\";

It copies the file inside but when i change it to String strSource = txtSource.getText(); and same with the destination there is no error but only catch but the destination folder is empty. If you guys confuse on my question i'll try to explain to you.

Copy Method

 public void copyFiles(String source, String destination){
        try {
            File fileFrom = new File(source);
            File fileTo = new File(destination);
            Files.copy( fileFrom.toPath(), fileTo.toPath());

        } catch (IOException e) {
//          e.printStackTrace();
            MessageBox msgBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
            msgBox.setText("Error");
            msgBox.setMessage("File is AlreadyExist."); //where this is the one catching..
            msgBox.open();
        }
    }

Copy Button

String strSource = new String(txtSource.getText());
String strDestination = new String (txtDestination.getText());
                try {
                    ArrayList<String> list = readConfigFileList(ConstantVariables.SPECIFIC_FILE_LIST);

                    for (String strList : list) {
                        copyFiles(strSource + strList, strDestination + strList);
                    }

                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }


问:
Optional include in PHP
I have a config file with the general configuration (in a git repo), and a local config file that overwrites configuration properties (ignored in the repo). Right now the local config file is included at the beginning of the config file:

```<code>include_once 'local_config.php';
</code>```

But I would like the include to be conditional: only do it if the file local_config.php actually exists. I can do a enter link description here without problems, but first I would need to check if the file exists. So I tried get_include_path() but it returns a list of paths, and I would have to parse this list and check for every one.

Another option would be to just call include_once() and suppress the warnings, but it is even messier. Is there a simpler way to do a real optional include in PHP?

答:
You can use stream_resolve_include_path($filename) if you have a PHP version higher than 5.3.2

http://php.net/stream_resolve_include_path

Title: Optional include in PHP

Body:
I have a config file with the general configuration (in a git repo), and a local config file that overwrites configuration properties (ignored in the repo). Right now the local config file is included at the beginning of the config file:

include_once 'local_config.php';

But I would like the include to be conditional: only do it if the file local_config.php actually exists. I can do a enter link description here without problems, but first I would need to check if the file exists. So I tried get_include_path() but it returns a list of paths, and I would have to parse this list and check for every one.

Another option would be to just call include_once() and suppress the warnings, but it is even messier. Is there a simpler way to do a real optional include in PHP?


问:
recordsTotal, recordsFiltered explanation Jquery DataTable
I'm reading datatable doc's but i can't find an answer. My question is:

I have a table with 10.000 rows. I do a search by state and result is 3000 rows. From 3000 rows, i'll show 20 per page.

"recordsTotal": what value should be in here?,
"recordsFiltered": what value should be in here?,

If recordsTotal value must be 10.000, can i hide this value if is not interesting?

答:
From official documentation:

recordsTotal

Total records, before filtering (i.e. the total number of records in the database)

recordsFiltered

Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data).

Your response should be:

```<code>{
    "draw": 1,
    "recordsTotal": 10000,
    "recordsFiltered": 3000,
    "data": [
       // ... skipped 20 records ...
    ]
}
</code>```

I believe recordsTotal is only used for informational panel Showing 1 to 20 of 3000 entries (filtered from 10000 total entries). If you're not using informational panel, you don't have to return recordsTotal property.

Property recordsFiltered is also used by jQuery DataTables to calculate number of pages required to display your dataset.

See Server-side - Returned data for more information.

Body:
From official documentation:

recordsTotal

Total records, before filtering (i.e. the total number of records in the database)

recordsFiltered

Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data).

Your response should be:

{
    "draw": 1,
    "recordsTotal": 10000,
    "recordsFiltered": 3000,
    "data": [
       // ... skipped 20 records ...
    ]
}

I believe recordsTotal is only used for informational panel Showing 1 to 20 of 3000 entries (filtered from 10000 total entries). If you're not using informational panel, you don't have to return recordsTotal property.

Property recordsFiltered is also used by jQuery DataTables to calculate number of pages required to display your dataset.

See Server-side - Returned data for more information.


问:
Bootstrap 4 Modal Will Not Open on Click
I can not get my modal to open. I tried just the plain HTML found on the Bootstrap 4 site and then used some Javascript. I really can not figure out what I am doing wrong. Any help would be very much appreciated!

enter code here<

```<code><div class="col-sm-3 col-centered  boxes" id="box1">

  <button type="button" class="btn btn-primary" id="box1modal" data-toggle="modal" data-target="#exampleModal">

    See More

  </button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">

    <div class="modal-dialog" role="document">

      <div class="modal-content">

        <div class="modal-header">

          <h5 class="modal-title" id="exampleModalLabel">Wedding Invites</h5>

          <button type="button" class="close" data-dismiss="modal" aria-label="Close">

            <span aria-hidden="true">×</span>

          </button>

        </div>

        <div class="modal-body">

          <img src="Wedding%20Invites.jpg">

        </div>

        <div class="modal-footer">

          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

          <button type="button" class="btn btn-primary">Save changes</button>

        </div>

      </div>

    </div>

  </div>

</div>
 `enter code here`<script type="text/javascript">
</code>```

enter code here $("#box1modal").click(function(event){

 enter code here$('#myModal').modal('show');
    enter code here  )};

答:
If You are using bootstrap no need of extra scripting.bootstrap itself provides its scripts to run different  animations and actions. I checked your code.
The error lies in line

```<code>   <button type="button" class="btn btn-primary" id="box1modal" data-toggle="modal" data-target="#exampleModal">
</code>```

See you've set data target as #exampleModal while id of your modal is "myModal". Just change above code to

```<code>   <button type="button" class="btn btn-primary" id="box1modal" data-toggle="modal" data-target="#myModal">
</code>```

And it will work fine without any other script.
Hope this Helps...

Body:
I can not get my modal to open. I tried just the plain HTML found on the Bootstrap 4 site and then used some Javascript. I really can not figure out what I am doing wrong. Any help would be very much appreciated!

enter code here<

  <button type="button" class="btn btn-primary" id="box1modal" data-toggle="modal" data-target="#exampleModal">

    See More

  </button>

Wedding Invites

          <button type="button" class="close" data-dismiss="modal" aria-label="Close">

            ×

          </button>

          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

          <button type="button" class="btn btn-primary">Save changes</button>

 `enter code here`

Body:
If You are using bootstrap no need of extra scripting.bootstrap itself provides its scripts to run different  animations and actions. I checked your code.
The error lies in line

   <button type="button" class="btn btn-primary" id="box1modal" data-toggle="modal" data-target="#exampleModal">

See you've set data target as #exampleModal while id of your modal is "myModal". Just change above code to

   <button type="button" class="btn btn-primary" id="box1modal" data-toggle="modal" data-target="#myModal">

And it will work fine without any other script.
Hope this Helps...


问:
Azume ML Cannot Find timeSeries function
I am trying to run an R Script in Azure ML Studio. Unfortunately, I receive the following error:

```<code>Error 0063: The following error occurred during evaluation of R script:
---------- Start of error message from R ----------
could not find function "timeSeries"
</code>```

It seems strange that Azure ML cannot find the function timeSeries as the timeSeries package is installed by default. Here is the proof, you can see that timeSeries is listed.

Here is my code and the Azure diagram. The 1st R script was used to write a CSV of the installed packages (1st Picture). The code in the second R script is displayed to the right of the 2nd picture.

Thanks

答:
The library needs to be loaded as it is an external library</p>

```<code>library(timeSeries)
#Map 1-based optional input ports to variables
dataset1 <- maml.mapInputPort(1) #class: data.frame
HOLD <- maml.mapInputPort(2) #class: data.frame

colnames(HOLD) <- c("Dates", "Val")

Daily.TS <- timeSeries(HOLD$Val, as.Date(HOLD$Dates),
     format="%Y-%m-%d")
</code>```

Body:
I am trying to run an R Script in Azure ML Studio. Unfortunately, I receive the following error:

Error 0063: The following error occurred during evaluation of R script:
---------- Start of error message from R ----------
could not find function "timeSeries"

It seems strange that Azure ML cannot find the function timeSeries as the timeSeries package is installed by default. Here is the proof, you can see that timeSeries is listed.

Here is my code and the Azure diagram. The 1st R script was used to write a CSV of the installed packages (1st Picture). The code in the second R script is displayed to the right of the 2nd picture.

Thanks

Body:
The library needs to be loaded as it is an external library

library(timeSeries)
#Map 1-based optional input ports to variables
dataset1 <- maml.mapInputPort(1) #class: data.frame
HOLD <- maml.mapInputPort(2) #class: data.frame

colnames(HOLD) <- c("Dates", "Val")

Daily.TS <- timeSeries(HOLD$Val, as.Date(HOLD$Dates),
     format="%Y-%m-%d")


问:
Element Positioning affected by Browser Screen Resolution Change
newbie developer here.

There's this small problem I always encounter. Every time I try to change browser resolution (or what do you call the event when you scroll the mouse wheel while pressing ctrl), some elements (Mostly form elements) get to be shifted down or somewhere else, which does not conform with the original positioning. Im not sure if the problem is with the CSS or the markup itself and Im not really sure if this is much of a problem. Should I ignore it? (It doesn't feel very comfortable though, thinking that it might become problematic in the near future) Otherwise, any solution on how to avoid this?

Simple explanations are very much appreciated, Thanks.

(Perhaps the used term newbie should be replaced with noob?. Haha.)

答: Ed, perhaps you can also go for max-width and min-width in your css to avoid that. focusing on the resolution lets say 1024 x 768 . you can use min-width for both your columns that at point below this resolution it won't skip downwards. Let me know if that helped</p>


问:
TFS 2015 - Rename Product Backlog Item & Show field based on another field state
How can I rename the name of the "Product Backlog Item" from the selection on TFS 2015

Secondly, I have added a new field in my Bug.xml, how can I set this particular field to only show when the State: field is "Done"? I have it showing now, but i need it to only be visible when the bug is marked as Done (State).

Thirdly, how Can i remove options from the drop down in image #1, for example Impediment & Feature specifically.

for #1 and #3 I can possibly use witadmin destroywitd / witadmin renamewitd after some researching, however I'm afraid what knock on effects it may have

答:
For #1, you could use witadmin renamewitd command to achieve:

```<code>witadmin renamewitd /collection:"http://FabrikamPrime:8080/tfs/DefaultCollection" /p:"team project name" /n:"Product Backlog Item" /new:"New name"
</code>```

For #2, you just add a WHENNOT rule for this custom field like this:

```<code><FIELD name="Root Cause" refname="core.resolution" type="String">
        <ALLOWEDVALUES expanditems="true">
          <LISTITEM value="value1" />
          <LISTITEM value="value2" />
          <LISTITEM value="value3" />
        </ALLOWEDVALUES>
        <WHENNOT field="System.State" value="Done">
          <READONLY />
        </WHENNOT>
      </FIELD>
</code>```

Using WHENNOT rule, you won't see the RootCause dropdown list until the state changed to Done.

For #3, you should first export the Category file of your team project. Then find the Hidden Types Category, add the Impediment under the Hidden Types Category:

```<code><CATEGORY refname="Microsoft.HiddenCategory" name="Hidden Types Category">
    <DEFAULTWORKITEMTYPE name="Code Review Request" />
      ......
    <WORKITEMTYPE name="Impediment" />
  </CATEGORY>
</code>```

Body:
For #1, you could use witadmin renamewitd command to achieve:

witadmin renamewitd /collection:"http://FabrikamPrime:8080/tfs/DefaultCollection" /p:"team project name" /n:"Product Backlog Item" /new:"New name"

For #2, you just add a WHENNOT rule for this custom field like this:

<FIELD name="Root Cause" refname="core.resolution" type="String">
        <ALLOWEDVALUES expanditems="true">
          <LISTITEM value="value1" />
          <LISTITEM value="value2" />
          <LISTITEM value="value3" />
        </ALLOWEDVALUES>
        <WHENNOT field="System.State" value="Done">
          <READONLY />
        </WHENNOT>
      </FIELD>

Using WHENNOT rule, you won't see the RootCause dropdown list until the state changed to Done.

For #3, you should first export the Category file of your team project. Then find the Hidden Types Category, add the Impediment under the Hidden Types Category:

<CATEGORY refname="Microsoft.HiddenCategory" name="Hidden Types Category">
    <DEFAULTWORKITEMTYPE name="Code Review Request" />
      ......
    <WORKITEMTYPE name="Impediment" />
  </CATEGORY>


问:
C# Method Return
I am writing a program which is about simple calculation in 3 different methods.
My code is working okay, but it doesn't grab the result back to Main.

Can anyone help me to find what is the problem for me?

Here is my code

```<code>static void Main(string[] args)
{
    Console.Write("Enter the first number\t");
    int number1 = Convert.ToInt32(Console.ReadLine());
    Console.Write("Enter the second number\t");
    int number2 = Convert.ToInt32(Console.ReadLine());

    sum(number1, number2);
    difference(number1, number2);
    multiplies(number1, number2);
}

public static int sum(int number1, int number2)
{
    Console.WriteLine("Sum is:");
    return number1 + number2;
}

public static int difference(int number1, int number2)
{
    Console.WriteLine("difference is:");
    return number1 - number2;
}

public static int multiplies(int number1, int number2)
{
    Console.WriteLine("multiplies:");
    return number1 - number2;
}
</code>```

Thank you in advance. :)

答:
You have called the method from the main, that all process your inputs correctly and return the result to the main, but you have not received the values to a variable or displayed the return values from that method, display the result like the following:

```<code>Console.Write("{0} + {1} = {2}",number1,number2,sum(number1, number2));
console.Write("{0} - {1} = {2}",number1,number2,difference(number1, number2));
Console.Write("{0} * {1} = {2}",number1,number2,multiplies(number1, number2));
</code>```

Let the inputs be 10 and 5 then the above code will displays the results as like the following:

```<code>10 + 5 = 15
10 - 5 = 5
10 * 5 = 50
</code>```

or else use a variable to store the return value and then proceed with those values.

```<code>int sumResult = sum(number1, number2);
int diffResult = difference(number1, number2);
int mulResult = multiplies(number1, number2);
</code>```

Title: C# Method Return

Body:
I am writing a program which is about simple calculation in 3 different methods.
My code is working okay, but it doesn't grab the result back to Main.

Can anyone help me to find what is the problem for me?

Here is my code

static void Main(string[] args)
{
    Console.Write("Enter the first number\t");
    int number1 = Convert.ToInt32(Console.ReadLine());
    Console.Write("Enter the second number\t");
    int number2 = Convert.ToInt32(Console.ReadLine());

    sum(number1, number2);
    difference(number1, number2);
    multiplies(number1, number2);
}

public static int sum(int number1, int number2)
{
    Console.WriteLine("Sum is:");
    return number1 + number2;
}

public static int difference(int number1, int number2)
{
    Console.WriteLine("difference is:");
    return number1 - number2;
}

public static int multiplies(int number1, int number2)
{
    Console.WriteLine("multiplies:");
    return number1 - number2;
}

Thank you in advance. :)

Body:
You have called the method from the main, that all process your inputs correctly and return the result to the main, but you have not received the values to a variable or displayed the return values from that method, display the result like the following:

Console.Write("{0} + {1} = {2}",number1,number2,sum(number1, number2));
console.Write("{0} - {1} = {2}",number1,number2,difference(number1, number2));
Console.Write("{0} * {1} = {2}",number1,number2,multiplies(number1, number2));

Let the inputs be 10 and 5 then the above code will displays the results as like the following:

10 + 5 = 15
10 - 5 = 5
10 * 5 = 50

or else use a variable to store the return value and then proceed with those values.

int sumResult = sum(number1, number2);
int diffResult = difference(number1, number2);
int mulResult = multiplies(number1, number2);


问:
Using Smooth Scroll Polyfill with Angular 2 CLI
Can anyone please guide how to use Smooth Scroll Polyfill with Angular 2 CLI.

I tried adding below to polyfills.ts but it throws error on work require

```<code>require('smoothscroll-polyfill').polyfill();
</code>```

I then tried adding

```<code>import 'smoothscroll-polyfill';
</code>```

Though it didn't throw any error during build but when I run the project in browser it show below error on console:

```<code>ERROR TypeError: Failed to execute 'scroll' on 'Window': No function was found that matched the signature provided.
</code>```

答:
#option 1

It can be included directly in the index.html it will run immediately and does not need to be invoked with smoothscroll.polyfill();

```<code><script src="https://unpkg.com/smoothscroll-polyfill@0.4.3/dist/smoothscroll.min.js"></script>
</code>```

#option 2

npm install smoothscroll-polyfill --save

including it in  src/polyfills.ts

import 'smoothscroll-polyfill';

or adding it to scripts in .angular-cli.json should work.

Importing in the Component:

```<code>import  { polyfill } from "smoothscroll-polyfill"

polyfill()
</code>```

#use:

window.scroll({ top: 200, left: 0, behavior: 'smooth' });

CodeSandbox

In both cases, the script will detect if the spec is natively supported and take action only when necessary.

smooth scroll behavior polyfill Documentation

MDN: scroll-behavior Browser compatibility

The code requires requestAnimationFrame polyfill for browsers which don't support it.

Body:
Can anyone please guide how to use Smooth Scroll Polyfill with Angular 2 CLI.

I tried adding below to polyfills.ts but it throws error on work require

require('smoothscroll-polyfill').polyfill();

I then tried adding

import 'smoothscroll-polyfill';

Though it didn't throw any error during build but when I run the project in browser it show below error on console:

ERROR TypeError: Failed to execute 'scroll' on 'Window': No function was found that matched the signature provided.

Body:
#option 1

It can be included directly in the index.html it will run immediately and does not need to be invoked with smoothscroll.polyfill();

<script src="https://unpkg.com/smoothscroll-polyfill@0.4.3/dist/smoothscroll.min.js"></script>

#option 2

npm install smoothscroll-polyfill --save

including it in  src/polyfills.ts

import 'smoothscroll-polyfill';

or adding it to scripts in .angular-cli.json should work.

Importing in the Component:

import  { polyfill } from "smoothscroll-polyfill"

polyfill()

#use:

window.scroll({ top: 200, left: 0, behavior: 'smooth' });

CodeSandbox

In both cases, the script will detect if the spec is natively supported and take action only when necessary.

smooth scroll behavior polyfill Documentation

MDN: scroll-behavior Browser compatibility

The code requires requestAnimationFrame polyfill for browsers which don't support it.


问:
SQL Query DBMS Actually Executes When View Query Uses an Aliased Aggregate Function
I'm working on a 3-step homework problem and I'm stumped on the last step. For the last step to make sense, I'll post the entire problem including my solutions for the first two steps:

The Problem and My Solutions for the First Two Steps

Create a view named TRIP_INVENTORY. It consists of the state and the total number of trips for each state. Use UNITS as the column name for the total number of trips for each state. Group and order the rows by state.

a. Write and execute the CREATE VIEW command to create the TRIP_INVENTORY view.

```<code>CREATE VIEW TRIP_INVENTORY AS
SELECT STATE, COUNT(TRIP_ID) AS UNITS
FROM TOURS_TRIP
GROUP BY STATE
</code>```

b. Write and execute the command to retreive the state and units for each state having more than 10 trips.

```<code>SELECT STATE, UNITS
FROM TRIP_INVENTORY
WHERE UNITS > 10
</code>```

The Step that has Me Stumped

c. Write and execute the query that the DBMS actually executes.

This was the unsuccessful query I came up with:

```<code>SELECT STATE, COUNT(TRIP_ID) AS UNITS
FROM TOURS_TRIP
WHERE UNITS > 10
GROUP BY STATE
</code>```

The problem is that the UNITS column alias can't be referenced in the WHERE clause. I can't use an aggregate function in the WHERE clause either. I'm pretty sure I need to use a subquery, but I can't figure out how to structure the constraints so that they will remove the unnecessary states using the results of the nested query.

Can anyone offer any insight?

答:
Depends on the implementation but

b)

```<code>SELECT STATE, COUNT(TRIP_ID) AS UNITS
FROM TOURS_TRIP
GROUP BY STATE
having COUNT(TRIP_ID) > 10
</code>```

c)

```<code>Select state, units from (
  SELECT STATE, COUNT(TRIP_ID) AS UNITS
  FROM TOURS_TRIP
  GROUP BY STATE
) temp (state,units)
where units > 10
</code>```

Body:
I'm working on a 3-step homework problem and I'm stumped on the last step. For the last step to make sense, I'll post the entire problem including my solutions for the first two steps:

The Problem and My Solutions for the First Two Steps

Create a view named TRIP_INVENTORY. It consists of the state and the total number of trips for each state. Use UNITS as the column name for the total number of trips for each state. Group and order the rows by state.

a. Write and execute the CREATE VIEW command to create the TRIP_INVENTORY view.

CREATE VIEW TRIP_INVENTORY AS
SELECT STATE, COUNT(TRIP_ID) AS UNITS
FROM TOURS_TRIP
GROUP BY STATE

b. Write and execute the command to retreive the state and units for each state having more than 10 trips.

SELECT STATE, UNITS
FROM TRIP_INVENTORY
WHERE UNITS > 10

The Step that has Me Stumped

c. Write and execute the query that the DBMS actually executes.

This was the unsuccessful query I came up with:

SELECT STATE, COUNT(TRIP_ID) AS UNITS
FROM TOURS_TRIP
WHERE UNITS > 10
GROUP BY STATE

The problem is that the UNITS column alias can't be referenced in the WHERE clause. I can't use an aggregate function in the WHERE clause either. I'm pretty sure I need to use a subquery, but I can't figure out how to structure the constraints so that they will remove the unnecessary states using the results of the nested query.

Can anyone offer any insight?

Body:
Depends on the implementation but

b)

SELECT STATE, COUNT(TRIP_ID) AS UNITS
FROM TOURS_TRIP
GROUP BY STATE
having COUNT(TRIP_ID) > 10

c)

Select state, units from (
  SELECT STATE, COUNT(TRIP_ID) AS UNITS
  FROM TOURS_TRIP
  GROUP BY STATE
) temp (state,units)
where units > 10


问:
How to copy only the commit messages of Android Studio from log of Version Control

When i block and copy those logs, it will copy the hash, committer, and time too.
For example:

```<code>7e15726 hendrawd on 11/13/16 at 10:18 PM Merge remote-tracking branch 'origin/master'
a464db8 hendrawd on 11/13/16 at 10:16 PM fix ignored files
094ef35 Hendra Wijaya Djiono on 11/10/16 at 4:59 PM Swipe refresh will refresh notification count too
4759306 Hendra Wijaya Djiono on 11/10/16 at 12:51 PM Restructure
33ad61b Hendra Wijaya Djiono on 11/10/16 at 12:46 PM Fix force closed when crop picture on create group
8763667 Hendra Wijaya Djiono on 11/9/16 at 7:02 PM Fix duplicate notification
</code>```

I don't remember when it was implemented, maybe in Android Studio 2.2. It used to be just copy commit messages.

So how i can get only commit messages? Because i just need that instead of the full detail and it is very inconvenience to edit the lines one by one to just get the commit messages.

My Android Studio version is:

```<code>Android Studio 2.3
Build #AI-162.3764568, built on February 24, 2017
JRE: 1.8.0_112-release-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
</code>```

答:
Since there is no setting/button/checkbox to do what i want, the simplest way that i can do without the help of any external software/terminal is just to use regex to detect AM/PM(and a space after it) and replace all the characters before it(inclusive) with empty string directly.

Here are the steps:

Copy the logs

Create a scratch file(Command+Shift+N for Mac)

Paste the logs to the scratch file

Open Replace menu for the scratch file(Command+R for Mac)

Check Regex checkbox

Use this regex on the search box .+?(?=(A|P)M\040)((A|P)M\040)

Hit button Replace all

To be noted, above method is unreliable. If we have commit message that contains string "AM " or "PM ", the previous string will automatically removed too. If IntelliJ decide to change again the copy format of the log, the regex will also be useless. So the best method is to use git command directly with terminal/command prompt

Here is the example:

```<code>git log --since="2017-04-09" --pretty=format:"%s"
</code>```

Body:
When i block and copy those logs, it will copy the hash, committer, and time too.
For example:

7e15726 hendrawd on 11/13/16 at 10:18 PM Merge remote-tracking branch 'origin/master'
a464db8 hendrawd on 11/13/16 at 10:16 PM fix ignored files
094ef35 Hendra Wijaya Djiono on 11/10/16 at 4:59 PM Swipe refresh will refresh notification count too
4759306 Hendra Wijaya Djiono on 11/10/16 at 12:51 PM Restructure
33ad61b Hendra Wijaya Djiono on 11/10/16 at 12:46 PM Fix force closed when crop picture on create group
8763667 Hendra Wijaya Djiono on 11/9/16 at 7:02 PM Fix duplicate notification

I don't remember when it was implemented, maybe in Android Studio 2.2. It used to be just copy commit messages.

So how i can get only commit messages? Because i just need that instead of the full detail and it is very inconvenience to edit the lines one by one to just get the commit messages.

My Android Studio version is:

Android Studio 2.3
Build #AI-162.3764568, built on February 24, 2017
JRE: 1.8.0_112-release-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Body:
Since there is no setting/button/checkbox to do what i want, the simplest way that i can do without the help of any external software/terminal is just to use regex to detect AM/PM(and a space after it) and replace all the characters before it(inclusive) with empty string directly.

Here are the steps:

Copy the logs

Create a scratch file(Command+Shift+N for Mac)

Paste the logs to the scratch file

Open Replace menu for the scratch file(Command+R for Mac)

Check Regex checkbox

Use this regex on the search box .+?(?=(A|P)M\040)((A|P)M\040)

Hit button Replace all

To be noted, above method is unreliable. If we have commit message that contains string "AM " or "PM ", the previous string will automatically removed too. If IntelliJ decide to change again the copy format of the log, the regex will also be useless. So the best method is to use git command directly with terminal/command prompt

Here is the example:

git log --since="2017-04-09" --pretty=format:"%s"


问:
BST nodes are not saving when trying to create a preorder traversal of a previous tree in c
I am trying to see if tree A is the preorder traversal of tree B and to do so, I created two trees which during a transversal were supposed to save the values. However, after hours of debugging I found out that the trees values were ALWAYS 0. I am confused as to why the trees values are 0. I've done a multitude of print statements (some of which I've left in the code posted below) and I just cannot seem to pinpoint why this is happening. Can someone please nudge me in the correct direction? I thought maybe the function was deleting variables as it exited and in effort to get to the bottom of the issue I had the preorder function return the tree ( as seen below), however, the output is ALWAYS 0 for the tree.

Code:

```<code>typedef struct node
{
    // Each node holds a single integer.
    int data;

    // Pointers to the node's left and right children.
    struct node *left, *right;
} node;
int tree_diff(node *a, node *b)
{
    if (a == NULL && b == NULL)
        return 0;

    else if (a == NULL || b == NULL)
        return 1;

    else if (a->data != b->data)
        return 1;
    printf("A %d , B %d", a->data, b->data);

        return tree_diff(a->left, b->left) || tree_diff(a->right, b->right);
}

node *preorder_recursive(node *root, node *A)
{
    if (root == NULL)
        return A;

    printf("root %d ", root->data);
    A = root;
    printf("= data %d\n", A->data);
    preorder_recursive(root->left, A->left);
    preorder_recursive(root->right, A->right);
}

void postorder_recursive(node *root, node *B)
{
    if (root == NULL)
        return;
    B = root;
    postorder_recursive(root->left, B->left);
    postorder_recursive(root->right, B->right);
    printf("root %d ", root->data);
    printf("= data %d\n", B->data);
}

int kindredSpirits(node *a, node *b)
{

  // Get the preorder of a
  node *A = malloc(sizeof(node));
  A = preorder_recursive(a, A);

  // Get the postorder of b
  printf("\n\n");
  node *B = malloc(sizeof(node));
  postorder_recursive(b, B);

if(tree_diff(A,B) == 1)
  return 0;
else
  return 1;
}
</code>```

The test case:

```<code>#include <stdio.h>
#include <stdlib.h>
#include "KindredSpirits.h"
  node *create_node(int data)
{
    node *n = malloc(sizeof(node));

    n->data = data;
    n->left = n->right = NULL;

    return n;
}

node *forest_fire(node *root)
{
    if (root == NULL)
        return NULL;

    forest_fire(root->left);
    forest_fire(root->right);
    free(root);
}

int main(void)
{
    node *root;

    root = create_node(23);
    root->left = create_node(12);
    root->left->left = create_node(5);
    root->left->right = create_node(18);
    root->right = create_node(71);
    root->right->right = create_node(56);

    printf("%s\n", !kindredSpirits(root, root) ? "Success!" : "fail whale :(");

    forest_fire(root);

    return 0;
}
</code>```

答:
Here's a code fragment that should get you started:</p>

```<code>typedef struct node {
    // Each node holds a single integer.
    int data;

    // Pointers to the node's left and right children.
    struct node *left,
    struct node *right;
} node;

typedef struct list {
    int lst_max;                        // maximum number of allocated cells
    int lst_cur;                        // current number of filled cells
    int *lst_base;                      // traversal list
} list;

list list_a = { 0, 0, NULL };
list list_b = { 0, 0, NULL };

void
list_append(list *lst,int data)
{
    int newidx;

    newidx = lst->lst_cur;

    if (newidx >= lst->lst_max) {
        lst->lst_max += 100;
        lst->lst_base = realloc(lst->lst_base,sizeof(int) * lst->lst_max);
        if (lst->lst_base == NULL) {
            printf("list_append: malloc error\n");
            exit(1);
        }
    }

    lst->lst_base[newidx] = data;

    lst->lst_cur = newidx + 1;
}

void
preorder_recursive(node *root,list *lst)
{

    if (root == NULL)
        return;

    list_append(lst,root->data);
    preorder_recursive(root->left,lst);
    preorder_recursive(root->right,lst);
}

void
postorder_recursive(node *root,list *lst)
{

    if (root == NULL)
        return;

    postorder_recursive(root->left,lst);
    postorder_recursive(root->right,lst);
    list_append(lst,root->data);
}

int
main(void)
{

    preorder_recursive(a,&list_a);
    postorder_recursive(b,&list_b);

    // compare list_a and list_b ...

    return 0;
}
</code>```

Body:
I am trying to see if tree A is the preorder traversal of tree B and to do so, I created two trees which during a transversal were supposed to save the values. However, after hours of debugging I found out that the trees values were ALWAYS 0. I am confused as to why the trees values are 0. I've done a multitude of print statements (some of which I've left in the code posted below) and I just cannot seem to pinpoint why this is happening. Can someone please nudge me in the correct direction? I thought maybe the function was deleting variables as it exited and in effort to get to the bottom of the issue I had the preorder function return the tree ( as seen below), however, the output is ALWAYS 0 for the tree.

Code:

typedef struct node
{
    // Each node holds a single integer.
    int data;

    // Pointers to the node's left and right children.
    struct node *left, *right;
} node;
int tree_diff(node *a, node *b)
{
    if (a == NULL && b == NULL)
        return 0;

    else if (a == NULL || b == NULL)
        return 1;

    else if (a->data != b->data)
        return 1;
    printf("A %d , B %d", a->data, b->data);

        return tree_diff(a->left, b->left) || tree_diff(a->right, b->right);
}

node *preorder_recursive(node *root, node *A)
{
    if (root == NULL)
        return A;

    printf("root %d ", root->data);
    A = root;
    printf("= data %d\n", A->data);
    preorder_recursive(root->left, A->left);
    preorder_recursive(root->right, A->right);
}

void postorder_recursive(node *root, node *B)
{
    if (root == NULL)
        return;
    B = root;
    postorder_recursive(root->left, B->left);
    postorder_recursive(root->right, B->right);
    printf("root %d ", root->data);
    printf("= data %d\n", B->data);
}

int kindredSpirits(node *a, node *b)
{

  // Get the preorder of a
  node *A = malloc(sizeof(node));
  A = preorder_recursive(a, A);

  // Get the postorder of b
  printf("\n\n");
  node *B = malloc(sizeof(node));
  postorder_recursive(b, B);

if(tree_diff(A,B) == 1)
  return 0;
else
  return 1;
}

The test case:

#include <stdio.h>
#include <stdlib.h>
#include "KindredSpirits.h"
  node *create_node(int data)
{
    node *n = malloc(sizeof(node));

    n->data = data;
    n->left = n->right = NULL;

    return n;
}

node *forest_fire(node *root)
{
    if (root == NULL)
        return NULL;

    forest_fire(root->left);
    forest_fire(root->right);
    free(root);
}

int main(void)
{
    node *root;

    root = create_node(23);
    root->left = create_node(12);
    root->left->left = create_node(5);
    root->left->right = create_node(18);
    root->right = create_node(71);
    root->right->right = create_node(56);

    printf("%s\n", !kindredSpirits(root, root) ? "Success!" : "fail whale :(");

    forest_fire(root);

    return 0;
}

Body:
Here's a code fragment that should get you started:

typedef struct node {
    // Each node holds a single integer.
    int data;

    // Pointers to the node's left and right children.
    struct node *left,
    struct node *right;
} node;

typedef struct list {
    int lst_max;                        // maximum number of allocated cells
    int lst_cur;                        // current number of filled cells
    int *lst_base;                      // traversal list
} list;

list list_a = { 0, 0, NULL };
list list_b = { 0, 0, NULL };

void
list_append(list *lst,int data)
{
    int newidx;

    newidx = lst->lst_cur;

    if (newidx >= lst->lst_max) {
        lst->lst_max += 100;
        lst->lst_base = realloc(lst->lst_base,sizeof(int) * lst->lst_max);
        if (lst->lst_base == NULL) {
            printf("list_append: malloc error\n");
            exit(1);
        }
    }

    lst->lst_base[newidx] = data;

    lst->lst_cur = newidx + 1;
}

void
preorder_recursive(node *root,list *lst)
{

    if (root == NULL)
        return;

    list_append(lst,root->data);
    preorder_recursive(root->left,lst);
    preorder_recursive(root->right,lst);
}

void
postorder_recursive(node *root,list *lst)
{

    if (root == NULL)
        return;

    postorder_recursive(root->left,lst);
    postorder_recursive(root->right,lst);
    list_append(lst,root->data);
}

int
main(void)
{

    preorder_recursive(a,&list_a);
    postorder_recursive(b,&list_b);

    // compare list_a and list_b ...

    return 0;
}


问:
Symfony 3 Ajax call routing issue
I'm setting up a simple Ajax call in one of my forms. When a user enters characters in a field, the following Ajax call is activated:

```<code>self.modify = function (input_field) {
    if ($(input_field).val().length > 5) {
        $.post("{{path('get_bio_control_sample')}}", {sample_number: $(input_field).val()},
            function (response) {
                if (response.code == 100 && response.success) {
                    alert(response.sample_number);
                }
            }, "json");
    }
};
</code>```

Which is meant to access the following controller action:

```<code>class BioControlController extends Controller {
    /**
     * @Route("/bio_control/sample", name="get_bio_control_sample")
     */
    public function getBioControlSampleAction(Request $request){

        $sample_number = $request->query->get('sample_number');

        $response = array("code" => 100, "success" => true, "sample_number" => $sample_number, "sample_data" => "test");

        return new JsonResponse($response);
    }
}
</code>```

However, when the call is activated JS returns the error:

```<code>http://127.0.0.1:8000/omics_experiment/%7B%7Bpath('get_bio_control_sample')%7D%7D 404 (Not Found)
</code>```

I'm accessing the Ajax call from omics_experiment/new (which is in the OmicsExperimentController) and using the route /bio_control/sample (as shown by the annotation), but it's not working. Can someone explain what I'm doing wrong?

I used this question as a template, the fact I'm using Symfony 3 might mean there are syntactic errors.

答:
I just had to do this recently. I'm no expert on Symfony either, but since I just did this I may be able to help. Using Symfony is not really much different than doing it with a static URL. The main thing is to make sure that your controller and route are set up properly and working without AJAX, then you just need to use the path set in your route for the .post call.

And what makes it worse, is that it's really hard to test this type of interaction. Even your twig includes can cause it to fail if they are set up wrong.

Looking at your code again I think this may be the problem. Change this

```<code>    $.post("{{path('get_bio_control_sample')}}", {sample_number:
</code>```

to this

```<code>    $.post("/bio_control/sample", {sample_number:
</code>```

Because I think the way you have it is only good for twig templates, so if Symfony is not looking at your JQuery file like it does a twig template, then, it's not going to understand how to get the route.

Title: Symfony 3 Ajax call routing issue

Body:
I'm setting up a simple Ajax call in one of my forms. When a user enters characters in a field, the following Ajax call is activated:

self.modify = function (input_field) {
    if ($(input_field).val().length > 5) {
        $.post("{{path('get_bio_control_sample')}}", {sample_number: $(input_field).val()},
            function (response) {
                if (response.code == 100 && response.success) {
                    alert(response.sample_number);
                }
            }, "json");
    }
};

Which is meant to access the following controller action:

class BioControlController extends Controller {
    /**
     * @Route("/bio_control/sample", name="get_bio_control_sample")
     */
    public function getBioControlSampleAction(Request $request){

        $sample_number = $request->query->get('sample_number');

        $response = array("code" => 100, "success" => true, "sample_number" => $sample_number, "sample_data" => "test");

        return new JsonResponse($response);
    }
}

However, when the call is activated JS returns the error:

http://127.0.0.1:8000/omics_experiment/%7B%7Bpath('get_bio_control_sample')%7D%7D 404 (Not Found)

I'm accessing the Ajax call from omics_experiment/new (which is in the OmicsExperimentController) and using the route /bio_control/sample (as shown by the annotation), but it's not working. Can someone explain what I'm doing wrong?

I used this question as a template, the fact I'm using Symfony 3 might mean there are syntactic errors.

Body:
I just had to do this recently. I'm no expert on Symfony either, but since I just did this I may be able to help. Using Symfony is not really much different than doing it with a static URL. The main thing is to make sure that your controller and route are set up properly and working without AJAX, then you just need to use the path set in your route for the .post call.

And what makes it worse, is that it's really hard to test this type of interaction. Even your twig includes can cause it to fail if they are set up wrong.

Looking at your code again I think this may be the problem. Change this

    $.post("{{path('get_bio_control_sample')}}", {sample_number:

to this

    $.post("/bio_control/sample", {sample_number:

Because I think the way you have it is only good for twig templates, so if Symfony is not looking at your JQuery file like it does a twig template, then, it's not going to understand how to get the route.


答:
Change your main method as below.</p>

```<code> static void Main(string[] args)
    {

        Console.Write("Enter the first number\t");
        int number1 = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter the second number\t");
        int number2 = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine(sum(number1, number2));
        Console.WriteLine(difference(number1, number2));
        Console.WriteLine(multiplies(number1, number2));

    }
</code>```

Title: C# Method Return

Body:
Change your main method as below.

 static void Main(string[] args)
    {

        Console.Write("Enter the first number\t");
        int number1 = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter the second number\t");
        int number2 = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine(sum(number1, number2));
        Console.WriteLine(difference(number1, number2));
        Console.WriteLine(multiplies(number1, number2));

    }