问:
Find MIN value between a variable range of cells in two columns that contain TRUE
Sorry if I'm not being super clear! I'm not very adept with Excel but have been making use of it lately for some analysis on financial data. I have a normal OHLC set of data and two other columns where I have some IF statements printing True or False.

How would I accomplish the following:

I want to find the minimum value in one of the OHLC columns that is in a range between where one column has a True value and the other has a True value? This range will be variable and changing depending on the distance between the two trues in each column, if they are there.

I do not need to continually do this, just on a day by day basis. I only need a formula to select this range going back, for example, where the day in my time-series begins at 10:00 each day.

sorry for being unclear, imagine this.

```<code>date  time  open  high  low  close  condition1  condition2
xxxx  xxxx  xxxx  xxxx  xxxx xxxx   true
xxxx  xxxx  xxxx  xxxx  xxxx xxxx                         <--------this range
xxxx  xxxx  xxxx  xxxx  xxxx xxxx                         <--------i want min
xxxx  xxxx  xxxx  xxxx  xxxx xxxx                true
</code>```

but of course this range is variable each day, the conditions may be spaced out differently or might not have (2) true's but if it does. i want to know how to specify whatever range of cells is inbetween these two values

答:
thank you for the interest. i plan to attatch a copy of the spreadsheet i was trying to execute this idea on, im just not around that laptop at the moment. first things first, not really anything complicated on the level of what you described. dont want to trade 'live' or anything super in-depth. just want to be able to do some data collection on price behaviour on the fly. ill add alot of comments on the spreadsheet i attatch so you can get the jist of it. and on the subject of what if the conditions switch. the second condition will be reliant on the first to show itself as true. so the only other permutation will be that condition 2 doesnt show itself. when i get around my other laptop i will add alot of comments to the spreadsheet explaining everything in fine detail and attatch it. sorry no VBA experience, although running into these problems is making me heavily consider it. I usually went about collecting the info i would like to by hand, but gathering a big sample size is tedious work. thanks again.

and on the other question you asked, i dont want to find the number of rows inbetween the range, i want to be able to specify that range in =MIN() calculation in another column.

the first condition will trigger true if price has broken the high price in a column i have in the 10:00 row which is a =MAX() calculation from 6:00-10:00 giving me the four hour high. if any of the sequential prices in the high column are >= to the 4h high price condition1 prints true. then if any of the sequential low prices after this column has printed true are <= the 6-10 high price - 0.0005 (5 points) another condition will hit True, with a third condition tracking this condition if its True and any of the sequential high prices reach back to the =max() high from 6-10 that condition will print True.

i then want to find the minimum low value that falls between where my first and last condition are true. if they are not, do nothing. and like i explained before all conditions will rely on each other to be active before the other can check for its own criteria. so the only permutations are them 'not' being active as opposed to being shuffled around in a different order

hopefully this explains it a lil before i can provide my spreadsheet

Body:
Sorry if I'm not being super clear! I'm not very adept with Excel but have been making use of it lately for some analysis on financial data. I have a normal OHLC set of data and two other columns where I have some IF statements printing True or False.

How would I accomplish the following:

I want to find the minimum value in one of the OHLC columns that is in a range between where one column has a True value and the other has a True value? This range will be variable and changing depending on the distance between the two trues in each column, if they are there.

I do not need to continually do this, just on a day by day basis. I only need a formula to select this range going back, for example, where the day in my time-series begins at 10:00 each day.

sorry for being unclear, imagine this.

date  time  open  high  low  close  condition1  condition2
xxxx  xxxx  xxxx  xxxx  xxxx xxxx   true
xxxx  xxxx  xxxx  xxxx  xxxx xxxx                         <--------this range
xxxx  xxxx  xxxx  xxxx  xxxx xxxx                         <--------i want min
xxxx  xxxx  xxxx  xxxx  xxxx xxxx                true

but of course this range is variable each day, the conditions may be spaced out differently or might not have (2) true's but if it does. i want to know how to specify whatever range of cells is inbetween these two values


来源: stackexchange

问:
Remove notification inside service android
I have a notification on one of my services. Below is the code:

```<code>Notification notification = new NotificationCompat.Builder(this)
                                .setContentIntent(contentIntent)
                                .setContentTitle("title")
                                .setContentText("content")
                                .setSmallIcon(R.drawable.ic_small_notif)
                                .setLargeIcon(bitmap)
                                .setSound(alarmSound)
                                .setColor(Color.parseColor("#999999"))
                                .build();

                        startForeground(100,
                                notification);
</code>```

I still confused how to stop this programmatically when I want to. Any suggestions?

答:
try this</p>

```<code> NotificationManager manager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(mnotinotifId);
    manager.cancelAll();
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a notification on one of my services. Below is the code:

Notification notification = new NotificationCompat.Builder(this)
                                .setContentIntent(contentIntent)
                                .setContentTitle("title")
                                .setContentText("content")
                                .setSmallIcon(R.drawable.ic_small_notif)
                                .setLargeIcon(bitmap)
                                .setSound(alarmSound)
                                .setColor(Color.parseColor("#999999"))
                                .build();

                        startForeground(100,
                                notification);

I still confused how to stop this programmatically when I want to. Any suggestions?

Body:
try this

 NotificationManager manager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(mnotinotifId);
    manager.cancelAll();


问:
How to pass access_token in API using kong gateway
How to pass access_token in API using Kong API gateway?? I have tried the below:

```<code>https://10.223.98.237:8000/API_analytics/AnalyticsInputHistoryController?user=1/oauth_callback#access_token=1234567890&token_type=Bearer&expires_in=3600
</code>```

and

```<code>http://10.223.98.237:8000/API_analytics/AnalyticsInputHistoryController?user=1&access_token=1234567890
</code>```

kindly help me out with the proper syntax of API. Thank you

答:
If you would like do from frontend using AJAX you can try this,

```<code>$.ajaxSetup(
    'headers': {
      'auth_token': "my_Token"
    }
  )
</code>```

Here is the KONG API method,

```<code>curl -X POST http://10.223.98.237:8000/API_analytics/AnalyticsInputHistoryController \
  --header 'content-type: application/json' \
  --data '{"name": "request-transformer", "config": {"add": {"headers": ["user:1,"access_token:1234567890"}}}'
</code>```

or

```<code>curl -X POST http://10.223.98.237:8000/API_analytics/AnalyticsInputHistoryController \
  --data "name=request-transformer" \
  --data "config.add.headers='user':1,'access_token':1234567890"
</code>```

Body:
How to pass access_token in API using Kong API gateway?? I have tried the below:

https://10.223.98.237:8000/API_analytics/AnalyticsInputHistoryController?user=1/oauth_callback#access_token=1234567890&token_type=Bearer&expires_in=3600

and

http://10.223.98.237:8000/API_analytics/AnalyticsInputHistoryController?user=1&access_token=1234567890

kindly help me out with the proper syntax of API. Thank you

Body:
If you would like do from frontend using AJAX you can try this,

$.ajaxSetup(
    'headers': {
      'auth_token': "my_Token"
    }
  )

Here is the KONG API method,

curl -X POST http://10.223.98.237:8000/API_analytics/AnalyticsInputHistoryController \
  --header 'content-type: application/json' \
  --data '{"name": "request-transformer", "config": {"add": {"headers": ["user:1,"access_token:1234567890"}}}'

or

curl -X POST http://10.223.98.237:8000/API_analytics/AnalyticsInputHistoryController \
  --data "name=request-transformer" \
  --data "config.add.headers='user':1,'access_token':1234567890"


问:
About ![CDATA[, what is it?

Possible Duplicate:

  what is the meaning of CDATA

What is, and when is used the ![CDATA[ string/variable/constant? (I don't know what is it)

答: It is used in XML, inside can be everything.</p>

ContentLicense: CC BY-SA 2.5

Title: About ![CDATA[, what is it?


问:
Textbox compulsory when radio button is selected
I have a view where add to electronic has 2 radiobuttons yes & no. And a submit button. When yes radiobutton is clicked. the quantity textbox should not be empty. But it can be empty if no radiobutton is clicked.
This functionality should work when submit button is clicked with yes radiobutton is selected.

```<code> <HTML>
    <head>
    radio
    </head>
    <body>
    <form id=radio>
     Add to electronic  <input type="radio" name="yes"onclick="validate(_this)"id="yes"/>Yes<input type="radio" name="yes" id="no" />No<br />
    <label>Quantity</label><input type="text"size="25"name="dir"id="dir" required/>
<button type=submit name=insert>insert</button>
</body>
<div>
<script src="~/Scripts/radiobuttonvalidation.js"></script>
</div>
</html>
</code>```

I'm new to mvc and javascript. Please help me with javascript code too, and the way i should link it with my view. Javascript:

```<code>function validate(_this) {
    if ($(_this).attr('id') == "yes") {
        $('#dir').attr('required');
        alert("Text Box required");
    }
    else {
        $('#dir').removeAttr('required');
        alert("Text Box not required");
    }
}
</code>```

答:
You have several issues

do not pass _this it is not a valid variable

you only test one radio - so the "no" never removes the required

your HTML is invalid - you need to close the form and not have any html other than  after the

You must remove the required if you want the input to be allowed empty if neither are checked

Here is a working and unobtrusive version. If you decide to use jQuery you have no reasons left to use inline event handlers

$(function() {
  $("[name='yes']").on("click", function() {
    if (this.id == "yes") {
      $('#dir').attr('required', true);
      console.log("Text Box required");
    } else {
      $('#dir').removeAttr('required');
      console.log("Text Box not required");
    }
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<form id=radio>
  Add to electronic <input type="radio" name="yes" id="yes" />Yes<input type="radio" name="yes" id="no" />No<br />
  <label>Quantity</label><input type="text" size="25" name="dir" id="dir" />
  <button type=submit name=insert>insert</button>
</form></code>```

RobG and I suggest to use a checkbox and I would hide the quantity to:

