问:
redirect location to docker registry port
I setup a Docker registry in my Nexus with https connector on port 8123. I can successfully login to it:

```<code>docker login nexus.myserver.com:8123
</code>```

But my goal is to use custom paths instead of port numbers, for example:

```<code>docker login nexus.myserver.com/myregistry1
</code>```

So I tried to configure my apache conf like this:

```<code>Redirect /myregistry1 http://127.0.0.1:8123
ProxyPass /myregistry1 http://127.0.0.1:8123
ProxyPassReverse /myregistry1 http://127.0.0.1:8123
</code>```

But when I try to login (docker login nexus.myserver.com/myregistry1), I get:

```<code>Error response from daemon: login attempt to http://nexus.myserver.com/v2/ failed with status: 404 Not Found
</code>```

I'm not very familiar with apache, so any idea would be appreciated.

答:
You may set server port on conf file.
Or both ports are using, then please add both ports on conf file.

Like this.

Listen 8123
Listen 80

You installed your site on 8123 port. so calling to 80 port returns 404 error.

Body:
I setup a Docker registry in my Nexus with https connector on port 8123. I can successfully login to it:

docker login nexus.myserver.com:8123

But my goal is to use custom paths instead of port numbers, for example:

docker login nexus.myserver.com/myregistry1

So I tried to configure my apache conf like this:

Redirect /myregistry1 http://127.0.0.1:8123
ProxyPass /myregistry1 http://127.0.0.1:8123
ProxyPassReverse /myregistry1 http://127.0.0.1:8123

But when I try to login (docker login nexus.myserver.com/myregistry1), I get:

Error response from daemon: login attempt to http://nexus.myserver.com/v2/ failed with status: 404 Not Found

I'm not very familiar with apache, so any idea would be appreciated.


来源: stackexchange

问:
how to locate objects in SCNNode object boundingBox for show/hide feature

Having an issue getting a function to work when trying to setup boundingBox detection in a SCNNode. I'm expecting to be able to call the boundingBox function to detect objects inside a SCNNode and hide/show those objects on a button tap, here is my current state below:

```<code> @IBAction func hideCubeButtonTapped(sender: UIButton) {
    guard let hatNode = hatNode?.presentation.worldPosition else { return }

    for cubeNode in cubeNodes {

        // hide/show cubeNodes in the hat
        if (hatNode.boundingBoxContains(point: cubeNode.presentation.worldPosition)) {
            print("Hide Button Tapped")
            if cubeNode.isHidden == true {
                cubeNode.isHidden = false
            } else {
                cubeNode.isHidden = true
            }
        }
    }
}
</code>```

which is calling the boundingBox function from this struct and extension:

```<code>extension SCNNode {
func boundingBoxContains(point: SCNVector3, in node: SCNNode) -> Bool {
    let localPoint = self.convertPosition(point, from: node)
    return boundingBoxContains(point: localPoint)
}

func boundingBoxContains(point: SCNVector3) -> Bool {
    return BoundingBox(self.boundingBox).contains(point)
}
</code>```

}

struct BoundingBox {
    let min: SCNVector3
    let max: SCNVector3

```<code>init(_ boundTuple: (min: SCNVector3, max: SCNVector3)) {
    min = boundTuple.min
    max = boundTuple.max
}

func contains(_ point: SCNVector3) -> Bool {
    let contains =
        min.x <= point.x &&
            min.y <= point.y &&
            min.z <= point.z &&

            max.x > point.x &&
            max.y > point.y &&
            max.z > point.z

    return contains
}
</code>```

}

when calling the hatNode.boundingBoxContains this error is showing:
"Value of type 'SCNVector3' has no member 'boundingBoxContains'"

the hatNode is not getting set as a SCNVector3? what am i missing here? i'm new to swift so please correct me here!

this code was adapted from this question:
How to detect if a specific SCNNode is located inside another SCNNode's boundingBox - SceneKit - iOS

答: In the second line of code you assign the worldPosition (a SCNVector3) to the hatNode variable. So by the time you call boundingBoxContains on hatNode, hatNode is a SCNVector3. Remove .worldPosition from the second line if code so you assign the presentation node to hatNode.</p>

ContentLicense: CC BY-SA 3.0

Body:
Having an issue getting a function to work when trying to setup boundingBox detection in a SCNNode. I'm expecting to be able to call the boundingBox function to detect objects inside a SCNNode and hide/show those objects on a button tap, here is my current state below:

 @IBAction func hideCubeButtonTapped(sender: UIButton) {
    guard let hatNode = hatNode?.presentation.worldPosition else { return }

    for cubeNode in cubeNodes {

        // hide/show cubeNodes in the hat
        if (hatNode.boundingBoxContains(point: cubeNode.presentation.worldPosition)) {
            print("Hide Button Tapped")
            if cubeNode.isHidden == true {
                cubeNode.isHidden = false
            } else {
                cubeNode.isHidden = true
            }
        }
    }
}

which is calling the boundingBox function from this struct and extension:

extension SCNNode {
func boundingBoxContains(point: SCNVector3, in node: SCNNode) -> Bool {
    let localPoint = self.convertPosition(point, from: node)
    return boundingBoxContains(point: localPoint)
}

func boundingBoxContains(point: SCNVector3) -> Bool {
    return BoundingBox(self.boundingBox).contains(point)
}

}

struct BoundingBox {
    let min: SCNVector3
    let max: SCNVector3

init(_ boundTuple: (min: SCNVector3, max: SCNVector3)) {
    min = boundTuple.min
    max = boundTuple.max
}

func contains(_ point: SCNVector3) -> Bool {
    let contains =
        min.x <= point.x &&
            min.y <= point.y &&
            min.z <= point.z &&

            max.x > point.x &&
            max.y > point.y &&
            max.z > point.z

    return contains
}

}

when calling the hatNode.boundingBoxContains this error is showing:
"Value of type 'SCNVector3' has no member 'boundingBoxContains'"

the hatNode is not getting set as a SCNVector3? what am i missing here? i'm new to swift so please correct me here!

this code was adapted from this question:
How to detect if a specific SCNNode is located inside another SCNNode's boundingBox - SceneKit - iOS


问:
Change <input type=text> font-size without changing its width
I have two text-boxes whose ratio of width is supposed to be 2:1, I can do that using flex. But when I change the font-size to 300% the width of the text boxes becomes equal.

How do I avoid that and keep the width in the ratio 2:1?

Here's the Code:

input[type=text] {
  font-size: 300%;
}
#b4 {
  flex: 2;
}
#b2 {
  flex: 1;
}
div {
  display: flex;
  width: 100%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
  <input type="text" id="b4"></input>
  <input type="text" id="b2"></input>
</div></code>```

Also, I don't want to set fixed width to any text-box.

答:
This is a Firefox issue.

The best solution is adding a min-width for the input.

```<code>input{ min-width:0;}
</code>```

OR

wrap the individual inputs in divs and flex those and set the inputs to be 100% wide.

Body:
I have two text-boxes whose ratio of width is supposed to be 2:1, I can do that using flex. But when I change the font-size to 300% the width of the text boxes becomes equal.

How do I avoid that and keep the width in the ratio 2:1?

Here's the Code:

input[type=text] {
  font-size: 300%;
}
#b4 {
  flex: 2;
}
#b2 {
  flex: 1;
}
div {
  display: flex;
  width: 100%;
}

  <input type="text" id="b4"></input>
  <input type="text" id="b2"></input>

Also, I don't want to set fixed width to any text-box.

Body:
This is a Firefox issue.

The best solution is adding a min-width for the input.

input{ min-width:0;}

OR

wrap the individual inputs in divs and flex those and set the inputs to be 100% wide.


问:
SQL query using Like and Between in the same statement
so here is my problem I need to select records in between year 2000-2008 but the columns I need to search for is in type varchar example:

```<code>IntRecordID     VARCHARYear
    1            1990-2000
    2            2001-2005
    3            2005-2006
    4            2007-2008
    5            2009-2020
</code>```

select all record id that has VARCHARYear between 2000 and 2008

```<code>IntRecordID
    2
    3
    4
</code>```

what is the sql query that I need to achieve this?

答:
Your sql will be like this...</p>

```<code>SELECT column_name
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
</code>```

Body:
so here is my problem I need to select records in between year 2000-2008 but the columns I need to search for is in type varchar example:

IntRecordID     VARCHARYear
    1            1990-2000
    2            2001-2005
    3            2005-2006
    4            2007-2008
    5            2009-2020

select all record id that has VARCHARYear between 2000 and 2008

IntRecordID
    2
    3
    4

what is the sql query that I need to achieve this?

Body:
Your sql will be like this...

SELECT column_name
FROM table_name
WHERE column_name BETWEEN value1 AND value2;


问:
Bootstrap datepicker make one selectable date each 7 days
I want to implement a feature on my calendars but i have no ideia on how to do it, what i want to achieve:

As soon i select a date in my first datepicker, i want the other datepicker to restrict the dates i can pick: make so that i only can pick the selected date on the first calendar plus 7 days, plus 14 days, etc, from 7 to 7 days i can pick that date and disable other dates.

```<code>$('#startdateajna').datepicker({
    startDate: date,
    format: "dd/mm/yyyy"
}).on('changeDate', function(e) {
    console.log('trigger');

    var oldDate = new Date(e.date);
    var newDate = new Date();
    newDate.setDate(oldDate.getDate() + 7);

    $('#enddateajna').datepicker('setDate', newDate);
});
</code>```

Thank you.

答:
Try this    </p>

```<code>$('#startdateajna').datepicker({
    dateFormat: 'dd/mm/yyyy',
    onSelect: function (selected)
    {
        var date2 = $('#startdateajna').datepicker('getDate');
        date2.setDate(date2.getDate() + 7);
        $("#enddateajna").datepicker("option", "minDate", selected);
        $("#enddateajna").datepicker("option", "maxDate", date2);
    }
});
</code>```

Body:
I want to implement a feature on my calendars but i have no ideia on how to do it, what i want to achieve:

As soon i select a date in my first datepicker, i want the other datepicker to restrict the dates i can pick: make so that i only can pick the selected date on the first calendar plus 7 days, plus 14 days, etc, from 7 to 7 days i can pick that date and disable other dates.

$('#startdateajna').datepicker({
    startDate: date,
    format: "dd/mm/yyyy"
}).on('changeDate', function(e) {
    console.log('trigger');

    var oldDate = new Date(e.date);
    var newDate = new Date();
    newDate.setDate(oldDate.getDate() + 7);

    $('#enddateajna').datepicker('setDate', newDate);
});

Thank you.

Body:
Try this

$('#startdateajna').datepicker({
    dateFormat: 'dd/mm/yyyy',
    onSelect: function (selected)
    {
        var date2 = $('#startdateajna').datepicker('getDate');
        date2.setDate(date2.getDate() + 7);
        $("#enddateajna").datepicker("option", "minDate", selected);
        $("#enddateajna").datepicker("option", "maxDate", date2);
    }
});


问:
Measure elapsed time in Swift
How can we measure the time elapsed for running a function in Swift? I am trying to display the elapsed time like this: "Elapsed time is .05 seconds". Saw that in Java, we can use System.nanoTime(), are there any equivalent methods available in Swift to accomplish this?

Please have a look at the sample program:

func isPrime(_ number: Int) -> Bool {
    var i = 0;
    for i=2; i<number; i++ {
        if number % i == 0, i != 0 {
            return false
        }
    }
    return true
}

var number = 5915587277

if isPrime(number) {
    print("Prime number")
} else {
    print("NOT a prime number")
}
```

答:
Here is my try for the simplest answer:

```<code>let startTime = Date().timeIntervalSince1970  // 1512538946.5705 seconds

// time passes (about 10 seconds)

let endTime = Date().timeIntervalSince1970    // 1512538956.57195 seconds
let elapsedTime = endTime - startTime         // 10.0014500617981 seconds
</code>```

Notes

startTime and endTime are of the type TimeInterval, which is just a typealias for Double, so it is easy to convert it to an Int or whatever. Time is measured in seconds with sub-millisecond precision.

See also DateInterval, which includes an actual start and end time.

Using the time since 1970 is similar to Java timestamps.

ContentLicense: CC BY-SA 4.0

Title: Measure elapsed time in Swift

Body:
Here is my try for the simplest answer:

let startTime = Date().timeIntervalSince1970  // 1512538946.5705 seconds

// time passes (about 10 seconds)

let endTime = Date().timeIntervalSince1970    // 1512538956.57195 seconds
let elapsedTime = endTime - startTime         // 10.0014500617981 seconds

Notes

startTime and endTime are of the type TimeInterval, which is just a typealias for Double, so it is easy to convert it to an Int or whatever. Time is measured in seconds with sub-millisecond precision.

See also DateInterval, which includes an actual start and end time.

Using the time since 1970 is similar to Java timestamps.


问:
My main div is stuck over my header div
I am pretty new to this. I am hoping for some help and advise keeping my divs side by side. One is a menu which works fine but now my content is overlapping and I'm not sure what I did. I should make multiple saves. any advice on positioning my divs would be crazy appreciated.

apologies if my formatting of the post is wrong. brain is fried and my website is due for class tomorrow.

```<code>body {
background-color: #35455e;
}

h1 {
text-align: center;
font-size: 400%;
color: #ecb3ff;
padding-left: 30px;
}

h2 {
text-align: center;
font-size: 300%;
color: #ecb3ff;
padding-left: 40px;
}

ul {
list-style: none;
overflow: hidden;
list-style: none;
text-align: center;
border-style: hidden;
}

a {
color: white;
text-decoration: none;
font-size: 125%;
padding-left: 12px;
}

a:hover {
color: #fff666;
}

a:active {
color: #9bc1ff;
}

div.header {
background-image: url("https://scontent-sea1-1.xx.fbcdn.net/v/t1.0-
9/22089728_10212094710577763_385045730802353501_n.jpg?
oh=534f6bd3108f6f68f96cf5709e404b9f&oe=5AD4BADA");
background-size: initial;
background-repeat: repeat;
border-radius: 8px;
height: 573px;
width: 449px;
border: 10px;
box-shadow: 10px 10px 5px #333333;
float: left;
position:fixed;}

div.main{

position: relative;
top: 500px;
right: 500px;

}

li {
width: 30%;
}

My HTML:

<!DOCTYPE html>

<html>
<head>
<title>Madison Queen's Art Portfolio: Home</title>
<link rel="stylesheet" type="text/css" href="final.css">
</head>
<body>

<div class="container">

<div class="header">

<h1>Madison Art Portfolio</h1>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="Photo.html">Photography</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>

</div><!--closing of header-->

<div class="main">

<h2>Madison Art Portfolio</h2>

</div><!--CLOSING OF MAIN-->

</div><!--CLOSING OF THE CONTAINER-->
</body>
</html>
</code>```

答: Remove all the code from div.main. It's not required. Also remove position: fixed from the div.header block.</p>

Title: My main div is stuck over my header div

Body:
I am pretty new to this. I am hoping for some help and advise keeping my divs side by side. One is a menu which works fine but now my content is overlapping and I'm not sure what I did. I should make multiple saves. any advice on positioning my divs would be crazy appreciated.

apologies if my formatting of the post is wrong. brain is fried and my website is due for class tomorrow.

body {
background-color: #35455e;
}

h1 {
text-align: center;
font-size: 400%;
color: #ecb3ff;
padding-left: 30px;
}

h2 {
text-align: center;
font-size: 300%;
color: #ecb3ff;
padding-left: 40px;
}

ul {
list-style: none;
overflow: hidden;
list-style: none;
text-align: center;
border-style: hidden;
}

a {
color: white;
text-decoration: none;
font-size: 125%;
padding-left: 12px;
}

a:hover {
color: #fff666;
}

a:active {
color: #9bc1ff;
}

div.header {
background-image: url("https://scontent-sea1-1.xx.fbcdn.net/v/t1.0-
9/22089728_10212094710577763_385045730802353501_n.jpg?
oh=534f6bd3108f6f68f96cf5709e404b9f&oe=5AD4BADA");
background-size: initial;
background-repeat: repeat;
border-radius: 8px;
height: 573px;
width: 449px;
border: 10px;
box-shadow: 10px 10px 5px #333333;
float: left;
position:fixed;}

div.main{

position: relative;
top: 500px;
right: 500px;

}

li {
width: 30%;
}

My HTML:

<!DOCTYPE html>

<title>Madison Queen's Art Portfolio: Home</title>
<link rel="stylesheet" type="text/css" href="final.css">

Madison Art Portfolio

Home

Photography

Contact

Madison Art Portfolio


问:
Noe4j : There is not enough memory to perform the current task
When we query to neo4j database management system it throws below error.

```<code>SEVERE: Servlet.service() for servlet [spring] in context with path [/connect_to_code] threw exception [Request processing failed; nested exception is org.neo4j.driver.v1.exceptions.TransientException: There is not enough memory to perform the current task. Please try increasing 'dbms.memory.heap.max_size' in the neo4j configuration (normally in 'conf/neo4j.conf' or, if you you are using Neo4j Desktop, found through the user interface) or if you are running an embedded installation increase the heap by using '-Xmx' command line flag, and then restart the database.] with root cause
org.neo4j.driver.v1.exceptions.TransientException: There is not enough memory to perform the current task. Please try increasing 'dbms.memory.heap.max_size' in the neo4j configuration (normally in 'conf/neo4j.conf' or, if you you are using Neo4j Desktop, found through the user interface) or if you are running an embedded installation increase the heap by using '-Xmx' command line flag, and then restart the database.
    at org.neo4j.driver.internal.net.SocketResponseHandler.handleFailureMessage(SocketResponseHandler.java:79)
    at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.unpackFailureMessage(PackStreamMessageFormatV1.java:457)
    at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.read(PackStreamMessageFormatV1.java:418)
    at org.neo4j.driver.internal.net.SocketClient.receiveOne(SocketClient.java:176)
</code>```

I have changed the neo4j.conf file with below parameter:

```<code>dbms.memory.heap.initial_size = 1024G
dbms.memory.heap.max_size= 1024G
</code>```

Still facing same issue.

Is there anything we can do to avoid this error?

I am not sure where this heap is allocated but my drive free size is as below:
C drive : 26.6 GB D drive : 67.6 GB
RAM :32 GB

答: Your configuration says  1024G  you may want to change that to 1024M not G.   Try increasing the heap settings if you still get the error after you fix the typo.</p>

Body:
When we query to neo4j database management system it throws below error.

SEVERE: Servlet.service() for servlet [spring] in context with path [/connect_to_code] threw exception [Request processing failed; nested exception is org.neo4j.driver.v1.exceptions.TransientException: There is not enough memory to perform the current task. Please try increasing 'dbms.memory.heap.max_size' in the neo4j configuration (normally in 'conf/neo4j.conf' or, if you you are using Neo4j Desktop, found through the user interface) or if you are running an embedded installation increase the heap by using '-Xmx' command line flag, and then restart the database.] with root cause
org.neo4j.driver.v1.exceptions.TransientException: There is not enough memory to perform the current task. Please try increasing 'dbms.memory.heap.max_size' in the neo4j configuration (normally in 'conf/neo4j.conf' or, if you you are using Neo4j Desktop, found through the user interface) or if you are running an embedded installation increase the heap by using '-Xmx' command line flag, and then restart the database.
    at org.neo4j.driver.internal.net.SocketResponseHandler.handleFailureMessage(SocketResponseHandler.java:79)
    at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.unpackFailureMessage(PackStreamMessageFormatV1.java:457)
    at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.read(PackStreamMessageFormatV1.java:418)
    at org.neo4j.driver.internal.net.SocketClient.receiveOne(SocketClient.java:176)

I have changed the neo4j.conf file with below parameter:

dbms.memory.heap.initial_size = 1024G
dbms.memory.heap.max_size= 1024G

Still facing same issue.

Is there anything we can do to avoid this error?

I am not sure where this heap is allocated but my drive free size is as below:
C drive : 26.6 GB D drive : 67.6 GB
RAM :32 GB


问:
What is the order of evaluation in F#?
I was reading this and now wonder: what is the evaluation order in F#?

Obviously ; makes effects happen in a sequential fashion. But what about things like function calls or applications, order of evaluation for operators, and the like.

I've glanced at the F# spec, but there is no mention of that. Thanks for any insight!

答:
I found some emails where we fixed the implementation to have a rigid application order.  The code

```<code>open System

let f a =
   Console.WriteLine "app1";
   fun b ->
       Console.WriteLine "app2";
       ()

(Console.WriteLine "f"; f) (Console.WriteLine "arg1") (Console.WriteLine "arg2")
</code>```

will print "f", "arg1", "arg2", "app1", "app2".   However this didn't make it into the spec.  I'll file a spec bug.

(Some other portions of the spec are already more explicit, e.g.

6.9.6        Evaluating Method Applications

For elaborated applications of methods, the elaborated form of the expression will be either expr.M(args) or M(args).

The (optional) expr and args are evaluated in left-to-right order and the body of the member is evaluated in an environment with formal parameters that are mapped to corresponding argument values.

If expr evaluates to null then NullReferenceException is raised.

If the method is a virtual dispatch slot (that is, a method that is declared abstract) then the body of the member is chosen according to the dispatch maps of the value of expr.

That said, some experts believe that you will live a longer, happier life if you do not rely on evaluation order. :) )

(Possibly see also

http://blogs.msdn.com/ericlippert/archive/2009/11/19/always-write-a-spec-part-one.aspx

http://blogs.msdn.com/ericlippert/archive/2009/11/23/always-write-a-spec-part-two.aspx

for more on how easy it is to screw things up with evaluation order.)

ContentLicense: CC BY-SA 2.5

Title: What is the order of evaluation in F#?

Body:
I found some emails where we fixed the implementation to have a rigid application order.  The code

open System

let f a =
   Console.WriteLine "app1";
   fun b ->
       Console.WriteLine "app2";
       ()

(Console.WriteLine "f"; f) (Console.WriteLine "arg1") (Console.WriteLine "arg2")

will print "f", "arg1", "arg2", "app1", "app2".   However this didn't make it into the spec.  I'll file a spec bug.

(Some other portions of the spec are already more explicit, e.g.

6.9.6        Evaluating Method Applications

For elaborated applications of methods, the elaborated form of the expression will be either expr.M(args) or M(args).

The (optional) expr and args are evaluated in left-to-right order and the body of the member is evaluated in an environment with formal parameters that are mapped to corresponding argument values.

If expr evaluates to null then NullReferenceException is raised.

If the method is a virtual dispatch slot (that is, a method that is declared abstract) then the body of the member is chosen according to the dispatch maps of the value of expr.

That said, some experts believe that you will live a longer, happier life if you do not rely on evaluation order. :) )

