问:
Laravel 5.4 NotFoundHttpException
So I am short on info as I have no idea whats going on.

So when I go to mysite.com/login I get NotFoundHttpException This just happened while I was creating another view.

If I go to homeController and change the index view to /auth.login and going to mysite.com shows the login page.

My routes:

```<code>Route::get('/', 'HomeController@index')->name("main");

Route::auth();
</code>```

What's going on?

答: Instead of Route::auth(), try this instead Auth::routes()

Title: Laravel 5.4 NotFoundHttpException

Body:
So I am short on info as I have no idea whats going on.

So when I go to mysite.com/login I get NotFoundHttpException This just happened while I was creating another view.

If I go to homeController and change the index view to /auth.login and going to mysite.com shows the login page.

My routes:

Route::get('/', 'HomeController@index')->name("main");

Route::auth();

What's going on?


来源: stackexchange

问:
Dealing with unknown dimensions in Tensorflow
I wrote a function that calculates the gram matrix for image features of shape (1, H, W, C). Method I wrote is below:

```<code>def calc_gram_matrix(features, normalize=True):
  #input: features is a tensor of shape (1, Height, Width, Channels)

  _, H, W, C = features.shape
  matrix = tf.reshape(features, shape=[-1, int(C)])
  gram = tf.matmul(tf.transpose(matrix), matrix)

  if normalize:
    tot_neurons = H * W * C
    gram = tf.divide(gram,tot_neurons)

return gram
</code>```

To Test my implementation of the gram matrix, There is a method:

```<code> def gram_matrix_test(correct):
    gram = calc_gram_matrix(model.extract_features()[5])     #
    student_output = sess.run(gram, {model.image: style_img_test})
    print(style_img_test.shape)
    error = rel_error(correct, student_output)
    print('Maximum error is {:.3f}'.format(error))

 gram_matrix_test(answers['gm_out'])
</code>```

When I run gram_matrix_test() I get an error -> ValueError: Cannot convert an unknown Dimension to a Tensor: ?

(The error is on this line -> "gram = tf.divide(gram,tot_neurons)" )

On debugging I found out that the shape of model.extract_features()[5] is (?, ?, ?, 128) and hence the division is not possible.

Dimensions of style_img_test are ((1, 192, 242, 3)), so when we run the session H,W,C will get populated.

Can you please guide me on how to fix this?

答:
I made the following changes and it worked.

def calc_gram_matrix(features, normalize=True):
  #input: features is a tensor of shape (1, Height, Width, Channels)

  features_shape = tf.shape(features)
  H = features_shape[1]
  W = features_shape[2]
  C = features_shape[3]

  matrix = tf.reshape(features, shape=[-1, C])
  gram = tf.matmul(tf.transpose(matrix), matrix)

  if normalize:
    tot_neurons = H * W * C
    tot_neurons = tf.cast(tot_neurons, tf.float32)

    gram = tf.divide(gram,tot_neurons)

return gram
```

ContentLicense: CC BY-SA 3.0

Body:
I wrote a function that calculates the gram matrix for image features of shape (1, H, W, C). Method I wrote is below:

def calc_gram_matrix(features, normalize=True):
  #input: features is a tensor of shape (1, Height, Width, Channels)

  _, H, W, C = features.shape
  matrix = tf.reshape(features, shape=[-1, int(C)])
  gram = tf.matmul(tf.transpose(matrix), matrix)

  if normalize:
    tot_neurons = H * W * C
    gram = tf.divide(gram,tot_neurons)

return gram

To Test my implementation of the gram matrix, There is a method:

 def gram_matrix_test(correct):
    gram = calc_gram_matrix(model.extract_features()[5])     #
    student_output = sess.run(gram, {model.image: style_img_test})
    print(style_img_test.shape)
    error = rel_error(correct, student_output)
    print('Maximum error is {:.3f}'.format(error))

 gram_matrix_test(answers['gm_out'])

When I run gram_matrix_test() I get an error -> ValueError: Cannot convert an unknown Dimension to a Tensor: ?

(The error is on this line -> "gram = tf.divide(gram,tot_neurons)" )

On debugging I found out that the shape of model.extract_features()[5] is (?, ?, ?, 128) and hence the division is not possible.

Dimensions of style_img_test are ((1, 192, 242, 3)), so when we run the session H,W,C will get populated.

Can you please guide me on how to fix this?

ContentLicense: CC BY-SA 4.0


问:
Unexpected token ":" with JSON returned from node and express
I'm building a small web service with Node.js and Express, and I'm running into a bit of a problem. Everything seems to work perfectly fine, until I true to use it with Ajax in a browser. If I run it in Postman, I get:

```<code>{
  "status": "ok",
  "data": [
    {
      "GUID": "2f779770-9e1c-415f-9518-ff7fd7d6631c",
      "name": "The Revolver",
      "description": "Rye heavy bourbon, coffee liqueur, orange bitters, orange garnish.",
      "active": 1,
      "categories": [
        "94162f2e-3b2f-4521-a543-068ed6c81011"
      ]
    },
    {
      "GUID": "f05a33ad-e684-4ae0-804c-0c1a61b9945d",
      "name": "Jack Rose",
      "description": "Laird's Applejack, Grenadine, Lemon, Peychaud's bitters, Lemon twist",
      "active": 1,
      "categories": []
    }
  ]
}
</code>```

Headers includes
Content-Type →application/json; charset=utf-8

But when I make the ajax call Chrome says "Uncaught SyntaxError: Unexpected token :"

I'm using res.json({status: "ok", data: result}) to return the response from Express. I've also tried res.setHeader('Content-Type', 'application/json'); with no luck.

Any ideas?

Edit: here's the ajax call:

```<code>function getDrinks(){
  $.ajax({
    url: serviceURL + "getDrinks",
    type: "GET",
    dataType: "jsonp",
    success: function(result){
      if (result.status=="ok"){
        var tableHTML=""
        for (var i = 0; i < result.data.length; i++) {
          var drink=result.data[i]
          tableHTML+="<tr><td>"+drink.name+"</td></tr>"
        }
        tableHTML="<table>"+tableHTML+"</table>"
        $("#drinksContainer").html(tableHTML);
      }
    }
  })
}
</code>```

答:
The client and server will need to agree on whether to use JSON or JSON-P. The two formats are related but aren't interchangeable.

Currently, the client is expecting JSON-P...

```<code>dataType: "jsonp",
</code>```

While the server is responding with JSON...

```<code>res.json({status: "ok", data: result})
</code>```

For JSON-P, the server's response should include Padding around the JSON data, consisting of a callback name and parenthesis.

```<code>var json = JSON.stringify({status: "ok", data: result});
res.send(req.query.callback + '(' + json + ')');
</code>```

Express also defines res.jsonp() to simplify this.

```<code>res.jsonp({status: "ok", data: result});
</code>```

And, jQuery will provide a generated callback name for you, typically consisting of the version of jQuery you're using, a random number, and a timestamp. With that, the response should be something like:

```<code>jQuery32101234567890123456_1496534400000({"status":"ok","data":...});
</code>```

Body:
I'm building a small web service with Node.js and Express, and I'm running into a bit of a problem. Everything seems to work perfectly fine, until I true to use it with Ajax in a browser. If I run it in Postman, I get:

{
  "status": "ok",
  "data": [
    {
      "GUID": "2f779770-9e1c-415f-9518-ff7fd7d6631c",
      "name": "The Revolver",
      "description": "Rye heavy bourbon, coffee liqueur, orange bitters, orange garnish.",
      "active": 1,
      "categories": [
        "94162f2e-3b2f-4521-a543-068ed6c81011"
      ]
    },
    {
      "GUID": "f05a33ad-e684-4ae0-804c-0c1a61b9945d",
      "name": "Jack Rose",
      "description": "Laird's Applejack, Grenadine, Lemon, Peychaud's bitters, Lemon twist",
      "active": 1,
      "categories": []
    }
  ]
}

Headers includes
Content-Type →application/json; charset=utf-8

But when I make the ajax call Chrome says "Uncaught SyntaxError: Unexpected token :"

I'm using res.json({status: "ok", data: result}) to return the response from Express. I've also tried res.setHeader('Content-Type', 'application/json'); with no luck.

Any ideas?

Edit: here's the ajax call:

function getDrinks(){
  $.ajax({
    url: serviceURL + "getDrinks",
    type: "GET",
    dataType: "jsonp",
    success: function(result){
      if (result.status=="ok"){
        var tableHTML=""
        for (var i = 0; i < result.data.length; i++) {
          var drink=result.data[i]
          tableHTML+="
"+drink.name+"
"
        }
        tableHTML="
"+tableHTML+"
"
        $("#drinksContainer").html(tableHTML);
      }
    }
  })
}

Body:
The client and server will need to agree on whether to use JSON or JSON-P. The two formats are related but aren't interchangeable.

Currently, the client is expecting JSON-P...

dataType: "jsonp",

While the server is responding with JSON...

res.json({status: "ok", data: result})

For JSON-P, the server's response should include Padding around the JSON data, consisting of a callback name and parenthesis.

var json = JSON.stringify({status: "ok", data: result});
res.send(req.query.callback + '(' + json + ')');

Express also defines res.jsonp() to simplify this.

res.jsonp({status: "ok", data: result});

And, jQuery will provide a generated callback name for you, typically consisting of the version of jQuery you're using, a random number, and a timestamp. With that, the response should be something like:

jQuery32101234567890123456_1496534400000({"status":"ok","data":...});


问:
Hadoop Installation Issue on Windows
I have been trying to install Hadoop on Windows 7 for quite sometime now. I am following this blog for instructions. But unfortunately I have not been be able to run the Namenode.
There seems to be issue with hdfs-site.xml file but I dont see anything wrong in it. Please have a look at it

hdfs-site.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
   <property>
       <name>dfs.replication</name>
       <value>1</value>
   </property>
   <property>
       <name>dfs.namenode.name.dir</name>
       <value>F:\hadoop-2.7.2\data\namenode</value>
   </property>
   <property>
       <name>dfs.datanode.data.dir</name>
     <value>F:\hadoop-2.7.2\data\datanode</value>
   </property>
</configuration>
</code>```

and the error log that I am getting on running hdfs namenode -format command in command prompt:

```<code>C:\Users\ABC>hdfs namenode -format
Hadoop common not found.
16/08/05 12:44:53 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = ABC-PC/172.20.0.51
STARTUP_MSG:   args = [-format]
STARTUP_MSG:   version = 2.7.2
STARTUP_MSG:   classpath = F:\hadoop-2.7.2\etc\hadoop;F:\hadoop-2.7.2\share\hado
op\common\lib\commons-compress-1.4.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib
\jersey-server-1.9.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jets3t-0.9.0.jar;
F:\hadoop-2.7.2\share\hadoop\common\lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\shar
e\hadoop\common\lib\hadoop-auth-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\li
b\commons-digester-1.8.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\log4j-1.2.17.
jar;F:\hadoop-2.7.2\share\hadoop\common\lib\java-xmlbuilder-0.4.jar;F:\hadoop-2.
7.2\share\hadoop\common\lib\curator-client-2.7.1.jar;F:\hadoop-2.7.2\share\hadoo
p\common\lib\jetty-util-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\xmlen
c-0.52.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\activation-1.1.jar;F:\hadoop-
2.7.2\share\hadoop\common\lib\jackson-core-asl-1.9.13.jar;F:\hadoop-2.7.2\share\
hadoop\common\lib\jaxb-impl-2.2.3-1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\
curator-framework-2.7.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\apacheds-ker
beros-codec-2.0.0-M15.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\netty-3.6.2.Fi
nal.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-collections-3.2.2.jar;F:
\hadoop-2.7.2\share\hadoop\common\lib\htrace-core-3.1.0-incubating.jar;F:\hadoop
-2.7.2\share\hadoop\common\lib\apacheds-i18n-2.0.0-M15.jar;F:\hadoop-2.7.2\share
\hadoop\common\lib\jetty-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\comm
ons-configuration-1.6.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\asm-3.2.jar;F:
\hadoop-2.7.2\share\hadoop\common\lib\commons-io-2.4.jar;F:\hadoop-2.7.2\share\h
adoop\common\lib\commons-codec-1.4.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\j
ackson-mapper-asl-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\curator-rec
ipes-2.7.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\mockito-all-1.8.5.jar;F:\
hadoop-2.7.2\share\hadoop\common\lib\commons-math3-3.1.1.jar;F:\hadoop-2.7.2\sha
re\hadoop\common\lib\commons-net-3.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib
\snappy-java-1.0.4.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jsch-0.1.42.jar
;F:\hadoop-2.7.2\share\hadoop\common\lib\stax-api-1.0-2.jar;F:\hadoop-2.7.2\shar
e\hadoop\common\lib\jackson-jaxrs-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\common
\lib\api-util-1.0.0-M20.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jsp-api-2.1.
jar;F:\hadoop-2.7.2\share\hadoop\common\lib\httpclient-4.2.5.jar;F:\hadoop-2.7.2
\share\hadoop\common\lib\guava-11.0.2.jar;F:\hadoop-2.7.2\share\hadoop\common\li
b\zookeeper-3.4.6.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-lang-2.6.j
ar;F:\hadoop-2.7.2\share\hadoop\common\lib\xz-1.0.jar;F:\hadoop-2.7.2\share\hado
op\common\lib\jackson-xc-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\hado
op-annotations-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jaxb-api-2.2.2.
jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jersey-json-1.9.jar;F:\hadoop-2.7.2\
share\hadoop\common\lib\protobuf-java-2.5.0.jar;F:\hadoop-2.7.2\share\hadoop\com
mon\lib\httpcore-4.2.5.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\avro-1.7.4.ja
r;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-beanutils-core-1.8.0.jar;F:\ha
doop-2.7.2\share\hadoop\common\lib\servlet-api-2.5.jar;F:\hadoop-2.7.2\share\had
oop\common\lib\api-asn1-api-1.0.0-M20.jar;F:\hadoop-2.7.2\share\hadoop\common\li
b\gson-2.2.4.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-cli-1.2.jar;F:\
hadoop-2.7.2\share\hadoop\common\lib\junit-4.11.jar;F:\hadoop-2.7.2\share\hadoop
\common\lib\jettison-1.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jsr305-3.0.
0.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-logging-1.1.3.jar;F:\hadoo
p-2.7.2\share\hadoop\common\lib\slf4j-log4j12-1.7.10.jar;F:\hadoop-2.7.2\share\h
adoop\common\lib\hamcrest-core-1.3.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\s
lf4j-api-1.7.10.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-httpclient-3
.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-beanutils-1.7.0.jar;F:\ha
doop-2.7.2\share\hadoop\common\lib\paranamer-2.3.jar;F:\hadoop-2.7.2\share\hadoo
p\common\hadoop-nfs-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\hadoop-common-
2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\hadoop-common-2.7.2-tests.jar;F:\h
adoop-2.7.2\share\hadoop\hdfs;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\jersey-serve
r-1.9.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\leveldbjni-all-1.8.jar;F:\hadoop
-2.7.2\share\hadoop\hdfs\lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\share\hadoop\hd
fs\lib\netty-all-4.0.23.Final.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\log4j-1.
2.17.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\jetty-util-6.1.26.jar;F:\hadoop-2
.7.2\share\hadoop\hdfs\lib\xmlenc-0.52.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib
\xercesImpl-2.9.1.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\jackson-core-asl-1.9
.13.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\commons-daemon-1.0.13.jar;F:\hadoo
p-2.7.2\share\hadoop\hdfs\lib\netty-3.6.2.Final.jar;F:\hadoop-2.7.2\share\hadoop
\hdfs\lib\htrace-core-3.1.0-incubating.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib
\jetty-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\asm-3.2.jar;F:\hadoop-2.
7.2\share\hadoop\hdfs\lib\commons-io-2.4.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\l
ib\xml-apis-1.3.04.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\commons-codec-1.4.j
ar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\jackson-mapper-asl-1.9.13.jar;F:\hadoop
-2.7.2\share\hadoop\hdfs\lib\guava-11.0.2.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\
lib\commons-lang-2.6.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\protobuf-java-2.5
.0.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\servlet-api-2.5.jar;F:\hadoop-2.7.2
\share\hadoop\hdfs\lib\commons-cli-1.2.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib
\jsr305-3.0.0.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\commons-logging-1.1.3.ja
r;F:\hadoop-2.7.2\share\hadoop\hdfs\hadoop-hdfs-2.7.2-tests.jar;F:\hadoop-2.7.2\
share\hadoop\hdfs\hadoop-hdfs-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\hadoop
-hdfs-nfs-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-compress-1.4.1
.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jersey-server-1.9.jar;F:\hadoop-2.7.2
\share\hadoop\yarn\lib\leveldbjni-all-1.8.jar;F:\hadoop-2.7.2\share\hadoop\yarn\
lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\log4j-1.2.17.jar;F
:\hadoop-2.7.2\share\hadoop\yarn\lib\jersey-client-1.9.jar;F:\hadoop-2.7.2\share
\hadoop\yarn\lib\jetty-util-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\act
ivation-1.1.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jackson-core-asl-1.9.13.ja
r;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jaxb-impl-2.2.3-1.jar;F:\hadoop-2.7.2\sh
are\hadoop\yarn\lib\netty-3.6.2.Final.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\
commons-collections-3.2.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\aopalliance-
1.0.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jetty-6.1.26.jar;F:\hadoop-2.7.2\s
hare\hadoop\yarn\lib\asm-3.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-i
o-2.4.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-codec-1.4.jar;F:\hadoop-
2.7.2\share\hadoop\yarn\lib\jersey-guice-1.9.jar;F:\hadoop-2.7.2\share\hadoop\ya
rn\lib\jackson-mapper-asl-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\zooke
eper-3.4.6-tests.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\javax.inject-1.jar;F:
\hadoop-2.7.2\share\hadoop\yarn\lib\stax-api-1.0-2.jar;F:\hadoop-2.7.2\share\had
oop\yarn\lib\jackson-jaxrs-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\guic
e-3.0.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\guava-11.0.2.jar;F:\hadoop-2.7.2
\share\hadoop\yarn\lib\zookeeper-3.4.6.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib
\commons-lang-2.6.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\xz-1.0.jar;F:\hadoop
-2.7.2\share\hadoop\yarn\lib\jackson-xc-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\
yarn\lib\jaxb-api-2.2.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jersey-json-1.
9.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\protobuf-java-2.5.0.jar;F:\hadoop-2.
7.2\share\hadoop\yarn\lib\servlet-api-2.5.jar;F:\hadoop-2.7.2\share\hadoop\yarn\
lib\guice-servlet-3.0.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-cli-1.2.
jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jettison-1.1.jar;F:\hadoop-2.7.2\share
\hadoop\yarn\lib\jsr305-3.0.0.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-
logging-1.1.3.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-api-2.7.2.jar;F:
\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-server-applicationhistoryservice-2.7
.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-server-web-proxy-2.7.2.jar;
F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-server-resourcemanager-2.7.2.jar;F
:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-server-sharedcachemanager-2.7.2.jar
;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-applications-distributedshell-2.7
.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-applications-unmanaged-am-l
auncher-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-registry-2.7.2.j
ar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-client-2.7.2.jar;F:\hadoop-2.7.
2\share\hadoop\yarn\hadoop-yarn-common-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\ya
rn\hadoop-yarn-server-common-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-
yarn-server-nodemanager-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-
server-tests-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\commons-compre
ss-1.4.1.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\jersey-server-1.9.jar;F:
\hadoop-2.7.2\share\hadoop\mapreduce\lib\leveldbjni-all-1.8.jar;F:\hadoop-2.7.2\
share\hadoop\mapreduce\lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\share\hadoop\mapr
educe\lib\log4j-1.2.17.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\jackson-co
re-asl-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\netty-3.6.2.Final.j
ar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\aopalliance-1.0.jar;F:\hadoop-2.7.
2\share\hadoop\mapreduce\lib\asm-3.2.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\
lib\commons-io-2.4.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\jersey-guice-1
.9.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\jackson-mapper-asl-1.9.13.jar;
F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\javax.inject-1.jar;F:\hadoop-2.7.2\sh
are\hadoop\mapreduce\lib\snappy-java-1.0.4.1.jar;F:\hadoop-2.7.2\share\hadoop\ma
preduce\lib\guice-3.0.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\xz-1.0.jar;
F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\hadoop-annotations-2.7.2.jar;F:\hadoo
p-2.7.2\share\hadoop\mapreduce\lib\protobuf-java-2.5.0.jar;F:\hadoop-2.7.2\share
\hadoop\mapreduce\lib\avro-1.7.4.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\
guice-servlet-3.0.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\junit-4.11.jar;
F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\hamcrest-core-1.3.jar;F:\hadoop-2.7.2
\share\hadoop\mapreduce\lib\paranamer-2.3.jar;F:\hadoop-2.7.2\share\hadoop\mapre
duce\hadoop-mapreduce-examples-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\
hadoop-mapreduce-client-hs-plugins-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\mapred
uce\hadoop-mapreduce-client-common-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\mapred
uce\hadoop-mapreduce-client-jobclient-2.7.2-tests.jar;F:\hadoop-2.7.2\share\hado
op\mapreduce\hadoop-mapreduce-client-hs-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\m
apreduce\hadoop-mapreduce-client-shuffle-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\
mapreduce\hadoop-mapreduce-client-core-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\ma
preduce\hadoop-mapreduce-client-jobclient-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop
\mapreduce\hadoop-mapreduce-client-app-2.7.2.jar
STARTUP_MSG:   build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r b16
5c4fe8a74265c792ce23f546c64604acf0e41; compiled by 'jenkins' on 2016-01-26T00:08
Z
STARTUP_MSG:   java = 1.7.0_79
************************************************************/
16/08/05 12:44:53 INFO namenode.NameNode: createNameNode [-format]
16/08/05 12:44:53 WARN util.NativeCodeLoader: Unable to load native-hadoop libra
ry for your platform... using builtin-java classes where applicable
16/08/05 12:44:54 ERROR common.Util: Syntax error in URI F:\hadoop-2.7.2\data\na
menode. Please check hdfs configuration.
java.net.URISyntaxException: Illegal character in opaque part at index 2: F:\had
oop-2.7.2\data\namenode
        at java.net.URI$Parser.fail(URI.java:2829)
        at java.net.URI$Parser.checkChars(URI.java:3002)
        at java.net.URI$Parser.parse(URI.java:3039)
        at java.net.URI.<init>(URI.java:595)
        at org.apache.hadoop.hdfs.server.common.Util.stringAsURI(Util.java:48)
        at org.apache.hadoop.hdfs.server.common.Util.stringCollectionAsURIs(Util
.java:98)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getStorageDirs(FS
Namesystem.java:1400)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNamespaceDirs(
FSNamesystem.java:1355)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:
966)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNo
de.java:1429)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:15
54)
16/08/05 12:44:54 WARN common.Util: Path F:\hadoop-2.7.2\data\namenode should be
 specified as a URI in configuration files. Please update hdfs configuration.
16/08/05 12:44:54 ERROR common.Util: Syntax error in URI F:\hadoop-2.7.2\data\na
menode. Please check hdfs configuration.
java.net.URISyntaxException: Illegal character in opaque part at index 2: F:\had
oop-2.7.2\data\namenode
        at java.net.URI$Parser.fail(URI.java:2829)
        at java.net.URI$Parser.checkChars(URI.java:3002)
        at java.net.URI$Parser.parse(URI.java:3039)
        at java.net.URI.<init>(URI.java:595)
        at org.apache.hadoop.hdfs.server.common.Util.stringAsURI(Util.java:48)
        at org.apache.hadoop.hdfs.server.common.Util.stringCollectionAsURIs(Util
.java:98)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getStorageDirs(FS
Namesystem.java:1400)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNamespaceEdits
Dirs(FSNamesystem.java:1445)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNamespaceEdits
Dirs(FSNamesystem.java:1414)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:
971)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNo
de.java:1429)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:15
54)
16/08/05 12:44:54 WARN common.Util: Path F:\hadoop-2.7.2\data\namenode should be
 specified as a URI in configuration files. Please update hdfs configuration.
Formatting using clusterid: CID-e302dfa9-9520-4074-9247-d9f09cd0f882
16/08/05 12:44:54 INFO namenode.FSNamesystem: No KeyProvider found.
16/08/05 12:44:54 INFO namenode.FSNamesystem: fsLock is fair:true
16/08/05 12:44:54 INFO blockmanagement.DatanodeManager: dfs.block.invalidate.lim
it=1000
16/08/05 12:44:54 INFO blockmanagement.DatanodeManager: dfs.namenode.datanode.re
gistration.ip-hostname-check=true
16/08/05 12:44:54 INFO blockmanagement.BlockManager: dfs.namenode.startup.delay.
block.deletion.sec is set to 000:00:00:00.000
16/08/05 12:44:54 INFO blockmanagement.BlockManager: The block deletion will sta
rt around 2016 Aug 05 12:44:54
16/08/05 12:44:54 INFO util.GSet: Computing capacity for map BlocksMap
16/08/05 12:44:54 INFO util.GSet: VM type       = 32-bit
16/08/05 12:44:54 INFO util.GSet: 2.0% max memory 966.7 MB = 19.3 MB
16/08/05 12:44:54 INFO util.GSet: capacity      = 2^22 = 4194304 entries
16/08/05 12:44:54 INFO blockmanagement.BlockManager: dfs.block.access.token.enab
le=false
16/08/05 12:44:54 INFO blockmanagement.BlockManager: defaultReplication
= 1
16/08/05 12:44:54 INFO blockmanagement.BlockManager: maxReplication
= 512
16/08/05 12:44:54 INFO blockmanagement.BlockManager: minReplication
= 1
16/08/05 12:44:54 INFO blockmanagement.BlockManager: maxReplicationStreams
= 2
16/08/05 12:44:54 INFO blockmanagement.BlockManager: replicationRecheckInterval
= 3000
16/08/05 12:44:54 INFO blockmanagement.BlockManager: encryptDataTransfer
= false
16/08/05 12:44:54 INFO blockmanagement.BlockManager: maxNumBlocksToLog
= 1000
16/08/05 12:44:54 INFO namenode.FSNamesystem: fsOwner             = ABC (auth:S
IMPLE)
16/08/05 12:44:54 INFO namenode.FSNamesystem: supergroup          = supergroup
16/08/05 12:44:54 INFO namenode.FSNamesystem: isPermissionEnabled = true
16/08/05 12:44:54 INFO namenode.FSNamesystem: HA Enabled: false
16/08/05 12:44:54 INFO namenode.FSNamesystem: Append Enabled: true
16/08/05 12:44:54 INFO util.GSet: Computing capacity for map INodeMap
16/08/05 12:44:54 INFO util.GSet: VM type       = 32-bit
16/08/05 12:44:54 INFO util.GSet: 1.0% max memory 966.7 MB = 9.7 MB
16/08/05 12:44:54 INFO util.GSet: capacity      = 2^21 = 2097152 entries
16/08/05 12:44:54 INFO namenode.FSDirectory: ACLs enabled? false
16/08/05 12:44:54 INFO namenode.FSDirectory: XAttrs enabled? true
16/08/05 12:44:54 INFO namenode.FSDirectory: Maximum size of an xattr: 16384
16/08/05 12:44:54 INFO namenode.NameNode: Caching file names occuring more than
10 times
16/08/05 12:44:54 INFO util.GSet: Computing capacity for map cachedBlocks
16/08/05 12:44:54 INFO util.GSet: VM type       = 32-bit
16/08/05 12:44:54 INFO util.GSet: 0.25% max memory 966.7 MB = 2.4 MB
16/08/05 12:44:54 INFO util.GSet: capacity      = 2^19 = 524288 entries
16/08/05 12:44:54 INFO namenode.FSNamesystem: dfs.namenode.safemode.threshold-pc
t = 0.9990000128746033
16/08/05 12:44:54 INFO namenode.FSNamesystem: dfs.namenode.safemode.min.datanode
s = 0
16/08/05 12:44:54 INFO namenode.FSNamesystem: dfs.namenode.safemode.extension
  = 30000
16/08/05 12:44:54 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.n
um.buckets = 10
16/08/05 12:44:54 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.user
s = 10
16/08/05 12:44:54 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.
minutes = 1,5,25
16/08/05 12:44:54 INFO namenode.FSNamesystem: Retry cache on namenode is enabled

16/08/05 12:44:54 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total
 heap and retry cache entry expiry time is 600000 millis
16/08/05 12:44:54 INFO util.GSet: Computing capacity for map NameNodeRetryCache
16/08/05 12:44:54 INFO util.GSet: VM type       = 32-bit
16/08/05 12:44:54 INFO util.GSet: 0.029999999329447746% max memory 966.7 MB = 29
7.0 KB
16/08/05 12:44:54 INFO util.GSet: capacity      = 2^16 = 65536 entries
Re-format filesystem in Storage Directory F:\hadoop-2.7.2\data\namenode ? (Y or
N) y
16/08/05 12:55:16 INFO namenode.FSImage: Allocated new BlockPoolId: BP-124614392
5-172.20.0.51-1470383716578
16/08/05 12:55:16 INFO common.Storage: Storage directory F:\hadoop-2.7.2\data\na
menode has been successfully formatted.
16/08/05 12:55:16 INFO namenode.NNStorageRetentionManager: Going to retain 1 ima
ges with txid >= 0
16/08/05 12:55:16 INFO util.ExitUtil: Exiting with status 0
16/08/05 12:55:16 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at ABC-PC/192.168.0.51
************************************************************/
</code>```