function validate() {
  var $check = $("#addToElectronic"), checked = $check.is(":checked");
  $("#quant").toggle(checked);
  $('#dir').attr('required', checked);
}
$(function() {
  $("#addToElectronic").on("click",validate);
  validate();
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#quant { display:none }</code>```

<form id=radio>
  Add to electronic <input type="checkbox" id="addToElectronic" value="yes" />Yes

  Quantity<input type="text" size="25" name="dir" id="dir" />

  <button type=submit name=insert>insert</button>
</form>```

Body:
I have a view where add to electronic has 2 radiobuttons yes & no. And a submit button. When yes radiobutton is clicked. the quantity textbox should not be empty. But it can be empty if no radiobutton is clicked.
This functionality should work when submit button is clicked with yes radiobutton is selected.

    radio

    <form id=radio>
     Add to electronic  <input type="radio" name="yes"onclick="validate(_this)"id="yes"/>Yes<input type="radio" name="yes" id="no" />No

    Quantity<input type="text"size="25"name="dir"id="dir" required/>
<button type=submit name=insert>insert</button>

I'm new to mvc and javascript. Please help me with javascript code too, and the way i should link it with my view. Javascript:

function validate(_this) {
    if ($(_this).attr('id') == "yes") {
        $('#dir').attr('required');
        alert("Text Box required");
    }
    else {
        $('#dir').removeAttr('required');
        alert("Text Box not required");
    }
}

Body:
You have several issues

do not pass _this it is not a valid variable

you only test one radio - so the "no" never removes the required

your HTML is invalid - you need to close the form and not have any html other than </html> after the </body>

You must remove the required if you want the input to be allowed empty if neither are checked

Here is a working and unobtrusive version. If you decide to use jQuery you have no reasons left to use inline event handlers

$(function() {
  $("[name='yes']").on("click", function() {
    if (this.id == "yes") {
      $('#dir').attr('required', true);
      console.log("Text Box required");
    } else {
      $('#dir').removeAttr('required');
      console.log("Text Box not required");
    }
  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<form id=radio>
  Add to electronic <input type="radio" name="yes" id="yes" />Yes<input type="radio" name="yes" id="no" />No<br />
  <label>Quantity</label><input type="text" size="25" name="dir" id="dir" />
  <button type=submit name=insert>insert</button>
</form>

RobG and I suggest to use a checkbox and I would hide the quantity to:

function validate() {
  var $check = $("#addToElectronic"), checked = $check.is(":checked");
  $("#quant").toggle(checked);
  $('#dir').attr('required', checked);
}
$(function() {
  $("#addToElectronic").on("click",validate);
  validate();
});

#quant { display:none }

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<form id=radio>
  Add to electronic <input type="checkbox" id="addToElectronic" value="yes" />Yes<br/>
  <div id="quant">
  <label>Quantity</label><input type="text" size="25" name="dir" id="dir" />
  </div>
  <button type=submit name=insert>insert</button>
</form>


问:
Async transactions in javascript
First of all rollback is something that I do not care about.

I would like to be able to lock a sequence of async functions/promises/tasks (let's call it a "transaction") with a name/id (or array of names), so that they happen in sequence, and so that any other "transaction" with the same name(s) that are run by another part of the system are delayed from starting until the running transaction using the same name(s) has completed.  So it basically is queueing the sequences of async tasks, or "transaction"s.

Here is some example code of the situation:

```<code>function a()
{
  // do stuff
  return new Promise(/*...*/);
}

function b()
{
  // do stuff
  return new Promise(/*...*/);
}

function c()
{
  // do stuff
  return a.then(() => b());
}
</code>```

Now at any time the system could call a, b, or c, and when it does I don't want c and b running at the same time, but obvious c depends on b.

I've been looking for a package on npm to help with this but I haven't found anything, I wonder if anyone can suggest something that I might have missed that would help with this?

答:
```<code>function a()
{
  // do stuff
  return new Promise(/*...*/);
}

function b()
{
  // do stuff
  return new Promise(/*...*/);
}

function c()
{
  // do stuff
  return new Value;
}

a().then(function(data_a) {
  // you can make use of return value (which is data_a) here or as an argument for function b or even function c
  b().then(function(data_b) {
    // you can make use of return value (which is data_b) here or as an argument for function c
    c().then(function(data_c) {
      // do your coding here
    });
  });
});
</code>```

you can check this link for reference : https://spring.io/understanding/javascript-promises

Title: Async transactions in javascript

Body:
First of all rollback is something that I do not care about.

I would like to be able to lock a sequence of async functions/promises/tasks (let's call it a "transaction") with a name/id (or array of names), so that they happen in sequence, and so that any other "transaction" with the same name(s) that are run by another part of the system are delayed from starting until the running transaction using the same name(s) has completed.  So it basically is queueing the sequences of async tasks, or "transaction"s.

Here is some example code of the situation:

function a()
{
  // do stuff
  return new Promise(/*...*/);
}

function b()
{
  // do stuff
  return new Promise(/*...*/);
}

function c()
{
  // do stuff
  return a.then(() => b());
}

Now at any time the system could call a, b, or c, and when it does I don't want c and b running at the same time, but obvious c depends on b.

I've been looking for a package on npm to help with this but I haven't found anything, I wonder if anyone can suggest something that I might have missed that would help with this?

Body:
function a()
{
  // do stuff
  return new Promise(/*...*/);
}

function b()
{
  // do stuff
  return new Promise(/*...*/);
}

function c()
{
  // do stuff
  return new Value;
}

a().then(function(data_a) {
  // you can make use of return value (which is data_a) here or as an argument for function b or even function c
  b().then(function(data_b) {
    // you can make use of return value (which is data_b) here or as an argument for function c
    c().then(function(data_c) {
      // do your coding here
    });
  });
});

you can check this link for reference : https://spring.io/understanding/javascript-promises


答:
use stopForeground(true);

it works with foregroud tasks.

Title: Remove notification inside service android


问:
How to remove pause menu video suggestions / related videos (class: ytp-pause-overlay) from Youtube embed
Youtube is showing a menu with video suggestions while my embedded video is paused. The element in the iframe has the class 'ytp-pause-overlay'

How can you remove it without removing controls?

答:
Yes it is possible. You have to use showinfo=0?ecver=2 in your iframe code.

Example:

```<code><iframe src="https://www.youtube.com/embed/pV1jC37ELmQ?rel=0&showinfo=0?ecver=2" width="640" height="360"></iframe>
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Yes it is possible. You have to use showinfo=0?ecver=2 in your iframe code.

Example:

<iframe src="https://www.youtube.com/embed/pV1jC37ELmQ?rel=0&amp;showinfo=0?ecver=2" width="640" height="360"></iframe>


问:
DROP FUNCTION without knowing the number/type of parameters?
I keep all my functions in a text file with 'CREATE OR REPLACE FUNCTION somefunction'.

So if I add or change some function I just feed the file to psql.

Now if I add or remove parameters to an existing function, it creates an overload with the same name and to delete the original I need type in all the parameter types in the exact order which is kind of tedious.

Is there some kind of wildcard I can use to DROP all functions with a given name so I can just add DROP FUNCTION lines to the top of my file?

答:
Improving original answer in order to take schema into account, ie. schema.my_function_name,

```<code>select
    format('DROP FUNCTION %s(%s);',
      p.oid::regproc, pg_get_function_identity_arguments(p.oid))
FROM pg_catalog.pg_proc p
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE
    p.oid::regproc::text = 'schema.my_function_name';
</code>```

Body:
Improving original answer in order to take schema into account, ie. schema.my_function_name,

select
    format('DROP FUNCTION %s(%s);',
      p.oid::regproc, pg_get_function_identity_arguments(p.oid))
FROM pg_catalog.pg_proc p
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE
    p.oid::regproc::text = 'schema.my_function_name';


问:
Using NSPredicate to refer other NSPredicate rules
Let's say I have a Core Data database for NSPredicate rules.

```<code>enum PredicateType,Int {
case beginswith
case endswith
case contains
}
</code>```

My Database looks like below

```<code>+------+-----------+
| Type |  Content  |
+------+-----------+
|    0 | Hello     |
|    1 | end       |
|    2 | somevalue |
|    0 | end       |
+------+-----------+
</code>```

I have a content "This is end". How can I query Core Data to check if there is any rule that satisfies this content? It should find second entry on the table

```<code>+------+-----------+
| Type |  Content  |
+------+-----------+
|    1 | end       |
+------+-----------+
</code>```

but shouldn't find

```<code>+------+-----------+
| Type |  Content  |
+------+-----------+
|    0 | end       |
+------+-----------+
</code>```

Because in this sentence end is not at the beginning.

Currently I am getting all values, Create predicate with Content and Type and query the database again which is a big overhead I believe.

答:
They way you doing it now is correct.  You first need to build your predicate (which in your case is very complex operation that also requires fetching) and run each predicate to see if which one matches.

I wouldn't be so quick to assume that there is a huge overhead with this.  If your data set is small (<300) I would suspect that there would be no problem with this at all.  If you are experencing problems then (and only then!) you should start optimizing.

If you see the app is running too slowly then use instrements to see where the issue is.  There are two possible places that I could see having perforance issues - 1) the fetching of all the predicates from the database and 2) the running of all of the predicates.

If you want to make the fetching faster, then I would recommend using a NSFetchedResultsController.  While it is generally used to keep data in sync with a tableview it can be used for any data that you want to have a correct data for at any time.  With the controller you do a single fetch and then it monitors core-data and keeps itself up to data.  Then when you you need all of the predicate instead of doing a fetch, you simply access the contoller's fetchedObjects property.

If you find that running all the predicates are taking a long time, then you can improve the running for beginsWith and endsWith by a clever use of a bianary search.  You keep two arrays of custom predicate objects, one sorted alphabetically and the other will all the revered strings sorted alphabetically.  To find which string it begins with use indexOfObject:inSortedRange:options:usingComparator: to find the relevant objects.  If don't know how you can improve contains.  You could see if running string methods on the objects is faster then NSPredicate methods.  You could also try running the predicates on a background thread concurrently.

Again, you shouldn't do any of this unless you find that you need to.  If your dataset is small, then the way you are doing it now is fine.

Body:
Let's say I have a Core Data database for NSPredicate rules.

enum PredicateType,Int {
case beginswith
case endswith
case contains
}

My Database looks like below

+------+-----------+
| Type |  Content  |
+------+-----------+
|    0 | Hello     |
|    1 | end       |
|    2 | somevalue |
|    0 | end       |
+------+-----------+

I have a content "This is end". How can I query Core Data to check if there is any rule that satisfies this content? It should find second entry on the table

+------+-----------+
| Type |  Content  |
+------+-----------+
|    1 | end       |
+------+-----------+

but shouldn't find

+------+-----------+
| Type |  Content  |
+------+-----------+
|    0 | end       |
+------+-----------+

Because in this sentence end is not at the beginning.

Currently I am getting all values, Create predicate with Content and Type and query the database again which is a big overhead I believe.


问:
How to allow PHP file read parameter passed in a clean way using htaccess
I've been trying fix my error, first here is my .htaccess code:

```<code># Clean Url for User Profiles
AddDefaultCharset UTF-8
Header unset ETag
FileETag None
Options +FollowSymLinks -MultiViews
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+friend\.php\?user_name=([^\s&]+) [NC]
RewriteRule ^ friend/%1? [R=301,L]
RewriteRule ^friend/([^/]+)/?$ friend.php?user_name=$1 [L,QSA]
# End Clean Url Htaccess
</code>```