(Possibly see also

http://blogs.msdn.com/ericlippert/archive/2009/11/19/always-write-a-spec-part-one.aspx

http://blogs.msdn.com/ericlippert/archive/2009/11/23/always-write-a-spec-part-two.aspx

for more on how easy it is to screw things up with evaluation order.)


问:
incron and rsync not working
I have incron setup and working, i can see things being logged when files are changed.
I've tried my rsync command separately and that works fine. But when rsync in triggered by incron, nothing happens. i explicitly stated all the paths i could see.

here is my incrontab -e

```<code>/home/dir/dir/ IN_MODIFY sudo rsync -pogr -e 'ssh -i /root/.ssh/rsasync1' /home/dir/dir/* root@ipaddress:/home/dir/dir/
</code>```

i'm working as root right now and executing the command as root. also tried /usr/bin/rsync and that didn't work in addition to sudo rsync etc...

thanks!

答:
Try this in incrontab:

```<code>/home/dir/dir/ IN_MODIFY sudo rsync -pogr -e ssh -i /root/.ssh/rsasync1 /home/dir/dir/* root@ipaddress:/home/dir/dir/
</code>```

In above command I have removed the quotes. Incrontab can not run with  Single quote OR double quote.

Remember: Pleas keep the quote while executing in terminal.

Title: incron and rsync not working

Body:
I have incron setup and working, i can see things being logged when files are changed.
I've tried my rsync command separately and that works fine. But when rsync in triggered by incron, nothing happens. i explicitly stated all the paths i could see.

here is my incrontab -e