and can anybody please guide what I am doing wrong here?

UPDATE
Thanks to @Binary Nerd for setting things correctly. But now I am facing another problem, even though the System Architecture is 32-bits the NameNode is not started and following error appears (excerpt):

```<code>CreateProcess error=216, This version of %1 is not compatible with the version of
Windows you're running. Check your computer's system information to see whether
you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact
 the software publisher
</code>```

答:
Kinda late, but for future reference.

My problem was that I copy pasted the hdfs-site.xml from the tutorial and a special character,probably newline, was added in this line

```<code><property><name>dfs.namenode.name.dir</name><value>/hadoop-
2.6.0/data/name</value><final>true</final></property>
</code>```

so just go and delete it

```<code><property>
<name>dfs.namenode.name.dir</name><value>/hadoop-2.6.0/data/name</value><final>true</final>
</property>
</code>```

this sort of installation problems are the worst...they just discourage you so much

Title: Hadoop Installation Issue on Windows

Body:
I have been trying to install Hadoop on Windows 7 for quite sometime now. I am following this blog for instructions. But unfortunately I have not been be able to run the Namenode.
There seems to be issue with hdfs-site.xml file but I dont see anything wrong in it. Please have a look at it

hdfs-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
   <property>
       <name>dfs.replication</name>
       <value>1</value>
   </property>
   <property>
       <name>dfs.namenode.name.dir</name>
       <value>F:\hadoop-2.7.2\data\namenode</value>
   </property>
   <property>
       <name>dfs.datanode.data.dir</name>
     <value>F:\hadoop-2.7.2\data\datanode</value>
   </property>
</configuration>

and the error log that I am getting on running hdfs namenode -format command in command prompt:

C:\Users\ABC>hdfs namenode -format
Hadoop common not found.
16/08/05 12:44:53 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = ABC-PC/172.20.0.51
STARTUP_MSG:   args = [-format]
STARTUP_MSG:   version = 2.7.2
STARTUP_MSG:   classpath = F:\hadoop-2.7.2\etc\hadoop;F:\hadoop-2.7.2\share\hado
op\common\lib\commons-compress-1.4.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib
\jersey-server-1.9.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jets3t-0.9.0.jar;
F:\hadoop-2.7.2\share\hadoop\common\lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\shar
e\hadoop\common\lib\hadoop-auth-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\li
b\commons-digester-1.8.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\log4j-1.2.17.
jar;F:\hadoop-2.7.2\share\hadoop\common\lib\java-xmlbuilder-0.4.jar;F:\hadoop-2.
7.2\share\hadoop\common\lib\curator-client-2.7.1.jar;F:\hadoop-2.7.2\share\hadoo
p\common\lib\jetty-util-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\xmlen
c-0.52.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\activation-1.1.jar;F:\hadoop-
2.7.2\share\hadoop\common\lib\jackson-core-asl-1.9.13.jar;F:\hadoop-2.7.2\share\
hadoop\common\lib\jaxb-impl-2.2.3-1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\
curator-framework-2.7.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\apacheds-ker
beros-codec-2.0.0-M15.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\netty-3.6.2.Fi
nal.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-collections-3.2.2.jar;F:
\hadoop-2.7.2\share\hadoop\common\lib\htrace-core-3.1.0-incubating.jar;F:\hadoop
-2.7.2\share\hadoop\common\lib\apacheds-i18n-2.0.0-M15.jar;F:\hadoop-2.7.2\share
\hadoop\common\lib\jetty-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\comm
ons-configuration-1.6.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\asm-3.2.jar;F:
\hadoop-2.7.2\share\hadoop\common\lib\commons-io-2.4.jar;F:\hadoop-2.7.2\share\h
adoop\common\lib\commons-codec-1.4.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\j
ackson-mapper-asl-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\curator-rec
ipes-2.7.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\mockito-all-1.8.5.jar;F:\
hadoop-2.7.2\share\hadoop\common\lib\commons-math3-3.1.1.jar;F:\hadoop-2.7.2\sha
re\hadoop\common\lib\commons-net-3.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib
\snappy-java-1.0.4.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jsch-0.1.42.jar
;F:\hadoop-2.7.2\share\hadoop\common\lib\stax-api-1.0-2.jar;F:\hadoop-2.7.2\shar
e\hadoop\common\lib\jackson-jaxrs-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\common
\lib\api-util-1.0.0-M20.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jsp-api-2.1.
jar;F:\hadoop-2.7.2\share\hadoop\common\lib\httpclient-4.2.5.jar;F:\hadoop-2.7.2
\share\hadoop\common\lib\guava-11.0.2.jar;F:\hadoop-2.7.2\share\hadoop\common\li
b\zookeeper-3.4.6.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-lang-2.6.j
ar;F:\hadoop-2.7.2\share\hadoop\common\lib\xz-1.0.jar;F:\hadoop-2.7.2\share\hado
op\common\lib\jackson-xc-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\hado
op-annotations-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jaxb-api-2.2.2.
jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jersey-json-1.9.jar;F:\hadoop-2.7.2\
share\hadoop\common\lib\protobuf-java-2.5.0.jar;F:\hadoop-2.7.2\share\hadoop\com
mon\lib\httpcore-4.2.5.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\avro-1.7.4.ja
r;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-beanutils-core-1.8.0.jar;F:\ha
doop-2.7.2\share\hadoop\common\lib\servlet-api-2.5.jar;F:\hadoop-2.7.2\share\had
oop\common\lib\api-asn1-api-1.0.0-M20.jar;F:\hadoop-2.7.2\share\hadoop\common\li
b\gson-2.2.4.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-cli-1.2.jar;F:\
hadoop-2.7.2\share\hadoop\common\lib\junit-4.11.jar;F:\hadoop-2.7.2\share\hadoop
\common\lib\jettison-1.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jsr305-3.0.
0.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-logging-1.1.3.jar;F:\hadoo
p-2.7.2\share\hadoop\common\lib\slf4j-log4j12-1.7.10.jar;F:\hadoop-2.7.2\share\h
adoop\common\lib\hamcrest-core-1.3.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\s
lf4j-api-1.7.10.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-httpclient-3
.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\commons-beanutils-1.7.0.jar;F:\ha
doop-2.7.2\share\hadoop\common\lib\paranamer-2.3.jar;F:\hadoop-2.7.2\share\hadoo
p\common\hadoop-nfs-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\hadoop-common-
2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\hadoop-common-2.7.2-tests.jar;F:\h
adoop-2.7.2\share\hadoop\hdfs;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\jersey-serve
r-1.9.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\leveldbjni-all-1.8.jar;F:\hadoop
-2.7.2\share\hadoop\hdfs\lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\share\hadoop\hd
fs\lib\netty-all-4.0.23.Final.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\log4j-1.
2.17.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\jetty-util-6.1.26.jar;F:\hadoop-2
.7.2\share\hadoop\hdfs\lib\xmlenc-0.52.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib
\xercesImpl-2.9.1.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\jackson-core-asl-1.9
.13.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\commons-daemon-1.0.13.jar;F:\hadoo
p-2.7.2\share\hadoop\hdfs\lib\netty-3.6.2.Final.jar;F:\hadoop-2.7.2\share\hadoop
\hdfs\lib\htrace-core-3.1.0-incubating.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib
\jetty-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\asm-3.2.jar;F:\hadoop-2.
7.2\share\hadoop\hdfs\lib\commons-io-2.4.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\l
ib\xml-apis-1.3.04.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\commons-codec-1.4.j
ar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\jackson-mapper-asl-1.9.13.jar;F:\hadoop
-2.7.2\share\hadoop\hdfs\lib\guava-11.0.2.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\
lib\commons-lang-2.6.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\protobuf-java-2.5
.0.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\servlet-api-2.5.jar;F:\hadoop-2.7.2
\share\hadoop\hdfs\lib\commons-cli-1.2.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib
\jsr305-3.0.0.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\lib\commons-logging-1.1.3.ja
r;F:\hadoop-2.7.2\share\hadoop\hdfs\hadoop-hdfs-2.7.2-tests.jar;F:\hadoop-2.7.2\
share\hadoop\hdfs\hadoop-hdfs-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\hdfs\hadoop
-hdfs-nfs-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-compress-1.4.1
.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jersey-server-1.9.jar;F:\hadoop-2.7.2
\share\hadoop\yarn\lib\leveldbjni-all-1.8.jar;F:\hadoop-2.7.2\share\hadoop\yarn\
lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\log4j-1.2.17.jar;F
:\hadoop-2.7.2\share\hadoop\yarn\lib\jersey-client-1.9.jar;F:\hadoop-2.7.2\share
\hadoop\yarn\lib\jetty-util-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\act
ivation-1.1.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jackson-core-asl-1.9.13.ja
r;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jaxb-impl-2.2.3-1.jar;F:\hadoop-2.7.2\sh
are\hadoop\yarn\lib\netty-3.6.2.Final.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\
commons-collections-3.2.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\aopalliance-
1.0.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jetty-6.1.26.jar;F:\hadoop-2.7.2\s
hare\hadoop\yarn\lib\asm-3.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-i
o-2.4.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-codec-1.4.jar;F:\hadoop-
2.7.2\share\hadoop\yarn\lib\jersey-guice-1.9.jar;F:\hadoop-2.7.2\share\hadoop\ya
rn\lib\jackson-mapper-asl-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\zooke
eper-3.4.6-tests.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\javax.inject-1.jar;F:
\hadoop-2.7.2\share\hadoop\yarn\lib\stax-api-1.0-2.jar;F:\hadoop-2.7.2\share\had
oop\yarn\lib\jackson-jaxrs-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\guic
e-3.0.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\guava-11.0.2.jar;F:\hadoop-2.7.2
\share\hadoop\yarn\lib\zookeeper-3.4.6.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib
\commons-lang-2.6.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\xz-1.0.jar;F:\hadoop
-2.7.2\share\hadoop\yarn\lib\jackson-xc-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\
yarn\lib\jaxb-api-2.2.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jersey-json-1.
9.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\protobuf-java-2.5.0.jar;F:\hadoop-2.
7.2\share\hadoop\yarn\lib\servlet-api-2.5.jar;F:\hadoop-2.7.2\share\hadoop\yarn\
lib\guice-servlet-3.0.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-cli-1.2.
jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\jettison-1.1.jar;F:\hadoop-2.7.2\share
\hadoop\yarn\lib\jsr305-3.0.0.jar;F:\hadoop-2.7.2\share\hadoop\yarn\lib\commons-
logging-1.1.3.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-api-2.7.2.jar;F:
\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-server-applicationhistoryservice-2.7
.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-server-web-proxy-2.7.2.jar;
F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-server-resourcemanager-2.7.2.jar;F
:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-server-sharedcachemanager-2.7.2.jar
;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-applications-distributedshell-2.7
.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-applications-unmanaged-am-l
auncher-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-registry-2.7.2.j
ar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-client-2.7.2.jar;F:\hadoop-2.7.
2\share\hadoop\yarn\hadoop-yarn-common-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\ya
rn\hadoop-yarn-server-common-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-
yarn-server-nodemanager-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\yarn\hadoop-yarn-
server-tests-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\commons-compre
ss-1.4.1.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\jersey-server-1.9.jar;F:
\hadoop-2.7.2\share\hadoop\mapreduce\lib\leveldbjni-all-1.8.jar;F:\hadoop-2.7.2\
share\hadoop\mapreduce\lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\share\hadoop\mapr
educe\lib\log4j-1.2.17.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\jackson-co
re-asl-1.9.13.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\netty-3.6.2.Final.j
ar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\aopalliance-1.0.jar;F:\hadoop-2.7.
2\share\hadoop\mapreduce\lib\asm-3.2.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\
lib\commons-io-2.4.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\jersey-guice-1
.9.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\jackson-mapper-asl-1.9.13.jar;
F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\javax.inject-1.jar;F:\hadoop-2.7.2\sh
are\hadoop\mapreduce\lib\snappy-java-1.0.4.1.jar;F:\hadoop-2.7.2\share\hadoop\ma
preduce\lib\guice-3.0.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\xz-1.0.jar;
F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\hadoop-annotations-2.7.2.jar;F:\hadoo
p-2.7.2\share\hadoop\mapreduce\lib\protobuf-java-2.5.0.jar;F:\hadoop-2.7.2\share
\hadoop\mapreduce\lib\avro-1.7.4.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\
guice-servlet-3.0.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\junit-4.11.jar;
F:\hadoop-2.7.2\share\hadoop\mapreduce\lib\hamcrest-core-1.3.jar;F:\hadoop-2.7.2
\share\hadoop\mapreduce\lib\paranamer-2.3.jar;F:\hadoop-2.7.2\share\hadoop\mapre
duce\hadoop-mapreduce-examples-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\mapreduce\
hadoop-mapreduce-client-hs-plugins-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\mapred
uce\hadoop-mapreduce-client-common-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\mapred
uce\hadoop-mapreduce-client-jobclient-2.7.2-tests.jar;F:\hadoop-2.7.2\share\hado
op\mapreduce\hadoop-mapreduce-client-hs-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\m
apreduce\hadoop-mapreduce-client-shuffle-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\
mapreduce\hadoop-mapreduce-client-core-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\ma
preduce\hadoop-mapreduce-client-jobclient-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop
\mapreduce\hadoop-mapreduce-client-app-2.7.2.jar
STARTUP_MSG:   build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r b16
5c4fe8a74265c792ce23f546c64604acf0e41; compiled by 'jenkins' on 2016-01-26T00:08
Z
STARTUP_MSG:   java = 1.7.0_79
************************************************************/
16/08/05 12:44:53 INFO namenode.NameNode: createNameNode [-format]
16/08/05 12:44:53 WARN util.NativeCodeLoader: Unable to load native-hadoop libra
ry for your platform... using builtin-java classes where applicable
16/08/05 12:44:54 ERROR common.Util: Syntax error in URI F:\hadoop-2.7.2\data\na
menode. Please check hdfs configuration.
java.net.URISyntaxException: Illegal character in opaque part at index 2: F:\had
oop-2.7.2\data\namenode
        at java.net.URI$Parser.fail(URI.java:2829)
        at java.net.URI$Parser.checkChars(URI.java:3002)
        at java.net.URI$Parser.parse(URI.java:3039)
        at java.net.URI.<init>(URI.java:595)
        at org.apache.hadoop.hdfs.server.common.Util.stringAsURI(Util.java:48)
        at org.apache.hadoop.hdfs.server.common.Util.stringCollectionAsURIs(Util
.java:98)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getStorageDirs(FS
Namesystem.java:1400)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNamespaceDirs(
FSNamesystem.java:1355)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:
966)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNo
de.java:1429)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:15
54)
16/08/05 12:44:54 WARN common.Util: Path F:\hadoop-2.7.2\data\namenode should be
 specified as a URI in configuration files. Please update hdfs configuration.
16/08/05 12:44:54 ERROR common.Util: Syntax error in URI F:\hadoop-2.7.2\data\na
menode. Please check hdfs configuration.
java.net.URISyntaxException: Illegal character in opaque part at index 2: F:\had
oop-2.7.2\data\namenode
        at java.net.URI$Parser.fail(URI.java:2829)
        at java.net.URI$Parser.checkChars(URI.java:3002)
        at java.net.URI$Parser.parse(URI.java:3039)
        at java.net.URI.<init>(URI.java:595)
        at org.apache.hadoop.hdfs.server.common.Util.stringAsURI(Util.java:48)
        at org.apache.hadoop.hdfs.server.common.Util.stringCollectionAsURIs(Util
.java:98)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getStorageDirs(FS
Namesystem.java:1400)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNamespaceEdits
Dirs(FSNamesystem.java:1445)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNamespaceEdits
Dirs(FSNamesystem.java:1414)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:
971)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNo
de.java:1429)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:15
54)
16/08/05 12:44:54 WARN common.Util: Path F:\hadoop-2.7.2\data\namenode should be
 specified as a URI in configuration files. Please update hdfs configuration.