My intentions with this code is to make this URL http://localhost:8888/circlepanda/friend?user_name=kendrick

Display like this http://localhost:8888/circlepanda/friend/kendrick and work.
The page opens good, burr the parameter isn't parsed. How do I fix this?

答:
There are a number of issues with your code. I tried to fix what I see, here is my version of what you probably are trying to implement:

```<code>Options -MultiViews
RewriteEngine on

# external: /..../friend?username=joe >> /..../friend/joe
RewriteCond %{QUERY_STRING} user_name=([^&]+)
RewriteRule ^friend/?$ friend/%1 [R=301,QSA]

# internal: /friend/joe >> friend.php?user_name=joe
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^friend/([^/]+)/?$ friend.php?user_name=$1 [END,QSA]
</code>```

Depending on your specific situation it might be that you need to add a RewriteBase. See the official documentation for that.

If you experience an internal server error using above lines chances are that you operate a very old version of the apache http server. In that case you need to replace the [END] flag with the [L] flag.

And a general hint: you should always prefer to place such rules inside the http servers (virtual) host configuration instead of using dynamic configuration files (.htaccess style files). Those files are notoriously error prone, hard to debug and they really slow down the server. They are only provided as a last option for situations where you do not have control over the host configuration (read: really cheap hosting service providers) or if you have an application that relies on writing its own rewrite rules (which is an obvious security nightmare).

Body:
I've been trying fix my error, first here is my .htaccess code:

# Clean Url for User Profiles
AddDefaultCharset UTF-8
Header unset ETag
FileETag None
Options +FollowSymLinks -MultiViews
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+friend\.php\?user_name=([^\s&]+) [NC]
RewriteRule ^ friend/%1? [R=301,L]
RewriteRule ^friend/([^/]+)/?$ friend.php?user_name=$1 [L,QSA]
# End Clean Url Htaccess

My intentions with this code is to make this URL http://localhost:8888/circlepanda/friend?user_name=kendrick

Display like this http://localhost:8888/circlepanda/friend/kendrick and work.
The page opens good, burr the parameter isn't parsed. How do I fix this?

Body:
There are a number of issues with your code. I tried to fix what I see, here is my version of what you probably are trying to implement:

Options -MultiViews
RewriteEngine on

# external: /..../friend?username=joe >> /..../friend/joe
RewriteCond %{QUERY_STRING} user_name=([^&]+)
RewriteRule ^friend/?$ friend/%1 [R=301,QSA]

# internal: /friend/joe >> friend.php?user_name=joe
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^friend/([^/]+)/?$ friend.php?user_name=$1 [END,QSA]

Depending on your specific situation it might be that you need to add a RewriteBase. See the official documentation for that.

If you experience an internal server error using above lines chances are that you operate a very old version of the apache http server. In that case you need to replace the [END] flag with the [L] flag.

And a general hint: you should always prefer to place such rules inside the http servers (virtual) host configuration instead of using dynamic configuration files (.htaccess style files). Those files are notoriously error prone, hard to debug and they really slow down the server. They are only provided as a last option for situations where you do not have control over the host configuration (read: really cheap hosting service providers) or if you have an application that relies on writing its own rewrite rules (which is an obvious security nightmare).


问:
Perl: Verify the command line argument is an integer and not a file
I need to check if the (Perl) command line argument is only an integer and a file.

I can check is the right number of arguments are entered:

```<code>if (@ARGV != 2){
</code>```

And, I can check to make sure the order of arguments is correct:

```<code>    if ($ARGV[0] >= $ARGV[1])
</code>```

But, I don't know how to check if the argument is a file. I want to print and error message if it is a file.

Thanks

答:
To test if, say, $ARGV[0] is strictly integer, you could use this predicate:

```<code>if ($ARGV[0] =~ /^\d+$/) {
    print "an integer\n";
} else {
    print "not an integer\n";
}
</code>```

Execute perldoc perlre for a whole lot more information.

To test if $ARGV[0] is a file, you would use something like this:

```<code>if (-f $ARGV[0]) {
    print "a file\n";
} else {
    print "not a file\n";
}
</code>```

Execute perldoc -f -f for quite a bit of information on file related tests.

Body:
I need to check if the (Perl) command line argument is only an integer and a file.

I can check is the right number of arguments are entered:

if (@ARGV != 2){

And, I can check to make sure the order of arguments is correct:

    if ($ARGV[0] >= $ARGV[1])

But, I don't know how to check if the argument is a file. I want to print and error message if it is a file.

Thanks

Body:
To test if, say, $ARGV[0] is strictly integer, you could use this predicate:

if ($ARGV[0] =~ /^\d+$/) {
    print "an integer\n";
} else {
    print "not an integer\n";
}

Execute perldoc perlre for a whole lot more information.

To test if $ARGV[0] is a file, you would use something like this:

if (-f $ARGV[0]) {
    print "a file\n";
} else {
    print "not a file\n";
}

Execute perldoc -f -f for quite a bit of information on file related tests.


问:
I have written a code in Python where even if i am using a break statement and continue still its going into an infinite loop in Python:
The below code is running however when I am trying to exit out of the code it goes into an infinite loop where even if i type in 1 still it does not break out of the loop. I am a beginner in Python please can anyone help me??

Here is my code,

```<code>import urllib2
import sys

urlToRead = ('https://www.google.com')

crawledWebLinks = {}

while urlToRead !='':
    try:
        urlToRead = raw_input('Please enter the Next weblink to crawl')
        if urlToRead == '':
            print ('Ok Existing the Loop')
            break
        shortName = raw_input('Please enter a short Name for the Url to Read  ' + urlToRead)
        webfile = urllib2.urlopen(urlToRead).read()
        crawledWebLinks[shortname] = webfile
    except:
        print (sys.exc_info()[0])
        stopOrproceed = raw_input('You want to Stop or Continue, Please type in 1 to stop or anything else to Continue')
        if stopOrproceed == 1:
            print ('Okies we are stopping')
            break
        else:
            print ('lets continue')
            continue

print (crawledWebLinks.keys())
</code>```

答:
The following few lines are the ones causing problem,

```<code>stopOrproceed = raw_input('You want to Stop or Continue, Please type in 1 to stop or anything else to Continue')
if stopOrproceed == 1:
    print ('Okies we are stopping')
    break
</code>```

You see raw_input gets input and stores it as a string. So after getting the value from user. your stopOrproceed variable would have "1"

And when you check for stopOrproceed==1 --> "1"==1. Which is definitely not equal in Python. So always false is evaluated And hence the control never goes inside the if and thus you never break.

Try changing that to this,

```<code>if stopOrproceed == "1":
        print ('Okies we are stopping')
        break
</code>```

Body:
The below code is running however when I am trying to exit out of the code it goes into an infinite loop where even if i type in 1 still it does not break out of the loop. I am a beginner in Python please can anyone help me??

Here is my code,

import urllib2
import sys

urlToRead = ('https://www.google.com')

crawledWebLinks = {}

while urlToRead !='':
    try:
        urlToRead = raw_input('Please enter the Next weblink to crawl')
        if urlToRead == '':
            print ('Ok Existing the Loop')
            break
        shortName = raw_input('Please enter a short Name for the Url to Read  ' + urlToRead)
        webfile = urllib2.urlopen(urlToRead).read()
        crawledWebLinks[shortname] = webfile
    except:
        print (sys.exc_info()[0])
        stopOrproceed = raw_input('You want to Stop or Continue, Please type in 1 to stop or anything else to Continue')
        if stopOrproceed == 1:
            print ('Okies we are stopping')
            break
        else:
            print ('lets continue')
            continue

print (crawledWebLinks.keys())

Body:
The following few lines are the ones causing problem,

stopOrproceed = raw_input('You want to Stop or Continue, Please type in 1 to stop or anything else to Continue')
if stopOrproceed == 1:
    print ('Okies we are stopping')
    break

You see raw_input gets input and stores it as a string. So after getting the value from user. your stopOrproceed variable would have "1"

And when you check for stopOrproceed==1 --> "1"==1. Which is definitely not equal in Python. So always false is evaluated And hence the control never goes inside the if and thus you never break.

Try changing that to this,

if stopOrproceed == "1":
        print ('Okies we are stopping')
        break


问:
Basic authorization command for curl
How do I set up the Basic authorization using Base64 encoded credentials?

I tried the below two commands, but of no use. Please suggest me the correct variant.

```<code>curl -i -H 'Accept:application/json' Authorization:Basic <username:password> http://example.com
curl -i -H 'Accept:application/json' Authorization:Basic.base64_encode(username:password) http://example.com
</code>```

答:
curl -D- -X GET -H "Authorization: Basic ZnJlZDpmcmVk" -H "Content-Type: application/json" http://localhost:7990/rest/api/1.0/projects

```<code>--note

base46 encode =ZnJlZDpmcmVk
</code>```

Title: Basic authorization command for curl

Body:
How do I set up the Basic authorization using Base64 encoded credentials?

I tried the below two commands, but of no use. Please suggest me the correct variant.

curl -i -H 'Accept:application/json' Authorization:Basic <username:password> http://example.com
curl -i -H 'Accept:application/json' Authorization:Basic.base64_encode(username:password) http://example.com

Body:
curl -D- -X GET -H "Authorization: Basic ZnJlZDpmcmVk" -H "Content-Type: application/json" http://localhost:7990/rest/api/1.0/projects

--note

base46 encode =ZnJlZDpmcmVk


问:
Move to a view controller on click of a button inside UIPopoverPresentationController
I have a table view controller with a cell that has a button.

On click of this button I am displaying a view controller as an UIPopoverPresentationController.

This pop over controller has two buttons , YES and NO.

On click of YES I want to be able to segue to another view controller and on click of NO I will dismiss the pop over controller.

On click of NO the popover gets dismissed but on click of YES I don't move to the required view controller .

Although the view did load() method of that view controller gets called. The problem is that the new view controller is not being displayed.

On click of YES,the popover gets dismissed but remains on the previous view controller

Following is my code

TableViewController class

```<code>func onTapPickButton(sender: UIButton) {

 let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let popoverViewController = storyboard.instantiateViewController(withIdentifier: "ConfirmDialogViewController") as! ConfirmDialogViewController
        popoverViewController.preferredContentSize = CGSize(width: view.frame.width/1.33, height: view.frame.height/2.34)
        popoverViewController.modalPresentationStyle = UIModalPresentationStyle.popover
        let popover: UIPopoverPresentationController = popoverViewController.popoverPresentationController!
        popover.sourceView = self.view
        popover.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
        popover.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
        popover.delegate = self

        present(popoverViewController, animated: true, completion: nil)
}
</code>```

PopOver View controller class

```<code>@IBAction func onTapNoButton(_ sender: UIButton) {
        self.dismiss(animated: true, completion: {})
    }

    @IBAction func onTapYesButton(_ sender: UIButton) {
        let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: "View") as! ViewController
present(viewController, animated: true, completion: nil)

    }
</code>```

Any help will be appreciated. Thank you.

答:
In YES button action, dismiss the popOver and in completion block present the new viewController

```<code> @IBAction func onTapYesButton(_ sender: UIButton) {
                let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
                let viewController = storyboard.instantiateViewController(withIdentifier: "View") as! ViewController
                self.dismiss(animated: true, completion: {
                       self.present(viewController, animated: true, completion: nil)
                })

            }
</code>```

Body:
I have a table view controller with a cell that has a button.

On click of this button I am displaying a view controller as an UIPopoverPresentationController.

This pop over controller has two buttons , YES and NO.

On click of YES I want to be able to segue to another view controller and on click of NO I will dismiss the pop over controller.

On click of NO the popover gets dismissed but on click of YES I don't move to the required view controller .

Although the view did load() method of that view controller gets called. The problem is that the new view controller is not being displayed.

On click of YES,the popover gets dismissed but remains on the previous view controller

Following is my code

TableViewController class

func onTapPickButton(sender: UIButton) {

 let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let popoverViewController = storyboard.instantiateViewController(withIdentifier: "ConfirmDialogViewController") as! ConfirmDialogViewController
        popoverViewController.preferredContentSize = CGSize(width: view.frame.width/1.33, height: view.frame.height/2.34)
        popoverViewController.modalPresentationStyle = UIModalPresentationStyle.popover
        let popover: UIPopoverPresentationController = popoverViewController.popoverPresentationController!
        popover.sourceView = self.view
        popover.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
        popover.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
        popover.delegate = self

        present(popoverViewController, animated: true, completion: nil)
}

PopOver View controller class

@IBAction func onTapNoButton(_ sender: UIButton) {
        self.dismiss(animated: true, completion: {})
    }

    @IBAction func onTapYesButton(_ sender: UIButton) {
        let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: "View") as! ViewController
present(viewController, animated: true, completion: nil)

    }