/home/dir/dir/ IN_MODIFY sudo rsync -pogr -e 'ssh -i /root/.ssh/rsasync1' /home/dir/dir/* root@ipaddress:/home/dir/dir/

i'm working as root right now and executing the command as root. also tried /usr/bin/rsync and that didn't work in addition to sudo rsync etc...

thanks!

Body:
Try this in incrontab:

/home/dir/dir/ IN_MODIFY sudo rsync -pogr -e ssh -i /root/.ssh/rsasync1 /home/dir/dir/* root@ipaddress:/home/dir/dir/

In above command I have removed the quotes. Incrontab can not run with  Single quote OR double quote.

Remember: Pleas keep the quote while executing in terminal.


问:
create Dynamic table in PHP While loop
I have data from my query result like this :

```<code>DATE           DEPTH    LOCATION    idx
2010-08-13      0.34    SAKE RIVER  1
2010-08-13      0.35    SAKE RIVER  2
2010-08-13      0.35    SAKE RIVER  3
2016-01-30     1.463    AKE KOBE    4
2016-04-12     1.524    AKE KOBE    5
2014-05-13      1.03    AKE KOBE    6
2008-12-16     0.617    SAGEA           7
2008-08-11     1.503    SAGEA           8
2008-07-03     1.369    SAGEA           9
</code>```

how to loop this query result to create dynamic table in one index page
like this:

```<code><span>SAKE RIVER<span>
<Table>
 <tr>
<th>IDX</th>
<th>DATETIME</th>
<th>DEPTH</th>
</tr>
 <tr>
  <td>VAL</td>
  <td>VAL</td>
  <td>VAL</td>
  </tr>
</Table>

<span>AKE KOBE<span>
<Table>
 <tr>
<th>IDX</th>
<th>DATETIME</th>
<th>DEPTH</th>
</tr>
 <tr>
  <td>VAL</td>
  <td>VAL</td>
  <td>VAL</td>
  </tr>
</Table>

<span>SAGEA<span>
<Table>
 <tr>
<th>IDX</th>
<th>DATETIME</th>
<th>DEPTH</th>
</tr>
 <tr>
  <td>VAL</td>
  <td>VAL</td>
  <td>VAL</td>
  </tr>
</Table>
</code>```

If add more location than it will create more table

Thankyou

sorry for my english

答:
After doing the database connection and the table.</p>

```<code> while ($pickresults= mysql_fetch_assoc($picksquery)) {

echo '<th> '.$pickresults['username'].' </th> ';

    echo ' <td> '.$pickresults['firstgame'].' </td> '; }
</code>```

Title: create Dynamic table in PHP While loop

Body:
I have data from my query result like this :

DATE           DEPTH    LOCATION    idx
2010-08-13      0.34    SAKE RIVER  1
2010-08-13      0.35    SAKE RIVER  2
2010-08-13      0.35    SAKE RIVER  3
2016-01-30     1.463    AKE KOBE    4
2016-04-12     1.524    AKE KOBE    5
2014-05-13      1.03    AKE KOBE    6
2008-12-16     0.617    SAGEA           7
2008-08-11     1.503    SAGEA           8
2008-07-03     1.369    SAGEA           9

how to loop this query result to create dynamic table in one index page
like this:

SAKE RIVER

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

AKE KOBE

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

SAGEA

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

If add more location than it will create more table

Thankyou

sorry for my english

Body:
After doing the database connection and the table.

 while ($pickresults= mysql_fetch_assoc($picksquery)) {

echo '<th> '.$pickresults['username'].' </th> ';

    echo ' <td> '.$pickresults['firstgame'].' </td> '; }


问:
How to create logo(picture) and size
I create new module not inherit, I create header but the logo still not show, how to fix it?

```

答:
Try this:

```

hope it will help you.

Title: How to create logo(picture) and size

Body:
Try this:

<img t-att-src='/your_module_name/static/src/img/L.png' style="max-height: 65px;"/>

hope it will help you.


问:
NSString Manipulation
I would like to manipulate the NSString like as

(0) Likes (1). (see. (2))

(0) =  Raman

(1) =  You

(2) = ThisGift

to

Raman Likes You. (see. ThisGift)

I dont know what approch can solve this problem.

Thanks in Advance,
Regards

Venkat.

答:
See -[NSString stringByReplacingOccurrencesOfString:withString:]</p>

```<code>NSString *foo = @"(0) likes (1). (see (2))";
NSString *bar;
bar = [foo stringByReplacingOccurrencesOfString:@"(0)"
                                     withString:@"Raman"];
bar = [bar stringByReplacingOccurrencesOfString:@"(1)"
                                     withString:@"You"];
bar = [bar stringByReplacingOccurrencesOfString:@"(2)"
                                     withString:@"ThisGift"];
</code>```

Title: NSString Manipulation

Body:
See -[NSString stringByReplacingOccurrencesOfString:withString:]

NSString *foo = @"(0) likes (1). (see (2))";
NSString *bar;
bar = [foo stringByReplacingOccurrencesOfString:@"(0)"
                                     withString:@"Raman"];
bar = [bar stringByReplacingOccurrencesOfString:@"(1)"
                                     withString:@"You"];
bar = [bar stringByReplacingOccurrencesOfString:@"(2)"
                                     withString:@"ThisGift"];


问:
How to center a cell in UICollectionView?
I have a UICollectionView which consists of 12 cells from Jan to Dec as shown in the screenshot below:

How can I make the current month to always to be at the center of the collection view? For example, Dec shall be shown on the center for this month.

One of the solutions is to scroll automatically to the next page and center the 12th cell but how can I achieve that?

答: You can try making min spacing to zero for cells and lines</p>


问:
Rails form_with change submit text
I'm creating a new form using form_with helper and as you know is detecting if you are on a new record page or a edit page ([following the CRUD example from rails guide][1], i render the form as a partial to reuse the form) changing the text on the submit button depending where i call the form.

```<code><%= form_with model: @article, local: true do |form| %>
   <p>
       <%= form.label :title %>
       <%= form.text_field :title %>
   </p>
   <p>
       <%= form.submit %>
   </p>
<% end %>
</code>```

But i want to the text on the form submit helpers for translating purpose, but I don't know if is possible to preserve the Create/Update recognition functionality and if there are some helper or class where I can configure those labels.

答:
I handle this with the @article object!

When the form is rendered from create method, @article doesn't have the ID in it otherwise from update method you'll have to pass an ID for it to be updated.

So it would be:

```<code><% if @article.id.present? %>
  <%= form.submit "Update" %>
<% else %>
  <%= form.submit "Create" %>
<% end %>
</code>```

Title: Rails form_with change submit text

Body:
I'm creating a new form using form_with helper and as you know is detecting if you are on a new record page or a edit page ([following the CRUD example from rails guide][1], i render the form as a partial to reuse the form) changing the text on the submit button depending where i call the form.

<%= form_with model: @article, local: true do |form| %>

       <%= form.label :title %>
       <%= form.text_field :title %>

       <%= form.submit %>

<% end %>

But i want to the text on the form submit helpers for translating purpose, but I don't know if is possible to preserve the Create/Update recognition functionality and if there are some helper or class where I can configure those labels.

Body:
I handle this with the @article object!

When the form is rendered from create method, @article doesn't have the ID in it otherwise from update method you'll have to pass an ID for it to be updated.

So it would be:

<% if @article.id.present? %>
  <%= form.submit "Update" %>
<% else %>
  <%= form.submit "Create" %>
<% end %>


问:
Library's style attributes have no values even though they are explicitly set
I made a library with a custom view that inflates a layout when created. Views in the layout are styled with style="?attr/labelStyle" or any other attribute.

The attribute is declared the library's attrs.xml:

```<code><attr name="myViewStyle" format="reference"/>

<declare-styleable name="MyView">
    <attr name="labelStyle" format="reference|color"/>
</declare-styleable>
</code>```

I have set a default value to this attribute in the library's styles.xml:

```<code><style name="MyViewStyle">
    <item name="labelStyle">@style/LabelStyle</item>
</style>

<style name="LabelStyle">
    <item name="android:textColor">?android:attr/textColorPrimary</item>
    <item name="...">...</item>
</style>
</code>```

And finally in the library's themes.xml:

```<code><style name="MyViewStyleLight" parent="Theme.AppCompat.Light">
    <item name="myViewStyle">@style/MyViewStyle</item>
</style>
</code>```

Now this was the library's default styles, but it is overridden in the main project styles.xml

```<code><style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="myViewStyle">@style/MyViewStyleCustom</item>
</style>

<style name="MyViewStyleCustom" parent="MyViewStyleLight">
    <item name="android:textColor">@color/gray</item>
    <item name="...">...</item>
</style>
</code>```

The custom view code:

```<code>public MyView(Context context) {
    this(context, null, R.attr.myViewStyle, 0);
}

public MyView(Context context, @Nullable AttributeSet attrs) {
    this(context, attrs, R.attr.myViewStyle, 0);
}

public MyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    this(context, attrs, defStyleAttr, 0);
}

public MyView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(createThemeWrapper(context, R.attr.myViewStyle, R.style.MyViewStyleLight),
            attrs, defStyleAttr, defStyleRes);
    initLayout();
}

private static Context createThemeWrapper(Context context, int styleAttr, int defaultStyle) {
    final TypedArray ta = context.obtainStyledAttributes(new int[]{styleAttr});
    int style = ta.getResourceId(0, defaultStyle);
    ta.recycle();
    return new ContextThemeWrapper(context, style);
}

private void initLayout() {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.my_view, this);
    ...
}
</code>```

I explain about the ContextThemeWrapper below. Now the app crashes on the line where the layout gets inflated. Here's the important part of the crash log:

```<code>android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.example.MyView
      at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
      [...]
    Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f030057 a=-1}
      at android.content.res.TypedArray.getDrawable(TypedArray.java:867)
      [...]
</code>```

The layout inflater can't find the attribute's value. When I tried to get the attribute by code, it returns nothing. The attribute actually exists, only it has no value set to it even though I have clearly set one.

How exactly I am supposed to style my library? I am almost certain that I did every thing the same as the SublimePicker library but it just won't work. There's a little difference in the part with the ContextThemeWrapper, but it probably isn't the problem. I feel like I forgot a tiny thing somewhere that makes the attribute have no value, something is not connected, I don't know.

I know this is a very long question, but it cannot be more concise, I simplified everything as much as I could. I changed most of the information that was in the previous version of my question, making it completely different. The two answers are not relevant at all now, not that they ever were. The bounty was automatically rewarded.

If that could help someone I can add a download to my actual project, but as I said this simplified example has the exact same form as my project.

答:
This answer is based on what I  understand from your question. If I misinterpret
,Please correct me.

First of all myTextColor is an attribute name in your library. not a attribute value. You supposed to give a value for myTextColor when ever you using this library. Otherwise there may occur 'InflateException' . You can avoid this by following way.

```<code><YourCustomeView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:myTextColor="#000"/>
</code>```

1. Set myTextColor value directly when you use outside the library.

OR

In your library where you using this myTextColor attribute, check if this attribute have value or not. If it doesn't have any value then use a default value for myTextColor

```<code> private void init(@Nullable AttributeSet attrs) {
             TypedArray ta = getContext().obtainStyledAttributes(attrs,
                             R.styleable.MyLibrary);
        boolean hasRawRes = ta.hasValue(R.styleable.myTextColor);
        if(hasRawRes){
          // Use `myTextColor` attr here
        }else{
          // use default color
        }
</code>```

}

UPDATE ANSWER

This answer for the updated question

First of all you are trying to fetch a attr value from your library  to your project using ?attr/ .Which does not going to work. because

Your project using Theme.AppCompat  theme as (I'm guessing) parent theme for your Activities. When you use ?attr inside that activity, you can only fetch attribute values of Theme.AppCompat. But you are trying to fetch ?attr/labelStyle which is not a attribute of Theme.AppCompat rather than it's your library attribute. That's why you are getting that crash. If you want to use any style from your library to your project you can use @style tag

For example

```<code> style="@style/labelStyle"
</code>```

If it's not what you are looking for ,Please kindly share your source code.So I can understand more on this problem.

Body:
I made a library with a custom view that inflates a layout when created. Views in the layout are styled with style="?attr/labelStyle" or any other attribute.

The attribute is declared the library's attrs.xml:

<attr name="myViewStyle" format="reference"/>

<declare-styleable name="MyView">
    <attr name="labelStyle" format="reference|color"/>
</declare-styleable>

I have set a default value to this attribute in the library's styles.xml:

And finally in the library's themes.xml:

Now this was the library's default styles, but it is overridden in the main project styles.xml

The custom view code:

public MyView(Context context) {
    this(context, null, R.attr.myViewStyle, 0);
}

public MyView(Context context, @Nullable AttributeSet attrs) {
    this(context, attrs, R.attr.myViewStyle, 0);
}

public MyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    this(context, attrs, defStyleAttr, 0);
}

public MyView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(createThemeWrapper(context, R.attr.myViewStyle, R.style.MyViewStyleLight),
            attrs, defStyleAttr, defStyleRes);
    initLayout();
}

private static Context createThemeWrapper(Context context, int styleAttr, int defaultStyle) {
    final TypedArray ta = context.obtainStyledAttributes(new int[]{styleAttr});
    int style = ta.getResourceId(0, defaultStyle);
    ta.recycle();
    return new ContextThemeWrapper(context, style);
}

private void initLayout() {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.my_view, this);
    ...
}

I explain about the ContextThemeWrapper below. Now the app crashes on the line where the layout gets inflated. Here's the important part of the crash log:

android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.example.MyView
      at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
      [...]
    Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f030057 a=-1}
      at android.content.res.TypedArray.getDrawable(TypedArray.java:867)
      [...]

The layout inflater can't find the attribute's value. When I tried to get the attribute by code, it returns nothing. The attribute actually exists, only it has no value set to it even though I have clearly set one.

How exactly I am supposed to style my library? I am almost certain that I did every thing the same as the SublimePicker library but it just won't work. There's a little difference in the part with the ContextThemeWrapper, but it probably isn't the problem. I feel like I forgot a tiny thing somewhere that makes the attribute have no value, something is not connected, I don't know.

I know this is a very long question, but it cannot be more concise, I simplified everything as much as I could. I changed most of the information that was in the previous version of my question, making it completely different. The two answers are not relevant at all now, not that they ever were. The bounty was automatically rewarded.

If that could help someone I can add a download to my actual project, but as I said this simplified example has the exact same form as my project.

Body:
This answer is based on what I  understand from your question. If I misinterpret
,Please correct me.

First of all myTextColor is an attribute name in your library. not a attribute value. You supposed to give a value for myTextColor when ever you using this library. Otherwise there may occur 'InflateException' . You can avoid this by following way.

<YourCustomeView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:myTextColor="#000"/>

1. Set myTextColor value directly when you use outside the library.

OR

In your library where you using this myTextColor attribute, check if this attribute have value or not. If it doesn't have any value then use a default value for myTextColor

 private void init(@Nullable AttributeSet attrs) {
             TypedArray ta = getContext().obtainStyledAttributes(attrs,
                             R.styleable.MyLibrary);
        boolean hasRawRes = ta.hasValue(R.styleable.myTextColor);
        if(hasRawRes){
          // Use `myTextColor` attr here
        }else{
          // use default color
        }

}

UPDATE ANSWER

This answer for the updated question

First of all you are trying to fetch a attr value from your library  to your project using ?attr/ .Which does not going to work. because

Your project using Theme.AppCompat  theme as (I'm guessing) parent theme for your Activities. When you use ?attr inside that activity, you can only fetch attribute values of Theme.AppCompat. But you are trying to fetch ?attr/labelStyle which is not a attribute of Theme.AppCompat rather than it's your library attribute. That's why you are getting that crash. If you want to use any style from your library to your project you can use @style tag

For example

 style="@style/labelStyle"

If it's not what you are looking for ,Please kindly share your source code.So I can understand more on this problem.


问:
Change Alertview UIAlertController Buttons and Title color in iOS
I wanted to change my alert view title and button color as per my App theme and for this, i have found the many solutions as below:

```<code>alertController.view.tintColor = UIColor.red
</code>```

But above code is changing only button title color not the Alert title.

Testing on iOS 11 using Xcode 9.1

答:
Use below code to change Alert title:

```<code> alertController.setValue(NSAttributedString(string: "test", attributes: [NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 15),NSAttributedStringKey.foregroundColor : UIColor.red]), forKey: "attributedTitle")
</code>```

Body:
I wanted to change my alert view title and button color as per my App theme and for this, i have found the many solutions as below:

alertController.view.tintColor = UIColor.red

But above code is changing only button title color not the Alert title.

Testing on iOS 11 using Xcode 9.1

Body:
Use below code to change Alert title:

 alertController.setValue(NSAttributedString(string: "test", attributes: [NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 15),NSAttributedStringKey.foregroundColor : UIColor.red]), forKey: "attributedTitle")


问:
Get int value from enum in C#
I have a class called Questions (plural). In this class there is an enum called Question (singular) which looks like this.

```<code>public enum Question
{
    Role = 2,
    ProjectFunding = 3,
    TotalEmployee = 4,
    NumberOfServers = 5,
    TopBusinessConcern = 6
}
</code>```

In the Questions class I have a get(int foo) function that returns a Questions object for that foo. Is there an easy way to get the integer value off the enum so I can do something like this Questions.Get(Question.Role)?

答:
Since enums can be declared with multiple primitive types, a generic extension method to cast any enum type can be useful.</p>

```<code>enum Box
{
    HEIGHT,
    WIDTH,
    DEPTH
}

public static void UseEnum()
{
    int height = Box.HEIGHT.GetEnumValue<int>();
    int width = Box.WIDTH.GetEnumValue<int>();
    int depth = Box.DEPTH.GetEnumValue<int>();
}

public static T GetEnumValue<T>(this object e) => (T)e;
</code>```

Title: Get int value from enum in C#

Body:
I have a class called Questions (plural). In this class there is an enum called Question (singular) which looks like this.

public enum Question
{
    Role = 2,
    ProjectFunding = 3,
    TotalEmployee = 4,
    NumberOfServers = 5,
    TopBusinessConcern = 6
}

In the Questions class I have a get(int foo) function that returns a Questions object for that foo. Is there an easy way to get the integer value off the enum so I can do something like this Questions.Get(Question.Role)?

Body:
Since enums can be declared with multiple primitive types, a generic extension method to cast any enum type can be useful.

enum Box
{
    HEIGHT,
    WIDTH,
    DEPTH
}

public static void UseEnum()
{
    int height = Box.HEIGHT.GetEnumValue<int>();
    int width = Box.WIDTH.GetEnumValue<int>();
    int depth = Box.DEPTH.GetEnumValue<int>();
}

public static T GetEnumValue<T>(this object e) => (T)e;


问:
Authentication plugin for Rails 3?
I'm migrating to Rails 3 and found that my Restful_authentication plugin gives me many problems. I never really liked it so I want to install another plugin instead but only found outdated plugins.

Is there any authentication plugin updated to work with Rails3?

答:
the best i've seen do far is Devise. You could also try authlogic, but i'd recommend the first one.

Used with an authorization gem like Cancan will make your life way easier.

here's railscasts episode 209 about devise (also check 210 for more customizing)

i followed this tutorial to do a combination between cancan and devise, and it worked "just like that" (there is also a part 2 of that tutorial)

Title: Authentication plugin for Rails 3?


问:
Changing object prototype
I have the following 2 functions:

```<code>function Dog() {}
function Cat() {}
</code>```

I set Dog.prototype = new Cat()

I then create a dog instance:

```<code>let dog = new Dog();
</code>```

Why is dog instanceof Dog === true. I understand why dog instanceof Cat === true because I just set it to Cat's prototype but how is there still some reference to Dog prototype when it has been overridden even before the instance was created? How would I make make dog instanceof Dog === false?

答:
As mentioned in MDN docs

The instanceof operator tests whether the prototype property of a
  constructor appears anywhere in the prototype chain of an object.

That means instanceof will check the prototype property of the constructor with the __proto__ of  the Object, not the value that prototype is holding. You can check this as following

```<code>console.log(Dog.prototype === dog.__proto__) // prints -> true
console.log(Dog.prototype === Object.getPrototypeOf(dog)) // prints -> true
</code>```

What you are doing is merely changing the prototypes's `value. It still is the same property.

Modified:

Take a look at simplified implementation on instanceof method

```<code>function instanceOf(object, constructor) {
  return Object.getPrototypeOf(object) === constructor.prototype;
}
</code>```

Here, you can see that instanceof returns true, if reference of Object.getPrototypeOf(object) is equal to constructor.prototype. In your case Dog.prototype is Cat, and Object.getPrototypeOf(dog) is also Cat. That's why instanceof will always return true.

Reference

Link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof

Search for Object.getPrototypeOf(o) === C.prototype

Title: Changing object prototype

Body:
I have the following 2 functions:

function Dog() {}
function Cat() {}

I set Dog.prototype = new Cat()

I then create a dog instance:

let dog = new Dog();

Why is dog instanceof Dog === true. I understand why dog instanceof Cat === true because I just set it to Cat's prototype but how is there still some reference to Dog prototype when it has been overridden even before the instance was created? How would I make make dog instanceof Dog === false?

Body:
As mentioned in MDN docs

The instanceof operator tests whether the prototype property of a
  constructor appears anywhere in the prototype chain of an object.

That means instanceof will check the prototype property of the constructor with the __proto__ of  the Object, not the value that prototype is holding. You can check this as following

console.log(Dog.prototype === dog.__proto__) // prints -> true
console.log(Dog.prototype === Object.getPrototypeOf(dog)) // prints -> true

What you are doing is merely changing the prototypes's `value. It still is the same property.

Modified:

Take a look at simplified implementation on instanceof method

function instanceOf(object, constructor) {
  return Object.getPrototypeOf(object) === constructor.prototype;
}

Here, you can see that instanceof returns true, if reference of Object.getPrototypeOf(object) is equal to constructor.prototype. In your case Dog.prototype is Cat, and Object.getPrototypeOf(dog) is also Cat. That's why instanceof will always return true.

Reference

Link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof

Search for Object.getPrototypeOf(o) === C.prototype


问:
Perpetual NativeScript Mac Installation Issues
I could really use someone's help on this as I have been troubleshooting this for a really long time now with no remediation.

The issue is simply installing the NativeScript CLI onto my OSX Yosemite Mac. I followed the steps according to NS' website (installing proper Node.JS version, downloaded Xcode 7.2 (due to OS constraints), installed JSDK, installed NS Sidekick, installed Android Studio w/ proper SDK along with every other required dependancy.

However, when I run "sudo npm i -g nativescript --unsafe-perm" (otherwise it will throw a EACCES error), I get the following log with it saying I missing all of these dependencies I know I have but it is claiming I don't.

The biggest kick is that while it still will say NativeScript successfully installed, whenever I run any tns command (like tns doctor), the bash command cannot be found.

I have made sure to follow the directions of adding NS to my path as well as my Android and Java SDKs. Here is the full log:

```<code>jsmbp:~ Js$ sudo npm i -g nativescript --unsafe-perm
Password:
/Users/Jmsquillaro/.npm-packages/bin/nativescript -> /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/bin/tns
/Users/Jmsquillaro/.npm-packages/bin/tns -> /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/bin/tns

> fsevents@1.1.2 install /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/node_modules/fsevents
> node install

[fsevents] Success: "/Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> nativescript@3.3.1 postinstall /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript
> node postinstall.js

WARNING: adb from the Android SDK is not installed or is not configured properly.
For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.

WARNING: The Android SDK is not installed or is not configured properly.
You will not be able to build your projects for Android and run them in the native emulator.
To be able to build for Android and run apps in the native emulator, verify that you have
installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.

WARNING: CocoaPods is not installed or is not configured properly.
You will not be able to build your projects for iOS if they contain plugin with CocoaPod file.
To be able to build such projects, verify that you have installed CocoaPods.
The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
To be able to perform Android build-related operations, set the ANDROID_HOME variable to point to the root of your Android SDK installation directory.

Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
Run $ sdkmanager to manage your Android SDK versions.

You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=26'.
Run $ sdkmanager from your command-line to install required Android Build Tools. In case you already have them installed, make sure ANDROID_HOME environment variable is set correctly.

You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
Run $ sdkmanager to manage the Android Support Repository. In case you already have it installed, make sure ANDROID_HOME environment variable is set correctly.

Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.
You will not be able to build your projects for Android.
To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as
 described in http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-os-x.html#system-requirements

There seem to be issues with your configuration.
? Do you want to visit the official documentation? No
? Do you want to run the setup script? No
Your components are up-to-date:
nativescript,tns-core-modules,tns-android,tns-ios

Autocompletion is already enabled

Installation successful. You are good to go. Connect with us on http://twitter.com/NativeScript.

+ nativescript@3.3.1
added 692 packages in 156.18s
jsmbp:~ Js$ tns doctor
-bash: tns: command not found
</code>```

What can I do to fix this? npm also declares "rollbackFailedOptional" every time I try to reinstall after I uninstall it. Is npm caching a broken version and can I force it to do a genuine "reinstall?" It has been so frustrating as everything looks messed up and I really don't want to give up on NS. Let me know your thoughts and thank you!

答:
Begin by installing node.js correctly. I've you are having to you --unsafe-perm that means, the node.js installation is not done right.
I suggest you install nvm using homebrew and then install node from that. Please refer to my solution in this post https://discourse.nativescript.org/t/not-installing-on-macos/3292/4

Body:
I could really use someone's help on this as I have been troubleshooting this for a really long time now with no remediation.

The issue is simply installing the NativeScript CLI onto my OSX Yosemite Mac. I followed the steps according to NS' website (installing proper Node.JS version, downloaded Xcode 7.2 (due to OS constraints), installed JSDK, installed NS Sidekick, installed Android Studio w/ proper SDK along with every other required dependancy.

However, when I run "sudo npm i -g nativescript --unsafe-perm" (otherwise it will throw a EACCES error), I get the following log with it saying I missing all of these dependencies I know I have but it is claiming I don't.

The biggest kick is that while it still will say NativeScript successfully installed, whenever I run any tns command (like tns doctor), the bash command cannot be found.

I have made sure to follow the directions of adding NS to my path as well as my Android and Java SDKs. Here is the full log:

jsmbp:~ Js$ sudo npm i -g nativescript --unsafe-perm
Password:
/Users/Jmsquillaro/.npm-packages/bin/nativescript -> /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/bin/tns
/Users/Jmsquillaro/.npm-packages/bin/tns -> /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/bin/tns

> fsevents@1.1.2 install /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/node_modules/fsevents
> node install

[fsevents] Success: "/Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> nativescript@3.3.1 postinstall /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript
> node postinstall.js

WARNING: adb from the Android SDK is not installed or is not configured properly.
For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.

WARNING: The Android SDK is not installed or is not configured properly.
You will not be able to build your projects for Android and run them in the native emulator.
To be able to build for Android and run apps in the native emulator, verify that you have
installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.

WARNING: CocoaPods is not installed or is not configured properly.
You will not be able to build your projects for iOS if they contain plugin with CocoaPod file.
To be able to build such projects, verify that you have installed CocoaPods.
The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
To be able to perform Android build-related operations, set the ANDROID_HOME variable to point to the root of your Android SDK installation directory.

Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
Run $ sdkmanager to manage your Android SDK versions.

You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=26'.
Run $ sdkmanager from your command-line to install required Android Build Tools. In case you already have them installed, make sure ANDROID_HOME environment variable is set correctly.

You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
Run $ sdkmanager to manage the Android Support Repository. In case you already have it installed, make sure ANDROID_HOME environment variable is set correctly.

Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.
You will not be able to build your projects for Android.
To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as
 described in http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-os-x.html#system-requirements

There seem to be issues with your configuration.
? Do you want to visit the official documentation? No
? Do you want to run the setup script? No
Your components are up-to-date:
nativescript,tns-core-modules,tns-android,tns-ios

Autocompletion is already enabled

Installation successful. You are good to go. Connect with us on http://twitter.com/NativeScript.

+ nativescript@3.3.1
added 692 packages in 156.18s
jsmbp:~ Js$ tns doctor
-bash: tns: command not found

What can I do to fix this? npm also declares "rollbackFailedOptional" every time I try to reinstall after I uninstall it. Is npm caching a broken version and can I force it to do a genuine "reinstall?" It has been so frustrating as everything looks messed up and I really don't want to give up on NS. Let me know your thoughts and thank you!


问:
Adding Replica Set Members error in MongoDB
i got error like this! Please advice me what should i do? I finished editing /etc/hosts with the one i will add to the primary! But it shown as errrors as below! </p>

```<code>rs2:PRIMARY> rs.add("192.168.56.101:27017")
{
    "ok" : 0,
    "errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 192.168.56.104:27017; the following nodes did not respond affirmatively: 192.168.56.101:27017 failed with Connection refused",
    "code" : 74
}
</code>```

答:
The mongod server with IP 192.168.56.101:27017 must be configured with a replicaSet.

Start mongod on 192.168.56.101:27017 with replicaSet option like:

```<code>mongod --replSet "rs2"
</code>```

Body:
i got error like this! Please advice me what should i do? I finished editing /etc/hosts with the one i will add to the primary! But it shown as errrors as below!

rs2:PRIMARY> rs.add("192.168.56.101:27017")
{
    "ok" : 0,
    "errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 192.168.56.104:27017; the following nodes did not respond affirmatively: 192.168.56.101:27017 failed with Connection refused",
    "code" : 74
}

Body:
The mongod server with IP 192.168.56.101:27017 must be configured with a replicaSet.

Start mongod on 192.168.56.101:27017 with replicaSet option like:

mongod --replSet "rs2"


答:
Hope you are getting this data in some array variable and my suggestion you can use foreach loop:-

```<code>$data = //Query to fetch data
foreach($data as $key => $value) {?>
<span><?php echo $value['LOCATION']; ?></span>
<Table>
 <tr>
<th>IDX</th>
<th>DATETIME</th>
<th>DEPTH</th>
</tr>
 <tr>
  <td><?php echo $value['idx']; ?></td>
  <td><?php echo $value['DATE'];  ?></td>
  <td><?php echo $value['DEPTH'];  ?></td>
  </tr>
</Table>
<?php } ?>
</code>```

Hope it helps!

Title: create Dynamic table in PHP While loop

Body:
I have data from my query result like this :

DATE           DEPTH    LOCATION    idx
2010-08-13      0.34    SAKE RIVER  1
2010-08-13      0.35    SAKE RIVER  2
2010-08-13      0.35    SAKE RIVER  3
2016-01-30     1.463    AKE KOBE    4
2016-04-12     1.524    AKE KOBE    5
2014-05-13      1.03    AKE KOBE    6
2008-12-16     0.617    SAGEA           7
2008-08-11     1.503    SAGEA           8
2008-07-03     1.369    SAGEA           9

how to loop this query result to create dynamic table in one index page
like this:

SAKE RIVER

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

AKE KOBE

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

SAGEA

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

If add more location than it will create more table

Thankyou

sorry for my english

Body:
Hope you are getting this data in some array variable and my suggestion you can use foreach loop:-

$data = //Query to fetch data
foreach($data as $key => $value) {?>
<span><?php echo $value['LOCATION']; ?></span>
<Table>
 <tr>
<th>IDX</th>
<th>DATETIME</th>
<th>DEPTH</th>
</tr>
 <tr>
  <td><?php echo $value['idx']; ?></td>
  <td><?php echo $value['DATE'];  ?></td>
  <td><?php echo $value['DEPTH'];  ?></td>
  </tr>
</Table>
<?php } ?>

Hope it helps!


问:
Retrofit Singleton Instance causing a 403 Issue in API calls?
I have setup a retrofit2 singleton instance which is accessed by all API methods. However, upon logging out the user and re-signing in, all API calls fail with a 403. The likely cause of this is retrofit re-using the previous destroyed access token and not resetting the retrofit instance.

Singleton:

```<code>public class RetroGenerator {

    private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    private static Retrofit.Builder builder;
    public static Retrofit retrofit;

    static synchronized private Retrofit.Builder getBuilder() {

        if (builder == null) {
            initRetrofit();
        }
        return builder;
    }

    public static void initRetrofit() {
        builder =
                new Retrofit.Builder()
                        .baseUrl(SessionManager.getInstance().baseUrl)
                        .addConverterFactory(GsonConverterFactory.create(initGson()));
    }

    private static Gson initGson() {
        return new GsonBuilder()
                .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
    }

    public static Retrofit getRetrofit() {
        return getBuilder().client(httpClient.build()).build();
    }

    public static <S> S createService(Class<S> serviceClass) {
        return getRetrofit().create(serviceClass);
    }

    public static <S> S createService(Class<S> serviceClass, final Auth auth) {
        if (retrofit == null) {
            if (auth != null) {

                //Adding request payload logging
                if (BuildConfig.DEBUG) {
                    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
                    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
                    httpClient.addInterceptor(logging);
                }

                httpClient.retryOnConnectionFailure(true);
                httpClient.addInterceptor(new Interceptor() {
                    @Override
                    public Response intercept(Interceptor.Chain chain) throws IOException {
                        Request original = chain.request();
                        Request.Builder requestBuilder = original.newBuilder()
                                .header("Accept", "application/json")
                                .header("Authorization",
                                        auth.token_type + " " + auth.access_token)
                                .method(original.method(), original.body());
                        Request request = requestBuilder.build();
                        return chain.proceed(request);
                    }
                });
            }

            OkHttpClient client = httpClient.build();

            if (retrofit == null) {
                retrofit = getBuilder().client(client).build();
            }
        }

        return retrofit.create(serviceClass);
    }

    public static void clearRetrofit(){
        retrofit = null;
    }
}
</code>```

An API class would use this by:

```<code>RetroGenerator.createService(APIServices.class).getUsers().enqueue(new Callback<ArrayList<User>> () {
    @Override
    public void onResponse(Call <ArrayList<User>> call, Response <ArrayList<User>> response) {
        if (response.isSuccessful()) {
            callBack.onSuccess(response.body());
        }
    }
    @Override
    public void onFailure(Call <ArrayList<User>> call, Throwable t) {

    }
});
</code>```

To amend this, my attempt was to set the retrofit instance as null upon signing out. Thus, the use of clearRetrofit() method. However, the issue still exists and setting it null didn't fix the issue. What is the reoolution for this?

答:
I solved this problem. Here's the write-up:

Problem:

I needed global access to a retrofit instance without having to re-initialise an instance every time

The code in the question was confusing the public retrofit instance with authenticated endpoints thus leading to a 401: Unauthorised error.

Solution:

The solution I've attached below was written to deliver the following:
- Re-usability of a retrofit instance by using a Singleton design pattern

Ability to write an interface APIServices and include all endpoints in it. This allows extensibility.

Ability to switch between a retrofit built for public endpoints and a retrofit built for authenticated endpoints.

Here's my solution:
https://gist.github.com/dinukapj/b315e5f4438bc670d7509f7aa7aaffdd

Body:
I have setup a retrofit2 singleton instance which is accessed by all API methods. However, upon logging out the user and re-signing in, all API calls fail with a 403. The likely cause of this is retrofit re-using the previous destroyed access token and not resetting the retrofit instance.

Singleton:

public class RetroGenerator {

    private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    private static Retrofit.Builder builder;
    public static Retrofit retrofit;

    static synchronized private Retrofit.Builder getBuilder() {

        if (builder == null) {
            initRetrofit();
        }
        return builder;
    }

    public static void initRetrofit() {
        builder =
                new Retrofit.Builder()
                        .baseUrl(SessionManager.getInstance().baseUrl)
                        .addConverterFactory(GsonConverterFactory.create(initGson()));
    }

    private static Gson initGson() {
        return new GsonBuilder()
                .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
    }

    public static Retrofit getRetrofit() {
        return getBuilder().client(httpClient.build()).build();
    }

    public static <S> S createService(Class<S> serviceClass) {
        return getRetrofit().create(serviceClass);
    }

    public static <S> S createService(Class<S> serviceClass, final Auth auth) {
        if (retrofit == null) {
            if (auth != null) {

                //Adding request payload logging
                if (BuildConfig.DEBUG) {
                    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
                    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
                    httpClient.addInterceptor(logging);
                }

                httpClient.retryOnConnectionFailure(true);
                httpClient.addInterceptor(new Interceptor() {
                    @Override
                    public Response intercept(Interceptor.Chain chain) throws IOException {
                        Request original = chain.request();
                        Request.Builder requestBuilder = original.newBuilder()
                                .header("Accept", "application/json")
                                .header("Authorization",
                                        auth.token_type + " " + auth.access_token)
                                .method(original.method(), original.body());
                        Request request = requestBuilder.build();
                        return chain.proceed(request);
                    }
                });
            }

            OkHttpClient client = httpClient.build();

            if (retrofit == null) {
                retrofit = getBuilder().client(client).build();
            }
        }

        return retrofit.create(serviceClass);
    }

    public static void clearRetrofit(){
        retrofit = null;
    }
}

An API class would use this by:

RetroGenerator.createService(APIServices.class).getUsers().enqueue(new Callback<ArrayList<User>> () {
    @Override
    public void onResponse(Call <ArrayList<User>> call, Response <ArrayList<User>> response) {
        if (response.isSuccessful()) {
            callBack.onSuccess(response.body());
        }
    }
    @Override
    public void onFailure(Call <ArrayList<User>> call, Throwable t) {

    }
});

To amend this, my attempt was to set the retrofit instance as null upon signing out. Thus, the use of clearRetrofit() method. However, the issue still exists and setting it null didn't fix the issue. What is the reoolution for this?


问:
USB blocking using minifilter driver (passThrough)
I am writing a mini-filter code for USB (Flash Drives) for blocking i.e (Access Denied).So, could someone help me out,  how to detect or block USB or what methods to use in passThrough WDK sample code for USB detection and USB blocking?

I am trying to use *IOCTL_STORAGE_QUERY_PROPERTY in PFLT_INSTANCE_SETUP_CALLBACK*. Am i on right path?? if yes then how to use IOCTL_STORAGE_QUERY_PROPERTY in PFLT_INSTANCE_SETUP_CALLBACK???

答: One way could be to get the device object using FltGetDiskDeviceObject and then check for FILE_REMOVABLE_MEDIA flag in device_object->Characteristics. Once you get to know about the device type, then you can block or allow the required operations (that you need to register with FLT_OPERATION_REGISTRATION).


问:
Merge up to a specific commit
I created a new branch named newbranch from the master branch in git. Now I have done some work and want to merge newbranch to master; however, I have made some extra changes to newbranch and I want to merge newbranch up to the fourth-from-the-last commit to master.

I used cherry-pick but it shows the message to use the right options:

```<code>git checkout master
git cherry-pick ^^^^HEAD newbranch
</code>```

Can I use git merge to do it instead?

```<code>git merge newbranch <commitid>
</code>```

答:
To keep the branching clean, you could do this:

```<code>git checkout newbranch
git branch newbranch2
git reset --hard <commit Id> # the commit at which you want to merge
git checkout master
git merge newbranch
git checkout newbranch2
</code>```

This way, newbranch will end where it was merged into master, and you continue working on newbranch2.

Title: Merge up to a specific commit

Body:
I created a new branch named newbranch from the master branch in git. Now I have done some work and want to merge newbranch to master; however, I have made some extra changes to newbranch and I want to merge newbranch up to the fourth-from-the-last commit to master.

I used cherry-pick but it shows the message to use the right options:

git checkout master
git cherry-pick ^^^^HEAD newbranch

Can I use git merge to do it instead?

git merge newbranch <commitid>

Body:
To keep the branching clean, you could do this:

git checkout newbranch
git branch newbranch2
git reset --hard <commit Id> # the commit at which you want to merge
git checkout master
git merge newbranch
git checkout newbranch2

This way, newbranch will end where it was merged into master, and you continue working on newbranch2.


问:
Dockerizing a Web Application
I am new to this Containerization and I was wondering how Docker could replace Virtual machines?

I am given a case study in which there are 2 virtual machines each acting as a virtual server, one is a Development server and the other is a Test Server and I am asked to study how Docker could help in managing the workflow efficiently.

In this case the 2 virtual Machines are Servers and the idea of Docker replacing virtual machines is confusing me.

can anyone help me understand this concept.

Thanks in Advance!!

答:
Each docker container is itself act as a virtual machine means each
container having its own os isolates the process from host.

So if you launch 2 containers means you will be running 2 ubuntu(for
ex) servers.In each containers you can run your software and expose
the service to outside world.

If eventually docker dies you can relaunch from image without
installing OS,application unlike the virtual machines.

You can transfer the docker images to other server just like the
import / export of your application , only requirement is to other
server has docker service running.

If there are 2 dependent service which is running as container we can
link those container for internal communication.Like wordpress as one
container and mysql as other where both should have coneected, it
that case docker link will help to interconnect.

You can manage the cpu,memory , disk for docker containers just like
virtual machine in any of hypervisors.

for detailed info :
https://docs.docker.com/engine/docker-overview/#docker-engine

Title: Dockerizing a Web Application


问:
MAMP Pro crashes whilst starting Apache if no internet connection present?
I've used MAMP Pro for years and never experienced this issue, until the last week or so. I haven't installed any updates for MacOS or MAMP Pro in that time.

On starting MAMP Pro the servers start to boot, MySQL fires up fine and before Apache can start properly the whole MAMP App crashes.

I'll not post the full crash report for fear of sending readers to sleep, however here is what I have worked out as the failing thread...

```<code>

    Crashed Thread:        0  Dispatch queue: com.apple.main-thread

    Exception Type:        EXC_CRASH (SIGABRT)
    Exception Codes:       0x0000000000000000, 0x0000000000000000
    Exception Note:        EXC_CORPSE_NOTIFY

    Application Specific Information:
    abort() called

    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   libsystem_kernel.dylib          0x00007fff6d9fefce __pthread_kill + 10
    1   libsystem_pthread.dylib         0x00007fff6db3c150 pthread_kill + 333
    2   libsystem_c.dylib               0x00007fff6d95b30a abort + 127
    3   net.hockeyapp.sdk.mac           0x000000010b5a3c02 uncaught_exception_handler + 27
    4   com.apple.CoreFoundation        0x00007fff4633fbd2 __handleUncaughtException + 770
    5   libobjc.A.dylib                 0x00007fff6ccc4a41 _objc_terminate() + 91
    6   net.hockeyapp.sdk.mac           0x000000010b591417 BITCrashUncaughtCXXTerminateHandler() + 766
    7   libc++abi.dylib                 0x00007fff6b95b7c9 std::__terminate(void (*)()) + 8
    8   libc++abi.dylib                 0x00007fff6b95b843 std::terminate() + 51
    9   libdispatch.dylib               0x00007fff6d875e9c _dispatch_client_callout + 28
    10  libdispatch.dylib               0x00007fff6d881471 _dispatch_main_queue_callback_4CF + 1148
    11  com.apple.CoreFoundation        0x00007fff46268b99 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    12  com.apple.CoreFoundation        0x00007fff4622b44a __CFRunLoopRun + 2586
    13  com.apple.CoreFoundation        0x00007fff4622a797 CFRunLoopRunSpecific + 487
    14  com.apple.HIToolbox             0x00007fff4553f866 RunCurrentEventLoopInMode + 286
    15  com.apple.HIToolbox             0x00007fff4553f5d6 ReceiveNextEventCommon + 613
    16  com.apple.HIToolbox             0x00007fff4553f354 _BlockUntilNextEventMatchingListInModeWithFilter + 64
    17  com.apple.AppKit                0x00007fff4383ca23 _DPSNextEvent + 2085
    18  com.apple.AppKit                0x00007fff43fd1e6c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
    19  com.apple.AppKit                0x00007fff43831831 -[NSApplication run] + 764
    20  com.apple.AppKit                0x00007fff438009d2 NSApplicationMain + 804
    21  libdyld.dylib                   0x00007fff6d8af145 start + 1

</code>```

Has anyone else experienced this, or can offer an explanation of how I might be able to fix it? I work offline a lot so not being able to fire up MAMP is a game changer.

Cheers.

答:
My issue is this: When connected to the web, Mamp freezes and takes several minutes just to load pages. As soon as I disconnect from the web- it loads pages immediately.

I've Flushed DNS, cleared caches etc all to no avail. I'm on a Macbook, tried editing etc/hosts and still nothing. Didn't change anything yet it all just came out of nowhere.

Frustrating and can't work properly like this.

Body:
I've used MAMP Pro for years and never experienced this issue, until the last week or so. I haven't installed any updates for MacOS or MAMP Pro in that time.

On starting MAMP Pro the servers start to boot, MySQL fires up fine and before Apache can start properly the whole MAMP App crashes.

I'll not post the full crash report for fear of sending readers to sleep, however here is what I have worked out as the failing thread...

    Crashed Thread:        0  Dispatch queue: com.apple.main-thread

    Exception Type:        EXC_CRASH (SIGABRT)
    Exception Codes:       0x0000000000000000, 0x0000000000000000
    Exception Note:        EXC_CORPSE_NOTIFY

    Application Specific Information:
    abort() called

    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   libsystem_kernel.dylib          0x00007fff6d9fefce __pthread_kill + 10
    1   libsystem_pthread.dylib         0x00007fff6db3c150 pthread_kill + 333
    2   libsystem_c.dylib               0x00007fff6d95b30a abort + 127
    3   net.hockeyapp.sdk.mac           0x000000010b5a3c02 uncaught_exception_handler + 27
    4   com.apple.CoreFoundation        0x00007fff4633fbd2 __handleUncaughtException + 770
    5   libobjc.A.dylib                 0x00007fff6ccc4a41 _objc_terminate() + 91
    6   net.hockeyapp.sdk.mac           0x000000010b591417 BITCrashUncaughtCXXTerminateHandler() + 766
    7   libc++abi.dylib                 0x00007fff6b95b7c9 std::__terminate(void (*)()) + 8
    8   libc++abi.dylib                 0x00007fff6b95b843 std::terminate() + 51
    9   libdispatch.dylib               0x00007fff6d875e9c _dispatch_client_callout + 28
    10  libdispatch.dylib               0x00007fff6d881471 _dispatch_main_queue_callback_4CF + 1148
    11  com.apple.CoreFoundation        0x00007fff46268b99 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    12  com.apple.CoreFoundation        0x00007fff4622b44a __CFRunLoopRun + 2586
    13  com.apple.CoreFoundation        0x00007fff4622a797 CFRunLoopRunSpecific + 487
    14  com.apple.HIToolbox             0x00007fff4553f866 RunCurrentEventLoopInMode + 286
    15  com.apple.HIToolbox             0x00007fff4553f5d6 ReceiveNextEventCommon + 613
    16  com.apple.HIToolbox             0x00007fff4553f354 _BlockUntilNextEventMatchingListInModeWithFilter + 64
    17  com.apple.AppKit                0x00007fff4383ca23 _DPSNextEvent + 2085
    18  com.apple.AppKit                0x00007fff43fd1e6c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
    19  com.apple.AppKit                0x00007fff43831831 -[NSApplication run] + 764
    20  com.apple.AppKit                0x00007fff438009d2 NSApplicationMain + 804
    21  libdyld.dylib                   0x00007fff6d8af145 start + 1

Has anyone else experienced this, or can offer an explanation of how I might be able to fix it? I work offline a lot so not being able to fire up MAMP is a game changer.

Cheers.


问:
Combination of Apache, Tomcat, port 80, 8080 and other stuff
I have a Centos5 with running httpd, mysql and tomcat6. All fine. My goal is to achieve the following

www.domain.com  >>> forwards/proxies to www.domain.com:8080/myapplication (served by tomcat)
www.domain.com/phpmyadmin >>> www.domain.com/phpmyadmin (served by Apache from htdocs)
www.domain.com/* >>> also serverd by htdocs folder as "normal" Apache content

How can I achieve this? Any ideas?

THX

答:
Your only deviation from apache serving htdocs seems to be sending stuff to tomcat, which is running a servlet "myappplication". In this case,

Define a worker (some text string, lets call it "myworker").

Near the end of file /etc/apache2/apache2.conf, add the lines

--Ignore this line in the post--

```<code># Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

             JkMount /myapplication/* myworker
</code>```

In that directory, create a file "workers.properties", that contains the following:

```<code>worker.myworker.type=ajp13
worker.myworker.host=localhost
worker.myworker.port=8081
worker.myworker.cachesize=10
worker.myworker.cache_timeout=600
worker.myworker.socket_keepalive=1
worker.myworker.socket_timeout=300
</code>```

Edit the line tomcat_inst_dir/conf/server.xml to put in a line

[Connector port="8081" protocol="AJP/1.3" /]

Note: change the square brackets to angle brackets.
The above line goes inside the [service]...[/Service] tags and out of the [Engine] ... [/Engine] tags, put it right above the [Engine] line.

Restart apache and tomcat

Now any request to "http://www.domain.com/myapplication/servletName[?par=value...]" gets redirected by apache (on port 80) to tomcat (on port 8081) and on to the servlet myapplication. I assume you have a directory "tomcat_home/webapps/myapplication", which in turn has a directory WEB-INF with a "web.xml" file in it. "servletName" above  is what you define between the [servlet-name]...[/servlet-name] tags in that file.

I chose the number 8081 (feel free to choose your port number as long as it doesnt conflict with other standard services) so that port 8080 is still active for you to test "http://www.domain.com:8080/myapplication/servletName" (should produce same output on ports 8080 and 80, the apache port).

IMPORTANT: Keep a backup copy of all the files changed in the above process, so you can revert back to your working system if the above doesn't work. I had to go through countless iterations of the above to get it working!

Good luck, and hope this works out for you, - M.S.

PS. Sorry about the formatting - I couldnt get this any better

Body:
Your only deviation from apache serving htdocs seems to be sending stuff to tomcat, which is running a servlet "myappplication". In this case,

Define a worker (some text string, lets call it "myworker").

Near the end of file /etc/apache2/apache2.conf, add the lines

--Ignore this line in the post--

# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

             JkMount /myapplication/* myworker

In that directory, create a file "workers.properties", that contains the following:

worker.myworker.type=ajp13
worker.myworker.host=localhost
worker.myworker.port=8081
worker.myworker.cachesize=10
worker.myworker.cache_timeout=600
worker.myworker.socket_keepalive=1
worker.myworker.socket_timeout=300

Edit the line tomcat_inst_dir/conf/server.xml to put in a line

[Connector port="8081" protocol="AJP/1.3" /]

Note: change the square brackets to angle brackets.
The above line goes inside the [service]...[/Service] tags and out of the [Engine] ... [/Engine] tags, put it right above the [Engine] line.

Restart apache and tomcat

Now any request to "http://www.domain.com/myapplication/servletName[?par=value...]" gets redirected by apache (on port 80) to tomcat (on port 8081) and on to the servlet myapplication. I assume you have a directory "tomcat_home/webapps/myapplication", which in turn has a directory WEB-INF with a "web.xml" file in it. "servletName" above  is what you define between the [servlet-name]...[/servlet-name] tags in that file.

I chose the number 8081 (feel free to choose your port number as long as it doesnt conflict with other standard services) so that port 8080 is still active for you to test "http://www.domain.com:8080/myapplication/servletName" (should produce same output on ports 8080 and 80, the apache port).

IMPORTANT: Keep a backup copy of all the files changed in the above process, so you can revert back to your working system if the above doesn't work. I had to go through countless iterations of the above to get it working!

Good luck, and hope this works out for you, - M.S.

PS. Sorry about the formatting - I couldnt get this any better


问:
Why can't I add a (String -> JsBoolean) to a Map[String, JsValue]?
I'm trying to add a Map("foo" -> JsBoolean(false)) to my JsObject's .fields, and it always results in a Map[String, Object]. None of the usual type coercion techniques seem to obtain a Map[String, JsValue] for applying a new JsObject. What's the deal? Is a JsBoolean not a JsValue?

```<code>val bar = format.write(image)
val bazz = bar.asJsObject.fields
val wrong: Map[String, JsValue] = bazz + ("newBoolean" -> JsBoolean(true))
</code>```

答:
See if following example helps:

```<code>val bar = JsObject(List(("key", JsNumber(1))))
val bazz = bar.value
val wrong = bazz + ("newBoolean" -> JsBoolean(true))
</code>```

This generates following:

```<code>wrong: scala.collection.Map[String,play.api.libs.json.JsValue] = Map(key -> 1, newBoolean -> true)
</code>```

Body:
I'm trying to add a Map("foo" -> JsBoolean(false)) to my JsObject's .fields, and it always results in a Map[String, Object]. None of the usual type coercion techniques seem to obtain a Map[String, JsValue] for applying a new JsObject. What's the deal? Is a JsBoolean not a JsValue?

val bar = format.write(image)
val bazz = bar.asJsObject.fields
val wrong: Map[String, JsValue] = bazz + ("newBoolean" -> JsBoolean(true))

Body:
See if following example helps:

val bar = JsObject(List(("key", JsNumber(1))))
val bazz = bar.value
val wrong = bazz + ("newBoolean" -> JsBoolean(true))

This generates following:

wrong: scala.collection.Map[String,play.api.libs.json.JsValue] = Map(key -> 1, newBoolean -> true)


问:
Getting an unexpected token error (expecting ";") in my react native screen?
I am getting this error in my react native screen file:

```<code>SyntaxError in /MyFile.js: Unexpected token, expected ; (5:10)
</code>```

I've been staring at it for quit a while trying to figure out what is wrong, but I am new to React.

Here is MyFile.js:

```<code>import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

const LogInScreen = () => {
  render(){
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Login</Text>
      </View>
      );
  };

};

export default LogInScreen
</code>```

I double checked the ES6 syntax, and my arrow function appears correct.  I have tried it with parentheses instead of braces, and parentheses around the braces just to be sure.

答:
Remove the render since it's a const.

```<code>import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

const LogInScreen = () => {
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Login</Text>
      </View>
      );

};

export default LogInScreen
</code>```

If you want to use render, change your code to this:

```<code>import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';

class LogInScreen extends Component {
  render(){
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Login</Text>
      </View>
      );
  };

};

export default LogInScreen
</code>```

Body:
I am getting this error in my react native screen file:

SyntaxError in /MyFile.js: Unexpected token, expected ; (5:10)

I've been staring at it for quit a while trying to figure out what is wrong, but I am new to React.

Here is MyFile.js:

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

const LogInScreen = () => {
  render(){
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Login</Text>
      </View>
      );
  };

};

export default LogInScreen

I double checked the ES6 syntax, and my arrow function appears correct.  I have tried it with parentheses instead of braces, and parentheses around the braces just to be sure.

Body:
Remove the render since it's a const.

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

const LogInScreen = () => {
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Login</Text>
      </View>
      );

};

export default LogInScreen

If you want to use render, change your code to this:

import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';

class LogInScreen extends Component {
  render(){
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Login</Text>
      </View>
      );
  };

};

export default LogInScreen


问:
Access Denied Connecting to MySQL with PHP
I know there are a lot of threads asking this question already, but I have been at this for hours and am at wits end.  I am attempting to connect to a MySQL database that I am running of my MacBook with the following PHP:

```<code><?php
DEFINE('DB_USER', 'webuser');
DEFINE('DB_PASSWORD', 'thispassword');
DEFINE('DB_HOST', '127.0.0.1:3306');
DEFINE('DB_NAME', 'learning_accounts');

$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die('Error connecting: ' .
mysqli_connect_error()
);

?>
</code>```

That returns the following error:

```<code>Error connecting: Access denied for user 'webuser'@'localhost' (using password: YES)
</code>```

I can connect fine through the terminal, even trying to connect with PHP and root does not work.  I am new to both PHP and MySQL so any guidance and insight would be appreciated!

I have tried tons of solutions such as granting privileges, flushing privileges, creating new users, using PDO, nothing has been working - please help!

Thanks so much, I hate learning new languages because then I'm a lost fish when it comes to debugging at first!

Update

I have a password set for my root account, but changing the DB_PASSWORD variable to '' changes the error to: Error connecting: Unknown database 'learning_accounts'

Update 2
I have fixed the issue, check my answer to see how, if you are having this problem then I hope you found this thread quickly!

Zach L

答: You probably have an anonymous user ''@'localhost' or ''@'127.0.0.1'</p>

Body:
I know there are a lot of threads asking this question already, but I have been at this for hours and am at wits end.  I am attempting to connect to a MySQL database that I am running of my MacBook with the following PHP:

<?php
DEFINE('DB_USER', 'webuser');
DEFINE('DB_PASSWORD', 'thispassword');
DEFINE('DB_HOST', '127.0.0.1:3306');
DEFINE('DB_NAME', 'learning_accounts');

$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die('Error connecting: ' .
mysqli_connect_error()
);

?>

That returns the following error:

Error connecting: Access denied for user 'webuser'@'localhost' (using password: YES)

I can connect fine through the terminal, even trying to connect with PHP and root does not work.  I am new to both PHP and MySQL so any guidance and insight would be appreciated!

I have tried tons of solutions such as granting privileges, flushing privileges, creating new users, using PDO, nothing has been working - please help!

Thanks so much, I hate learning new languages because then I'm a lost fish when it comes to debugging at first!

Update

I have a password set for my root account, but changing the DB_PASSWORD variable to '' changes the error to: Error connecting: Unknown database 'learning_accounts'

Update 2
I have fixed the issue, check my answer to see how, if you are having this problem then I hope you found this thread quickly!

Zach L