Formatting using clusterid: CID-e302dfa9-9520-4074-9247-d9f09cd0f882
16/08/05 12:44:54 INFO namenode.FSNamesystem: No KeyProvider found.
16/08/05 12:44:54 INFO namenode.FSNamesystem: fsLock is fair:true
16/08/05 12:44:54 INFO blockmanagement.DatanodeManager: dfs.block.invalidate.lim
it=1000
16/08/05 12:44:54 INFO blockmanagement.DatanodeManager: dfs.namenode.datanode.re
gistration.ip-hostname-check=true
16/08/05 12:44:54 INFO blockmanagement.BlockManager: dfs.namenode.startup.delay.
block.deletion.sec is set to 000:00:00:00.000
16/08/05 12:44:54 INFO blockmanagement.BlockManager: The block deletion will sta
rt around 2016 Aug 05 12:44:54
16/08/05 12:44:54 INFO util.GSet: Computing capacity for map BlocksMap
16/08/05 12:44:54 INFO util.GSet: VM type       = 32-bit
16/08/05 12:44:54 INFO util.GSet: 2.0% max memory 966.7 MB = 19.3 MB
16/08/05 12:44:54 INFO util.GSet: capacity      = 2^22 = 4194304 entries
16/08/05 12:44:54 INFO blockmanagement.BlockManager: dfs.block.access.token.enab
le=false
16/08/05 12:44:54 INFO blockmanagement.BlockManager: defaultReplication
= 1
16/08/05 12:44:54 INFO blockmanagement.BlockManager: maxReplication
= 512
16/08/05 12:44:54 INFO blockmanagement.BlockManager: minReplication
= 1
16/08/05 12:44:54 INFO blockmanagement.BlockManager: maxReplicationStreams
= 2
16/08/05 12:44:54 INFO blockmanagement.BlockManager: replicationRecheckInterval
= 3000
16/08/05 12:44:54 INFO blockmanagement.BlockManager: encryptDataTransfer
= false
16/08/05 12:44:54 INFO blockmanagement.BlockManager: maxNumBlocksToLog
= 1000
16/08/05 12:44:54 INFO namenode.FSNamesystem: fsOwner             = ABC (auth:S
IMPLE)
16/08/05 12:44:54 INFO namenode.FSNamesystem: supergroup          = supergroup
16/08/05 12:44:54 INFO namenode.FSNamesystem: isPermissionEnabled = true
16/08/05 12:44:54 INFO namenode.FSNamesystem: HA Enabled: false
16/08/05 12:44:54 INFO namenode.FSNamesystem: Append Enabled: true
16/08/05 12:44:54 INFO util.GSet: Computing capacity for map INodeMap
16/08/05 12:44:54 INFO util.GSet: VM type       = 32-bit
16/08/05 12:44:54 INFO util.GSet: 1.0% max memory 966.7 MB = 9.7 MB
16/08/05 12:44:54 INFO util.GSet: capacity      = 2^21 = 2097152 entries
16/08/05 12:44:54 INFO namenode.FSDirectory: ACLs enabled? false
16/08/05 12:44:54 INFO namenode.FSDirectory: XAttrs enabled? true
16/08/05 12:44:54 INFO namenode.FSDirectory: Maximum size of an xattr: 16384
16/08/05 12:44:54 INFO namenode.NameNode: Caching file names occuring more than
10 times
16/08/05 12:44:54 INFO util.GSet: Computing capacity for map cachedBlocks
16/08/05 12:44:54 INFO util.GSet: VM type       = 32-bit
16/08/05 12:44:54 INFO util.GSet: 0.25% max memory 966.7 MB = 2.4 MB
16/08/05 12:44:54 INFO util.GSet: capacity      = 2^19 = 524288 entries
16/08/05 12:44:54 INFO namenode.FSNamesystem: dfs.namenode.safemode.threshold-pc
t = 0.9990000128746033
16/08/05 12:44:54 INFO namenode.FSNamesystem: dfs.namenode.safemode.min.datanode
s = 0
16/08/05 12:44:54 INFO namenode.FSNamesystem: dfs.namenode.safemode.extension
  = 30000
16/08/05 12:44:54 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.n
um.buckets = 10
16/08/05 12:44:54 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.user
s = 10
16/08/05 12:44:54 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.
minutes = 1,5,25
16/08/05 12:44:54 INFO namenode.FSNamesystem: Retry cache on namenode is enabled

16/08/05 12:44:54 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total
 heap and retry cache entry expiry time is 600000 millis
16/08/05 12:44:54 INFO util.GSet: Computing capacity for map NameNodeRetryCache
16/08/05 12:44:54 INFO util.GSet: VM type       = 32-bit
16/08/05 12:44:54 INFO util.GSet: 0.029999999329447746% max memory 966.7 MB = 29
7.0 KB
16/08/05 12:44:54 INFO util.GSet: capacity      = 2^16 = 65536 entries
Re-format filesystem in Storage Directory F:\hadoop-2.7.2\data\namenode ? (Y or
N) y
16/08/05 12:55:16 INFO namenode.FSImage: Allocated new BlockPoolId: BP-124614392
5-172.20.0.51-1470383716578
16/08/05 12:55:16 INFO common.Storage: Storage directory F:\hadoop-2.7.2\data\na
menode has been successfully formatted.
16/08/05 12:55:16 INFO namenode.NNStorageRetentionManager: Going to retain 1 ima
ges with txid >= 0
16/08/05 12:55:16 INFO util.ExitUtil: Exiting with status 0
16/08/05 12:55:16 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at ABC-PC/192.168.0.51
************************************************************/

and can anybody please guide what I am doing wrong here?

UPDATE
Thanks to @Binary Nerd for setting things correctly. But now I am facing another problem, even though the System Architecture is 32-bits the NameNode is not started and following error appears (excerpt):

CreateProcess error=216, This version of %1 is not compatible with the version of
Windows you're running. Check your computer's system information to see whether
you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact
 the software publisher

Body:
Kinda late, but for future reference.

My problem was that I copy pasted the hdfs-site.xml from the tutorial and a special character,probably newline, was added in this line

<property><name>dfs.namenode.name.dir</name><value>/hadoop-
2.6.0/data/name</value><final>true</final></property>

so just go and delete it

<property>
<name>dfs.namenode.name.dir</name><value>/hadoop-2.6.0/data/name</value><final>true</final>
</property>

this sort of installation problems are the worst...they just discourage you so much


问:
REST only use get and post
Since not all client browsers support put and delete, is it good practice to only use 'get' and 'post' for all crud operations?</p>

答: Typically when you use a restful interface, its not intended for a browser...its intended for client software such as Javascript, Desktop applications, or 3-rd party interfaces.</p>

Title: REST only use get and post

ContentLicense: CC BY-SA 2.5


问:
How to stop the rotation with cancelAnimationFrame?
I am working currently with threejs and the requestAnimationFrame method. I try to rotate a camera to the right by holding a button. My problem here is, that by releasing the button, the rotation doesn't stop end gets accelerated everytime I press the button again.

HTML:

```<code><button id="right" onmousedown="rotateRight()" onmouseup="rotatestopRight()">Right</button>
</code>```

JavaScript:

```<code>function rotateRight(){
    mainPivot.add(camera);
    mainPivot.rotation.y+=Math.PI/180;
    requestAnimationFrame( rotateRight );
}

function rotatestopRight(){
    cancelAnimationFrame( rotateRight );
}
</code>```

I tried to solve this by making mainPivot.rotation.y-=Math.PI/180;on release, which worked, but it's not the best solution, since onmouseup event can easily be bypassed. Any idea how to get around?

答:
You are using it incorrectly. requestAnimationFrame returns an id which you use when you call cancelAnimationFrame.

```<code>var id = requestAnimationFrame();

...

cancelAnimationFrame( id );
</code>```

Body:
I am working currently with threejs and the requestAnimationFrame method. I try to rotate a camera to the right by holding a button. My problem here is, that by releasing the button, the rotation doesn't stop end gets accelerated everytime I press the button again.

HTML:

<button id="right" onmousedown="rotateRight()" onmouseup="rotatestopRight()">Right</button>

JavaScript:

function rotateRight(){
    mainPivot.add(camera);
    mainPivot.rotation.y+=Math.PI/180;
    requestAnimationFrame( rotateRight );
}

function rotatestopRight(){
    cancelAnimationFrame( rotateRight );
}

I tried to solve this by making mainPivot.rotation.y-=Math.PI/180;on release, which worked, but it's not the best solution, since onmouseup event can easily be bypassed. Any idea how to get around?

Body:
You are using it incorrectly. requestAnimationFrame returns an id which you use when you call cancelAnimationFrame.

var id = requestAnimationFrame();

...

cancelAnimationFrame( id );


问:
Database Update with Prepared Statement in JSF
I have mainpage.xhtml which displays entire records in my database and allows me to edit them. In case of clicling Edit button it calls mainPageController.edit() function which fills _bilgi variable in MainPageConroller class then it redirects to edit.xhtml page.

In edit.xhtml page it basically displays the values of _bilgi that are filled before in MainPageController class. There's no problem till here(probably there is but I am not aware of it.)

When I want to update one of those variables such as baslik I created a method in MainPageController which calls updateBilgi(_bilgi) in bilgiDAO class.

In UpdateBilgi it is pretty clear what it does yet it is not updating the table. It is interesting for me that when I debug and follow the variables, everything goes well but in the end it just does not update.

Another thing is when I put just a string in BilgilerDAO such is  ps.setString(1, "aqa1") it works but ps.setString(2, bilgi.getBaslik()) does not eventho bilgi.getBaslik() returns the changed value.

What could be wrong?
Thank you for the answers in advance.

I hope I am clear enough.

Edit: I found the glitch. in BilgilerDAO the function updateBilgi(Bilgi bilgi)
the variable bilgi doesn't get the id from _bilgi but gets other variables. Why it wouldn't get the id?

mainpage.xhtml

```<code><h:form id="bilgiForm">
    <h:dataTable id="bilgiTable" value="#{mainPageController.bilgiListesi}"
        var="bilgiler" border="1">
        <h:column>
            <f:facet name="header">
                <h:outputText value="Başlık" />
            </f:facet>
            <h:outputText value="#{bilgiler.baslik}" />
            <f:facet name="footer">
                <h:outputText value="Başlık" />
            </f:facet>
        </h:column>

        <h:column>
            <f:facet name="header">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
            <h:outputText value="#{bilgiler.bilgi}" />
            <f:facet name="footer">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
        </h:column>

        <h:column>
            <f:facet name="header">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
            <h:outputText value="#{bilgiler.bilgi}" />
            <f:facet name="footer">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
        </h:column>

        <h:column>
            <f:facet name="header">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
            <h:graphicImage
                value="https://canakkale.000webhostapp.com/showImage.php/?name=#{bilgiler.img.name}" />
            <f:facet name="footer">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
        </h:column>

        <h:column>
            <fcore:facet name="header">Edit</fcore:facet>
            <h:commandButton action="edit" value="Edit"
                actionListener="#{mainPageController.edit()}">
                <fcore:param name="id" value="#{bilgiler.id}" />
            </h:commandButton>
        </h:column>
    </h:dataTable>
</h:form>

    <fcore:view>
        <h:form>
            <fcore:view>
                <h:form>
                    <h1>Update</h1>
                    <h:panelGrid border="" cellpadding="20" cellspacing="20"
                        columns="3">
                        <h:outputLabel value="Bilgi ID" />
                        <h:inputText value="#{mainPageController._bilgi.id}"
                            readonly="true" required="true" requiredMessage="Id is Required"
                            id="bilgiID">
                        </h:inputText>
                        <h:message for="bilgiID" />

                        <h:outputLabel value="Tag" />
                        <h:inputText value="#{mainPageController._bilgi.tag}"
                            readonly="true" required="true"
                            requiredMessage="Tag Girmeniz Gereklidir." id="bilgiTag">
                        </h:inputText>
                        <h:message for="bilgiTag" />
                        <h:outputLabel value="Başlık" />
                        <h:inputText value="#{mainPageController._bilgi.baslik}"
                            required="true" requiredMessage="Başlık Girmeniz Gereklidir."
                            id="bilgiBaslik">
                        </h:inputText>
                        <h:message for="bilgiBaslik" />

                        <h:outputLabel value="Bilgi Metni" />
                        <h:inputTextarea value="#{mainPageController._bilgi.bilgi}"
                            required="true" requiredMessage="Başlık Girmeniz Gereklidir."
                            id="bilgiBilgi">
                        </h:inputTextarea>
                        <h:message for="bilgiBilgi" />

                        <h:outputLabel value="Image URL" />
                        <h:inputText value="#{mainPageController._bilgi.img.name}"
                            required="true" requiredMessage="Başlık Girmeniz Gereklidir."
                            readonly="true" id="bilgiImgName">
                        </h:inputText>
                        <h:message for="bilgiImgName" />

                        <h:outputLabel value="Başlık" />
                        <input type="file" value="#{mainPageController._bilgi.img.image}" />
                        <h:commandButton action="#{mainPageController.updateRecord()}"
                            value="Update">
                        </h:commandButton>
                    </h:panelGrid>
                </h:form>
            </fcore:view>

        </h:form>
    </fcore:view>
</h:body>
</html>
</code>```