Any help will be appreciated. Thank you.

Body:
In YES button action, dismiss the popOver and in completion block present the new viewController

 @IBAction func onTapYesButton(_ sender: UIButton) {
                let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
                let viewController = storyboard.instantiateViewController(withIdentifier: "View") as! ViewController
                self.dismiss(animated: true, completion: {
                       self.present(viewController, animated: true, completion: nil)
                })

            }


问:
NoMethodError: undefined method `to_d' for nil:NilClass
```<code>NoMethodError: undefined method `to_d' for nil:NilClass
</code>```

this seems to be inconsistent with other "to_"

eg with Rails 3.2.14, and ruby 1.9.3p362:

```<code>1.9.3p362 :055 > nil.to_f
 => 0.0
1.9.3p362 :056 > nil.to_d
NoMethodError: undefined method `to_d' for nil:NilClass
1.9.3p362 :057 > nil.to_s
 => ""
1.9.3p362 :058 > nil.to_i
 => 0
</code>```

it means that when ever i might want to convert to big decimal that i first have to make sure the value is not nil and assign it a 0 value anyway... so... comments on what is the best way to make this consistent? and should i consider this a bug?

答:
or
(nil.try(:to_d) || 0) + value

Body:
NoMethodError: undefined method `to_d' for nil:NilClass

this seems to be inconsistent with other "to_"

eg with Rails 3.2.14, and ruby 1.9.3p362:

1.9.3p362 :055 > nil.to_f
 => 0.0
1.9.3p362 :056 > nil.to_d
NoMethodError: undefined method `to_d' for nil:NilClass
1.9.3p362 :057 > nil.to_s
 => ""
1.9.3p362 :058 > nil.to_i
 => 0

it means that when ever i might want to convert to big decimal that i first have to make sure the value is not nil and assign it a 0 value anyway... so... comments on what is the best way to make this consistent? and should i consider this a bug?

Body:
or
(nil.try(:to_d) || 0) + value


问:
How to add a transition for a slide show?
I wanted to add a transition for the slide show which i am making for one of my page..

Here is the code,

        var index= 1;

        var toggle=0;

        function plusIndex(n){
         index = index + n;
         showImage(n);
        }
        showImage(1);

        function showImage(n){
        var i;
        var x = document.getElementsByClassName("placestovisit");
        if (index > x.length) {index=1};
        if (index < 1) {index= x.length};
        for (i=0; i<x.length; i++)
        {
          x[i].style.display="none";
        }
            x[index-1].style.display= "block";
        }

        autoSlide();
        function autoSlide(){
        if (toggle) {return};
        var i;
        var x = document.getElementsByClassName("placestovisit");
        for (i=0; i<x.length; i++)
        {
          x[i].style.display="none";
        }
        if (index > x.length) {index = 1};
            x[index-1].style.display= "block";
        index++;
        setTimeout(autoSlide, 4000);
        }```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <body style="height:100%;">

<div id="placescontainer">
<div class="placestovisit fade">
      <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Hanumangundi_Falls.jpg/1200px-Hanumangundi_Falls.jpg" alt="" />
      <h1>Hanumanagundi Falls</h1>
      <h2 > Suthanabbe Falls or Hanumanagundi Falls is located in the hilly surroundings of the Kudremukh National Park in the Chikkamagaluru district of Karnataka, India.
Suthanabbe Falls is located between Karkala and Lakya dam in the Kudremukh national park. The water falls from a height of 22 meters creating a scenic surroundings around it.</h2>
</div>

<div class="placestovisit fade">
      <img src="https://upload.wikimedia.org/wikipedia/commons/4/4b/Hampi_virupaksha_temple.jpg" alt="" />
      <h1> Hambi(Hambe) </h1>
          <h2> Hampi (Hampe) is a village and temple town recognised as a UNESCO World Heritage Site, listed as the Group of Monuments at Hampi. in northern Karnataka, India. It was one of the richest and largest cities in the world during its prime. It is located within the ruins of the city of Vijayanagara, the former capital of the Vijayanagara Empire. Predating the city of Vijayanagara, Hampi continues to be an important religious centre, housing the Virupaksha Temple and several other monuments belonging to the old city. According to statistics of 2014, Hampi is the most searched historical place in Karnataka on Google.</h2>
</div>
<div class="placestovisit w3-animate-fading">
      <img src="http://www.thebetterindia.com/wp-content/uploads/2012/09/IMG_0750-Com-800x533.jpg" alt="" />
      <h1> Agumbe </h1>
          <h2> Agumbe is a hill station which can be reached by bikes or cars. The way to this place is a diversion from Parkala (The diversion is just a few kms from DT). The best part of the trip to Agumbe is the ride. Beautiful sceneries on both sides will keep company all along the way. This place is abount 45 km from Manipal. Agumbe is one of the highest peaks of the Western Ghats located about 60kms from Udupi. Situated at a height of 830 metres from sea level, it overlooks the Arabian Sea. Agumbe is part of the Shimoga district which is a neighboring district of Udupi. </h2>
</div>

<div class="placestovisit fade">
      <img src="https://d28dwf34zswvrl.cloudfront.net/wp-content/uploads/2017/01/kerala-carbon-neutral-panchayat.jpg" alt="" />
      <h1> Kerala </h1>
          <h2> The border of Kerala is just 75 km from Manipal. The 300-year-old Bekal Fort, shaped like a giant key-hole, is one of the largest and best-preserved forts in Kerala. Surrounded by a splendid beach, the historic Bekal Fort offers a superb view of the Arabian Sea from its tall observation towers, where a few centuries ago huge cannons used to be placed. Today, it is one of the favourite spots for film-makers because the Bekal Fort and its surroundings with backwaters and hilly destinations make fascinating locales. This fort was made by Tipu Sultan and is built right next to the sea. The popular song 'Tu Hi Re' was picturised with this fort in the backdrop.</h2>
</div>

<div class="placestovisit fade">
      <img src="http://udupitoday.com/udtoday/images/uploads/January/images/jan1431attur1.jpg" alt="" />
      <h1> Attur church </h1>
          <h2> Attur Church situated in the outskirts of Karkala town in Karnataka state — India. It is situated 58 km from Mangalore.
Placed amidst placid greenery, the Attur-Karkala parish has a rich history with its origin tracing back to 1759. Moreover it is known for its miraculous history. Miracle, history, beauty, social activities, all bundled into one.
Unlike others, the church is a place of worship and belief for all, irrespective of caste and creed. An vidence for universal peace and brotherhood. People from all walks of the society come here to offer their prayers to St Lawrence</h2>
</div>
<button class="btn" onclick="plusIndex(-1)" id="btn1"> ❮</button>
<button class="btn"  onclick="plusIndex(1)" id="btn2"> ❯</button>

<button class="play"  onclick="toggle=1-toggle; autoSlide()" id="btn3">  Play/Pause </button>

