qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
70,912,921 | I am trying to improve the time complexity and quality of the code snippet below.
I am iterating through one array to check if the element this array exists in the object, should this be true it should return the name matching the element id in the object.
how can I do this without having a nested loop?
Can someone tel... | 2022/01/30 | [
"https://Stackoverflow.com/questions/70912921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15989850/"
] | The simplest improvement would probably be converting `genres` to a Set <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set>
and use the `has` method to check if each id in the data is a member of the set of chosen genres.
You can also convert the data to a map with the ids as the key... | **If** you might be doing this more than once then I'd recommend using a `Map`. By creating a hash map, retrieving genre names per id is much more performant.
```
let genres = [28, 12, 878];
data = {
genres: [
{
id: 28,
name: 'Action',
},
{
id: 12,
name: 'Adven... |
744,044 | A pure torque does not have a point of application. For example, in the beam shown below, the reactions are same regardless of the torque placement:
[](https://i.stack.imgur.com/B7hD8.jpg)
But how do you apply torque in reality?
For example if you us... | 2023/01/05 | [
"https://physics.stackexchange.com/questions/744044",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/355019/"
] | >
> A pure torque does not have a point of application.
>
>
>
This is incorrect (as you show in your second example). A better statement is
*"The location of application of a pure torque doesn't matter in certain analyses, such as when balancing moments around any point of a rigid free object."*
The qualifiers a... | >
> How do you apply a pure torque
>
>
>
A pure torque or pure moment, is referred to as a force couple, or simply a couple. It is achieved by applying two equal and opposite parallel forces of magnitude $F$ separated by a distance $d$. This produces a net torque of $Fd$ with no net force. By convention, the symbo... |
744,044 | A pure torque does not have a point of application. For example, in the beam shown below, the reactions are same regardless of the torque placement:
[](https://i.stack.imgur.com/B7hD8.jpg)
But how do you apply torque in reality?
For example if you us... | 2023/01/05 | [
"https://physics.stackexchange.com/questions/744044",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/355019/"
] | >
> A pure torque does not have a point of application.
>
>
>
This is incorrect (as you show in your second example). A better statement is
*"The location of application of a pure torque doesn't matter in certain analyses, such as when balancing moments around any point of a rigid free object."*
The qualifiers a... | I think that the heart of this paradox is that "pure torque" is in idealization (as is "rigid body") in fact "pure torques" do not exist (anything applying a torque applies finite forces at points that have a finite distance apart). What we are seeing with the latter example is that the idea of applying torque at a poi... |
744,044 | A pure torque does not have a point of application. For example, in the beam shown below, the reactions are same regardless of the torque placement:
[](https://i.stack.imgur.com/B7hD8.jpg)
But how do you apply torque in reality?
For example if you us... | 2023/01/05 | [
"https://physics.stackexchange.com/questions/744044",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/355019/"
] | >
> How do you apply a pure torque
>
>
>
A pure torque or pure moment, is referred to as a force couple, or simply a couple. It is achieved by applying two equal and opposite parallel forces of magnitude $F$ separated by a distance $d$. This produces a net torque of $Fd$ with no net force. By convention, the symbo... | I think that the heart of this paradox is that "pure torque" is in idealization (as is "rigid body") in fact "pure torques" do not exist (anything applying a torque applies finite forces at points that have a finite distance apart). What we are seeing with the latter example is that the idea of applying torque at a poi... |
17,776,369 | I've been searching for hours now, but can't seem to figure it out.
I want to center the Menu at the bottom of the Header Div, but it seems like it will either center it but keep it at the top or keep it at the bottom but not center it.
It has something to do with the position:relative/absolute, I believe.
This i... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17776369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2512724/"
] | The only elegant ways to connect to a SQL Server in another domain but still use Windows Authentication are:
* What you're already doing: `runas /netonly`
* Connecting via remote desktop and opening SSMS locally on the remote server | In addition to the other answers you've received, you can also shift-right click on an executable or a shortcut to one and in the resulting context menu, there should be an option to run as a different user. I tried this on my Win 7 machine. I seem to recall that in XP, I had to install [ShellRunAs](http://technet.micr... |
17,776,369 | I've been searching for hours now, but can't seem to figure it out.
I want to center the Menu at the bottom of the Header Div, but it seems like it will either center it but keep it at the top or keep it at the bottom but not center it.
It has something to do with the position:relative/absolute, I believe.
This i... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17776369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2512724/"
] | The only elegant ways to connect to a SQL Server in another domain but still use Windows Authentication are:
* What you're already doing: `runas /netonly`
* Connecting via remote desktop and opening SSMS locally on the remote server | You can get a graphical password prompt by downloading [ShellRunAs](http://technet.microsoft.com/en-us/sysinternals/cc300361.aspx) or better yet, the entire [Sysinternals Suite](http://technet.microsoft.com/en-us/sysinternals/bb842062).
* Store the executable(s) for ShellRunAs or the Sysinternals Suite in a location ... |
17,776,369 | I've been searching for hours now, but can't seem to figure it out.
I want to center the Menu at the bottom of the Header Div, but it seems like it will either center it but keep it at the top or keep it at the bottom but not center it.
It has something to do with the position:relative/absolute, I believe.
This i... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17776369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2512724/"
] | In addition to the other answers you've received, you can also shift-right click on an executable or a shortcut to one and in the resulting context menu, there should be an option to run as a different user. I tried this on my Win 7 machine. I seem to recall that in XP, I had to install [ShellRunAs](http://technet.micr... | You can get a graphical password prompt by downloading [ShellRunAs](http://technet.microsoft.com/en-us/sysinternals/cc300361.aspx) or better yet, the entire [Sysinternals Suite](http://technet.microsoft.com/en-us/sysinternals/bb842062).
* Store the executable(s) for ShellRunAs or the Sysinternals Suite in a location ... |
41,904,526 | I use a (C) library with functions taking different parameters but always returning an int greater than zero in case of error:
```
int functionA(int param1, char param2); /* return an error code on failure, 0 otherwise */
int functionB(LIB_BOOLEAN param1); /* return an error code on failure, 0 otherwise */
// ...... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41904526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902536/"
] | Do you mean something like this?
```
template<typename F, typename... Args>
auto my_invoke(F &&f, Args&&... args) {
if(std::forward<F>(f)(std::forward<Args>(args)...)) {
throw std::runtime_error("Method failed");
}
}
```
You can call it as;
```
my_invoke(functionA, 0, 'c');
``` | ```
template <typename ... A> void executeFunction(int(*func_ptr)(A...), A...) {
if (func_ptr(A...) > 0)
throw std::runtime_error("Method failed");
}
int func(int A, int B) {
}
int main() {
int a, b;
a = 0;
b = 4;
executeFunction(func, a, b)
}
```
Not tested but something like this should w... |
41,904,526 | I use a (C) library with functions taking different parameters but always returning an int greater than zero in case of error:
```
int functionA(int param1, char param2); /* return an error code on failure, 0 otherwise */
int functionB(LIB_BOOLEAN param1); /* return an error code on failure, 0 otherwise */
// ...... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41904526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902536/"
] | Here is a template-based solution using C++17's new `auto` template parameters:
```
template <auto &> struct CallerImpl;
template <typename ...Args, int (&F)(Args ...)>
struct CallerImpl<F>
{
static int CallOrThrow(Args ... args)
{
if (int n = F(args...); n > 0)
throw std::runtime_error("M... | ```
template <typename ... A> void executeFunction(int(*func_ptr)(A...), A...) {
if (func_ptr(A...) > 0)
throw std::runtime_error("Method failed");
}
int func(int A, int B) {
}
int main() {
int a, b;
a = 0;
b = 4;
executeFunction(func, a, b)
}
```
Not tested but something like this should w... |
41,904,526 | I use a (C) library with functions taking different parameters but always returning an int greater than zero in case of error:
```
int functionA(int param1, char param2); /* return an error code on failure, 0 otherwise */
int functionB(LIB_BOOLEAN param1); /* return an error code on failure, 0 otherwise */
// ...... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41904526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902536/"
] | I know I'll get downvoted for this, but I honestly think this is one case where the preprocessor can usefully be used:
```
#define CHECK( fn ) \
{ \
if( fn > 0 ) { \
throw "problem"; \
} \
}
int f(int x) {
return x - 1;
}
int main() {
CHECK( f(42) );
}
```
It's clear, i... | ```
template <typename ... A> void executeFunction(int(*func_ptr)(A...), A...) {
if (func_ptr(A...) > 0)
throw std::runtime_error("Method failed");
}
int func(int A, int B) {
}
int main() {
int a, b;
a = 0;
b = 4;
executeFunction(func, a, b)
}
```
Not tested but something like this should w... |
41,904,526 | I use a (C) library with functions taking different parameters but always returning an int greater than zero in case of error:
```
int functionA(int param1, char param2); /* return an error code on failure, 0 otherwise */
int functionB(LIB_BOOLEAN param1); /* return an error code on failure, 0 otherwise */
// ...... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41904526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902536/"
] | Do you mean something like this?
```
template<typename F, typename... Args>
auto my_invoke(F &&f, Args&&... args) {
if(std::forward<F>(f)(std::forward<Args>(args)...)) {
throw std::runtime_error("Method failed");
}
}
```
You can call it as;
```
my_invoke(functionA, 0, 'c');
``` | Here’s one approach that doesn’t require changing call sites. Assuming these C functions all have the same convention for return codes, you can write a wrapper that converts the return code to an exception.
```
inline void checked(const char *name, int result) {
if (result > 0)
throw std::runtime_error(nam... |
41,904,526 | I use a (C) library with functions taking different parameters but always returning an int greater than zero in case of error:
```
int functionA(int param1, char param2); /* return an error code on failure, 0 otherwise */
int functionB(LIB_BOOLEAN param1); /* return an error code on failure, 0 otherwise */
// ...... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41904526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902536/"
] | Do you mean something like this?
```
template<typename F, typename... Args>
auto my_invoke(F &&f, Args&&... args) {
if(std::forward<F>(f)(std::forward<Args>(args)...)) {
throw std::runtime_error("Method failed");
}
}
```
You can call it as;
```
my_invoke(functionA, 0, 'c');
``` | Here is a template-based solution using C++17's new `auto` template parameters:
```
template <auto &> struct CallerImpl;
template <typename ...Args, int (&F)(Args ...)>
struct CallerImpl<F>
{
static int CallOrThrow(Args ... args)
{
if (int n = F(args...); n > 0)
throw std::runtime_error("M... |
41,904,526 | I use a (C) library with functions taking different parameters but always returning an int greater than zero in case of error:
```
int functionA(int param1, char param2); /* return an error code on failure, 0 otherwise */
int functionB(LIB_BOOLEAN param1); /* return an error code on failure, 0 otherwise */
// ...... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41904526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902536/"
] | Do you mean something like this?
```
template<typename F, typename... Args>
auto my_invoke(F &&f, Args&&... args) {
if(std::forward<F>(f)(std::forward<Args>(args)...)) {
throw std::runtime_error("Method failed");
}
}
```
You can call it as;
```
my_invoke(functionA, 0, 'c');
``` | I know I'll get downvoted for this, but I honestly think this is one case where the preprocessor can usefully be used:
```
#define CHECK( fn ) \
{ \
if( fn > 0 ) { \
throw "problem"; \
} \
}
int f(int x) {
return x - 1;
}
int main() {
CHECK( f(42) );
}
```
It's clear, i... |
41,904,526 | I use a (C) library with functions taking different parameters but always returning an int greater than zero in case of error:
```
int functionA(int param1, char param2); /* return an error code on failure, 0 otherwise */
int functionB(LIB_BOOLEAN param1); /* return an error code on failure, 0 otherwise */
// ...... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41904526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902536/"
] | Here is a template-based solution using C++17's new `auto` template parameters:
```
template <auto &> struct CallerImpl;
template <typename ...Args, int (&F)(Args ...)>
struct CallerImpl<F>
{
static int CallOrThrow(Args ... args)
{
if (int n = F(args...); n > 0)
throw std::runtime_error("M... | Here’s one approach that doesn’t require changing call sites. Assuming these C functions all have the same convention for return codes, you can write a wrapper that converts the return code to an exception.
```
inline void checked(const char *name, int result) {
if (result > 0)
throw std::runtime_error(nam... |
41,904,526 | I use a (C) library with functions taking different parameters but always returning an int greater than zero in case of error:
```
int functionA(int param1, char param2); /* return an error code on failure, 0 otherwise */
int functionB(LIB_BOOLEAN param1); /* return an error code on failure, 0 otherwise */
// ...... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41904526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902536/"
] | I know I'll get downvoted for this, but I honestly think this is one case where the preprocessor can usefully be used:
```
#define CHECK( fn ) \
{ \
if( fn > 0 ) { \
throw "problem"; \
} \
}
int f(int x) {
return x - 1;
}
int main() {
CHECK( f(42) );
}
```
It's clear, i... | Here’s one approach that doesn’t require changing call sites. Assuming these C functions all have the same convention for return codes, you can write a wrapper that converts the return code to an exception.
```
inline void checked(const char *name, int result) {
if (result > 0)
throw std::runtime_error(nam... |
22,835,138 | I want to make a function of natural numbers comparison in coq
I declare a Set of invariant contain sup, inf, egal
```
Inductive invr:Type:=inf | sup | egal.
```
And I define a function comparaison
```
Definition comparaison (inv:invr)(a b:nat):bool:=
match invr with
|inf => if (a < b) then true else false
... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22835138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3432329/"
] | You are trying to match type (set) invr with its constructors values instead of variable inv, so you get an error
>
> The term "invr" has type "Set" while it is expected to have type
> "invr".
>
>
>
You need to do the matching for `inv`, not `invr`
```
Definition comparaison (inv:invr)(a b:nat):bool:=
match... | This is a typical beginner mistake.
`<` stands for `lt`, which has type:
```
lt : nat -> nat -> Prop
```
That is, `a < b` is just a proposition, not a procedure that computes whether `a` is less than `b`!
The same goes for equality.
What you want to use is a function that computes the truth of these propositions, ... |
1,371,788 | I have a web service and an outsource company will use my service. I don't want to open my service to the internet. I want to give only wsdl file to the outsource company. They use Delphi. Is this possible importing a wsdl file in Delphi offline? | 2009/09/03 | [
"https://Stackoverflow.com/questions/1371788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33417/"
] | Yes is possible, Delphi can import a WSDL file stored locally.
In Delphi Win32 Go to
File->New->Others->Delphi projects->WebServices->WSDL Importer

Then you get a dialog that prompts you for the location of the WSDL file. From the WSDL, Delphi ... | Sure!
Just provide them with the wsdl as a file. The WSDL Importer can import from a URL or from a file. |
13,872,747 | Here's my HTML when the questionnaire starts:
```
<form id="questionnaire">
Question 1: Do you like dogs?<br>
<input type="radio" name="answer" value="yes">Yes<br>
<input type-"radio" name="answer" value="no">No<br>
<input type="submit" value="Next Question" />
</form>
```
Here's my Javascript so far:
```
$... | 2012/12/14 | [
"https://Stackoverflow.com/questions/13872747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1626730/"
] | [Fiddle](http://jsfiddle.net/Schlogen/Lk8Mh/)
Javascript:
```
var questions = ['Question 1: Do you like dogs?<br><input type="radio" name="answer" value="yes">Yes<br><input type-"radio" name="answer" value="no">No<br><input type="submit" value="Next Question" />', 'Question 2: Do you like cats?<input type="radio... | Here's one way to do it: <http://jsfiddle.net/zXM74/2/>
```
var questions = {
2: 'Question 2: Do you like cats?' +
'<input type="radio" name="answer" value="yes">Yes<br>' +
'<input type="radio" name="answer" value="no">No<br>',
3: 'Question 3: Do you like bunnies?' +
'<input type="radio" n... |
13,872,747 | Here's my HTML when the questionnaire starts:
```
<form id="questionnaire">
Question 1: Do you like dogs?<br>
<input type="radio" name="answer" value="yes">Yes<br>
<input type-"radio" name="answer" value="no">No<br>
<input type="submit" value="Next Question" />
</form>
```
Here's my Javascript so far:
```
$... | 2012/12/14 | [
"https://Stackoverflow.com/questions/13872747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1626730/"
] | Here's one way to do it: <http://jsfiddle.net/zXM74/2/>
```
var questions = {
2: 'Question 2: Do you like cats?' +
'<input type="radio" name="answer" value="yes">Yes<br>' +
'<input type="radio" name="answer" value="no">No<br>',
3: 'Question 3: Do you like bunnies?' +
'<input type="radio" n... | I would put all of your questions in the HTML separated into different DIVs. Each DIV should have a unique id. Only the first question would be displayed, the rest would be hidden.
You could put the next question's id into the submit input from the previous question, like so...
```
<input id="2" type="submit" value="... |
13,872,747 | Here's my HTML when the questionnaire starts:
```
<form id="questionnaire">
Question 1: Do you like dogs?<br>
<input type="radio" name="answer" value="yes">Yes<br>
<input type-"radio" name="answer" value="no">No<br>
<input type="submit" value="Next Question" />
</form>
```
Here's my Javascript so far:
```
$... | 2012/12/14 | [
"https://Stackoverflow.com/questions/13872747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1626730/"
] | Here's one way to do it: <http://jsfiddle.net/zXM74/2/>
```
var questions = {
2: 'Question 2: Do you like cats?' +
'<input type="radio" name="answer" value="yes">Yes<br>' +
'<input type="radio" name="answer" value="no">No<br>',
3: 'Question 3: Do you like bunnies?' +
'<input type="radio" n... | ```
<script>
var mark = 0;
var currIdx = -1;
var result = "1/";
var quest = [
{
ID: 1,
question: "Who is CEO?",
options: [
{
optionID: 1,
optionText: "Bill Gate"
},
{
... |
13,872,747 | Here's my HTML when the questionnaire starts:
```
<form id="questionnaire">
Question 1: Do you like dogs?<br>
<input type="radio" name="answer" value="yes">Yes<br>
<input type-"radio" name="answer" value="no">No<br>
<input type="submit" value="Next Question" />
</form>
```
Here's my Javascript so far:
```
$... | 2012/12/14 | [
"https://Stackoverflow.com/questions/13872747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1626730/"
] | [Fiddle](http://jsfiddle.net/Schlogen/Lk8Mh/)
Javascript:
```
var questions = ['Question 1: Do you like dogs?<br><input type="radio" name="answer" value="yes">Yes<br><input type-"radio" name="answer" value="no">No<br><input type="submit" value="Next Question" />', 'Question 2: Do you like cats?<input type="radio... | I would put all of your questions in the HTML separated into different DIVs. Each DIV should have a unique id. Only the first question would be displayed, the rest would be hidden.
You could put the next question's id into the submit input from the previous question, like so...
```
<input id="2" type="submit" value="... |
13,872,747 | Here's my HTML when the questionnaire starts:
```
<form id="questionnaire">
Question 1: Do you like dogs?<br>
<input type="radio" name="answer" value="yes">Yes<br>
<input type-"radio" name="answer" value="no">No<br>
<input type="submit" value="Next Question" />
</form>
```
Here's my Javascript so far:
```
$... | 2012/12/14 | [
"https://Stackoverflow.com/questions/13872747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1626730/"
] | [Fiddle](http://jsfiddle.net/Schlogen/Lk8Mh/)
Javascript:
```
var questions = ['Question 1: Do you like dogs?<br><input type="radio" name="answer" value="yes">Yes<br><input type-"radio" name="answer" value="no">No<br><input type="submit" value="Next Question" />', 'Question 2: Do you like cats?<input type="radio... | ```
<script>
var mark = 0;
var currIdx = -1;
var result = "1/";
var quest = [
{
ID: 1,
question: "Who is CEO?",
options: [
{
optionID: 1,
optionText: "Bill Gate"
},
{
... |
181,053 | Is it proper grammar to write July 17th or would it be the 17th of July? | 2014/06/27 | [
"https://english.stackexchange.com/questions/181053",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/82335/"
] | the **late-night** part comes from:
[Late-night talk show](http://en.wikipedia.org/wiki/Late-night_talk_show)
>
> A late-night talk show is a subgenre of the talk show genre. In
> American television at least, it is specifically a kind of
> comedy-oriented talk and variety show that airs late at night.
> Characte... | The proper parsing is: "The governor went from X to Y." X equals "presidential contender." Y equals "late night punch line."
So the phrase means, "The governor used to be a Presidential contender. Now he is a late night punch line (aka, a "joke.")
There is no such phrase as "contender to late night punch line." That ... |
46,618,085 | I would like to modify my WordPress theme without changing the code. Specifically, I would like to show the number of minutes required to read the post, How can I do that?
Similare to showing posting date and author. | 2017/10/07 | [
"https://Stackoverflow.com/questions/46618085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8712965/"
] | Go to your Dashboard>Appearance>Themes>Customize
Make sure to install theme that has more than standard options. | You can install a plugin as per: <https://www.shoutmeloud.com/estimated-reading-time-wordpress-posts.html>
There is a full installation and configuration tutorial here and you will get your desired result of showing how many minutes it will take to a read a post. |
72,811,094 | I am trying to write unit test cases for Mycontroller using **WebTestClient** in my web-flux Spring boot application.
It is always returning **401** while try to execute my unit test case. I already go through some old answers of stackoverflow but no luck.
Below are the approaches that I followed till now:
1. Disabl... | 2022/06/30 | [
"https://Stackoverflow.com/questions/72811094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19449059/"
] | Encryption in transit refers to using **HTTPS** protocol to upload your objects to S3. S3 supports both `HTTP` (unencrypted) and `HTTPS` (encrypted) [endpoints](https://docs.aws.amazon.com/general/latest/gr/s3.html). Just like with any other website that uses `HTTPS`, you don't have to do anything. All encryption/decry... | Typically, you don't need to do anything with the bucket. Encryption *in transit* depends on the settings of your, well, *in transit* methods. So, when you say *application is accessing the S3 data* - it's not enough. For example, CLI and API encrypt the data out of the box.
If you have a static website, then you can'... |
387 | When using IFTTT, it's trivial to connect one trigger (*if this*) to one event/output (*then that*). However, I'm interested in using IFTTT for a slightly more complex query, along the lines of *"if this happens 3 times, do that"*.
A [Quora question](https://www.quora.com/Can-you-use-two-or-more-triggers-and-actions-o... | 2016/12/18 | [
"https://iot.stackexchange.com/questions/387",
"https://iot.stackexchange.com",
"https://iot.stackexchange.com/users/12/"
] | Update May 2019. [Stringify is shutting down](https://www.stringify.com/stringifyshuttingdown/).
I've only just discovered this platform, but <https://www.stringify.com/> appears to support both logic processing,
[ handles all that but runs only on phones and has only phone events (it can do http call though)
* [Netvibes](http://www.netvibes.com/) manages ... |
387 | When using IFTTT, it's trivial to connect one trigger (*if this*) to one event/output (*then that*). However, I'm interested in using IFTTT for a slightly more complex query, along the lines of *"if this happens 3 times, do that"*.
A [Quora question](https://www.quora.com/Can-you-use-two-or-more-triggers-and-actions-o... | 2016/12/18 | [
"https://iot.stackexchange.com/questions/387",
"https://iot.stackexchange.com",
"https://iot.stackexchange.com/users/12/"
] | In fact you are searching for a IFTTT equivalent with internal variables and eventually fork actions to store a counter for example...
* [Tasker](http://tasker.dinglisch.net/) handles all that but runs only on phones and has only phone events (it can do http call though)
* [Netvibes](http://www.netvibes.com/) manages ... | IFTTT have now launched a [maker platform](https://ifttt.com/blog/2017/05/calling-all-makers) which appears to support filters and chaining. I've not yet worked out if it has timers and cloud side variables/storage. |
387 | When using IFTTT, it's trivial to connect one trigger (*if this*) to one event/output (*then that*). However, I'm interested in using IFTTT for a slightly more complex query, along the lines of *"if this happens 3 times, do that"*.
A [Quora question](https://www.quora.com/Can-you-use-two-or-more-triggers-and-actions-o... | 2016/12/18 | [
"https://iot.stackexchange.com/questions/387",
"https://iot.stackexchange.com",
"https://iot.stackexchange.com/users/12/"
] | Update May 2019. [Stringify is shutting down](https://www.stringify.com/stringifyshuttingdown/).
I've only just discovered this platform, but <https://www.stringify.com/> appears to support both logic processing,
[ is another tool you can use if you are not aware:
>
> Zapier moves info between your web apps automatically, so you can focus on your most important work.
>
>
>
There is a [list of integrations here](https://zapier.com/zapbook/)—most are related to web applications rather than IoT ... |
387 | When using IFTTT, it's trivial to connect one trigger (*if this*) to one event/output (*then that*). However, I'm interested in using IFTTT for a slightly more complex query, along the lines of *"if this happens 3 times, do that"*.
A [Quora question](https://www.quora.com/Can-you-use-two-or-more-triggers-and-actions-o... | 2016/12/18 | [
"https://iot.stackexchange.com/questions/387",
"https://iot.stackexchange.com",
"https://iot.stackexchange.com/users/12/"
] | Update May 2019. [Stringify is shutting down](https://www.stringify.com/stringifyshuttingdown/).
I've only just discovered this platform, but <https://www.stringify.com/> appears to support both logic processing,
[ which appears to support filters and chaining. I've not yet worked out if it has timers and cloud side variables/storage. |
387 | When using IFTTT, it's trivial to connect one trigger (*if this*) to one event/output (*then that*). However, I'm interested in using IFTTT for a slightly more complex query, along the lines of *"if this happens 3 times, do that"*.
A [Quora question](https://www.quora.com/Can-you-use-two-or-more-triggers-and-actions-o... | 2016/12/18 | [
"https://iot.stackexchange.com/questions/387",
"https://iot.stackexchange.com",
"https://iot.stackexchange.com/users/12/"
] | [Zapier](http://www.zapier.com) is another tool you can use if you are not aware:
>
> Zapier moves info between your web apps automatically, so you can focus on your most important work.
>
>
>
There is a [list of integrations here](https://zapier.com/zapbook/)—most are related to web applications rather than IoT ... | IFTTT have now launched a [maker platform](https://ifttt.com/blog/2017/05/calling-all-makers) which appears to support filters and chaining. I've not yet worked out if it has timers and cloud side variables/storage. |
26,643,794 | I am working with the function require\_once but keep getting errors when trying to run the page.
actually, this code is already running to public.
but, when i copy all the code to my local computer. this code is not working .
i use XAMPP 1.7.2 PHP 5.3.0.
This is my code : "db\connect.php"
```
<?
/* Connecting, sele... | 2014/10/30 | [
"https://Stackoverflow.com/questions/26643794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4124208/"
] | Add the link identifier in your [select\_db](http://php.net/manual/en/function.mysql-select-db.php) funct.
```
$link = mysql_connect("localhost", "root", "") or die("Could not connect : " . mysql_error());
mysql_select_db("amr",$link ) or die("Could not select database" . mysql_error());
```
Do the same with your qu... | Looks like your problem is in this line:
```
mysql_select_db("amr")
```
try this:
```
$link = mysql_connect("localhost", "root", "") or die("Could not connect : " . mysql_error());
mysql_select_db("amr", $link) or die("Could not select database" . mysql_error());
``` |
3,921,202 | Suppose we have a set of numbers, $C=\{1,2,3,\dots,n\}$, and we have the function $\pi(x)$ that moves all elements to right by $x$ places iteratively, starting in the first element. If there are not $x$ more elements to the right, it goes back to the start.
For example, if $C=\{1,2,3,4,5\}$, then $\pi(1)$ applied to $... | 2020/11/24 | [
"https://math.stackexchange.com/questions/3921202",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/834779/"
] | The story would be like(*any resemblance to reality is pure coincidence*) :
Suppose you want to build a committee of $n$ mathematicians. You have a pool of $n$ graduate students and $m$ full professors. The rule is that you have to double vote the graduate students. That means, first you choose the graduate students... | Using coefficient extractors we get for the LHS
$$\sum\_{r=0}^n {n\choose r} {m+r\choose n}
= [z^n] (1+z)^m \sum\_{r=0}^n {n\choose r} (1+z)^r
= [z^n] (1+z)^m (2+z)^n.$$
We get for the RHS
$$\sum\_{r=0}^n {n\choose r} {m\choose r} 2^r
= \sum\_{r=0}^n {n\choose r} {m\choose m-r} 2^r
\\ = [z^m] (1+z)^m \sum\_{r=0}^n {... |
3,921,202 | Suppose we have a set of numbers, $C=\{1,2,3,\dots,n\}$, and we have the function $\pi(x)$ that moves all elements to right by $x$ places iteratively, starting in the first element. If there are not $x$ more elements to the right, it goes back to the start.
For example, if $C=\{1,2,3,4,5\}$, then $\pi(1)$ applied to $... | 2020/11/24 | [
"https://math.stackexchange.com/questions/3921202",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/834779/"
] | The story would be like(*any resemblance to reality is pure coincidence*) :
Suppose you want to build a committee of $n$ mathematicians. You have a pool of $n$ graduate students and $m$ full professors. The rule is that you have to double vote the graduate students. That means, first you choose the graduate students... | $$
\eqalign{
& \sum\limits\_{\left( {0\, \le } \right)\,r\,\left( { \le \,n} \right)} {\left( \matrix{
n \cr
r \cr} \right)\left( \matrix{
m + r \cr
n \cr} \right)} = \sum\limits\_{\left( {0\, \le } \right)\,r\,\left( { \le \,n} \right)} {\left( \matrix{
n \cr
r \cr} \right)\sum\limits\_{\left( {0\, \le } \ri... |
3,921,202 | Suppose we have a set of numbers, $C=\{1,2,3,\dots,n\}$, and we have the function $\pi(x)$ that moves all elements to right by $x$ places iteratively, starting in the first element. If there are not $x$ more elements to the right, it goes back to the start.
For example, if $C=\{1,2,3,4,5\}$, then $\pi(1)$ applied to $... | 2020/11/24 | [
"https://math.stackexchange.com/questions/3921202",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/834779/"
] | The story would be like(*any resemblance to reality is pure coincidence*) :
Suppose you want to build a committee of $n$ mathematicians. You have a pool of $n$ graduate students and $m$ full professors. The rule is that you have to double vote the graduate students. That means, first you choose the graduate students... | This is another version of Phicar’s solution.
There are $n$ students and $m$ professionals. All professionals are member of chess club while students can be in the club or not. Suppose that we want to choose $n$ people from the club’s members to join a competition.
In the LHS, $r$ students are in chess club, $\binom{... |
3,921,202 | Suppose we have a set of numbers, $C=\{1,2,3,\dots,n\}$, and we have the function $\pi(x)$ that moves all elements to right by $x$ places iteratively, starting in the first element. If there are not $x$ more elements to the right, it goes back to the start.
For example, if $C=\{1,2,3,4,5\}$, then $\pi(1)$ applied to $... | 2020/11/24 | [
"https://math.stackexchange.com/questions/3921202",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/834779/"
] | Using coefficient extractors we get for the LHS
$$\sum\_{r=0}^n {n\choose r} {m+r\choose n}
= [z^n] (1+z)^m \sum\_{r=0}^n {n\choose r} (1+z)^r
= [z^n] (1+z)^m (2+z)^n.$$
We get for the RHS
$$\sum\_{r=0}^n {n\choose r} {m\choose r} 2^r
= \sum\_{r=0}^n {n\choose r} {m\choose m-r} 2^r
\\ = [z^m] (1+z)^m \sum\_{r=0}^n {... | $$
\eqalign{
& \sum\limits\_{\left( {0\, \le } \right)\,r\,\left( { \le \,n} \right)} {\left( \matrix{
n \cr
r \cr} \right)\left( \matrix{
m + r \cr
n \cr} \right)} = \sum\limits\_{\left( {0\, \le } \right)\,r\,\left( { \le \,n} \right)} {\left( \matrix{
n \cr
r \cr} \right)\sum\limits\_{\left( {0\, \le } \ri... |
3,921,202 | Suppose we have a set of numbers, $C=\{1,2,3,\dots,n\}$, and we have the function $\pi(x)$ that moves all elements to right by $x$ places iteratively, starting in the first element. If there are not $x$ more elements to the right, it goes back to the start.
For example, if $C=\{1,2,3,4,5\}$, then $\pi(1)$ applied to $... | 2020/11/24 | [
"https://math.stackexchange.com/questions/3921202",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/834779/"
] | Using coefficient extractors we get for the LHS
$$\sum\_{r=0}^n {n\choose r} {m+r\choose n}
= [z^n] (1+z)^m \sum\_{r=0}^n {n\choose r} (1+z)^r
= [z^n] (1+z)^m (2+z)^n.$$
We get for the RHS
$$\sum\_{r=0}^n {n\choose r} {m\choose r} 2^r
= \sum\_{r=0}^n {n\choose r} {m\choose m-r} 2^r
\\ = [z^m] (1+z)^m \sum\_{r=0}^n {... | This is another version of Phicar’s solution.
There are $n$ students and $m$ professionals. All professionals are member of chess club while students can be in the club or not. Suppose that we want to choose $n$ people from the club’s members to join a competition.
In the LHS, $r$ students are in chess club, $\binom{... |
7,566,670 | I'm wondering what APIs are available to avoid the following problem.
Casting my mind back to Operating System lectures on my old CS course, the topic was multiprocess scheduling and concurrent I/O. Here's what the lecturer gave as an example of what would happen:
Two processes, X and Y have some work to do. There's ... | 2011/09/27 | [
"https://Stackoverflow.com/questions/7566670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/458742/"
] | In common operating systems you typically don't care about the delay of the task but you try to maximize the throughput - in 110 seconds will both X and Y be done, period. Of course, some of the processes can be interactive and therefore the OS takes the extra overhead of context switches between processes to keep the ... | >
> The only argument in the "fair" system's favour is that if we did all of Y before any of X then a small job X would be delayed by a large job Y and we need to keep both jobs "responsive".
>
>
>
That's exactly the rationale. Fair scheduling is fair in that it tends to distribute computing time, and therefore de... |
7,566,670 | I'm wondering what APIs are available to avoid the following problem.
Casting my mind back to Operating System lectures on my old CS course, the topic was multiprocess scheduling and concurrent I/O. Here's what the lecturer gave as an example of what would happen:
Two processes, X and Y have some work to do. There's ... | 2011/09/27 | [
"https://Stackoverflow.com/questions/7566670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/458742/"
] | If all tasks represent work that will have no value until they are run to completion, then the best approach is to run all the jobs in some sequence so as to minimize the cost of other things' (or peoples') having to wait for them. In practice, many tasks represent a sequence of operations which may have some individua... | >
> The only argument in the "fair" system's favour is that if we did all of Y before any of X then a small job X would be delayed by a large job Y and we need to keep both jobs "responsive".
>
>
>
That's exactly the rationale. Fair scheduling is fair in that it tends to distribute computing time, and therefore de... |
46,197,247 | I'm pretty new to jQuery but have managed to develop a script which manipulates the heights of th and td tags at particular breakpoints. It basically looks for the highest th or td in each row of a given table and applies that height to all th and td tags in that particular row, then moves on to the next row etc.
The ... | 2017/09/13 | [
"https://Stackoverflow.com/questions/46197247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1286106/"
] | I think there are lot of avoidable loops in this. But since this is working for one table, you can try the following code, which loop through all tables and apply your logic.
```
$(window).resize(function(){
$('table.tablepress').each(function() {
var responsivemode = $(this).attr('class').split(/ |-/);
... | you can change this:
```
$("#tablepress-999-no-2 thead tr")
```
to
```
$('table[id^="tablepress"] thead tr')
```
and it will apply to all tables that have an id starting with tablepress. |
29,406,741 | How to store data from database in a variable in `PHP`. because the data I want to use that many times in my project. like:
```
foreach ($data as $value)
{
$Table = '
<TR>
<TD>' . $value['name'] . '</td>
<TD>' . $value['date'] . '</TD>
<TD>' . $value['time'] . '</TD>
... | 2015/04/02 | [
"https://Stackoverflow.com/questions/29406741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3232285/"
] | ```
foreach ($data as $value){
$table.='
<tr>
<td>'.$value['name'].'</td>
<td>'.$value['date'].'</td>
<td>'.$value['time'].'</td>
</tr>';
}
echo $table;
``` | Please take a look to below code, I have made some modification and hope this will help you.
```
$Table = "<table name='data' id='data'>";
foreach ($data as $value){
$Table .= "<tr>";
$Table .= "<td>".$value['name']."</td>";
$Table .= "<td>".$value['date']."</td>";
$Table .= "<td>".$value['... |
49,935,160 | I would like to align links to the bottom center of cards. I tried adding the classes `d-flex` and `flex-column` to .card-body and `mt-auto` to the link, as suggested elsewhere. Note I'm not using a `container` or `container-fluid` div class (Bootstrap [documentation](https://codepen.io/nataliecardot/pen/PRMvbP) sugges... | 2018/04/20 | [
"https://Stackoverflow.com/questions/49935160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8888320/"
] | The link is placed on the end with `d-flex` and `flex-column` on `card-body` and `mt-auto` on the link. On your CodePen you are missing some of these classes ([example with classes](https://codepen.io/anon/pen/wjaKVq))!
**Note:** You can find this example also on the [official documentation](https://getbootstrap.com/d... | Add this css, it will work
```
.card-body {
display: flex;
flex-direction: column;
}
.card-link {
margin-top: auto;
}
```
[codepen link](https://codepen.io/arpanpatel/pen/xjGwBN) |
49,935,160 | I would like to align links to the bottom center of cards. I tried adding the classes `d-flex` and `flex-column` to .card-body and `mt-auto` to the link, as suggested elsewhere. Note I'm not using a `container` or `container-fluid` div class (Bootstrap [documentation](https://codepen.io/nataliecardot/pen/PRMvbP) sugges... | 2018/04/20 | [
"https://Stackoverflow.com/questions/49935160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8888320/"
] | Add this css, it will work
```
.card-body {
display: flex;
flex-direction: column;
}
.card-link {
margin-top: auto;
}
```
[codepen link](https://codepen.io/arpanpatel/pen/xjGwBN) | An alternative solution
-----------------------
You can align the link at the bottom of the `card-body` by following these three steps:
1. Apply the `d-flex` and `flex-column` classes to `card-body`
2. Wrap all the content of `card-body` in a `div`.
3. Use `flex: 1 1 auto` on this new `div`
Doing so, the newly creat... |
49,935,160 | I would like to align links to the bottom center of cards. I tried adding the classes `d-flex` and `flex-column` to .card-body and `mt-auto` to the link, as suggested elsewhere. Note I'm not using a `container` or `container-fluid` div class (Bootstrap [documentation](https://codepen.io/nataliecardot/pen/PRMvbP) sugges... | 2018/04/20 | [
"https://Stackoverflow.com/questions/49935160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8888320/"
] | The link is placed on the end with `d-flex` and `flex-column` on `card-body` and `mt-auto` on the link. On your CodePen you are missing some of these classes ([example with classes](https://codepen.io/anon/pen/wjaKVq))!
**Note:** You can find this example also on the [official documentation](https://getbootstrap.com/d... | An alternative solution
-----------------------
You can align the link at the bottom of the `card-body` by following these three steps:
1. Apply the `d-flex` and `flex-column` classes to `card-body`
2. Wrap all the content of `card-body` in a `div`.
3. Use `flex: 1 1 auto` on this new `div`
Doing so, the newly creat... |
37,956,088 | I found a piece of code I don't really understand. It basically goes like this:
```
array = np.ones((5, 4))*np.nan
s1 = pd.Series([1,4,0,4,5], index=[0,1,2,3,4])
I = s1 == 4
print(I)
0 False
1 True
2 False
3 True
4 False
dtype: bool
```
I really understand this part, it return a pd.Series of boolea... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37956088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5236675/"
] | The explanation lies in the fact that `numpy` array and `pandas` series treat the *logic index* differently. The former treat `True` as 1 and `False` as 0 while latter pick up the value where the logic is `True` and drop the value where the logic is `False`. As a demonstration:
```
import numpy as np
import pandas as ... | Its a mistake. I don't know exactly how numpy is interpreting `I` in the index. But I'm pretty sure this is what was intended:
```
array[I.values, 0] = 3
array[I.values, 1] = 7
array[I.values, 2] = 2
array[I.values, 3] = 5
print(array)
[[ nan nan nan nan]
[ 3. 7. 2. 5.]
[ nan nan nan nan]
[ 3. 7. ... |
4,413,645 | I know the answer to this question is $1-(35/36)^n$. This is the concept behind it:
>
> Probability of not getting a double six on a roll of two dice = 1–1/36 = 35/36.
> Therefore the probability of not getting a double six on n rolls =$(35/36)^n$
> Therefore the probability of getting at least a double six on n roll... | 2022/03/27 | [
"https://math.stackexchange.com/questions/4413645",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/1014405/"
] | Here, $v\_1, v\_2, \ldots, v\_n$ are $n$ vectors.
Let us fix some notation first.
We define $T = \mbox{span}\left\{ v\_1, v\_2, \ldots, v\_n \right\}$.
It is easy to verify that $T$ is a subspace of $V$.
The question is this: How to show that $T$ is the smallest subspace of $V$ containing the $n$ vectors $v\_1, v\_... | The confusion you are having is that you are checking the equivalence of one definition with itself.
If you define $span\{v\_{1},v\_{2},...,v\_{n}\}$ as the smallest subspace containing $v\_{1},...v\_{n}$ then by definition it is the intersection of all subspaces containing $v\_{1},...v\_{n}$. You already say that you... |
73,092,792 | ```css
.menu > .item:nth-child(n+2) {
display: none;
}
.menu:hover > .item,
.menu:focus > .item,
.menu > .item:focus,
.item:focus ~ .item {
display: block;
}
.item:focus {
outline: 3px solid red;
}
```
```html
<button>Go from here</button>
<div class="menu">
<a class="item" href="#">One</a>
<a class="item"... | 2022/07/23 | [
"https://Stackoverflow.com/questions/73092792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5380103/"
] | From the accessibility point of view, you should just stop using :hover to display or hide elements. It's bad for several reasons:
* AS you have noticed, hidden elements aren't reachable with the keyboard. There are solutions, but you are probably going to create illogical and confusing navigation where tabbing back a... | The solution is to toggle the hidden part of the menu with an invisible checkbox:
```css
.menu {
position: relative;
}
.menu > input {
position: absolute;
top: 0;
right: 0;
opacity: 0;
z-index: -1;
}
.menu > .item:nth-of-type(1),
.menu > label {
display: inline-block;
}
.menu > .item:nth-of-type(n+2) ... |
44,445,931 | I have a Google Form that uses the File Upload feature that is mentioned on the below site,
<https://sites.google.com/site/scriptsexamples/home/announcements/google-forms-file-upload-feature>
I am wondering 2 things:
1. Is there a way to prevent the renaming of the uploaded file. (IE: original\_file\_name - Name of U... | 2017/06/08 | [
"https://Stackoverflow.com/questions/44445931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4743375/"
] | I just wanted to post that I was able to create a work-around for the renaming of the file.
```
var form = FormApp.openById('formID');
var formResponses = form.getResponses();
var numResponses = formResponses.length;
var lastResponse = formResponses[numResponses - 1];
var lastResponseItem = lastResponse.getItemResp... | I change your code a little bit so the name of the file is changed to its ID.
```js
function changenametoid() {
var form = FormApp.openById('formID');
var formResponses = form.getResponses();
var numResponses = formResponses.length;
var lastResponse = formResponses[numResponses - 1];
var lastResponseItem = las... |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
$firstItem = current(returnsArray());
``` | <http://us3.php.net/reset>
Only available in php version 5. |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I actually use a convenience function i wrote for such purposes:
```
/**
* Grabs an element from an array using a key much like array_pop
*/
function array_key_value($array, $key) {
if(!empty($array) && array_key_exists($key, $array)) {
return $array[$key];
}
else {
return FALSE;
}
}
... | nickf, good to know, thanks. Unfortunately that has readability problems beyond a few commas. |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Either `current($array)` or `array_shift($array)` will work, the former will leave the *array* intact. | <http://us3.php.net/reset>
Only available in php version 5. |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Try:
```
<?php
$firstElement = reset(functionThatReturnsAnArray());
```
If you're just looking for the first element of the array. | Either `current($array)` or `array_shift($array)` will work, the former will leave the *array* intact. |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | nickf, good to know, thanks. Unfortunately that has readability problems beyond a few commas. | As far as I know this is not possible, I have wanted to do this myself several times. |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Well, I have found a couple of ways to get what you want without calling another function.
```
$firstElement = ($t = functionThatReturnsAnArray()) ? $t[0] : false;
```
and for strings you could use
```
$string = (($t = functionThatReturnsAnArray())==0) . $t[0];
```
.. Interesting problem
Draco | Sometimes I'll change the function, so it can optionally return an element instead of the entire array:
```
<?php
function functionThatReturnsAnArray($n = NULL) {
return ($n === NULL ? $myArray : $myArray[$n]);
}
$firstElement = functionThatReturnsAnArray(0);
``` |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You *can* do this in one line! Use [array\_shift()](http://us.php.net/array_shift).
```
<?php
echo array_shift(i_return_an_array());
function i_return_an_array() {
return array('foo', 'bar', 'baz');
}
```
When this is executed, it will echo "`foo`". | If it's always the first element, you should probably think about having the function return just the first item in the array. If that is the most common case, you could use a little bit of coolness:
```
function func($first = false) {
...
if $first return $array[0];
else return $array;
}
$array = func();... |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | @Scott Reynen
that's not true. This will work:
```
list(,,$thirdElement) = $myArray;
``` | I actually use a convenience function i wrote for such purposes:
```
/**
* Grabs an element from an array using a key much like array_pop
*/
function array_key_value($array, $key) {
if(!empty($array) && array_key_exists($key, $array)) {
return $array[$key];
}
else {
return FALSE;
}
}
... |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Either `current($array)` or `array_shift($array)` will work, the former will leave the *array* intact. | I think any of the above would require a comment to explain what you're doing, thus becoming two lines. I find it simpler to do:
```
$element = functionThatReturnsArray();
$element = $element[0];
```
This way, you're not using an extra variable and it's obvious what you're doing. |
68,711 | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | @Scott Reynen
that's not true. This will work:
```
list(,,$thirdElement) = $myArray;
``` | ```
$firstItem = current(returnsArray());
``` |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | All the tools you are trying will never give you the right answer. The reason is that the information you are requesting is lost when the connection is made.
Let's use an example: suppose your web server has one IP address (**1.2.3.4**) and two host names (**a.mydomain.com** and **b.mydomain.com**) that resolve to tha... | You can check this with:
```
netstat -na | grep 'ESTA'
``` |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | [Andrea Corbellini's answer](https://askubuntu.com/a/239643/88802) explains you why it won't work with the tools you're using and how Virtual Hosting works. Here's the most simple way I can think of to get it done in Apache...
### `mod_status` will help you out.
*Disclaimer: I can't tell how this is done in Webmin - ... | You can check this with:
```
netstat -na | grep 'ESTA'
``` |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | All the tools you are trying will never give you the right answer. The reason is that the information you are requesting is lost when the connection is made.
Let's use an example: suppose your web server has one IP address (**1.2.3.4**) and two host names (**a.mydomain.com** and **b.mydomain.com**) that resolve to tha... | If you want pid, user and command:
```
lsof -i tcp:443,80 | egrep 'PID|->' | sort -k9
``` |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | You can check this with:
```
netstat -na | grep 'ESTA'
``` | You can also use [GoAccess](https://goaccess.io "GoAccess") interactively to view your current visitors. It parses your Apache access log for this purpose and shows a bunch of statistics about your site. |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | You can check all ips connected on port 80 with this bash
```
netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
```
**Note:** if you want to see other port, change 80
**OUTPUT:**
```
19 x.174.143.1
13 x.175.135.1
9 x.68.135.1
8 x.144.87.1
7 x.68.150.1
... | You can check this with:
```
netstat -na | grep 'ESTA'
``` |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | You can check all ips connected on port 80 with this bash
```
netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
```
**Note:** if you want to see other port, change 80
**OUTPUT:**
```
19 x.174.143.1
13 x.175.135.1
9 x.68.135.1
8 x.144.87.1
7 x.68.150.1
... | You can also use [GoAccess](https://goaccess.io "GoAccess") interactively to view your current visitors. It parses your Apache access log for this purpose and shows a bunch of statistics about your site. |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | You can check all ips connected on port 80 with this bash
```
netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
```
**Note:** if you want to see other port, change 80
**OUTPUT:**
```
19 x.174.143.1
13 x.175.135.1
9 x.68.135.1
8 x.144.87.1
7 x.68.150.1
... | If you want pid, user and command:
```
lsof -i tcp:443,80 | egrep 'PID|->' | sort -k9
``` |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | Another way is to type
```
tail -f /var/log/apache2/access.log
```
in your terminal | You can check this with:
```
netstat -na | grep 'ESTA'
``` |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | Another way is to type
```
tail -f /var/log/apache2/access.log
```
in your terminal | If you want pid, user and command:
```
lsof -i tcp:443,80 | egrep 'PID|->' | sort -k9
``` |
239,631 | I am hosting quite a lot of virtual hosts using Apache in a basic LAMP set up with the help of Webmin/Virtualmin. I am looking for a top-like tool in which I can monitor current connections. The virtual hosting part seems to be giving me trouble here. Here's what I've tried:
* `netstat` - I can see the connections, bu... | 2013/01/10 | [
"https://askubuntu.com/questions/239631",
"https://askubuntu.com",
"https://askubuntu.com/users/37108/"
] | Another way is to type
```
tail -f /var/log/apache2/access.log
```
in your terminal | You can also use [GoAccess](https://goaccess.io "GoAccess") interactively to view your current visitors. It parses your Apache access log for this purpose and shows a bunch of statistics about your site. |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | Another reason you can use vinegar in a bread recipe - to produce a sourdough. Under traditional methods of making a sourdough bread, one keeps a 'sour' (sponge) or a piece of dough from the days previous production, which acts as a starter for the current bread. In many of todays commercial bakeries (grocery stores, e... | It might also, in addition to something like bicarbonate soda act as a raising agent for some types of bread - the reaction of the vinegar with the bicarb causing gas release causing rising.
This is only a guess however |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | When I asked this question - [Is there anything I can add to homemade bread to preserve it?](https://cooking.stackexchange.com/questions/7804/is-there-anything-i-can-add-to-homemade-bread-to-preserve-it) - Arafangion said that one commercial bread company now uses vinegar as a preservative. This is his answer to my que... | In making faster no-Knead bread Jim Lahey suggest adding 4 drops or up to 1/4 tsp of red wine vinegar to the basic recipe. Improve gluten development and flavor. See the video with Mark Bittman here:
<http://www.nytimes.com/2008/10/08/dining/08mini.html?ref=dining> |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | If it contained a high amount of rye flour, an acid would be needed for the bread to leaven. This is because bread with lots of rye rises due to polysaccharates called "pentosans" (if i remember correctly) being sticky and holding in the carbon dioxide bubbles. With heat, an enzyme in rye called "amylase" will start ea... | When I asked this question - [Is there anything I can add to homemade bread to preserve it?](https://cooking.stackexchange.com/questions/7804/is-there-anything-i-can-add-to-homemade-bread-to-preserve-it) - Arafangion said that one commercial bread company now uses vinegar as a preservative. This is his answer to my que... |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | When I asked this question - [Is there anything I can add to homemade bread to preserve it?](https://cooking.stackexchange.com/questions/7804/is-there-anything-i-can-add-to-homemade-bread-to-preserve-it) - Arafangion said that one commercial bread company now uses vinegar as a preservative. This is his answer to my que... | It might also, in addition to something like bicarbonate soda act as a raising agent for some types of bread - the reaction of the vinegar with the bicarb causing gas release causing rising.
This is only a guess however |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | Another reason you can use vinegar in a bread recipe - to produce a sourdough. Under traditional methods of making a sourdough bread, one keeps a 'sour' (sponge) or a piece of dough from the days previous production, which acts as a starter for the current bread. In many of todays commercial bakeries (grocery stores, e... | I've found that a lower pH (more acidity) weakens the gluten and makes the crumb less chewey or less rubbery.
Certainly one thing to try before taking the step of adding vinegar to a bread recipe is to replace any bread flour with general purpose flour instead -- it should have the same effect. |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | Another reason you can use vinegar in a bread recipe - to produce a sourdough. Under traditional methods of making a sourdough bread, one keeps a 'sour' (sponge) or a piece of dough from the days previous production, which acts as a starter for the current bread. In many of todays commercial bakeries (grocery stores, e... | In making faster no-Knead bread Jim Lahey suggest adding 4 drops or up to 1/4 tsp of red wine vinegar to the basic recipe. Improve gluten development and flavor. See the video with Mark Bittman here:
<http://www.nytimes.com/2008/10/08/dining/08mini.html?ref=dining> |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | If it contained a high amount of rye flour, an acid would be needed for the bread to leaven. This is because bread with lots of rye rises due to polysaccharates called "pentosans" (if i remember correctly) being sticky and holding in the carbon dioxide bubbles. With heat, an enzyme in rye called "amylase" will start ea... | It might also, in addition to something like bicarbonate soda act as a raising agent for some types of bread - the reaction of the vinegar with the bicarb causing gas release causing rising.
This is only a guess however |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | In making faster no-Knead bread Jim Lahey suggest adding 4 drops or up to 1/4 tsp of red wine vinegar to the basic recipe. Improve gluten development and flavor. See the video with Mark Bittman here:
<http://www.nytimes.com/2008/10/08/dining/08mini.html?ref=dining> | It might also, in addition to something like bicarbonate soda act as a raising agent for some types of bread - the reaction of the vinegar with the bicarb causing gas release causing rising.
This is only a guess however |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | If it contained a high amount of rye flour, an acid would be needed for the bread to leaven. This is because bread with lots of rye rises due to polysaccharates called "pentosans" (if i remember correctly) being sticky and holding in the carbon dioxide bubbles. With heat, an enzyme in rye called "amylase" will start ea... | I've found that a lower pH (more acidity) weakens the gluten and makes the crumb less chewey or less rubbery.
Certainly one thing to try before taking the step of adding vinegar to a bread recipe is to replace any bread flour with general purpose flour instead -- it should have the same effect. |
9,907 | Yesterday I made bread based on a recipe I found on the flour bag. It contained both rye and wheat flour but also three tablespoons of vinegar. I've never seen it used in bread before, why is it there? | 2010/12/09 | [
"https://cooking.stackexchange.com/questions/9907",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1870/"
] | I've found that a lower pH (more acidity) weakens the gluten and makes the crumb less chewey or less rubbery.
Certainly one thing to try before taking the step of adding vinegar to a bread recipe is to replace any bread flour with general purpose flour instead -- it should have the same effect. | It might also, in addition to something like bicarbonate soda act as a raising agent for some types of bread - the reaction of the vinegar with the bicarb causing gas release causing rising.
This is only a guess however |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | The tutorial from which this code originates has a logical flaw, identified and rectified by the initial two contributors [gittert](https://stackoverflow.com/users/9473052/gittert) and [eduardosufan](https://stackoverflow.com/users/1732969/eduardosufan). This vexed me too, but I couldn't work out whether it was just my... | The anchor tag in the HTML file being rendered should reference the function that it is being directed to.
For example following the code snippet below, if we want to reference index in HTML, the flask app "app.py" must contain a function called index.
>
> I have added the about function to clarify what I mean.
>
> ... |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | You need to add in the **else section (GET)**, the html code for your login.
```
from flask import Flask, request, render_template, redirect, url_for
app = Flask(__name__)
@app.route('/success/<name>')
def success(name):
return 'welcome %s' % name
@app.route('/login',methods = ['POST', 'GET'])
def login():
i... | You're trying to access the login directly. You first have to open the html page. then it accesses the value.
try this fix and open the html page first
```
@app.route('/login',methods=["POST","GET"])
def login():
if request.method=="POST":
user=request.form["nm"]
else:
user=request.args.get("n... |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | Have a look at this. In your login function I added a render\_template for the first GET request when opening the login page. This will probably also prevent the error you're getting now.
Bear in mind this does not contain any error handling, like what happens if user is unknown in your login procedure.
```
@app.route... | For blueprint routes as a module check url\_for function in HTML template
```html
<a href="{{url_for('index')}}">Index</a>
to
<a href="{{url_for('auth.index')}}">Index</a>
``` |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | Have a look at this. In your login function I added a render\_template for the first GET request when opening the login page. This will probably also prevent the error you're getting now.
Bear in mind this does not contain any error handling, like what happens if user is unknown in your login procedure.
```
@app.route... | There's nothing wrong with your code, all you need to do is navigate to the folder containing your .py code and the html file containing the form (ensuring they are in the same folder) and run the html file, complete the form and submit. the server takes care of the connection between the python code and html code usin... |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | You need to add in the **else section (GET)**, the html code for your login.
```
from flask import Flask, request, render_template, redirect, url_for
app = Flask(__name__)
@app.route('/success/<name>')
def success(name):
return 'welcome %s' % name
@app.route('/login',methods = ['POST', 'GET'])
def login():
i... | For blueprint routes as a module check url\_for function in HTML template
```html
<a href="{{url_for('index')}}">Index</a>
to
<a href="{{url_for('auth.index')}}">Index</a>
``` |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | You need to add in the **else section (GET)**, the html code for your login.
```
from flask import Flask, request, render_template, redirect, url_for
app = Flask(__name__)
@app.route('/success/<name>')
def success(name):
return 'welcome %s' % name
@app.route('/login',methods = ['POST', 'GET'])
def login():
i... | There's nothing wrong with your code, all you need to do is navigate to the folder containing your .py code and the html file containing the form (ensuring they are in the same folder) and run the html file, complete the form and submit. the server takes care of the connection between the python code and html code usin... |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | The anchor tag in the HTML file being rendered should reference the function that it is being directed to.
For example following the code snippet below, if we want to reference index in HTML, the flask app "app.py" must contain a function called index.
>
> I have added the about function to clarify what I mean.
>
> ... | You're trying to access the login directly. You first have to open the html page. then it accesses the value.
try this fix and open the html page first
```
@app.route('/login',methods=["POST","GET"])
def login():
if request.method=="POST":
user=request.form["nm"]
else:
user=request.args.get("n... |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | The anchor tag in the HTML file being rendered should reference the function that it is being directed to.
For example following the code snippet below, if we want to reference index in HTML, the flask app "app.py" must contain a function called index.
>
> I have added the about function to clarify what I mean.
>
> ... | There's nothing wrong with your code, all you need to do is navigate to the folder containing your .py code and the html file containing the form (ensuring they are in the same folder) and run the html file, complete the form and submit. the server takes care of the connection between the python code and html code usin... |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | The anchor tag in the HTML file being rendered should reference the function that it is being directed to.
For example following the code snippet below, if we want to reference index in HTML, the flask app "app.py" must contain a function called index.
>
> I have added the about function to clarify what I mean.
>
> ... | For blueprint routes as a module check url\_for function in HTML template
```html
<a href="{{url_for('index')}}">Index</a>
to
<a href="{{url_for('auth.index')}}">Index</a>
``` |
54,417,742 | >
> "werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"
>
>
>
How to solve this error? I have tried many things but can't solve it by myself.
http\_methods.py:
```
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.rou... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54417742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10862637/"
] | Have a look at this. In your login function I added a render\_template for the first GET request when opening the login page. This will probably also prevent the error you're getting now.
Bear in mind this does not contain any error handling, like what happens if user is unknown in your login procedure.
```
@app.route... | You need to add in the **else section (GET)**, the html code for your login.
```
from flask import Flask, request, render_template, redirect, url_for
app = Flask(__name__)
@app.route('/success/<name>')
def success(name):
return 'welcome %s' % name
@app.route('/login',methods = ['POST', 'GET'])
def login():
i... |
3,415,428 | >
> **Possible Duplicate:**
>
> [How does the Google “Did you mean?” Algorithm work?](https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work)
>
>
>
I have a database table with about 2 million records. I'm using mysql fulltext to searching but users very often enter bad word... | 2010/08/05 | [
"https://Stackoverflow.com/questions/3415428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296123/"
] | You could use an API like Yahoo's [Spelling Suggestion](http://developer.yahoo.com/search/web/V1/spellingSuggestion.html) as any easy way of completing it with out having to roll your own. | An index is a list of words, and the place they occur. E.g. games occurs on row 123 and 456. If you have such a list with all words, you can easily search for the word that matches best. This way, you could match gmes with games.
However, this is not possible with the index MySQL provides. |
3,415,428 | >
> **Possible Duplicate:**
>
> [How does the Google “Did you mean?” Algorithm work?](https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work)
>
>
>
I have a database table with about 2 million records. I'm using mysql fulltext to searching but users very often enter bad word... | 2010/08/05 | [
"https://Stackoverflow.com/questions/3415428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296123/"
] | An index is a list of words, and the place they occur. E.g. games occurs on row 123 and 456. If you have such a list with all words, you can easily search for the word that matches best. This way, you could match gmes with games.
However, this is not possible with the index MySQL provides. | Another option would be the [PHP Pspell functions](http://www.php.net/manual/en/ref.pspell.php) in particular [pspell\_suggest](http://www.php.net/manual/en/function.pspell-suggest.php), but you need to install the [aspell library](http://aspell.net/) on the server. |
3,415,428 | >
> **Possible Duplicate:**
>
> [How does the Google “Did you mean?” Algorithm work?](https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work)
>
>
>
I have a database table with about 2 million records. I'm using mysql fulltext to searching but users very often enter bad word... | 2010/08/05 | [
"https://Stackoverflow.com/questions/3415428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296123/"
] | You could use an API like Yahoo's [Spelling Suggestion](http://developer.yahoo.com/search/web/V1/spellingSuggestion.html) as any easy way of completing it with out having to roll your own. | if you're not planning to rely on 3rd party sites, you definitely need your own dictionary with levenshtein algorithm to find out how close the user entries are to the dictionary terms |
3,415,428 | >
> **Possible Duplicate:**
>
> [How does the Google “Did you mean?” Algorithm work?](https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work)
>
>
>
I have a database table with about 2 million records. I'm using mysql fulltext to searching but users very often enter bad word... | 2010/08/05 | [
"https://Stackoverflow.com/questions/3415428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296123/"
] | You could use an API like Yahoo's [Spelling Suggestion](http://developer.yahoo.com/search/web/V1/spellingSuggestion.html) as any easy way of completing it with out having to roll your own. | Another option would be the [PHP Pspell functions](http://www.php.net/manual/en/ref.pspell.php) in particular [pspell\_suggest](http://www.php.net/manual/en/function.pspell-suggest.php), but you need to install the [aspell library](http://aspell.net/) on the server. |
3,415,428 | >
> **Possible Duplicate:**
>
> [How does the Google “Did you mean?” Algorithm work?](https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work)
>
>
>
I have a database table with about 2 million records. I'm using mysql fulltext to searching but users very often enter bad word... | 2010/08/05 | [
"https://Stackoverflow.com/questions/3415428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296123/"
] | You could use an API like Yahoo's [Spelling Suggestion](http://developer.yahoo.com/search/web/V1/spellingSuggestion.html) as any easy way of completing it with out having to roll your own. | You could use Yahoo Spelling API etc. if your queries are very generic. But if you have a domain specific vocabulary then you are better off using [Apache Solr](http://lucene.apache.org/solr/).
You can use it to index your 2MM records, easy! And use it as a search server with faceting etc. It also generate a spell-che... |
3,415,428 | >
> **Possible Duplicate:**
>
> [How does the Google “Did you mean?” Algorithm work?](https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work)
>
>
>
I have a database table with about 2 million records. I'm using mysql fulltext to searching but users very often enter bad word... | 2010/08/05 | [
"https://Stackoverflow.com/questions/3415428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296123/"
] | if you're not planning to rely on 3rd party sites, you definitely need your own dictionary with levenshtein algorithm to find out how close the user entries are to the dictionary terms | Another option would be the [PHP Pspell functions](http://www.php.net/manual/en/ref.pspell.php) in particular [pspell\_suggest](http://www.php.net/manual/en/function.pspell-suggest.php), but you need to install the [aspell library](http://aspell.net/) on the server. |
3,415,428 | >
> **Possible Duplicate:**
>
> [How does the Google “Did you mean?” Algorithm work?](https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work)
>
>
>
I have a database table with about 2 million records. I'm using mysql fulltext to searching but users very often enter bad word... | 2010/08/05 | [
"https://Stackoverflow.com/questions/3415428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296123/"
] | You could use Yahoo Spelling API etc. if your queries are very generic. But if you have a domain specific vocabulary then you are better off using [Apache Solr](http://lucene.apache.org/solr/).
You can use it to index your 2MM records, easy! And use it as a search server with faceting etc. It also generate a spell-che... | Another option would be the [PHP Pspell functions](http://www.php.net/manual/en/ref.pspell.php) in particular [pspell\_suggest](http://www.php.net/manual/en/function.pspell-suggest.php), but you need to install the [aspell library](http://aspell.net/) on the server. |
313,975 | I have this mail notification for new post.
All the new post contain arround 100 words and no pictures, so I would like to include in the notification the post content and if is possible, the number of words in the post.
Anybody could help me?
Thanks for all
```
/* avisar al admin*/
function submit_send_email ... | 2018/09/12 | [
"https://wordpress.stackexchange.com/questions/313975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/150466/"
] | ```
//add SVG to allowed file uploads
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'add_file_types_to_uploads');
``` | Add this hooks , i tested on wp 5.3 it works :
```php
// Allow SVG
add_filter('wp_check_filetype_and_ext', function ($data, $file, $filename, $mimes) {
if (!$data['type']) {
$wp_filetype = wp_check_filetype($filename, $mimes);
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
... |
313,975 | I have this mail notification for new post.
All the new post contain arround 100 words and no pictures, so I would like to include in the notification the post content and if is possible, the number of words in the post.
Anybody could help me?
Thanks for all
```
/* avisar al admin*/
function submit_send_email ... | 2018/09/12 | [
"https://wordpress.stackexchange.com/questions/313975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/150466/"
] | @rana-umer your code is correct just remove the "+xml" after 'image/svg'.
```
//add SVG to allowed file uploads
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg';
$file_types = array_merge($file_types, $new_filetypes );
return $file_typ... | The first function is to check the WordPress and add support on WP version lower than 4.8. The second function is to register the mime file type(SVG) and the last one is to fix the thumbnails on media library.
```
/**
* Add svg support
*
*/
add_filter( 'wp_check_filetype_and_ext', function( $data, $file, $filename... |
313,975 | I have this mail notification for new post.
All the new post contain arround 100 words and no pictures, so I would like to include in the notification the post content and if is possible, the number of words in the post.
Anybody could help me?
Thanks for all
```
/* avisar al admin*/
function submit_send_email ... | 2018/09/12 | [
"https://wordpress.stackexchange.com/questions/313975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/150466/"
] | After adding **upload\_mimes** action still anyone facing issue then add this in your wp-config.php file
```
define( 'ALLOW_UNFILTERED_UPLOADS', true );
``` | The first function is to check the WordPress and add support on WP version lower than 4.8. The second function is to register the mime file type(SVG) and the last one is to fix the thumbnails on media library.
```
/**
* Add svg support
*
*/
add_filter( 'wp_check_filetype_and_ext', function( $data, $file, $filename... |
313,975 | I have this mail notification for new post.
All the new post contain arround 100 words and no pictures, so I would like to include in the notification the post content and if is possible, the number of words in the post.
Anybody could help me?
Thanks for all
```
/* avisar al admin*/
function submit_send_email ... | 2018/09/12 | [
"https://wordpress.stackexchange.com/questions/313975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/150466/"
] | This question had me scratching my head. Yeah, how come WordPress doesn't support this natively? And then I found out.
You asked how to upload SVG in WordPress 4.9.8 (the current version at the time of writing). You mention that you "tried uploading after installing different plugins". You don't say which plugins, no... | Add this hooks , i tested on wp 5.3 it works :
```php
// Allow SVG
add_filter('wp_check_filetype_and_ext', function ($data, $file, $filename, $mimes) {
if (!$data['type']) {
$wp_filetype = wp_check_filetype($filename, $mimes);
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
... |
313,975 | I have this mail notification for new post.
All the new post contain arround 100 words and no pictures, so I would like to include in the notification the post content and if is possible, the number of words in the post.
Anybody could help me?
Thanks for all
```
/* avisar al admin*/
function submit_send_email ... | 2018/09/12 | [
"https://wordpress.stackexchange.com/questions/313975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/150466/"
] | @rana-umer your code is correct just remove the "+xml" after 'image/svg'.
```
//add SVG to allowed file uploads
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg';
$file_types = array_merge($file_types, $new_filetypes );
return $file_typ... | Add this hooks , i tested on wp 5.3 it works :
```php
// Allow SVG
add_filter('wp_check_filetype_and_ext', function ($data, $file, $filename, $mimes) {
if (!$data['type']) {
$wp_filetype = wp_check_filetype($filename, $mimes);
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
... |
313,975 | I have this mail notification for new post.
All the new post contain arround 100 words and no pictures, so I would like to include in the notification the post content and if is possible, the number of words in the post.
Anybody could help me?
Thanks for all
```
/* avisar al admin*/
function submit_send_email ... | 2018/09/12 | [
"https://wordpress.stackexchange.com/questions/313975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/150466/"
] | This question had me scratching my head. Yeah, how come WordPress doesn't support this natively? And then I found out.
You asked how to upload SVG in WordPress 4.9.8 (the current version at the time of writing). You mention that you "tried uploading after installing different plugins". You don't say which plugins, no... | ```
//add SVG to allowed file uploads
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'add_file_types_to_uploads');
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.