MainPageController Class

```<code> @ManagedBean
    public class MainPageController implements Serializable {

        List<Bilgi> bilgiListesi = new ArrayList<Bilgi>();
        private Bilgi _bilgi = new Bilgi();
        private static final long serialVersionUID = 1L;

        BilgilerDAO bilgiDao = new BilgilerDAO();
        ImageDAO imgDao = new ImageDAO();

        public MainPageController() {// Default Constructor
            try {
                bilgiListesi = showAllRecords();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        public List<Bilgi> showAllRecords() throws SQLException {
            return bilgiDao.getAllBilgiler();
        }

        public List<Image> showAllImages() throws Exception {
            return imgDao.getAllImages();

        }

        public void updateRecord() {
            try {
                bilgiDao.updateBilgi(_bilgi);
                //imgDao.updateImage(_bilgi.getImg());
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

        public void edit() {
            FacesContext fc = FacesContext.getCurrentInstance();
            int id;
            HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
            id = Integer.parseInt(request.getParameter("id"));
            try {
                bilgiListesi = bilgiDao.getAllBilgiler();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            for (Bilgi bilgi : bilgiListesi) {
                if (bilgi.getId() == id) {
                    _bilgi.setBaslik(bilgi.getBaslik());
                    _bilgi.setBilgi(bilgi.getBilgi());
                    _bilgi.setImg(bilgi.getImg());
                    _bilgi.setTag(bilgi.getTag());
                    _bilgi.setId(bilgi.getId());
                }

            }
        }

        public void edit(Bilgi bilgi) {
            for (Bilgi existing : getBilgiListesi()) {
                existing.setEditable(false);
            }
            bilgi.setEditable(true);
        }

    }
</code>```

BilgilerDAO

```<code>@Override
    public String updateBilgi(Bilgi bilgi) throws Exception {
        String sql = "UPDATE bilgiler SET bilgi=?, baslik =? WHERE id=? ";
        ps = DatabaseConnection.getConnection().prepareStatement(sql);

        ps.setString(1, "aqa1");
        ps.setString(2, bilgi.getBaslik());
        ps.setInt(3, bilgi.getId());

        int ex = ps.executeUpdate();
        if (ex > 0) {
            System.err.println("coodld");
        }
        ps.close();
        return "mainpage";

    }
</code>```

答:
I kind of solved the issue.

```<code><h:inputText value="#{mainPageController._bilgi.id}" readonly="true" required="true" requiredMessage="Id is Required" id="bilgiID">
</code>```

in this xhtml line readonly="true" caused it return null. I removed it now it works how I wanted. Though, I still want them to be displayed but not editable.

Body:
I have mainpage.xhtml which displays entire records in my database and allows me to edit them. In case of clicling Edit button it calls mainPageController.edit() function which fills _bilgi variable in MainPageConroller class then it redirects to edit.xhtml page.

In edit.xhtml page it basically displays the values of _bilgi that are filled before in MainPageController class. There's no problem till here(probably there is but I am not aware of it.)

When I want to update one of those variables such as baslik I created a method in MainPageController which calls updateBilgi(_bilgi) in bilgiDAO class.

In UpdateBilgi it is pretty clear what it does yet it is not updating the table. It is interesting for me that when I debug and follow the variables, everything goes well but in the end it just does not update.

Another thing is when I put just a string in BilgilerDAO such is  ps.setString(1, "aqa1") it works but ps.setString(2, bilgi.getBaslik()) does not eventho bilgi.getBaslik() returns the changed value.

What could be wrong?
Thank you for the answers in advance.

I hope I am clear enough.

Edit: I found the glitch. in BilgilerDAO the function updateBilgi(Bilgi bilgi)
the variable bilgi doesn't get the id from _bilgi but gets other variables. Why it wouldn't get the id?

mainpage.xhtml

<h:form id="bilgiForm">
    <h:dataTable id="bilgiTable" value="#{mainPageController.bilgiListesi}"
        var="bilgiler" border="1">
        <h:column>
            <f:facet name="header">
                <h:outputText value="Başlık" />
            </f:facet>
            <h:outputText value="#{bilgiler.baslik}" />
            <f:facet name="footer">
                <h:outputText value="Başlık" />
            </f:facet>
        </h:column>

        <h:column>
            <f:facet name="header">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
            <h:outputText value="#{bilgiler.bilgi}" />
            <f:facet name="footer">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
        </h:column>

        <h:column>
            <f:facet name="header">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
            <h:outputText value="#{bilgiler.bilgi}" />
            <f:facet name="footer">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
        </h:column>

        <h:column>
            <f:facet name="header">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
            <h:graphicImage
                value="https://canakkale.000webhostapp.com/showImage.php/?name=#{bilgiler.img.name}" />
            <f:facet name="footer">
                <h:outputText value="Bilgi Metni" />
            </f:facet>
        </h:column>

        <h:column>
            <fcore:facet name="header">Edit</fcore:facet>
            <h:commandButton action="edit" value="Edit"
                actionListener="#{mainPageController.edit()}">
                <fcore:param name="id" value="#{bilgiler.id}" />
            </h:commandButton>
        </h:column>
    </h:dataTable>
</h:form>

    <fcore:view>
        <h:form>
            <fcore:view>
                <h:form>

Update

                    <h:panelGrid border="" cellpadding="20" cellspacing="20"
                        columns="3">
                        <h:outputLabel value="Bilgi ID" />
                        <h:inputText value="#{mainPageController._bilgi.id}"
                            readonly="true" required="true" requiredMessage="Id is Required"
                            id="bilgiID">
                        </h:inputText>
                        <h:message for="bilgiID" />

                        <h:outputLabel value="Tag" />
                        <h:inputText value="#{mainPageController._bilgi.tag}"
                            readonly="true" required="true"
                            requiredMessage="Tag Girmeniz Gereklidir." id="bilgiTag">
                        </h:inputText>
                        <h:message for="bilgiTag" />
                        <h:outputLabel value="Başlık" />
                        <h:inputText value="#{mainPageController._bilgi.baslik}"
                            required="true" requiredMessage="Başlık Girmeniz Gereklidir."
                            id="bilgiBaslik">
                        </h:inputText>
                        <h:message for="bilgiBaslik" />

                        <h:outputLabel value="Bilgi Metni" />
                        <h:inputTextarea value="#{mainPageController._bilgi.bilgi}"
                            required="true" requiredMessage="Başlık Girmeniz Gereklidir."
                            id="bilgiBilgi">
                        </h:inputTextarea>
                        <h:message for="bilgiBilgi" />

                        <h:outputLabel value="Image URL" />
                        <h:inputText value="#{mainPageController._bilgi.img.name}"
                            required="true" requiredMessage="Başlık Girmeniz Gereklidir."
                            readonly="true" id="bilgiImgName">
                        </h:inputText>
                        <h:message for="bilgiImgName" />

                        <h:outputLabel value="Başlık" />
                        <input type="file" value="#{mainPageController._bilgi.img.image}" />
                        <h:commandButton action="#{mainPageController.updateRecord()}"
                            value="Update">
                        </h:commandButton>
                    </h:panelGrid>
                </h:form>
            </fcore:view>

        </h:form>
    </fcore:view>
</h:body>