</div>

    </body></code>```

Fiddle Demo

I am newbie to javascript as well as css.

The above works properly, which out transition offline, I dont know what is the problem in fiddle. I think that there is some small misunderstanding, with that..

Could any one help me in adding a slide transition.

I need something like the link http://www.devtrix.net/sliderman/examples.html

答:
Have a look at below snippet. I have introduced jQuery for simple animation effects.

Effect Used: jQuery.fadeIn

jQuery also has lot of other animation effects which can be used in the place where jQuery.fadeIn is being used.

Have a look jQuery.animate method

And also I have cleaned up some code and wrote a simple logic to display next place in autoSlide

var index = 0,
  totalPlaceCount = 0;

function plusIndex(n) {
  index = index + n;
  showImage(index);
}

function updateVisible(index) {
  $(".placestovisit").css({
    display: "none"
  });
  var targetPlace = $($(".placestovisit").get(index));
  targetPlace.fadeIn(1000);
  //console.log("Showing : ", index);
}

function showImage(n) {
  updateVisible(n);
}

function autoSlide() {
  index++;
  var targetPlaceToShow = index % totalPlaceCount;
  showImage(targetPlaceToShow);
  setTimeout(autoSlide, 4000);
}
$(document).ready(function() {
  totalPlaceCount = $(".placestovisit").length;
  $("#btn1").on("click", plusIndex.bind(null, -1));
  $("#btn2").on("click", plusIndex.bind(null, 1));
  autoSlide();
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.html .body {
  height: 100%;
}

#placescontainer {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  border: 1px solid black;
}

#placescontainer img {
  width: 100%;
  height: 100%;
  position: absolute;
  -webkit-transition: width 2s, height 4s;
  /* For Safari 3.1 to 6.0 */
  transition: width 2s, height 4s;
}

#placescontainer .btn {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 2px solid;
  border-radius: 50px;
  top: 50%;
  background: none;
  color: white;
  font-size: 20px;
}

#placescontainer .play {
  position: absolute;
  height: 50px;
  border: 2px solid;
  top: 20%;
  right: 10%;
  color: white;
  border-radius: 20px;
  background: none;
  font-size: 20px;
}

#placescontainer .play:hover {
  position: absolute;
  height: 50px;
  border: 2px solid;
  top: 20%;
  right: 10%;
  color: white;
  border-radius: 20px;
  background: #06445F;
  font-size: 20px;
}

#placescontainer #btn2 {
  position: relative;
  float: right;
}

#placescontainer #btn3 {
  position: absolute;
  top: 5%;
}

#placescontainer #btn1:hover {
  background: #06445F;
}

#placescontainer #btn2:hover {
  background: #06445F;
}

.placestovisit {
  position: absolute;
  width: 100%;
  height: 100%;
}

.placestovisit h1 {
  position: absolute;
  display-type: block;
  top: 17%;
  left: 5%;
  color: white;
  border: 2px solid;
  padding: 10px;
}

.placestovisit h1:hover {
  position: absolute;
  display-type: block;
  top: 17%;
  left: 5%;
  color: white;
  border: 2px solid;
  background: #06445F;
  padding: 10px;
}

.placestovisit h2 {
  position: absolute;
  color: white;
  top: 30%;
  left: 5%;
  width: 30%;
  font: 15px/25px Serif;
  font-weight: 300;
  padding: 10px;
  border-radius: 15px;
  background: rgba(4, 10, 12, 0.6);
}

.placestovisit h2:hover {
  position: absolute;
  color: white;
  top: 30%;
  left: 5%;
  width: 30%;
  font: 15px/25px Serif;
  font-weight: 300;
  padding: 10px;
  border-radius: 15px;
  background: #06445F;
}

.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 2.5s;
  animation-name: fade;
  animation-duration: 2.5s;
}

@-webkit-keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

@keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}</code>```

Hanumanagundi Falls

 Suthanabbe Falls or Hanumanagundi Falls is located in the hilly surroundings of the Kudremukh National Park in the Chikkamagaluru district of Karnataka, India. Suthanabbe Falls is located between Karkala and Lakya dam in the Kudremukh national park.
      The water falls from a height of 22 meters creating a scenic surroundings around it.

 Hambi(Hambe)

 Hampi (Hampe) is a village and temple town recognised as a UNESCO World Heritage Site, listed as the Group of Monuments at Hampi. in northern Karnataka, India. It was one of the richest and largest cities in the world during its prime. It is located
      within the ruins of the city of Vijayanagara, the former capital of the Vijayanagara Empire. Predating the city of Vijayanagara, Hampi continues to be an important religious centre, housing the Virupaksha Temple and several other monuments belonging
      to the old city. According to statistics of 2014, Hampi is the most searched historical place in Karnataka on Google.

 Agumbe

 Agumbe is a hill station which can be reached by bikes or cars. The way to this place is a diversion from Parkala (The diversion is just a few kms from DT). The best part of the trip to Agumbe is the ride. Beautiful sceneries on both sides will keep
      company all along the way. This place is abount 45 km from Manipal. Agumbe is one of the highest peaks of the Western Ghats located about 60kms from Udupi. Situated at a height of 830 metres from sea level, it overlooks the Arabian Sea. Agumbe is
      part of the Shimoga district which is a neighboring district of Udupi.

 Kerala

 The border of Kerala is just 75 km from Manipal. The 300-year-old Bekal Fort, shaped like a giant key-hole, is one of the largest and best-preserved forts in Kerala. Surrounded by a splendid beach, the historic Bekal Fort offers a superb view of the
      Arabian Sea from its tall observation towers, where a few centuries ago huge cannons used to be placed. Today, it is one of the favourite spots for film-makers because the Bekal Fort and its surroundings with backwaters and hilly destinations make
      fascinating locales. This fort was made by Tipu Sultan and is built right next to the sea. The popular song 'Tu Hi Re' was picturised with this fort in the backdrop.

 Attur church

 Attur Church situated in the outskirts of Karkala town in Karnataka state — India. It is situated 58 km from Mangalore. Placed amidst placid greenery, the Attur-Karkala parish has a rich history with its origin tracing back to 1759. Moreover it is
      known for its miraculous history. Miracle, history, beauty, social activities, all bundled into one. Unlike others, the church is a place of worship and belief for all, irrespective of caste and creed. An vidence for universal peace and brotherhood.
      People from all walks of the society come here to offer their prayers to St Lawrence

  <button class="btn" id="btn1"> ❮</button>
  <button class="btn" id="btn2"> ❯</button>

  <button class="play" onclick="toggle=1-toggle; autoSlide()" id="btn3"> Play/Pause </button>

```

Body:
I wanted to add a transition for the slide show which i am making for one of my page..

Here is the code,

        var index= 1;

        var toggle=0;

        function plusIndex(n){
         index = index + n;
         showImage(n);
        }
        showImage(1);

        function showImage(n){
        var i;
        var x = document.getElementsByClassName("placestovisit");
        if (index > x.length) {index=1};
        if (index < 1) {index= x.length};
        for (i=0; i<x.length; i++)
        {
          x[i].style.display="none";
        }
            x[index-1].style.display= "block";
        }

        autoSlide();
        function autoSlide(){
        if (toggle) {return};
        var i;
        var x = document.getElementsByClassName("placestovisit");
        for (i=0; i<x.length; i++)
        {
          x[i].style.display="none";
        }
        if (index > x.length) {index = 1};
            x[index-1].style.display= "block";
        index++;
        setTimeout(autoSlide, 4000);
        }

Hanumanagundi Falls

 Suthanabbe Falls or Hanumanagundi Falls is located in the hilly surroundings of the Kudremukh National Park in the Chikkamagaluru district of Karnataka, India.
Suthanabbe Falls is located between Karkala and Lakya dam in the Kudremukh national park. The water falls from a height of 22 meters creating a scenic surroundings around it.

 Hambi(Hambe)

 Hampi (Hampe) is a village and temple town recognised as a UNESCO World Heritage Site, listed as the Group of Monuments at Hampi. in northern Karnataka, India. It was one of the richest and largest cities in the world during its prime. It is located within the ruins of the city of Vijayanagara, the former capital of the Vijayanagara Empire. Predating the city of Vijayanagara, Hampi continues to be an important religious centre, housing the Virupaksha Temple and several other monuments belonging to the old city. According to statistics of 2014, Hampi is the most searched historical place in Karnataka on Google.

 Agumbe

 Agumbe is a hill station which can be reached by bikes or cars. The way to this place is a diversion from Parkala (The diversion is just a few kms from DT). The best part of the trip to Agumbe is the ride. Beautiful sceneries on both sides will keep company all along the way. This place is abount 45 km from Manipal. Agumbe is one of the highest peaks of the Western Ghats located about 60kms from Udupi. Situated at a height of 830 metres from sea level, it overlooks the Arabian Sea. Agumbe is part of the Shimoga district which is a neighboring district of Udupi.

 Kerala

 The border of Kerala is just 75 km from Manipal. The 300-year-old Bekal Fort, shaped like a giant key-hole, is one of the largest and best-preserved forts in Kerala. Surrounded by a splendid beach, the historic Bekal Fort offers a superb view of the Arabian Sea from its tall observation towers, where a few centuries ago huge cannons used to be placed. Today, it is one of the favourite spots for film-makers because the Bekal Fort and its surroundings with backwaters and hilly destinations make fascinating locales. This fort was made by Tipu Sultan and is built right next to the sea. The popular song 'Tu Hi Re' was picturised with this fort in the backdrop.

 Attur church

 Attur Church situated in the outskirts of Karkala town in Karnataka state — India. It is situated 58 km from Mangalore.
Placed amidst placid greenery, the Attur-Karkala parish has a rich history with its origin tracing back to 1759. Moreover it is known for its miraculous history. Miracle, history, beauty, social activities, all bundled into one.
Unlike others, the church is a place of worship and belief for all, irrespective of caste and creed. An vidence for universal peace and brotherhood. People from all walks of the society come here to offer their prayers to St Lawrence

<button class="btn" onclick="plusIndex(-1)" id="btn1"> ❮</button>
<button class="btn"  onclick="plusIndex(1)" id="btn2"> ❯</button>

<button class="play"  onclick="toggle=1-toggle; autoSlide()" id="btn3">  Play/Pause </button>

Fiddle Demo

I am newbie to javascript as well as css.

The above works properly, which out transition offline, I dont know what is the problem in fiddle. I think that there is some small misunderstanding, with that..

Could any one help me in adding a slide transition.

I need something like the link http://www.devtrix.net/sliderman/examples.html

Body:
Have a look at below snippet. I have introduced jQuery for simple animation effects.

Effect Used: jQuery.fadeIn

jQuery also has lot of other animation effects which can be used in the place where jQuery.fadeIn is being used.

Have a look jQuery.animate method

And also I have cleaned up some code and wrote a simple logic to display next place in autoSlide

var index = 0,
  totalPlaceCount = 0;

function plusIndex(n) {
  index = index + n;
  showImage(index);
}

function updateVisible(index) {
  $(".placestovisit").css({
    display: "none"
  });
  var targetPlace = $($(".placestovisit").get(index));
  targetPlace.fadeIn(1000);
  //console.log("Showing : ", index);
}

function showImage(n) {
  updateVisible(n);
}

function autoSlide() {
  index++;
  var targetPlaceToShow = index % totalPlaceCount;
  showImage(targetPlaceToShow);
  setTimeout(autoSlide, 4000);
}
$(document).ready(function() {
  totalPlaceCount = $(".placestovisit").length;
  $("#btn1").on("click", plusIndex.bind(null, -1));
  $("#btn2").on("click", plusIndex.bind(null, 1));
  autoSlide();
});

.html .body {
  height: 100%;
}

#placescontainer {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  border: 1px solid black;
}

#placescontainer img {
  width: 100%;
  height: 100%;
  position: absolute;
  -webkit-transition: width 2s, height 4s;
  /* For Safari 3.1 to 6.0 */
  transition: width 2s, height 4s;
}

#placescontainer .btn {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 2px solid;
  border-radius: 50px;
  top: 50%;
  background: none;
  color: white;
  font-size: 20px;
}

#placescontainer .play {
  position: absolute;
  height: 50px;
  border: 2px solid;
  top: 20%;
  right: 10%;
  color: white;
  border-radius: 20px;
  background: none;
  font-size: 20px;
}

#placescontainer .play:hover {
  position: absolute;
  height: 50px;
  border: 2px solid;
  top: 20%;
  right: 10%;
  color: white;
  border-radius: 20px;
  background: #06445F;
  font-size: 20px;
}

#placescontainer #btn2 {
  position: relative;
  float: right;
}

#placescontainer #btn3 {
  position: absolute;
  top: 5%;
}

#placescontainer #btn1:hover {
  background: #06445F;
}

#placescontainer #btn2:hover {
  background: #06445F;
}

.placestovisit {
  position: absolute;
  width: 100%;
  height: 100%;
}

.placestovisit h1 {
  position: absolute;
  display-type: block;
  top: 17%;
  left: 5%;
  color: white;
  border: 2px solid;
  padding: 10px;
}

.placestovisit h1:hover {
  position: absolute;
  display-type: block;
  top: 17%;
  left: 5%;
  color: white;
  border: 2px solid;
  background: #06445F;
  padding: 10px;
}

.placestovisit h2 {
  position: absolute;
  color: white;
  top: 30%;
  left: 5%;
  width: 30%;
  font: 15px/25px Serif;
  font-weight: 300;
  padding: 10px;
  border-radius: 15px;
  background: rgba(4, 10, 12, 0.6);
}

.placestovisit h2:hover {
  position: absolute;
  color: white;
  top: 30%;
  left: 5%;
  width: 30%;
  font: 15px/25px Serif;
  font-weight: 300;
  padding: 10px;
  border-radius: 15px;
  background: #06445F;
}

.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 2.5s;
  animation-name: fade;
  animation-duration: 2.5s;
}

@-webkit-keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

@keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="placescontainer">
  <div class="placestovisit fade">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Hanumangundi_Falls.jpg/1200px-Hanumangundi_Falls.jpg" alt="" />
    <h1>Hanumanagundi Falls</h1>
    <h2> Suthanabbe Falls or Hanumanagundi Falls is located in the hilly surroundings of the Kudremukh National Park in the Chikkamagaluru district of Karnataka, India. Suthanabbe Falls is located between Karkala and Lakya dam in the Kudremukh national park.
      The water falls from a height of 22 meters creating a scenic surroundings around it.</h2>
  </div>

  <div class="placestovisit fade">
    <img src="https://upload.wikimedia.org/wikipedia/commons/4/4b/Hampi_virupaksha_temple.jpg" alt="" />
    <h1> Hambi(Hambe) </h1>
    <h2> Hampi (Hampe) is a village and temple town recognised as a UNESCO World Heritage Site, listed as the Group of Monuments at Hampi. in northern Karnataka, India. It was one of the richest and largest cities in the world during its prime. It is located
      within the ruins of the city of Vijayanagara, the former capital of the Vijayanagara Empire. Predating the city of Vijayanagara, Hampi continues to be an important religious centre, housing the Virupaksha Temple and several other monuments belonging
      to the old city. According to statistics of 2014, Hampi is the most searched historical place in Karnataka on Google.</h2>
  </div>
  <div class="placestovisit w3-animate-fading">
    <img src="http://www.thebetterindia.com/wp-content/uploads/2012/09/IMG_0750-Com-800x533.jpg" alt="" />
    <h1> Agumbe </h1>
    <h2> Agumbe is a hill station which can be reached by bikes or cars. The way to this place is a diversion from Parkala (The diversion is just a few kms from DT). The best part of the trip to Agumbe is the ride. Beautiful sceneries on both sides will keep
      company all along the way. This place is abount 45 km from Manipal. Agumbe is one of the highest peaks of the Western Ghats located about 60kms from Udupi. Situated at a height of 830 metres from sea level, it overlooks the Arabian Sea. Agumbe is
      part of the Shimoga district which is a neighboring district of Udupi. </h2>
  </div>

  <div class="placestovisit fade">
    <img src="https://d28dwf34zswvrl.cloudfront.net/wp-content/uploads/2017/01/kerala-carbon-neutral-panchayat.jpg" alt="" />
    <h1> Kerala </h1>
    <h2> The border of Kerala is just 75 km from Manipal. The 300-year-old Bekal Fort, shaped like a giant key-hole, is one of the largest and best-preserved forts in Kerala. Surrounded by a splendid beach, the historic Bekal Fort offers a superb view of the
      Arabian Sea from its tall observation towers, where a few centuries ago huge cannons used to be placed. Today, it is one of the favourite spots for film-makers because the Bekal Fort and its surroundings with backwaters and hilly destinations make
      fascinating locales. This fort was made by Tipu Sultan and is built right next to the sea. The popular song 'Tu Hi Re' was picturised with this fort in the backdrop.</h2>
  </div>

  <div class="placestovisit fade">
    <img src="http://udupitoday.com/udtoday/images/uploads/January/images/jan1431attur1.jpg" alt="" />
    <h1> Attur church </h1>
    <h2> Attur Church situated in the outskirts of Karkala town in Karnataka state — India. It is situated 58 km from Mangalore. Placed amidst placid greenery, the Attur-Karkala parish has a rich history with its origin tracing back to 1759. Moreover it is
      known for its miraculous history. Miracle, history, beauty, social activities, all bundled into one. Unlike others, the church is a place of worship and belief for all, irrespective of caste and creed. An vidence for universal peace and brotherhood.
      People from all walks of the society come here to offer their prayers to St Lawrence</h2>
  </div>
  <button class="btn" id="btn1"> &#10094;</button>
  <button class="btn" id="btn2"> &#10095;</button>

  <button class="play" onclick="toggle=1-toggle; autoSlide()" id="btn3"> Play/Pause </button>

</div>


问:
Error in pulling data from RPD -OBIEE 11g
I created 2 hierarchies in RPD:

1.) Time-Qtr

2.) Time-Month

When I tried pulling it out from OBI 11g , it returned the following error:

"Type Error:Unable to get property 'getAllLevelInfos' of undefined or null reference".

What can be done to rectify this errror?

答: Looks like your dimensional hierarchies are messed up. They must be constructed on either separate logical dimension tables in order to end on different leaf levels or on one logical dimension table id they are alternate hierarchies inside one dimensional hierarchy this ending on the same leaf level.</p>


问:
How do I get ILSVRC12 data in image format or how to create ilsvrc12_val_lmdb?
I am trying to run imagenet example in Caffe. In this(https://github.com/BVLC/caffe/tree/master/examples/imagenet) page they say

```<code>We assume that you already have downloaded the ImageNet training data and validation data, and they are stored on your disk like:

/path/to/imagenet/train/n01440764/n01440764_10026.JPEG
/path/to/imagenet/val/ILSVRC2012_val_00000001.JPEG
</code>```

Where do I find this data?

答:
It's a bit of a process.

1. Got to imagenet's download page and select "Download Image URLs".

2. Download the image URL list from the links at the bottom of the page, e.g., fall 2011's list.

3. Download the images from their URLs (this may take a few days).

Note that some of the URLs (~5% last time I checked) are no longer valid, and will return a "stub" flickr image.

Here's a perl script I used to download the images using convert utility:

```<code>#!/usr/bin/perl

use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use File::Copy;

my $base = "/path/to/imagenet/train/";