MainPageController Class

 @ManagedBean
    public class MainPageController implements Serializable {

        List<Bilgi> bilgiListesi = new ArrayList<Bilgi>();
        private Bilgi _bilgi = new Bilgi();
        private static final long serialVersionUID = 1L;

        BilgilerDAO bilgiDao = new BilgilerDAO();
        ImageDAO imgDao = new ImageDAO();

        public MainPageController() {// Default Constructor
            try {
                bilgiListesi = showAllRecords();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        public List<Bilgi> showAllRecords() throws SQLException {
            return bilgiDao.getAllBilgiler();
        }

        public List<Image> showAllImages() throws Exception {
            return imgDao.getAllImages();

        }

        public void updateRecord() {
            try {
                bilgiDao.updateBilgi(_bilgi);
                //imgDao.updateImage(_bilgi.getImg());
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

        public void edit() {
            FacesContext fc = FacesContext.getCurrentInstance();
            int id;
            HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
            id = Integer.parseInt(request.getParameter("id"));
            try {
                bilgiListesi = bilgiDao.getAllBilgiler();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            for (Bilgi bilgi : bilgiListesi) {
                if (bilgi.getId() == id) {
                    _bilgi.setBaslik(bilgi.getBaslik());
                    _bilgi.setBilgi(bilgi.getBilgi());
                    _bilgi.setImg(bilgi.getImg());
                    _bilgi.setTag(bilgi.getTag());
                    _bilgi.setId(bilgi.getId());
                }

            }
        }

        public void edit(Bilgi bilgi) {
            for (Bilgi existing : getBilgiListesi()) {
                existing.setEditable(false);
            }
            bilgi.setEditable(true);
        }

    }

BilgilerDAO

@Override
    public String updateBilgi(Bilgi bilgi) throws Exception {
        String sql = "UPDATE bilgiler SET bilgi=?, baslik =? WHERE id=? ";
        ps = DatabaseConnection.getConnection().prepareStatement(sql);

        ps.setString(1, "aqa1");
        ps.setString(2, bilgi.getBaslik());
        ps.setInt(3, bilgi.getId());

        int ex = ps.executeUpdate();
        if (ex > 0) {
            System.err.println("coodld");
        }
        ps.close();
        return "mainpage";

    }

Body:
I kind of solved the issue.

<h:inputText value="#{mainPageController._bilgi.id}" readonly="true" required="true" requiredMessage="Id is Required" id="bilgiID">

in this xhtml line readonly="true" caused it return null. I removed it now it works how I wanted. Though, I still want them to be displayed but not editable.


问:
How to solve the error convert String date from xml file to an int format?
I also find myself facing the date problem today, I extracted the date from an xml file in string format but when I try to convert it  into an int format  I have an error.

This is a part of my code :

```<code>DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputFile);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName("top");
for (int j=0; j<= inputFile.length();j++)
    for (int temp =0; temp < nList.getLength(); temp++) {
         j++;
         System.out.println("---------------------------------------");
         Node nNode = nList.item(temp);
         System.out.println("\n La requete numero " +j+ " " + nNode.getNodeName());
         if (nNode.getNodeType() == Node.ELEMENT_NODE) {
             Element eElement = (Element) nNode;
             dateq=eElement.getElementsByTagName("querytime").item(0).getTextContent();
             System.out.println("date de la requete est " +dateq);
             DateFormat dfq = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.FRENCH);
             Date date1 = dfq.parse(dateq);
             System.out.println("new date: " +date1);
</code>```

and the output is :

```<code>date de la requete est  Tue Feb 08 12:30:27 +0000 2011
java.text.ParseException: Unparseable date: " Tue Feb 08 12:30:27 +0000 2011 "
</code>```

答:
The problem is in your lines

```<code>DateFormat dfq = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.FRENCH);
Date date1 = dfq.parse(dateq);
</code>```

You got a ParseException because in " Tue Feb 08 12:30:27 +0000 2011 "
you have leading and trailing space, and the parts Tue and Feb are English but not French.

Change these lines to

```<code>DateFormat dfq = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
Date date1 = dfq.parse(dateq.trim());
</code>```

and it will work.

Body:
I also find myself facing the date problem today, I extracted the date from an xml file in string format but when I try to convert it  into an int format  I have an error.

This is a part of my code :

DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputFile);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName("top");
for (int j=0; j<= inputFile.length();j++)
    for (int temp =0; temp < nList.getLength(); temp++) {
         j++;
         System.out.println("---------------------------------------");
         Node nNode = nList.item(temp);
         System.out.println("\n La requete numero " +j+ " " + nNode.getNodeName());
         if (nNode.getNodeType() == Node.ELEMENT_NODE) {
             Element eElement = (Element) nNode;
             dateq=eElement.getElementsByTagName("querytime").item(0).getTextContent();
             System.out.println("date de la requete est " +dateq);
             DateFormat dfq = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.FRENCH);
             Date date1 = dfq.parse(dateq);
             System.out.println("new date: " +date1);

and the output is :

date de la requete est  Tue Feb 08 12:30:27 +0000 2011
java.text.ParseException: Unparseable date: " Tue Feb 08 12:30:27 +0000 2011 "

Body:
The problem is in your lines

DateFormat dfq = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.FRENCH);
Date date1 = dfq.parse(dateq);

You got a ParseException because in " Tue Feb 08 12:30:27 +0000 2011 "
you have leading and trailing space, and the parts Tue and Feb are English but not French.

Change these lines to

DateFormat dfq = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
Date date1 = dfq.parse(dateq.trim());

and it will work.


问:
expandable iOS tableViewCell
I have a custom tableViewControlelr that has rounded card view cells. The tableViewCells also have the ability to be clicked and when clicked, it expands.

```<code> func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        self.selectedIndex = indexPath
        self.didExpandCell()

    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if isExpanded && self.selectedIndex == indexPath{
            return 300
        }
        return 126
</code>```

within my tableviewcell, I have a custom view that is white, this is what allows for the card view appearance and it is also rounded. When the cell is not clicked, the cell is the standard height and looks like this:

And when the cell is clicked, it expands and looks like this:

As you can see when the cell is not clicked, the bottom part is straight and not rounded, I attempted to use this code to make it rounded but it did not work.

```<code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cells", for: indexPath) as! ProfileTableViewCell

if TableView.rowHeight == 126 {

            cell.CustomView = UIView(frame: CGRect(x: 7, y: 8, width: 359, height: 20))

            return cell
        }
        else{

        }
}
</code>```

答:
Your custom view is always the fully expanded height as you never do anything to make it otherwise (at least going by the code you have shared).

The reason your attempted fix doesn't work is because TableView.rowHeight is the height used for cells if you are not using the delegate method to determine what the cell height is and you are using the delegate method.  TableView.rowHeight will always be what you set it to initially and will not vary by cell so it will never match (or always match if you set it to 126).

If you want to get the effect you are after I would suggest looking into either auto layout or the auto resizing mask to make the custom view size dynamically as the cell does.

Title: expandable iOS tableViewCell

Body:
I have a custom tableViewControlelr that has rounded card view cells. The tableViewCells also have the ability to be clicked and when clicked, it expands.

 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        self.selectedIndex = indexPath
        self.didExpandCell()

    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if isExpanded && self.selectedIndex == indexPath{
            return 300
        }
        return 126

within my tableviewcell, I have a custom view that is white, this is what allows for the card view appearance and it is also rounded. When the cell is not clicked, the cell is the standard height and looks like this:

And when the cell is clicked, it expands and looks like this:

As you can see when the cell is not clicked, the bottom part is straight and not rounded, I attempted to use this code to make it rounded but it did not work.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cells", for: indexPath) as! ProfileTableViewCell

if TableView.rowHeight == 126 {

            cell.CustomView = UIView(frame: CGRect(x: 7, y: 8, width: 359, height: 20))

            return cell
        }
        else{

        }
}


问:
Group by Distance in Rails/SQL?
Is it possible to group by distance using the geokit-rails gem for ActiveRecord?

Say I have 10,000 users and I want to know how many are 1 mile, 2 miles... 100 miles from a point. How can I do that in as few queries as possible?

Doing something like this kills performance obviously:

```<code>(1..100).map { |i| User.count(:within => i, :origin => location) }
</code>```

Is there someway to do:

```<code>User.count(:within => 100, :origin => location, :group => "distance / 100") # some sort of math perhaps
</code>```

Any point in the right direction would be awesome!  Some sort of way to chunk the records in one db call by a range.

答:
I think the following db call will do what you ask for:

```<code>result = User.all(:select => "ROUND(distance / 100) AS distance, COUNT(*) AS user_count",
                  :group => "ROUND(id / 100)")
</code>```

Since this will not load an actual user instance, you have to specify in the select what data you want to access. Then you can loop through the result like this:

```<code><% result.each do |group| %>
  <p>Distance: <%= group.distance %>, Number of users: <%= group.user_count %></p>
<% end %>
</code>```

Title: Group by Distance in Rails/SQL?

Body:
Is it possible to group by distance using the geokit-rails gem for ActiveRecord?

Say I have 10,000 users and I want to know how many are 1 mile, 2 miles... 100 miles from a point. How can I do that in as few queries as possible?

Doing something like this kills performance obviously:

(1..100).map { |i| User.count(:within => i, :origin => location) }

Is there someway to do:

User.count(:within => 100, :origin => location, :group => "distance / 100") # some sort of math perhaps

Any point in the right direction would be awesome!  Some sort of way to chunk the records in one db call by a range.

Body:
I think the following db call will do what you ask for:

result = User.all(:select => "ROUND(distance / 100) AS distance, COUNT(*) AS user_count",
                  :group => "ROUND(id / 100)")

Since this will not load an actual user instance, you have to specify in the select what data you want to access. Then you can loop through the result like this:

<% result.each do |group| %>
  <p>Distance: <%= group.distance %>, Number of users: <%= group.user_count %></p>
<% end %>


问:
vba ms-word find text and get adjacent number
I am working with Word Docs containing quite a lot of pages and formulas.

I have an array containing expressions

```<code>dim YellowWord(1 to 100) as string
</code>```

I want to start at the beginning of the word text to look for every of those words and have a look the instances where that word or expression is followed by a number or numbers into brackets
EXMAPLE:
    yellowword(2)="the blue table"

using wildcards I can find: the blue table (34, 23) in the text.
what I want is filling another array that would be:

```<code>yellowwood_reference(2) = "(34, 23)"
</code>```

the code I have is so:

```<code>for i=1 to NRofYellowWords
with active document.content.find
    .clearformating
    .text = yellowWord(i) & " " & "\((*)\)"
    with .replacement
       .clearformating
       .text = yellowWord(i) & "(\1)"
       'HERE IS WHERE I WANT TO SAY TO WORD:
       'PUT THAT PART "(\1)" INTO A VARIABLE YELLOWWORD_REFERENCE(i)
       'HOWW??????
       .font.color = wdcolorred
       'here i changed the color of the string with the references into red.
    end with
.fordward = true
.wrap = wdfindcontinue
.format = true
.matchcase = false
.matchewholeword = false
.matchwildcards = true
.matchsoundslike = false
.matchallwordforms= false
.execute replace:=wdreplaceall
end with
next i
</code>```

In the above code there are several problems:
the first one I wrote it in capital letters, getting that reference of the wild card into a variable.
The second one is that there might be many appearances of the YellowWord(2) in the text, I only need/want the first reference, not the rest. That means that the first time the code finds the blue table (24,26) after passing the value "(24, 26)" into another array the code should move on and not look for more instances of the blue table in the text.

btw, i used wildcards because there might be the case that the references are simple not into brackets, so i would have to run everything twice with a different wildcard.

By the way as you can imagine, once I get the array yellowWord_reference(i) I would add the references there where there are instances of YellowWord without refferences.

I would really appreciate help since I really clicked many websites with little success.

thanks a lot

cheers

PS: If you think that there is a better way to do all that without using .find just mention it please, i am quite new in Ms-Word and coming from VBA Excel i get headaches figuring out where is the selection point.

答:
I modified your code so that if it finds your 'words', it will capture the numbers that follow.

The code you posted would never work due to the number of compile errors ... strongly suggest you start using "Option Explicit" and posting actual code rather than typing in in yourself.

Other notes:

The numbers are enclosed in parenthesis () - not brackets []

You were using a 'ReplaceAll'; if you only wanted the first occurance, change from '...All'

I removed the 'red font' and 'Replace' ... add it back if needed.

Your code would remove the space between the word and the number - is that what you wanted?

Here's the code:

```<code>Option Explicit

Sub Find_Words()
Dim yellowWord(100) As String
Dim yellowwood_reference(100) As String
Dim NRofYellowWords     As Integer
Dim i                   As Integer
Dim lS          As Long
Dim lE          As Long
Dim sFound      As String
Dim rng         As Range

    yellowWord(1) = "blue table"
    yellowWord(2) = "little"
    yellowWord(3) = "big"
    yellowWord(4) = "xxx last xxx"

    NRofYellowWords = 4

    Set rng = ActiveDocument.Range

    For i = 1 To NRofYellowWords
        With rng.Find
            .Text = yellowWord(i) & " " & "\((*)\)"
            With .Replacement
                .Text = yellowWord(i) & "(\1)"
            End With
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = True
            .MatchSoundsLike = False
            .MatchAllWordForms = False
            .Execute
            If .Found Then
                ' Find (numbers) & save
                lS = InStr(rng.Start, ActiveDocument.Range.Text, "(")
                If lS > 0 Then
                    lE = InStr(lS, ActiveDocument.Range.Text, ")")
                    sFound = Mid(ActiveDocument.Range.Text, lS, lE - lS + 1)
                    yellowwood_reference(i) = sFound
                    Debug.Print "Found: " & yellowWord(i) & vbTab & sFound
                Else
                    MsgBox "Bad format; missing '('" & vbTab & Mid(ActiveDocument.Range.Text, lS, 50)
                End If
            Else
                Debug.Print "Not Found: " & yellowWord(i)
            End If
        End With
    Next i

    Debug.Print "Finished"

End Sub
</code>```

Body:
I am working with Word Docs containing quite a lot of pages and formulas.

I have an array containing expressions

dim YellowWord(1 to 100) as string

I want to start at the beginning of the word text to look for every of those words and have a look the instances where that word or expression is followed by a number or numbers into brackets
EXMAPLE:
    yellowword(2)="the blue table"

using wildcards I can find: the blue table (34, 23) in the text.
what I want is filling another array that would be:

yellowwood_reference(2) = "(34, 23)"

the code I have is so:

for i=1 to NRofYellowWords
with active document.content.find
    .clearformating
    .text = yellowWord(i) & " " & "\((*)\)"
    with .replacement
       .clearformating
       .text = yellowWord(i) & "(\1)"
       'HERE IS WHERE I WANT TO SAY TO WORD:
       'PUT THAT PART "(\1)" INTO A VARIABLE YELLOWWORD_REFERENCE(i)
       'HOWW??????
       .font.color = wdcolorred
       'here i changed the color of the string with the references into red.
    end with
.fordward = true
.wrap = wdfindcontinue
.format = true
.matchcase = false
.matchewholeword = false
.matchwildcards = true
.matchsoundslike = false
.matchallwordforms= false
.execute replace:=wdreplaceall
end with
next i

In the above code there are several problems:
the first one I wrote it in capital letters, getting that reference of the wild card into a variable.
The second one is that there might be many appearances of the YellowWord(2) in the text, I only need/want the first reference, not the rest. That means that the first time the code finds the blue table (24,26) after passing the value "(24, 26)" into another array the code should move on and not look for more instances of the blue table in the text.

btw, i used wildcards because there might be the case that the references are simple not into brackets, so i would have to run everything twice with a different wildcard.

By the way as you can imagine, once I get the array yellowWord_reference(i) I would add the references there where there are instances of YellowWord without refferences.

I would really appreciate help since I really clicked many websites with little success.

thanks a lot

cheers

PS: If you think that there is a better way to do all that without using .find just mention it please, i am quite new in Ms-Word and coming from VBA Excel i get headaches figuring out where is the selection point.

Body:
I modified your code so that if it finds your 'words', it will capture the numbers that follow.

The code you posted would never work due to the number of compile errors ... strongly suggest you start using "Option Explicit" and posting actual code rather than typing in in yourself.

Other notes:

The numbers are enclosed in parenthesis () - not brackets []

You were using a 'ReplaceAll'; if you only wanted the first occurance, change from '...All'

I removed the 'red font' and 'Replace' ... add it back if needed.

Your code would remove the space between the word and the number - is that what you wanted?

Here's the code:

Option Explicit

Sub Find_Words()
Dim yellowWord(100) As String
Dim yellowwood_reference(100) As String
Dim NRofYellowWords     As Integer
Dim i                   As Integer
Dim lS          As Long
Dim lE          As Long
Dim sFound      As String
Dim rng         As Range

    yellowWord(1) = "blue table"
    yellowWord(2) = "little"
    yellowWord(3) = "big"
    yellowWord(4) = "xxx last xxx"

    NRofYellowWords = 4

    Set rng = ActiveDocument.Range

    For i = 1 To NRofYellowWords
        With rng.Find
            .Text = yellowWord(i) & " " & "\((*)\)"
            With .Replacement
                .Text = yellowWord(i) & "(\1)"
            End With
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = True
            .MatchSoundsLike = False
            .MatchAllWordForms = False
            .Execute
            If .Found Then
                ' Find (numbers) & save
                lS = InStr(rng.Start, ActiveDocument.Range.Text, "(")
                If lS > 0 Then
                    lE = InStr(lS, ActiveDocument.Range.Text, ")")
                    sFound = Mid(ActiveDocument.Range.Text, lS, lE - lS + 1)
                    yellowwood_reference(i) = sFound
                    Debug.Print "Found: " & yellowWord(i) & vbTab & sFound
                Else
                    MsgBox "Bad format; missing '('" & vbTab & Mid(ActiveDocument.Range.Text, lS, 50)
                End If
            Else
                Debug.Print "Not Found: " & yellowWord(i)
            End If
        End With
    Next i

    Debug.Print "Finished"

End Sub


问:
Code working for one, but how can I make work for multiple combobox
I'm new to VBA and have been using a piece of code to sort, remove duplicates and populate a Combobox from a certain range on my worksheet. My question is, what additions do I need to make so that I can populate another Combobox from a different Column and still have it sort.

Code I'm using is as below. As you can see I'm currently filling cboTask with information starting from B4. I want to add another range to fill another Combobox, which would be cboEquipment with information starting at D4.

```<code>Dim Cell                As Range
Dim Col                 As Variant
Dim Descending          As Boolean
Dim Entries             As Collection
Dim Items               As Variant
Dim index               As Long
Dim j                   As Long
Dim RngBeg              As Range
Dim RngEnd              As Range
Dim row                 As Long
Dim Sorted              As Boolean
Dim temp                As Variant
Dim test                As Variant
Dim Wks                 As Worksheet

Set Wks = ThisWorkbook.Worksheets("Maintenance")

Set RngBeg = Wks.Range("b4")

Col = RngBeg.Column

Set RngEnd = Wks.Cells(Rows.Count, Col).End(xlUp)

    Set Entries = New Collection
    ReDim Items(0)

    For row = RngBeg.row To RngEnd.row
        Set Cell = Wks.Cells(row, Col)
            On Error Resume Next
                test = Entries(Cell.Text)
                If Err = 5 Then
                    Entries.Add index, Cell.Text
                    Items(index) = Cell.Text
                    index = index + 1
                    ReDim Preserve Items(index)
                End If
            On Error GoTo 0
    Next row

    index = index - 1
    Descending = False

    ReDim Preserve Items(index)

        Do
            Sorted = True

            For j = 0 To index - 1
                If Descending Xor StrComp(Items(j), Items(j + 1), vbTextCompare) = 1 Then
                    temp = Items(j + 1)
                    Items(j + 1) = Items(j)
                    Items(j) = temp

                    Sorted = False
                End If
            Next j

            index = index - 1

        Loop Until Sorted Or index < 1

    cboTask.List = Items
</code>```

Thank you in advance, I thought this would be as simple as copying the code and changing the dim values, but it doesn't seem to work.

答:
Thanks very much Tim. I ended up getting it working using your method. I'll post what I did below so people know what was changed.

So under UserForm_Initialize I kept the Dim entries and placed

```<code>With ThisWorkbook.Worksheets("Maintenance 2017")

    FillComboFromRange cboTask, .Range("B4")

End With
</code>```

Then I moved the code for each combobox into a seperate Sub like Tim said.

Sub FillComboFromRange(cboTask As MSForms.ComboBox, RngBeg As Range)

```<code>Set Wks = ThisWorkbook.Worksheets("Maintenance 2017")

Set RngBeg = Wks.Range("B4")

Col = RngBeg.Column

Set RngEnd = Wks.Cells(Rows.Count, Col).End(xlUp)

    Set Entries = New Collection
    ReDim Items(0)

    For row = RngBeg.row To RngEnd.row
        Set Cell = Wks.Cells(row, Col)
            On Error Resume Next
                test = Entries(Cell.Text)
                If Err = 5 Then
                    Entries.Add index, Cell.Text
                    Items(index) = Cell.Text
                    index = index + 1
                    ReDim Preserve Items(index)
                End If
            On Error GoTo 0
    Next row

    index = index - 1
    Descending = False

    ReDim Preserve Items(index)

        Do
            Sorted = True

            For j = 0 To index - 1
                If Descending Xor StrComp(Items(j), Items(j + 1), vbTextCompare) = 1 Then
                    temp = Items(j + 1)
                    Items(j + 1) = Items(j)
                    Items(j) = temp

                    Sorted = False
                End If
            Next j

            index = index - 1

        Loop Until Sorted Or index < 1

    cboTask.List = Items

End Sub
</code>```

After this, each combobox populated correctly after changing the required range for each combobox.

Again, thank you very much!

Body:
I'm new to VBA and have been using a piece of code to sort, remove duplicates and populate a Combobox from a certain range on my worksheet. My question is, what additions do I need to make so that I can populate another Combobox from a different Column and still have it sort.

Code I'm using is as below. As you can see I'm currently filling cboTask with information starting from B4. I want to add another range to fill another Combobox, which would be cboEquipment with information starting at D4.

Dim Cell                As Range
Dim Col                 As Variant
Dim Descending          As Boolean
Dim Entries             As Collection
Dim Items               As Variant
Dim index               As Long
Dim j                   As Long
Dim RngBeg              As Range
Dim RngEnd              As Range
Dim row                 As Long
Dim Sorted              As Boolean
Dim temp                As Variant
Dim test                As Variant
Dim Wks                 As Worksheet

Set Wks = ThisWorkbook.Worksheets("Maintenance")

Set RngBeg = Wks.Range("b4")

Col = RngBeg.Column

Set RngEnd = Wks.Cells(Rows.Count, Col).End(xlUp)

    Set Entries = New Collection
    ReDim Items(0)

    For row = RngBeg.row To RngEnd.row
        Set Cell = Wks.Cells(row, Col)
            On Error Resume Next
                test = Entries(Cell.Text)
                If Err = 5 Then
                    Entries.Add index, Cell.Text
                    Items(index) = Cell.Text
                    index = index + 1
                    ReDim Preserve Items(index)
                End If
            On Error GoTo 0
    Next row

    index = index - 1
    Descending = False

    ReDim Preserve Items(index)

        Do
            Sorted = True

            For j = 0 To index - 1
                If Descending Xor StrComp(Items(j), Items(j + 1), vbTextCompare) = 1 Then
                    temp = Items(j + 1)
                    Items(j + 1) = Items(j)
                    Items(j) = temp

                    Sorted = False
                End If
            Next j

            index = index - 1

        Loop Until Sorted Or index < 1

    cboTask.List = Items

Thank you in advance, I thought this would be as simple as copying the code and changing the dim values, but it doesn't seem to work.

Body:
Thanks very much Tim. I ended up getting it working using your method. I'll post what I did below so people know what was changed.

So under UserForm_Initialize I kept the Dim entries and placed

With ThisWorkbook.Worksheets("Maintenance 2017")

    FillComboFromRange cboTask, .Range("B4")

End With

Then I moved the code for each combobox into a seperate Sub like Tim said.

Sub FillComboFromRange(cboTask As MSForms.ComboBox, RngBeg As Range)

Set Wks = ThisWorkbook.Worksheets("Maintenance 2017")

Set RngBeg = Wks.Range("B4")

Col = RngBeg.Column

Set RngEnd = Wks.Cells(Rows.Count, Col).End(xlUp)

    Set Entries = New Collection
    ReDim Items(0)

    For row = RngBeg.row To RngEnd.row
        Set Cell = Wks.Cells(row, Col)
            On Error Resume Next
                test = Entries(Cell.Text)
                If Err = 5 Then
                    Entries.Add index, Cell.Text
                    Items(index) = Cell.Text
                    index = index + 1
                    ReDim Preserve Items(index)
                End If
            On Error GoTo 0
    Next row

    index = index - 1
    Descending = False

    ReDim Preserve Items(index)

        Do
            Sorted = True

            For j = 0 To index - 1
                If Descending Xor StrComp(Items(j), Items(j + 1), vbTextCompare) = 1 Then
                    temp = Items(j + 1)
                    Items(j + 1) = Items(j)
                    Items(j) = temp

                    Sorted = False
                End If
            Next j

            index = index - 1

        Loop Until Sorted Or index < 1

    cboTask.List = Items

End Sub

After this, each combobox populated correctly after changing the required range for each combobox.

Again, thank you very much!