open my $fh, '/path/to/train_image_urls.txt' or die "Cannot not open url list: $!";
while( my $line = <$fh> )  {
    # a line in the url list looks like:
    # n00005787_13    http://www.powercai.net/Photo/UploadPhotos/200503/20050307172201492.jpg
    chomp($line);
    if ( $line =~ /^(n\d+)_(\d+)\s+(\S.+)$/ ) {
      my $type = $1;
      my $filename = $1 . "_" . $2;
      my $url = $3;
      my $dst = "$base/$type/$filename" . ".JPEG";
      if (! -d $base.$type ) {
        mkdir($base.$type)
      }
      my $convertCmd = "convert \"$url\" $dst";
      if ( system( $convertCmd ) == 0 ) {
         if ( -e $dst ) {
           my $size = -s $dst;
           # check that image is not a "flickr" stub:
           if ( $size == 24921 || $size == 6898 ) {
              open( my $FILE, $dst );
              binmode($FILE);
              my $md5sum = Digest::MD5->new->addfile($FILE)->hexdigest;
              if ( $md5sum eq "513dd080b92472dab22ad3e09f58f1af" || $md5sum == "ed15d4fe8b5680d1b3e01c0d2778d145" ) {
                print $invl "$dst\n";
                move( $dst, $base . "../invalid/" );
              }
              close($FILE);
           }
         }
      } else {
        # invalid image file
      }
    } else {
      # error downloading an image
    }
}
close $fh;
exit(0);
</code>```

Body:
I am trying to run imagenet example in Caffe. In this(https://github.com/BVLC/caffe/tree/master/examples/imagenet) page they say

We assume that you already have downloaded the ImageNet training data and validation data, and they are stored on your disk like:

/path/to/imagenet/train/n01440764/n01440764_10026.JPEG
/path/to/imagenet/val/ILSVRC2012_val_00000001.JPEG

Where do I find this data?

Body:
It's a bit of a process.

1. Got to imagenet's download page and select "Download Image URLs".

2. Download the image URL list from the links at the bottom of the page, e.g., fall 2011's list.

3. Download the images from their URLs (this may take a few days).

Note that some of the URLs (~5% last time I checked) are no longer valid, and will return a "stub" flickr image.

Here's a perl script I used to download the images using convert utility:

#!/usr/bin/perl

use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use File::Copy;

my $base = "/path/to/imagenet/train/";

open my $fh, '/path/to/train_image_urls.txt' or die "Cannot not open url list: $!";
while( my $line = <$fh> )  {
    # a line in the url list looks like:
    # n00005787_13    http://www.powercai.net/Photo/UploadPhotos/200503/20050307172201492.jpg
    chomp($line);
    if ( $line =~ /^(n\d+)_(\d+)\s+(\S.+)$/ ) {
      my $type = $1;
      my $filename = $1 . "_" . $2;
      my $url = $3;
      my $dst = "$base/$type/$filename" . ".JPEG";
      if (! -d $base.$type ) {
        mkdir($base.$type)
      }
      my $convertCmd = "convert \"$url\" $dst";
      if ( system( $convertCmd ) == 0 ) {
         if ( -e $dst ) {
           my $size = -s $dst;
           # check that image is not a "flickr" stub:
           if ( $size == 24921 || $size == 6898 ) {
              open( my $FILE, $dst );
              binmode($FILE);
              my $md5sum = Digest::MD5->new->addfile($FILE)->hexdigest;
              if ( $md5sum eq "513dd080b92472dab22ad3e09f58f1af" || $md5sum == "ed15d4fe8b5680d1b3e01c0d2778d145" ) {
                print $invl "$dst\n";
                move( $dst, $base . "../invalid/" );
              }
              close($FILE);
           }
         }
      } else {
        # invalid image file
      }
    } else {
      # error downloading an image
    }
}
close $fh;
exit(0);


问:
How to minimize latency in a Kafka Streams application?
My Kafka Streams application typically takes about 100ms from the time that a message is sent to the time that a response message is sent on a different topic as a result. What configuration options can I adjust or best-practices can I use to minimize latency?</p>

答:
This seems to be related to producer config linger.ms.

From (http://kafka.apache.org/documentation/#producerconfigs)

The producer groups together any records that arrive in between request transmissions into a single batched request. Normally this occurs only under load when records arrive faster than they can be sent out. However in some circumstances the client may want to reduce the number of requests even under moderate load. This setting accomplishes this by adding a small amount of artificial delay—that is, rather than immediately sending out a record the producer will wait for up to the given delay to allow other records to be sent so that the sends can be batched together. This can be thought of as analogous to Nagle's algorithm in TCP. This setting gives the upper bound on the delay for batching: once we get batch.size worth of records for a partition it will be sent immediately regardless of this setting, however if we have fewer than this many bytes accumulated for this partition we will 'linger' for the specified time waiting for more records to show up. This setting defaults to 0 (i.e. no delay). Setting linger.ms=5, for example, would have the effect of reducing the number of requests sent but would add up to 5ms of latency to records sent in the absense of load.

Kafka Streams sets this value to 100ms (plain producer default value is 0ms) to increase throughput.

You can reduce the value via StreamsConfig parameter producer.linger.ms. It's recommended to prefix producer configs with producer. in Streams to isolate producer/consumer configs. You can use StreamsConfig.producerPrefix(ProducerConfig.LINGER_MS_CONFIG) as parameter name for highest convenience :)


问:
In MS Access accdb VBA, how do I know in what order to suppy parameters for a query built on queries that require parameters
In my VBA subroutine I want to create a new table from a complex query

(qryA UNION ALL qryB UNION ALL qryC)

```<code>strSQL = "select * into tblNew from qryComplex"
</code>```

The subsequent queries (more than the 3 initial) require parameters (assume 4) that are found in a form that is open.

By working through choices, it works for example,

```<code>Set qdf = db.CreateQueryDef("", strSQL)
qdf.Parameters(0) = Forms!frmMain.txtF1
qdf.Parameters(1) = Forms!frmMain.txtF2
qdf.Parameters(2) = Forms!frmMain.txtF3
qdf.Parameters(3) = Forms!frmMain.txtF1
qdf.Execute
</code>```

How do I know the required order is deterministic?

How can I determine the order and content without having to dig into the subsequent queries and try combinations?

答:
Use the parameter names rather than their index numbers</p>

```<code>qdf.Parameters("parameter example name 1") = Forms!frmMain.txtF1
qdf.Parameters("parameter example name 2") = Forms!frmMain.txtF2
qdf.Parameters("parameter example name 3") = Forms!frmMain.txtF3
qdf.Parameters("parameter example name 4") = Forms!frmMain.txtF1
</code>```

Body:
In my VBA subroutine I want to create a new table from a complex query

(qryA UNION ALL qryB UNION ALL qryC)

strSQL = "select * into tblNew from qryComplex"

The subsequent queries (more than the 3 initial) require parameters (assume 4) that are found in a form that is open.

By working through choices, it works for example,

Set qdf = db.CreateQueryDef("", strSQL)
qdf.Parameters(0) = Forms!frmMain.txtF1
qdf.Parameters(1) = Forms!frmMain.txtF2
qdf.Parameters(2) = Forms!frmMain.txtF3
qdf.Parameters(3) = Forms!frmMain.txtF1
qdf.Execute

How do I know the required order is deterministic?

How can I determine the order and content without having to dig into the subsequent queries and try combinations?

Body:
Use the parameter names rather than their index numbers

qdf.Parameters("parameter example name 1") = Forms!frmMain.txtF1
qdf.Parameters("parameter example name 2") = Forms!frmMain.txtF2
qdf.Parameters("parameter example name 3") = Forms!frmMain.txtF3
qdf.Parameters("parameter example name 4") = Forms!frmMain.txtF1


问:
boost msm euml fusion issue
I am actually working in boost::msm with eUML, which is really a great thing and I created some simpler FSM with it before.

However I am facing an issue, that I am not able to solve, so I hope to get some help here.

The code is fairly easy (but a bit long - see end of this post). The issue is located within the transition table, that is somewho misformed:

```<code>BOOST_MSM_EUML_TRANSITION_TABLE ((

  state_entryPrimary == state_init  [ fsm_(FsmNo) == Int_<fsm_primary>() ]   ,
  state_entrySecondary == state_init  [ fsm_(FsmNo) == Int_<fsm_secondary>() ] ,

  state_1 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_1>() ],
  state_2 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_3>() ], //!!!!!
  state_3 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_4>() ],
  state_6 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_2>() ],

  state_4 == state_1 + event_1,
  state_5 == state_4 + event_2,
  state_1 == state_3 + event_3,
  state_7 == state_6 + event_4,
  state_exit == state_5 + event_9,
  state_exit == state_7 + event_9

), my_transition_table)
</code>```

I got a very long error message with g++ 5.4.0 and boost 1.58 based on some fusion code that failed to build the code. The first error line is like:

```<code>/usr/include/boost/fusion/container/set/convert.hpp:27:13: error: invalid use of incomplete type ‘struct boost::fusion::detail::barrier::as_set<11>’
</code>```

In case, I comment out the line marked with //!!!!!, the FSM compiles without any issue.

Is somebody out there, who could help with this?

```<code>#include <boost/msm/front/euml/euml.hpp>
#include <boost/msm/front/euml/state_grammar.hpp>
#include <boost/msm/back/state_machine.hpp>
#include <boost/msm/front/euml/operator.hpp>
#include <iostream>

namespace msm = boost::msm;
using namespace boost::msm::front::euml;
using namespace msm::front::euml;

enum UStatusType {
    statid_1,
    statid_2,
    statid_3,
    statid_4
};

enum FsmType {
    fsm_primary,
    fsm_secondary
};

BOOST_MSM_EUML_DECLARE_ATTRIBUTE(UStatusType, uStatus)
BOOST_MSM_EUML_DECLARE_ATTRIBUTE(FsmType, FsmNo)
BOOST_MSM_EUML_DECLARE_ATTRIBUTE(int, cnt)

BOOST_MSM_EUML_ACTION(act_do_a) {
  template <class Evt,class Fsm, class State> void operator()(Evt const& ,Fsm& fsm, State& state ) const
    { std::cout << " -> do a " << std::endl; }
};

BOOST_MSM_EUML_ACTION(act_do_b) {
  template <class Evt,class Fsm, class State> void operator()(Evt const& ,Fsm& fsm, State& state ) const
    { std::cout << " -> do b " << std::endl; }
};

BOOST_MSM_EUML_STATE((), state_init)
BOOST_MSM_EUML_STATE((act_do_b), state_exit)

BOOST_MSM_EUML_STATE((), state_entryPrimary)
BOOST_MSM_EUML_STATE((act_do_a), state_1)
BOOST_MSM_EUML_STATE((act_do_a), state_2)
BOOST_MSM_EUML_STATE((act_do_a), state_3)
BOOST_MSM_EUML_STATE((act_do_a), state_4)
BOOST_MSM_EUML_STATE((act_do_a), state_5)
BOOST_MSM_EUML_STATE((act_do_a), state_6)
BOOST_MSM_EUML_STATE((act_do_a), state_7)

BOOST_MSM_EUML_STATE((), state_entrySecondary)

BOOST_MSM_EUML_EVENT(event_1)
BOOST_MSM_EUML_EVENT(event_2)
BOOST_MSM_EUML_EVENT(event_3)
BOOST_MSM_EUML_EVENT(event_4)
BOOST_MSM_EUML_EVENT(event_9)

BOOST_MSM_EUML_TRANSITION_TABLE ((

  state_entryPrimary == state_init  [ fsm_(FsmNo) == Int_<fsm_primary>() ]   ,
  state_entrySecondary == state_init  [ fsm_(FsmNo) == Int_<fsm_secondary>() ] ,

  state_1 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_1>() ],
  state_2 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_3>() ], //!!!!!
  state_3 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_4>() ],
  state_6 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_2>() ],

  state_4 == state_1 + event_1,
  state_5 == state_4 + event_2,
  state_1 == state_3 + event_3,
  state_7 == state_6 + event_4,
  state_exit == state_5 + event_9,
  state_exit == state_7 + event_9

), my_transition_table)

BOOST_MSM_EUML_DECLARE_STATE_MACHINE((my_transition_table, init_ << state_init, no_action, no_action,
    attributes_ << FsmNo << uStatus << cnt ), my_fsm)

int main()
{
  msm::back::state_machine<my_fsm> my;

  // testing some start conditions
  my.get_attribute(uStatus) = statid_1; // read from device
  my.get_attribute(FsmNo) = fsm_primary;
  my.get_attribute(cnt) = 1;

  my.start();
  my.process_event(event_1);
  my.process_event(event_2);
  my.process_event(event_9);

  std::cout << "\nRestart Statemachine with statid_3\n\n";
  my.get_attribute(uStatus) = statid_3;
  my.start();
  my.process_event(event_3);

  std::cout << "\nRestart Statemachine with statid_2\n\n";
  my.get_attribute(uStatus) = statid_2;
  my.start();
  my.process_event(event_4);
  my.process_event(event_9);
}
</code>```

答:
Define FUSION_MAX_VECTOR_SIZE to whatever you need before the include section. In case your transition table exceeds 20 entries, following defines have to be added:

```<code>#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_VECTOR_SIZE 30 //max table size
#define BOOST_MPL_LIMIT_MAP_SIZE 30 //max table size
</code>```

http://www.boost.org/doc/libs/1_63_0/libs/msm/doc/HTML/ch03s02.html#d0e358

Title: boost msm euml fusion issue

Body:
I am actually working in boost::msm with eUML, which is really a great thing and I created some simpler FSM with it before.

However I am facing an issue, that I am not able to solve, so I hope to get some help here.

The code is fairly easy (but a bit long - see end of this post). The issue is located within the transition table, that is somewho misformed:

BOOST_MSM_EUML_TRANSITION_TABLE ((

  state_entryPrimary == state_init  [ fsm_(FsmNo) == Int_<fsm_primary>() ]   ,
  state_entrySecondary == state_init  [ fsm_(FsmNo) == Int_<fsm_secondary>() ] ,

  state_1 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_1>() ],
  state_2 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_3>() ], //!!!!!
  state_3 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_4>() ],
  state_6 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_2>() ],

  state_4 == state_1 + event_1,
  state_5 == state_4 + event_2,
  state_1 == state_3 + event_3,
  state_7 == state_6 + event_4,
  state_exit == state_5 + event_9,
  state_exit == state_7 + event_9

), my_transition_table)

I got a very long error message with g++ 5.4.0 and boost 1.58 based on some fusion code that failed to build the code. The first error line is like:

/usr/include/boost/fusion/container/set/convert.hpp:27:13: error: invalid use of incomplete type ‘struct boost::fusion::detail::barrier::as_set<11>’

In case, I comment out the line marked with //!!!!!, the FSM compiles without any issue.

Is somebody out there, who could help with this?

#include <boost/msm/front/euml/euml.hpp>
#include <boost/msm/front/euml/state_grammar.hpp>
#include <boost/msm/back/state_machine.hpp>
#include <boost/msm/front/euml/operator.hpp>
#include <iostream>

namespace msm = boost::msm;
using namespace boost::msm::front::euml;
using namespace msm::front::euml;

enum UStatusType {
    statid_1,
    statid_2,
    statid_3,
    statid_4
};

enum FsmType {
    fsm_primary,
    fsm_secondary
};

BOOST_MSM_EUML_DECLARE_ATTRIBUTE(UStatusType, uStatus)
BOOST_MSM_EUML_DECLARE_ATTRIBUTE(FsmType, FsmNo)
BOOST_MSM_EUML_DECLARE_ATTRIBUTE(int, cnt)

BOOST_MSM_EUML_ACTION(act_do_a) {
  template <class Evt,class Fsm, class State> void operator()(Evt const& ,Fsm& fsm, State& state ) const
    { std::cout << " -> do a " << std::endl; }
};

BOOST_MSM_EUML_ACTION(act_do_b) {
  template <class Evt,class Fsm, class State> void operator()(Evt const& ,Fsm& fsm, State& state ) const
    { std::cout << " -> do b " << std::endl; }
};

BOOST_MSM_EUML_STATE((), state_init)
BOOST_MSM_EUML_STATE((act_do_b), state_exit)

BOOST_MSM_EUML_STATE((), state_entryPrimary)
BOOST_MSM_EUML_STATE((act_do_a), state_1)
BOOST_MSM_EUML_STATE((act_do_a), state_2)
BOOST_MSM_EUML_STATE((act_do_a), state_3)
BOOST_MSM_EUML_STATE((act_do_a), state_4)
BOOST_MSM_EUML_STATE((act_do_a), state_5)
BOOST_MSM_EUML_STATE((act_do_a), state_6)
BOOST_MSM_EUML_STATE((act_do_a), state_7)

BOOST_MSM_EUML_STATE((), state_entrySecondary)

BOOST_MSM_EUML_EVENT(event_1)
BOOST_MSM_EUML_EVENT(event_2)
BOOST_MSM_EUML_EVENT(event_3)
BOOST_MSM_EUML_EVENT(event_4)
BOOST_MSM_EUML_EVENT(event_9)

BOOST_MSM_EUML_TRANSITION_TABLE ((

  state_entryPrimary == state_init  [ fsm_(FsmNo) == Int_<fsm_primary>() ]   ,
  state_entrySecondary == state_init  [ fsm_(FsmNo) == Int_<fsm_secondary>() ] ,

  state_1 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_1>() ],
  state_2 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_3>() ], //!!!!!
  state_3 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_4>() ],
  state_6 == state_entryPrimary [ fsm_(uStatus) == Int_<statid_2>() ],

  state_4 == state_1 + event_1,
  state_5 == state_4 + event_2,
  state_1 == state_3 + event_3,
  state_7 == state_6 + event_4,
  state_exit == state_5 + event_9,
  state_exit == state_7 + event_9

), my_transition_table)

BOOST_MSM_EUML_DECLARE_STATE_MACHINE((my_transition_table, init_ << state_init, no_action, no_action,
    attributes_ << FsmNo << uStatus << cnt ), my_fsm)

int main()
{
  msm::back::state_machine<my_fsm> my;

  // testing some start conditions
  my.get_attribute(uStatus) = statid_1; // read from device
  my.get_attribute(FsmNo) = fsm_primary;
  my.get_attribute(cnt) = 1;

  my.start();
  my.process_event(event_1);
  my.process_event(event_2);
  my.process_event(event_9);

  std::cout << "\nRestart Statemachine with statid_3\n\n";
  my.get_attribute(uStatus) = statid_3;
  my.start();
  my.process_event(event_3);

  std::cout << "\nRestart Statemachine with statid_2\n\n";
  my.get_attribute(uStatus) = statid_2;
  my.start();
  my.process_event(event_4);
  my.process_event(event_9);
}

Body:
Define FUSION_MAX_VECTOR_SIZE to whatever you need before the include section. In case your transition table exceeds 20 entries, following defines have to be added:

#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_VECTOR_SIZE 30 //max table size
#define BOOST_MPL_LIMIT_MAP_SIZE 30 //max table size

http://www.boost.org/doc/libs/1_63_0/libs/msm/doc/HTML/ch03s02.html#d0e358


问:
how to fix slow loading actions in asp.net mvc on azure web apps
We have notice a huge performance impact on our asp.net mvc application since we moved to azure web apps. One thing we've noticed is that request times slow down significantly when an action is loaded the first time in a couple hours. Our app is not used a lot so there's a lot of idle time. I'll give a few examples (please note these are just back-end request response times, and exclude dom, js, image, etc. load times):

user dashboard - first request will take around 20 seconds. Subsequent loads are around 1 second

loading some object - first request will be around 7 seconds. refreshing will get you around 2 secs. loading other objects using same action is also faster after that action is hit the first time

I realize that some of the speed up might be due to query caching, but I am wondering if that's all. I am on a standard plan and do have "Always On" enabled, so I know that's not the issue.  And this seems to be happening per action. So even if the user visited action1 already and now visits action2 for the first time, they'll still experience slowness.

What can I look for here to fix? Are there any azure specific settings?

答:
One thing we've noticed is that request times slow down significantly when an action is loaded the first time in a couple hours.

As you did, enabling “Always On” setting on Azure web app can increase application responsiveness, especially if application is not very frequently accessed by users.

these are just back-end request response times, and exclude dom, js, image, etc. load times

Please check the code logic of those actions and make sure the code is efficient. Besides, you can try to specify custom initialization/warm-up actions for those pages (that always take long response time when the first time client browse the page). If possible, you can cache the frequently used data instead of retrieving data from database (or other sources) every time client browse the web page.

```<code><system.webServer>
  <applicationInitialization doAppInitAfterRestart="true">
    <add initializationPage="/Home/Contact" hostName="appname.azurewebsites.net" />
  </applicationInitialization>
</system.webServer>
</code>```

Body:
One thing we've noticed is that request times slow down significantly when an action is loaded the first time in a couple hours.

As you did, enabling “Always On” setting on Azure web app can increase application responsiveness, especially if application is not very frequently accessed by users.

these are just back-end request response times, and exclude dom, js, image, etc. load times

Please check the code logic of those actions and make sure the code is efficient. Besides, you can try to specify custom initialization/warm-up actions for those pages (that always take long response time when the first time client browse the page). If possible, you can cache the frequently used data instead of retrieving data from database (or other sources) every time client browse the web page.

<system.webServer>
  <applicationInitialization doAppInitAfterRestart="true">
    <add initializationPage="/Home/Contact" hostName="appname.azurewebsites.net" />
  </applicationInitialization>
</system.webServer>


问:
Accessing Androids UpdateEngine (or other SystemApi classes) from application code
I'm trying to write a system-updater application, which uses the UpdateEngine of Android 7+. However, I can't seem to get access to it from my java code, since the class and its methods are marked with @SystemApi.

I integrated my application into the AOSP tree, but I can't start a successful compile from my application directory: When i run mm in the app dir, I directly get the following error:

The import android.os.UpdateEngine cannot be resolved

This also happens if I just add the import statement to an already existing aosp system-app, e.g.

What is the correct way to use UpdateEngine (or actually any other @SystemApi) from an application? I don't want to change the android api by removing all the SystemApi and break compatibility.

答:
Of course I find the solution right after posting the question...

In case someone else stumbles upon this in the future - The problem was that I had the following SDK version defined in my Android.mk:

LOCAL_SDK_VERSION := current

System APIs (and thus UpdateEngine) became accessible after changing the sdk version as follows:

LOCAL_SDK_VERSION := system_current


问:
How to remove key from an array in php
I need to remove keys from my arrays, and array be like

```<code>Array ( [0] => 23/2 [1] => KG Halli [2] => D' Souza Layout [3] => Sampangi Rama Nagar [4] => Bengaluru [5] => Bangalore Urban [6] => Karnataka [7] => India [8] => 560001 )
</code>```

and i need it as

23/2, KG Halli, D' Souza Layout, Sampangi Rama Nagar, Bengaluru, Banglore Urban

答:
Simply use the implode() function of PHP.

Example: implode(', ', $your_arr);

Title: How to remove key from an array in php

Body:
I need to remove keys from my arrays, and array be like

Array ( [0] => 23/2 [1] => KG Halli [2] => D' Souza Layout [3] => Sampangi Rama Nagar [4] => Bengaluru [5] => Bangalore Urban [6] => Karnataka [7] => India [8] => 560001 )

and i need it as

23/2, KG Halli, D' Souza Layout, Sampangi Rama Nagar, Bengaluru, Banglore Urban


问:
Echo arrays with regular text
How would I write this so I'm only using one echo? </p>

```<code>echo "<div class='post'>";
echo $row['title'];
echo "</div>";
</code>```

<p>I'm using an array to echo out a table's values but it would be a lot easier on the eyes if I could combine these into one echo statement. However, when I try to the page goes blank. </p>

答:
```<code>echo "<div class=\"post\">{$row['title']}</div>";
</code>```

Title: Echo arrays with regular text

Body:
How would I write this so I'm only using one echo?

echo "
";
echo $row['title'];
echo "
";

I'm using an array to echo out a table's values but it would be a lot easier on the eyes if I could combine these into one echo statement. However, when I try to the page goes blank.