qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
1,645,568 | I am developing a website using ASP.Net MVC 1.0. Can i host that website on a server having ASP.Net 2.0? Because my hosting provider supports only ASP.Net 2.0. Does anyone know how to host a website developed using ASP.Net MVC 1.0 in a web server supports ASP.Net 2.0 | 2009/10/29 | [
"https://Stackoverflow.com/questions/1645568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144250/"
] | ASP.NET MVC requires at least .NET 3.5 as i know but you can (devil smile)
read this:
<http://www.hanselman.com/blog/DeployingASPNETMVCOnASPNET20.aspx> | I have used the webhost4life, it is good based on my experience.
Asp.Net mvc also supports bin deployment, meaning that you can compile all the mvc assembly and deploy it into your bin directory. You may consider this solution if your hosting company doesn't have this in GAC. |
1,645,568 | I am developing a website using ASP.Net MVC 1.0. Can i host that website on a server having ASP.Net 2.0? Because my hosting provider supports only ASP.Net 2.0. Does anyone know how to host a website developed using ASP.Net MVC 1.0 in a web server supports ASP.Net 2.0 | 2009/10/29 | [
"https://Stackoverflow.com/questions/1645568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144250/"
] | I don't think you can run asp.net mvc without 3.5. I know you can run MVC on a iis 6 server(with 3.5 installed) but that already required extra work.
As people have stated it you should switch to new hosting company or demand your hosting company to upgrade to 3.5. Like come on it gets built on top of 3.5 and should n... | ASP.NET MVC requires at least .NET 3.5 as i know but you can (devil smile)
read this:
<http://www.hanselman.com/blog/DeployingASPNETMVCOnASPNET20.aspx> |
1,645,568 | I am developing a website using ASP.Net MVC 1.0. Can i host that website on a server having ASP.Net 2.0? Because my hosting provider supports only ASP.Net 2.0. Does anyone know how to host a website developed using ASP.Net MVC 1.0 in a web server supports ASP.Net 2.0 | 2009/10/29 | [
"https://Stackoverflow.com/questions/1645568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144250/"
] | ASP.NET MVC requires at least .NET 3.5 as i know but you can (devil smile)
read this:
<http://www.hanselman.com/blog/DeployingASPNETMVCOnASPNET20.aspx> | I've been using webhost4life since November 2009 and it's been great. That is until they recently switched me over to their "new" platform. My site broke and has been down for almost two weeks now. I've spent numerous attempts to work with their new support team to resolve the issue, but they are complete morons. I sug... |
1,645,568 | I am developing a website using ASP.Net MVC 1.0. Can i host that website on a server having ASP.Net 2.0? Because my hosting provider supports only ASP.Net 2.0. Does anyone know how to host a website developed using ASP.Net MVC 1.0 in a web server supports ASP.Net 2.0 | 2009/10/29 | [
"https://Stackoverflow.com/questions/1645568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144250/"
] | I don't think you can run asp.net mvc without 3.5. I know you can run MVC on a iis 6 server(with 3.5 installed) but that already required extra work.
As people have stated it you should switch to new hosting company or demand your hosting company to upgrade to 3.5. Like come on it gets built on top of 3.5 and should n... | I have used the webhost4life, it is good based on my experience.
Asp.Net mvc also supports bin deployment, meaning that you can compile all the mvc assembly and deploy it into your bin directory. You may consider this solution if your hosting company doesn't have this in GAC. |
1,645,568 | I am developing a website using ASP.Net MVC 1.0. Can i host that website on a server having ASP.Net 2.0? Because my hosting provider supports only ASP.Net 2.0. Does anyone know how to host a website developed using ASP.Net MVC 1.0 in a web server supports ASP.Net 2.0 | 2009/10/29 | [
"https://Stackoverflow.com/questions/1645568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144250/"
] | I don't think you can run asp.net mvc without 3.5. I know you can run MVC on a iis 6 server(with 3.5 installed) but that already required extra work.
As people have stated it you should switch to new hosting company or demand your hosting company to upgrade to 3.5. Like come on it gets built on top of 3.5 and should n... | I've been using webhost4life since November 2009 and it's been great. That is until they recently switched me over to their "new" platform. My site broke and has been down for almost two weeks now. I've spent numerous attempts to work with their new support team to resolve the issue, but they are complete morons. I sug... |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | Basic difference is this:
```
. is the member of a structure
-> is the member of a POINTED TO structure
```
So the `.` is used when there is a direct access to a variable in the structure. But the `->` is used when you are accessing a variable of a structure through a pointer to that structure.
Say you have struct ... | When dealing with pointers to structs, use `->` and when using them directly, use `.`. |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | `->` is defined in terms of `.`
That is, `a->b` is equivalent to `(*a).b` and so you'll obviously get the same results.
`->` exists for convenience. | When dealing with pointers to structs, use `->` and when using them directly, use `.`. |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | Basic difference is this:
```
. is the member of a structure
-> is the member of a POINTED TO structure
```
So the `.` is used when there is a direct access to a variable in the structure. But the `->` is used when you are accessing a variable of a structure through a pointer to that structure.
Say you have struct ... | In simple words it is expected to give the same result, what you do is to change the memory allocation and how to access data from a structure.
Some of good links about what you want to understand is [an tutorial about dynamic memory allocation](https://users.cs.jmu.edu/bernstdh/web/common/lectures/slides_cpp_dynamic-m... |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | Basic difference is this:
```
. is the member of a structure
-> is the member of a POINTED TO structure
```
So the `.` is used when there is a direct access to a variable in the structure. But the `->` is used when you are accessing a variable of a structure through a pointer to that structure.
Say you have struct ... | when **.** is used, it is termed as structure to member..
and when **->** is used, it is termed as pointer to member..
how ever if pointer to member is used, it can be resolved like this..
x -> y and (\*x).y are both the same.. |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | Basic difference is this:
```
. is the member of a structure
-> is the member of a POINTED TO structure
```
So the `.` is used when there is a direct access to a variable in the structure. But the `->` is used when you are accessing a variable of a structure through a pointer to that structure.
Say you have struct ... | Use the first approach when you need to manually manage the lifetime of the created object. Use the second approach when the lifetime of the created object is limited to the scope in which it is created or the scope of the object that contains it. |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | `->` is defined in terms of `.`
That is, `a->b` is equivalent to `(*a).b` and so you'll obviously get the same results.
`->` exists for convenience. | In simple words it is expected to give the same result, what you do is to change the memory allocation and how to access data from a structure.
Some of good links about what you want to understand is [an tutorial about dynamic memory allocation](https://users.cs.jmu.edu/bernstdh/web/common/lectures/slides_cpp_dynamic-m... |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | Basic difference is this:
```
. is the member of a structure
-> is the member of a POINTED TO structure
```
So the `.` is used when there is a direct access to a variable in the structure. But the `->` is used when you are accessing a variable of a structure through a pointer to that structure.
Say you have struct ... | `->` is defined in terms of `.`
That is, `a->b` is equivalent to `(*a).b` and so you'll obviously get the same results.
`->` exists for convenience. |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | `->` is defined in terms of `.`
That is, `a->b` is equivalent to `(*a).b` and so you'll obviously get the same results.
`->` exists for convenience. | Use the first approach when you need to manually manage the lifetime of the created object. Use the second approach when the lifetime of the created object is limited to the scope in which it is created or the scope of the object that contains it. |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | `->` is defined in terms of `.`
That is, `a->b` is equivalent to `(*a).b` and so you'll obviously get the same results.
`->` exists for convenience. | when **.** is used, it is termed as structure to member..
and when **->** is used, it is termed as pointer to member..
how ever if pointer to member is used, it can be resolved like this..
x -> y and (\*x).y are both the same.. |
14,087,274 | >
> **Possible Duplicate:**
>
> [Arrow operator (->) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c)
>
>
>
I am trying to figure out the difference between the "." and "->" styles of data access in C language.
Eg.
```
struct div{
int quo;
int rem;
};
```
1) Using "... | 2012/12/30 | [
"https://Stackoverflow.com/questions/14087274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1846332/"
] | `->` is defined in terms of `.`
That is, `a->b` is equivalent to `(*a).b` and so you'll obviously get the same results.
`->` exists for convenience. | In C, `->` is very similar to `.`, but deals with pointers. In a structure, the `.` is used to reference directly to a member within the structure, while `->` is used to reference the member of a pointed to structure. You get the same pretty much the same result using pointers or not, depending on the situation.
`a ->... |
32,025,000 | I am writing an application that needs to communicate over SSL/TLS.
When I use the following code, the device connects, but I always read 0 bytes:
```
byte[] buffer = new byte[2048];
StringBuilder messageData = new StringBuilder();
int bytes = -1;
do
{
// Read the ... | 2015/08/15 | [
"https://Stackoverflow.com/questions/32025000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2196799/"
] | I did end up solving this eventually and wanted to post the answer for everyone. The certificate was self-signed, thus "invalid", but this is common on devices. I had to create a validation callback that always returned true.
I forget where I found this code but I think it was MSDN
```
// The following method is ... | Find below a example of a Client-Server communicating through sslstream [original source here](https://cboard.cprogramming.com/csharp-programming/165902-sslstream-client-certificates.html)
Server
```
static void Main(string[] args)
{
var _certificate = "certificate-string";
TcpListener server = ne... |
11,874,327 | I have an application which displays a list of users , When clicking on the email button I want the email client to open up with a prepopulated message ( I make the message using javascript) , I am not sure about how to prepopulate the message
Any help would be appreciated
I would post snippets , but honestly I dnt... | 2012/08/08 | [
"https://Stackoverflow.com/questions/11874327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1569896/"
] | [URI encode](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent) the text and then append it to a `mailto:` URL:
```
<a href='mailto:person@place.com?body=text%20here'>Send mail!</a>
```
More generally, you can use:
* subject
* body (multiple `body` parameters will put e... | You can use jQuery to find all the links that have `mailto:`, then process their href to add the message body:
```
$("a[href^='mailto:']").prop( "href", function(i, prop){
return prop + "?body=" + encodeURIComponent( "Your message here" );
});
```
Demo:
<http://jsfiddle.net/6qXrU/> |
52,285,104 | I have been searching for 3D plots in python with seaborn and haven't seen any. I would like to 3D plot a dataset that I originally plotted using seaborn pairplot. Can anyone help me with these 2 issues:
1. I am not able to get same color palette as sns pairplot, e.g. how to get the color palette from figure 2 and app... | 2018/09/11 | [
"https://Stackoverflow.com/questions/52285104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1351534/"
] | 1. The color palette from Seaborn can be turned into a Matplotlib color map from an instance of a `ListedColorMap` class initialized with the list of colors in the Seaborn palette with the `as_hex()` method (as proposed in [this original answer](https://stackoverflow.com/questions/37902459/seaborn-color-palette-as-matp... | There is no color palette specification for fig 2 but it looks like it is the Paired qualitative colormap from matplotlib ([from here](https://matplotlib.org/tutorials/colors/colormaps.html)). So you need to specify that in your code for the 3D plot with the `cmap` argument and with the `palette` option in your pairplo... |
18,570,575 | I need to get the value which I have selected from a selectOneMenu in JSF. I used an ArrayList and I am holding data in it.
```
<h:outputText value="Meslek : " />
<h:selectOneMenu value="meslek">
<f:selectItems id="meslek7" value="#{comyon.selectıtem}"/>
</h:selectOneMenu>
```
And this is my bean:
```
@... | 2013/09/02 | [
"https://Stackoverflow.com/questions/18570575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2523595/"
] | You should read those tutorials:
1. [Mkyoung selectOneMenu tutorial](http://www.mkyong.com/jsf2/jsf-2-dropdown-box-example/)
2. [Mkyong converter tutorial](http://www.mkyong.com/jsf2/custom-converter-in-jsf-2-0/)
Basically you should select value container for selectOneMenu tag. it means that it should look like:
``... | Although what you choose in your drop-down list, the item's value will be the frist line
```
<h:selectOneMenu value="#{meslek}">
```
So, let's declare a variable with name "meslek" and getter/setter to use the value.
```
private String meslek;
``` |
40,581,967 | I am stuck on a question where I have to return the sum of all numbers within 10 seeds of the number entered by the user (inclusive). For instance, if the number was 1, it would be 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45. So far I have:
```
def temp(n1):
seed = n1
counter = 0
while counter < 9:
n... | 2016/11/14 | [
"https://Stackoverflow.com/questions/40581967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6023943/"
] | Answer of @Majora320 is correct and explains why your code does not work. But a liitle more concise solution would be
```
def temp(n):
seed = 10
return ((seed * (seed-1))/2) + (n-1)
print temp(1)
print temp(10)
print temp(11)
print temp(12)
```
**OP**
```
45
54
55
56
```
Basically it take advance of mathe... | In your code, you are adding 1 each time, where you should be adding the counter plus 1 (since you should be incrementing be one *more* each time):
```
def temp(n1):
n1 -= 1 <-- HERE
counter = 0
while counter < 9:
n1 += counter + 1 <-- HERE
counter += 1
... |
46,992,346 | I have a `DataFrame` with two columns, `Type` and `Time`:
```
import pandas as pd
import dateutil.parser
df = pd.DataFrame({'Type' : ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo', 'foo', 'foo'],
'Time' : ['9:11', '9:54', '15:12', '11:39', '21:50', '15:40', '1:23', '1:48', '9:13', '9:48']}... | 2017/10/28 | [
"https://Stackoverflow.com/questions/46992346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/995862/"
] | You can try this:
```
s = "********u"
l ={0,2,4}
final_string = ''.join(["a" if i in l else a for i, a in enumerate(s)])
```
Output:
```
'a*a*a***u'
``` | Another way:
```
your_string = list("********u")
your_list = [0,2,4]
for index_number in your_list:
your_string[index_number] = 'a'
your_output = ''.join(your_string)
print(your_output)
``` |
46,992,346 | I have a `DataFrame` with two columns, `Type` and `Time`:
```
import pandas as pd
import dateutil.parser
df = pd.DataFrame({'Type' : ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo', 'foo', 'foo'],
'Time' : ['9:11', '9:54', '15:12', '11:39', '21:50', '15:40', '1:23', '1:48', '9:13', '9:48']}... | 2017/10/28 | [
"https://Stackoverflow.com/questions/46992346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/995862/"
] | You can try this:
```
s = "********u"
l ={0,2,4}
final_string = ''.join(["a" if i in l else a for i, a in enumerate(s)])
```
Output:
```
'a*a*a***u'
``` | Just use a function and pass the parameter as index ,string and replace character :
```
def replace(index_list,character,string):
string=list(string)
for index in index_list:
string[index]=character
return "".join(string)
print(replace([0,2,4],'a',"********u"))
```
Output:
```
a*a*a***u
``` |
46,992,346 | I have a `DataFrame` with two columns, `Type` and `Time`:
```
import pandas as pd
import dateutil.parser
df = pd.DataFrame({'Type' : ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo', 'foo', 'foo'],
'Time' : ['9:11', '9:54', '15:12', '11:39', '21:50', '15:40', '1:23', '1:48', '9:13', '9:48']}... | 2017/10/28 | [
"https://Stackoverflow.com/questions/46992346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/995862/"
] | Just use a function and pass the parameter as index ,string and replace character :
```
def replace(index_list,character,string):
string=list(string)
for index in index_list:
string[index]=character
return "".join(string)
print(replace([0,2,4],'a',"********u"))
```
Output:
```
a*a*a***u
``` | Another way:
```
your_string = list("********u")
your_list = [0,2,4]
for index_number in your_list:
your_string[index_number] = 'a'
your_output = ''.join(your_string)
print(your_output)
``` |
401,343 | I have a file "a.txt" and its hardlink "ha.txt". If I open either of those files in notepad and save any changes it would appear in both files as they are still linked. But if I overwrite (copy) a.txt with another file with same name the hardlink breaks. What other operations do this?
Also, can I use it to backup a f... | 2012/03/16 | [
"https://superuser.com/questions/401343",
"https://superuser.com",
"https://superuser.com/users/120159/"
] | Anything that deletes and recreates the target file will break the link. Some applications will do this, some won't. I don't think there's any way to predict this in advance.
Hard links are not a sensible backup mechanism, since there is only ever one copy of the file. Backups should always be to a different physical ... | Anything that rewrites the filename will break the link. Modifying the file contents will not, nor will changing the filename metadata. |
1,901,112 | Let $f:R\to R$ be a bounded Borel measurable function,Endow $R$ with Lebesgue measure $\mu$. Suppose there are constants $M>0$ and $0<a<1$ such that for any $y>0$ has
$$
\mu(\{x\in R :|f(x)|>y\})<M/y^a
$$
Prove that $f\in L^1(R,\mu)$
My solution
assume $|f|<B, A\_n=\mu(\{x\in R :|f(x)|>1/n\}$,
so$\int\_R |f|=\lim\_{... | 2016/08/23 | [
"https://math.stackexchange.com/questions/1901112",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/27743/"
] | The following fact can be very useful when relating $L^p$ and weak-$L^p$ spaces: $$\int\_R |f|^p \, d\mu = p \int\_0^\infty y^{p-1}\mu(\{ |f| > y\}) \, dy.$$
Take $p = 1$. Since $f$ is bounded you get $$\int\_R |f| \, d\mu = \int\_0^{\|f\|\_\infty} \mu(\{ |f| > y\}) \, dy \le \int\_0^{\|f\|\_\infty} My^{-\alpha} \, dy... | WLOG $0 \le f \le 1.$ Then
$$\int\_\mathbb R f = \sum\_{n=1}^{\infty}\int\_{\{2^{-n}< f \le 2^{-(n-1)}\} }f\le \sum\_{n=1}^{\infty}2^{-(n-1)}\mu(\{f>2^{-n}\})$$ $$ \le \sum\_{n=1}^{\infty}2^{-(n-1)}[M/(2^{-n})^{\alpha}] = 2M\sum\_{n=1}^{\infty}[2^{\alpha-1}]^n < \infty.$$ |
2,844,526 | In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.
E.g. instead of
```
Math.sqrt(5)
```
it would make more sense to have
```
5.s... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2844526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816/"
] | I don't know the early history of Ruby, but I have a feeling the Math module was modelled after the C <math.h> header. It is an odd duck in the Ruby standard library though.
But, it's Ruby! So you can always bust out the monkey patching!
```
class Float
def sqrt; Math.sqrt(self); end
def sin; Math.sin(self); end
... | When talking about modules and namespaces, Programming Ruby (the pickaxe) gave an example of an object with both mathematical functions mixed in, and functions to do with morality mixed in, so that it could calculate [how many angels can dance on the head of a pin](http://en.wikipedia.org/wiki/How_many_angels_can_dance... |
2,844,526 | In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.
E.g. instead of
```
Math.sqrt(5)
```
it would make more sense to have
```
5.s... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2844526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816/"
] | I don't know the early history of Ruby, but I have a feeling the Math module was modelled after the C <math.h> header. It is an odd duck in the Ruby standard library though.
But, it's Ruby! So you can always bust out the monkey patching!
```
class Float
def sqrt; Math.sqrt(self); end
def sin; Math.sin(self); end
... | To expand on [Michael's answer](https://stackoverflow.com/questions/2844526/why-is-sqrt-not-a-method-on-float/2844568#2844568), there's no need to define all those methods by hand. Note that I explicitly skip the two Math methods that take two arguments.
```
class Numeric
(Math.methods - Module.methods - ["hypot", "... |
2,844,526 | In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.
E.g. instead of
```
Math.sqrt(5)
```
it would make more sense to have
```
5.s... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2844526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816/"
] | I don't know the early history of Ruby, but I have a feeling the Math module was modelled after the C <math.h> header. It is an odd duck in the Ruby standard library though.
But, it's Ruby! So you can always bust out the monkey patching!
```
class Float
def sqrt; Math.sqrt(self); end
def sin; Math.sin(self); end
... | I've rewritten Mark's answer to be more concise, and not require removing `hypot` and `ldexp`, since I'm using this approach myself.
```
class Numeric
Math.methods(false).each do |method|
define_method method do |*args|
Math.send(method, self, *args)
end
end
end
>> 3.hypot(4)
=> 5.0
>> Math::PI.sqr... |
2,844,526 | In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.
E.g. instead of
```
Math.sqrt(5)
```
it would make more sense to have
```
5.s... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2844526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816/"
] | I don't know the early history of Ruby, but I have a feeling the Math module was modelled after the C <math.h> header. It is an odd duck in the Ruby standard library though.
But, it's Ruby! So you can always bust out the monkey patching!
```
class Float
def sqrt; Math.sqrt(self); end
def sin; Math.sin(self); end
... | `5 ** 0.5` demonstrates that ruby's exponentiation operator can handle square roots directly, as for log, sin etc, these make more sense to me as global functions rather than methods: their origins are in mathematics and are not closely related to any one float instance. |
2,844,526 | In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.
E.g. instead of
```
Math.sqrt(5)
```
it would make more sense to have
```
5.s... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2844526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816/"
] | To expand on [Michael's answer](https://stackoverflow.com/questions/2844526/why-is-sqrt-not-a-method-on-float/2844568#2844568), there's no need to define all those methods by hand. Note that I explicitly skip the two Math methods that take two arguments.
```
class Numeric
(Math.methods - Module.methods - ["hypot", "... | When talking about modules and namespaces, Programming Ruby (the pickaxe) gave an example of an object with both mathematical functions mixed in, and functions to do with morality mixed in, so that it could calculate [how many angels can dance on the head of a pin](http://en.wikipedia.org/wiki/How_many_angels_can_dance... |
2,844,526 | In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.
E.g. instead of
```
Math.sqrt(5)
```
it would make more sense to have
```
5.s... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2844526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816/"
] | I've rewritten Mark's answer to be more concise, and not require removing `hypot` and `ldexp`, since I'm using this approach myself.
```
class Numeric
Math.methods(false).each do |method|
define_method method do |*args|
Math.send(method, self, *args)
end
end
end
>> 3.hypot(4)
=> 5.0
>> Math::PI.sqr... | When talking about modules and namespaces, Programming Ruby (the pickaxe) gave an example of an object with both mathematical functions mixed in, and functions to do with morality mixed in, so that it could calculate [how many angels can dance on the head of a pin](http://en.wikipedia.org/wiki/How_many_angels_can_dance... |
2,844,526 | In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.
E.g. instead of
```
Math.sqrt(5)
```
it would make more sense to have
```
5.s... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2844526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816/"
] | To expand on [Michael's answer](https://stackoverflow.com/questions/2844526/why-is-sqrt-not-a-method-on-float/2844568#2844568), there's no need to define all those methods by hand. Note that I explicitly skip the two Math methods that take two arguments.
```
class Numeric
(Math.methods - Module.methods - ["hypot", "... | `5 ** 0.5` demonstrates that ruby's exponentiation operator can handle square roots directly, as for log, sin etc, these make more sense to me as global functions rather than methods: their origins are in mathematics and are not closely related to any one float instance. |
2,844,526 | In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.
E.g. instead of
```
Math.sqrt(5)
```
it would make more sense to have
```
5.s... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2844526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816/"
] | I've rewritten Mark's answer to be more concise, and not require removing `hypot` and `ldexp`, since I'm using this approach myself.
```
class Numeric
Math.methods(false).each do |method|
define_method method do |*args|
Math.send(method, self, *args)
end
end
end
>> 3.hypot(4)
=> 5.0
>> Math::PI.sqr... | `5 ** 0.5` demonstrates that ruby's exponentiation operator can handle square roots directly, as for log, sin etc, these make more sense to me as global functions rather than methods: their origins are in mathematics and are not closely related to any one float instance. |
30,215,415 | I just recently did a sudoku solver in java using backtracking.
Is it possible, given the solutions, to formulate a problem or puzzle?
**EDIT**
to formulate the original puzzle, is there some way to achieve this?
and an additional question,
given the puzzle and the solutions.
If I am able to solve the puzzle usin... | 2015/05/13 | [
"https://Stackoverflow.com/questions/30215415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It is possible to formulate **one of the multiple possible** original states.
1. Start with the final solution (all numbers are present)
2. Remove one number (chosen randomly or not)
3. Check if this number can be found back given the current state of the board (you already have a solver, it should be easy)
4. If this... | >
> If I am able to solve the puzzle using the solutions (result is puzzles)
> and at the same time able to solve the solutions using the puzzle (result is solutions)
>
>
> Which has the greater number?
>
>
> the puzzles? or the solutions?
>
>
>
There is no well-defined answer.
Each solution has exactly 281 ... |
30,215,415 | I just recently did a sudoku solver in java using backtracking.
Is it possible, given the solutions, to formulate a problem or puzzle?
**EDIT**
to formulate the original puzzle, is there some way to achieve this?
and an additional question,
given the puzzle and the solutions.
If I am able to solve the puzzle usin... | 2015/05/13 | [
"https://Stackoverflow.com/questions/30215415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It is possible to formulate **one of the multiple possible** original states.
1. Start with the final solution (all numbers are present)
2. Remove one number (chosen randomly or not)
3. Check if this number can be found back given the current state of the board (you already have a solver, it should be easy)
4. If this... | Creating a puzzle from a solution is very simple. You just apply the solving steps backwards.
For example, if a line contains 8 digits, you can fill in the 9th. If you do that backwards, if a line contains 9 digits, you can remove one. This will yield a very boring puzzle, but still a valid one (a valid puzzle is a pu... |
32,570,939 | I am trying to connect to cloud sql from app engine using cloud back-end java servlet in android studio. But I got error in getting connection from **DriverManager**.
```
Connection conn = DriverManager.getConnection("jdbc:google:mysql://<id:<sql-id>/database",
"myuser","password");
```
and driver ... | 2015/09/14 | [
"https://Stackoverflow.com/questions/32570939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5334524/"
] | As of Sep 14, 2015 Sql Server Reporting Services (SSRS) **hasn't been released** as part of SSDT 2015.
[](https://i.stack.imgur.com/JVhJF.png)
[Link to the page](http://blogs.msdn.com/b/ssdt/archive/2015/09/01/sql-server-data-tools-preview-update-fo... | SSDT is updated on July 7 2016, can be downloaded from Microsoft website <https://msdn.microsoft.com/en-us/library/mt204009.aspx> |
46,299,300 | I am very new to javascript so please don't flame me. (or you can if you want I don't mind).
I am trying to remove href anchors within a specific parent which are loaded from another database, while keeping the `css` values. Basically disable the the user from clicking on the link. using `css` to disable pointer event... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46299300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8619752/"
] | The latter approach would be better, as it makes easier to make sure that there is no teacher and student with same ID.
Just add all users to the same table, rather than to two different tables. | I prefer second approach.
Add field type in your table and stored user's type like 1:teacher, 2:student(it's useful than boolean field. if you want to add another user type like 3:principal 4:helper ....)
And after successful login check user type and redirect where you want. |
46,299,300 | I am very new to javascript so please don't flame me. (or you can if you want I don't mind).
I am trying to remove href anchors within a specific parent which are loaded from another database, while keeping the `css` values. Basically disable the the user from clicking on the link. using `css` to disable pointer event... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46299300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8619752/"
] | The latter approach would be better, as it makes easier to make sure that there is no teacher and student with same ID.
Just add all users to the same table, rather than to two different tables. | Controller.php:
```
if(isset($_POST['login'])){
$this->model->check();
}
```
Model.php:
```
public function check(){
$id=$_POST['user_id'];
$this->db->select('user_id');
$this->db->from('user');
$q1= $this->db->get();
$this->db->select('teacher_id');
$this->db->from('teacher');
$q2= $this->db->get();
... |
46,299,300 | I am very new to javascript so please don't flame me. (or you can if you want I don't mind).
I am trying to remove href anchors within a specific parent which are loaded from another database, while keeping the `css` values. Basically disable the the user from clicking on the link. using `css` to disable pointer event... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46299300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8619752/"
] | Controller.php:
```
if(isset($_POST['login'])){
$this->model->check();
}
```
Model.php:
```
public function check(){
$id=$_POST['user_id'];
$this->db->select('user_id');
$this->db->from('user');
$q1= $this->db->get();
$this->db->select('teacher_id');
$this->db->from('teacher');
$q2= $this->db->get();
... | I prefer second approach.
Add field type in your table and stored user's type like 1:teacher, 2:student(it's useful than boolean field. if you want to add another user type like 3:principal 4:helper ....)
And after successful login check user type and redirect where you want. |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | I can recommend two approaches:
Coding your own plug-in, like Quakelive.
Using HTML Canvas.
That itself, open a plethora of options, there are SEVERAL ways to use Canvas, the mentioned WebGL by Mr. Sauer is one way, currently there are some people making a Quake II port to WebGL, using HTML Canvas. Other options are... | Powerful 3D games can be created with Adobe Schockwave, for example on site: <http://www.shockwave.com/> |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | I can recommend two approaches:
Coding your own plug-in, like Quakelive.
Using HTML Canvas.
That itself, open a plethora of options, there are SEVERAL ways to use Canvas, the mentioned WebGL by Mr. Sauer is one way, currently there are some people making a Quake II port to WebGL, using HTML Canvas. Other options are... | JOGL is one option, when you are coding with Java, performance will not be a problem.
<http://jogamp.org/jogl/www>
A better option in my opinion is Unity 3D. If you feel like coding something in JavaScript or C# Unity 3D is your program. It has a huge scripting reference, amazing built in graphics and such, and you c... |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | Definitely <http://unity3d.com>. Cross-platform.., web, iphone, wii.., and more coming soon.
It is so easy to learn (relatively), and so fun to work with!
It is free, or you could choose the Pro version with more advance features (profiling, etc..) | I can recommend two approaches:
Coding your own plug-in, like Quakelive.
Using HTML Canvas.
That itself, open a plethora of options, there are SEVERAL ways to use Canvas, the mentioned WebGL by Mr. Sauer is one way, currently there are some people making a Quake II port to WebGL, using HTML Canvas. Other options are... |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | I can recommend two approaches:
Coding your own plug-in, like Quakelive.
Using HTML Canvas.
That itself, open a plethora of options, there are SEVERAL ways to use Canvas, the mentioned WebGL by Mr. Sauer is one way, currently there are some people making a Quake II port to WebGL, using HTML Canvas. Other options are... | Depending on how risky you want to go and when you want to release, you might want to look at the [WebGL](http://en.wikipedia.org/wiki/WebGL) approach.
Current Chrome and Firefox pre-releases support it and I have a feeling that the [Chrome Frame](http://code.google.com/chrome/chromeframe/) will support it too in a fu... |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | Definitely <http://unity3d.com>. Cross-platform.., web, iphone, wii.., and more coming soon.
It is so easy to learn (relatively), and so fun to work with!
It is free, or you could choose the Pro version with more advance features (profiling, etc..) | Powerful 3D games can be created with Adobe Schockwave, for example on site: <http://www.shockwave.com/> |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | I would go for JOGL.
Performance will not be an issue when going for Java. Not as long as you handle the graphics properly (such as by using JOGL). | Powerful 3D games can be created with Adobe Schockwave, for example on site: <http://www.shockwave.com/> |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | Definitely <http://unity3d.com>. Cross-platform.., web, iphone, wii.., and more coming soon.
It is so easy to learn (relatively), and so fun to work with!
It is free, or you could choose the Pro version with more advance features (profiling, etc..) | Depending on how risky you want to go and when you want to release, you might want to look at the [WebGL](http://en.wikipedia.org/wiki/WebGL) approach.
Current Chrome and Firefox pre-releases support it and I have a feeling that the [Chrome Frame](http://code.google.com/chrome/chromeframe/) will support it too in a fu... |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | I would go for JOGL.
Performance will not be an issue when going for Java. Not as long as you handle the graphics properly (such as by using JOGL). | Definitely <http://unity3d.com>. Cross-platform.., web, iphone, wii.., and more coming soon.
It is so easy to learn (relatively), and so fun to work with!
It is free, or you could choose the Pro version with more advance features (profiling, etc..) |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | I would go for JOGL.
Performance will not be an issue when going for Java. Not as long as you handle the graphics properly (such as by using JOGL). | Depending on how risky you want to go and when you want to release, you might want to look at the [WebGL](http://en.wikipedia.org/wiki/WebGL) approach.
Current Chrome and Firefox pre-releases support it and I have a feeling that the [Chrome Frame](http://code.google.com/chrome/chromeframe/) will support it too in a fu... |
2,743,617 | I have enjoyed making 2D games in various langues (actionscript 3.0, java, python, others) but now I'm ready to move into 3D and to really get me amped up while learning 3D development I'm going to attempt to make a 3D multiplayer game (I already have server written in python).
I'm looking for a platform that will run... | 2010/04/30 | [
"https://Stackoverflow.com/questions/2743617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152986/"
] | I would go for JOGL.
Performance will not be an issue when going for Java. Not as long as you handle the graphics properly (such as by using JOGL). | JOGL is one option, when you are coding with Java, performance will not be a problem.
<http://jogamp.org/jogl/www>
A better option in my opinion is Unity 3D. If you feel like coding something in JavaScript or C# Unity 3D is your program. It has a huge scripting reference, amazing built in graphics and such, and you c... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | First, you have to understand a what a hash function is.
A hash function is a function that takes a key (for example, an string of arbritrary length) and returns a number *as unique as possible*. The same key must always return the same hash. A really simple string hashing function in java might look like
```
public i... | You wouldn't want to use a hash table for 100 randomly generated numbers.
A good way to think about hash tables is to think about value pairs. Let's use students, and say everyone has a student ID number. In your program you store information on students (names, phone numbers, bills, etc). You want to find all of the ... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | First, you have to understand a what a hash function is.
A hash function is a function that takes a key (for example, an string of arbritrary length) and returns a number *as unique as possible*. The same key must always return the same hash. A really simple string hashing function in java might look like
```
public i... | *[This is the reply to a comment made by me.yahoo.com/a above]*
That depends on your hash function. Lets suppose that your hash function hashes a word as per the length of your word, the key for chris will be 5. Similarly, key for yahoo will also be 5. Now, both values (chris and yahoo) will go under 5 (i.e. in a 'buc... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | First, you have to understand a what a hash function is.
A hash function is a function that takes a key (for example, an string of arbritrary length) and returns a number *as unique as possible*. The same key must always return the same hash. A really simple string hashing function in java might look like
```
public i... | Here is, in short, how a hash table works.
Imagine you have a library, full of books. If you were to store the books in an array, you would put each book on a spot on a shelf, and then when someone asked you to find a book, you'd look through all the shelves -- pretty slow. If someone said "book #12345", you could fin... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | Hashtables are *associative*. This is a huge difference from arrays, which are just linear data structures. With an array, you might do something like this:
```
int[] arr = ...
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i] + 1);
}
```
Notice how you are getting an element out of the array by s... | *[This is the reply to a comment made by me.yahoo.com/a above]*
That depends on your hash function. Lets suppose that your hash function hashes a word as per the length of your word, the key for chris will be 5. Similarly, key for yahoo will also be 5. Now, both values (chris and yahoo) will go under 5 (i.e. in a 'buc... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | First, you have to understand a what a hash function is.
A hash function is a function that takes a key (for example, an string of arbritrary length) and returns a number *as unique as possible*. The same key must always return the same hash. A really simple string hashing function in java might look like
```
public i... | Something I didn't see specifically noted yet:
The point of using a hash table over an array is performance.
Iterating through an array would typically take anywhere from O(1) to O(x) where x is the number of items in the array. However the time to find your item will be extremely *variable*, expecially if we are ta... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | Hashtables are *associative*. This is a huge difference from arrays, which are just linear data structures. With an array, you might do something like this:
```
int[] arr = ...
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i] + 1);
}
```
Notice how you are getting an element out of the array by s... | Hash table is a data structure that is created for quick look up.
The hash tables are not effective when the number of entries are very small.
[reference](https://stackoverflow.com/a/18417489/730807)
Some examples:
```
import java.util.Collection;
import java.util.Enumeration;
import java.util.Hashtable... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | The answers so far have helped to define hash tables and explain some theory, but I think an example may help you get a better feeling for them.
*What is the difference between a hash table and just a normal array?*
A hash table and an array are both structures that allow you to store and retrieve data. Both allow yo... | You wouldn't want to use a hash table for 100 randomly generated numbers.
A good way to think about hash tables is to think about value pairs. Let's use students, and say everyone has a student ID number. In your program you store information on students (names, phone numbers, bills, etc). You want to find all of the ... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | Something I didn't see specifically noted yet:
The point of using a hash table over an array is performance.
Iterating through an array would typically take anywhere from O(1) to O(x) where x is the number of items in the array. However the time to find your item will be extremely *variable*, expecially if we are ta... | *[This is the reply to a comment made by me.yahoo.com/a above]*
That depends on your hash function. Lets suppose that your hash function hashes a word as per the length of your word, the key for chris will be 5. Similarly, key for yahoo will also be 5. Now, both values (chris and yahoo) will go under 5 (i.e. in a 'buc... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | The answers so far have helped to define hash tables and explain some theory, but I think an example may help you get a better feeling for them.
*What is the difference between a hash table and just a normal array?*
A hash table and an array are both structures that allow you to store and retrieve data. Both allow yo... | Here is, in short, how a hash table works.
Imagine you have a library, full of books. If you were to store the books in an array, you would put each book on a spot on a shelf, and then when someone asked you to find a book, you'd look through all the shelves -- pretty slow. If someone said "book #12345", you could fin... |
282,712 | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | First, you have to understand a what a hash function is.
A hash function is a function that takes a key (for example, an string of arbritrary length) and returns a number *as unique as possible*. The same key must always return the same hash. A really simple string hashing function in java might look like
```
public i... | The question, I believe, is answered quite clearly and in many different ways by now.
I would just like to add another perspective (which may confuse a new reader as well)
At a level of least abstraction, arrays are just contiguous block of memory. Given the starting address (`startAddress`), size (`sizeOfElement`) a... |
246,669 | I am creating a LED lighting unit for an Aquarium and I have a 240vAC to 24v DC power supply.
I want to output 12V and 5V also in addition to the 24v DC.
I have 2 buck modules - like these <http://www.ebay.com/itm/1Pcs-Lm2596-Power-Supply-Output-1-23V-30V-Dc-Dc-Buck-Converter-Step-Down-Modul-A-/301988858332?hash=item... | 2016/07/19 | [
"https://electronics.stackexchange.com/questions/246669",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/117140/"
] | This is okay, except that your 240 vac negative terminal is NOT ground. The wiring diagram is a little ambiguous there, but I think you understand.
Best in this case would be a large bread board or something similar to give you a nice working surface, as well as plenty of access to your 5v rail.
Ideally, you want y... | This is an old question, but here's a more concise answer. The circuit linked to uses an LM2596, these have a single ground pin and typical usage is with a common GND. You can see the typical usage by searching for the datasheet pdf. |
246,669 | I am creating a LED lighting unit for an Aquarium and I have a 240vAC to 24v DC power supply.
I want to output 12V and 5V also in addition to the 24v DC.
I have 2 buck modules - like these <http://www.ebay.com/itm/1Pcs-Lm2596-Power-Supply-Output-1-23V-30V-Dc-Dc-Buck-Converter-Step-Down-Modul-A-/301988858332?hash=item... | 2016/07/19 | [
"https://electronics.stackexchange.com/questions/246669",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/117140/"
] | This is okay, except that your 240 vac negative terminal is NOT ground. The wiring diagram is a little ambiguous there, but I think you understand.
Best in this case would be a large bread board or something similar to give you a nice working surface, as well as plenty of access to your 5v rail.
Ideally, you want y... | Although the link to the item is no longer working, in general most available DC-DC buck converter modules have a current limiting function based on a resistor on the output ground to measure current. This will not work if input and output ground are connected together outside the module. The difference between the inp... |
246,669 | I am creating a LED lighting unit for an Aquarium and I have a 240vAC to 24v DC power supply.
I want to output 12V and 5V also in addition to the 24v DC.
I have 2 buck modules - like these <http://www.ebay.com/itm/1Pcs-Lm2596-Power-Supply-Output-1-23V-30V-Dc-Dc-Buck-Converter-Step-Down-Modul-A-/301988858332?hash=item... | 2016/07/19 | [
"https://electronics.stackexchange.com/questions/246669",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/117140/"
] | Although the link to the item is no longer working, in general most available DC-DC buck converter modules have a current limiting function based on a resistor on the output ground to measure current. This will not work if input and output ground are connected together outside the module. The difference between the inp... | This is an old question, but here's a more concise answer. The circuit linked to uses an LM2596, these have a single ground pin and typical usage is with a common GND. You can see the typical usage by searching for the datasheet pdf. |
110,082 | Let $X$ be a nonempty set, and $\{A\_\alpha : \alpha\in I\}$ be a partition of $X$. If $B\subseteq X$ such that $A\_\alpha\cap B\neq\emptyset$ for every $\alpha\in I$, is $\{A\_\alpha\cap B : \alpha\in I\}$ a partition of $B$?
I just need a starting point on how to think about this. Is there any logic that says taking... | 2012/02/16 | [
"https://math.stackexchange.com/questions/110082",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/25006/"
] | In a previous question of yours I have written the three properties of a partition.
So we need to verify three things:
1. $A\_\alpha\cap B\neq\varnothing$ for all $\alpha\in I$, which is the working assumption.
2. $A\_\alpha\cap A\_\beta=\varnothing$ whenever $\alpha\neq\beta$, which you can deduce from the fact the ... | Ask yourself some questions:
* Given some $x\in B$ is there some $\alpha\in I$ such that $x \in A\_\alpha \cap B$?
* Could there be more than one such $\alpha$?
* If there is more than one---call them $\alpha$ and $\beta$---is $A\_\alpha\cap B$ the same set as $A\_\beta \cap B$? |
15,543,660 | What is the recommended way to pass cached jQuery references, e.g. `$domContainer` in `var $domContainer = $('#container');` to functions as a callback if the functions are defined before and outside of `$(document).ready()`?
Example:
```
<script src="/plugins.js"></script>
```
In this external file of re-usable fu... | 2013/03/21 | [
"https://Stackoverflow.com/questions/15543660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/573688/"
] | Numeric *values* don't have leading or trailing zeros. `1.5` is the same value as `1.50` is the same value as `1.5000000000`. Numeric types don't save the formatting, they save the *value*. Format the value on output if needed or use a *text* type if you need to save the literal value. | You can store 1.5 in database but you If you want to display it 1.5000000 then it is possible.
You can do this using LPAD like this. Lpad is for adding zeroes on left side and Rpad is for adding zeroes right side.
```
SELECT LPAD( '1.5', '10', '0' )
SELECT RPAD( '1.5', '10', '0' )
```
Please give reply if it works... |
15,543,660 | What is the recommended way to pass cached jQuery references, e.g. `$domContainer` in `var $domContainer = $('#container');` to functions as a callback if the functions are defined before and outside of `$(document).ready()`?
Example:
```
<script src="/plugins.js"></script>
```
In this external file of re-usable fu... | 2013/03/21 | [
"https://Stackoverflow.com/questions/15543660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/573688/"
] | DCoder should post the comment as the answer.
You need to use DECIMAL to represent the price, then you will have trailing zeros.
And you should always format the output. | You can store 1.5 in database but you If you want to display it 1.5000000 then it is possible.
You can do this using LPAD like this. Lpad is for adding zeroes on left side and Rpad is for adding zeroes right side.
```
SELECT LPAD( '1.5', '10', '0' )
SELECT RPAD( '1.5', '10', '0' )
```
Please give reply if it works... |
1,619,631 | I'm trying to output the hex value of a char and format it in a nice way.
Required: `0x01 : value 0x1`
All I can get is: `00x1 : value 0x1` // or 0x1 if i don't use iomanip
Here's the code i have, 'ch' was declared to be a unsigned char. Is there any other way to do it other than checking the value and manually ad... | 2009/10/25 | [
"https://Stackoverflow.com/questions/1619631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/160870/"
] | ```
std::cout << "0x" << std::noshowbase << std::hex << std::setw(2) << std::setfill('0') << (int)ch;
```
Since `setw` pads out to the left of the overall printed number (after `showbase` is applied), `showbase` isn't usable in your case. Instead, manually print out the base as shown above. | In one on my projects I did this:
```
ostream &operator<<(ostream &stream, byte value)
{
stream << "0x" << hex << (int)value;
return stream;
}
```
I surchaged the operator<< for stream output, and anything that was a byte was shown in hexadecimal. byte is a typedef for unsigned char. |
10,555,603 | I have a union query that's getting the count from two different populations. How can I force the results to be returned in the order they're written in the query and not in ascending/descending order?
```
select count(datediff(yyyy,dob,admitdate) as counts
from myTable
where condition
union
select count(datediff(yyyy... | 2012/05/11 | [
"https://Stackoverflow.com/questions/10555603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/645070/"
] | You have to specify the order with an ORDER BY clause. In your example, you might do:
```
SELECT 1 AS seq, COUNT(datediff(yyyy,dob,admitdate) as counts
FROM myTable
WHERE ...condition-1...
UNION
SELECT 2 AS seq, COUNT(datediff(yyyy,dob,admitdate) as counts
FROM myTable
WHERE ...condition-2...
ORDER BY seq
``` | ```
select 1, count(datediff(yyyy,dob,admitdate) as counts
from myTable
where condition
union
select 2, count(datediff(yyyy,dob,admitdate) as counts
from myTable
where condition
order by 1
``` |
45,725,815 | I am trying to convert a yyyyww which is actually starting as a string object I think at is like 201731. I want to capture the last 6 weeks including its self.
```
def generate_6_last_week(yearweek):
weeks = [int(yearweek)]
date = time.mktime(datetime.strptime(str(yearweek)+"0","%Y%W%w").timetuple())
for i... | 2017/08/17 | [
"https://Stackoverflow.com/questions/45725815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2386086/"
] | This requires the "isoweek" package to be installed but gave me what i want with some manipulation of the format of my str YYYYWW and works well with the crossover years.
```
from isoweek import Week
yearweek = "201702"
weeks = [int(yearweek)]
x = 1
for i in range(5):
week = int(str(Week(int(yearweek[:4]), int(y... | I do not know anything about `striptime()`. So I have solved the problem by writing my own code. Here's the code:
```
date=input()
a=int(date[0:4])
b=int(date[4:])
k=5-b
finallist=[]
def m(x,y):
return(x-y)
if b>=5:
date=int(date)
finallist=[date,date-1,date-2,date-3,date-4,date-5]
print(finallis... |
1,752,123 | I'm running Kali Linux on my Macbook Pro and it is not recognizing my keyboard. I am unable to type special characters like `~` and `ˆ`. | 2022/11/10 | [
"https://superuser.com/questions/1752123",
"https://superuser.com",
"https://superuser.com/users/1746456/"
] | Assuming Firefox was closed (and properly), right click on the Firefox icon on the taskbar and select "Unpin from Taskbar" .
This works Windows 10 and 11 for any icon that can be removed (any closed app) .
Once unpinned, Firefox should no longer stay on the taskbar at Firefox exit. Make sure you have exited from Fire... | One can use this [Batch](https://en.wikipedia.org/wiki/Batch_file) script from [thewindowsclub.com](https://www.thewindowsclub.com/unpin-all-taskbar-icons-at-once-in-windows) to remove all pins:
```
DEL /F /S /Q /A "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\*"
REG DELETE HKCU\Software\Micr... |
391,885 | Let $C\_n$ be a cubical $n \times n \times n$ subset of the integer lattice,
so consisting of $n^3$ vertices.
I am interested in special Hamiltonian cycles in $C\_n$, special in the
sense that (a) each edge of the cycle has unit length, and
(b) no two adjacent edges are collinear---the path turns $90^\circ$ at every ve... | 2021/05/04 | [
"https://mathoverflow.net/questions/391885",
"https://mathoverflow.net",
"https://mathoverflow.net/users/6094/"
] | Partial answer: It is possible for $C\_n$ if $n$ is a power of two.
$C\_2$ and $C\_4$ are shown in the question. For larger $n$ the idea is to take a three-dimensional Moore curve (a recursive construction of a Hamiltonian circuit), and fix any straight-edge trouble *locally*.
By "recursive" I mean the construction b... | In the recent book "Bicycle or Unicycle?" by Velleman and Wagon, this is problem #16 "Wiggle Room." (Actually, there it's generalized to computing the maximum length path, with a Hamiltonian path in the next-best case, and the best case being a Hamiltonian cycle.) It's known that there is a Hamiltonian cycle for all ev... |
5,722,578 | It would simplify data import for our software if I could export the tables to SQL or CSV or other workable format. We often export from QuickBooks and import into our software and it would be simpler and faster if we could just get the customer's QBM file and then do the rest on our end. We have been exporting individ... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5722578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/463304/"
] | The ODBC driver for QuickBooks is avaiable [here](http://qodbc.com/). This driver is based on the QuickBooks SDK. You can find out more about the SDK [here](http://qbsdk.developer.intuit.com/sdk/qb). If you want to build a complex and robust export utility, should consider using the SDK directly. This will involde some... | There are ODBC drivers for Quickbooks. I *think* it even ships with one, but I could be wrong about that. |
5,722,578 | It would simplify data import for our software if I could export the tables to SQL or CSV or other workable format. We often export from QuickBooks and import into our software and it would be simpler and faster if we could just get the customer's QBM file and then do the rest on our end. We have been exporting individ... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5722578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/463304/"
] | We had a similar requirement in our application and found something called [Quickbooks Data Provider](http://www.rssbus.com/ado/quickbooks/). It’s like a tool that allows you to get information from QB and access it as SQL tables, just like using SQL Server. It’s great because you can manipulate the data in any way you... | There are ODBC drivers for Quickbooks. I *think* it even ships with one, but I could be wrong about that. |
5,722,578 | It would simplify data import for our software if I could export the tables to SQL or CSV or other workable format. We often export from QuickBooks and import into our software and it would be simpler and faster if we could just get the customer's QBM file and then do the rest on our end. We have been exporting individ... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5722578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/463304/"
] | The ODBC driver for QuickBooks is avaiable [here](http://qodbc.com/). This driver is based on the QuickBooks SDK. You can find out more about the SDK [here](http://qbsdk.developer.intuit.com/sdk/qb). If you want to build a complex and robust export utility, should consider using the SDK directly. This will involde some... | We had a similar requirement in our application and found something called [Quickbooks Data Provider](http://www.rssbus.com/ado/quickbooks/). It’s like a tool that allows you to get information from QB and access it as SQL tables, just like using SQL Server. It’s great because you can manipulate the data in any way you... |
8,750,769 | ```
_________
|A |
| _____ |
| |B | |
| |____| |
|________|
```
The user is authenticated on django-based site B.
Site A attempts to display site B in an iframe.
Currently, site B will always log the user out when displayed in this manner. I assume this is some security feature of django. How can I simply... | 2012/01/05 | [
"https://Stackoverflow.com/questions/8750769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1088009/"
] | I've gone through a process that is probably very similar to yours of attempting to find an efficient way to load data from an MR into HBase. What I found to work is using `HFileOutputFormat` as the OutputFormatClass of the MR.
Below is the basis of my code that I have to generate the `job` and the Mapper `map` funct... | >
> One interesting thing is that during insertion of 1,000,000 rows, 25 Mappers (tasks) are spawned but they run serially (one after another); is this normal?
>
>
>
`mapreduce.tasktracker.map.tasks.maximum` parameter which is defaulted to 2 determines the maximum number of tasks that can run in parallel on a node... |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | use
```
submit_tag "Submit", id: "foo-submit", data: { disable_with: "Please wait..." }
``` | You use CoffeeScript to do something like these lines:
```
jQuery ->
$('.theform').submit ->
$('input:submit').attr("disabled", true)
```
This disables the form submit button when the form with `class="theform"` is submitted. Depending on your need you adjust this to fit with your class/id for the form. |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | You use CoffeeScript to do something like these lines:
```
jQuery ->
$('.theform').submit ->
$('input:submit').attr("disabled", true)
```
This disables the form submit button when the form with `class="theform"` is submitted. Depending on your need you adjust this to fit with your class/id for the form. | The problem was caused by invalid HTML code. See [<div> breaks <form>](https://stackoverflow.com/q/21813561/2779926)
`disable_with` works now |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | You use CoffeeScript to do something like these lines:
```
jQuery ->
$('.theform').submit ->
$('input:submit').attr("disabled", true)
```
This disables the form submit button when the form with `class="theform"` is submitted. Depending on your need you adjust this to fit with your class/id for the form. | Since it is an ajax call, the resultant js.erb file from the corresponding action will be triggered.
The disable-on-click algorithm can be placed inside this js.erb file.
```
# in the controller
def foo_method
...
# will render js.erb for ajax call
# assuming there is no .html view file in the directory
end
# in fo... |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | An alternative to the `submit_tag` is the `button_tag`. The `button_tag` allows you to add a font awesome spinner.
```
<%= button_tag 'Submit', class: 'btn btn-primary',
data: { disable_with: "<i class='fa fa-refresh fa-spin'>
</i> Submitting Changes..."} %>
``` | You use CoffeeScript to do something like these lines:
```
jQuery ->
$('.theform').submit ->
$('input:submit').attr("disabled", true)
```
This disables the form submit button when the form with `class="theform"` is submitted. Depending on your need you adjust this to fit with your class/id for the form. |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | use
```
submit_tag "Submit", id: "foo-submit", data: { disable_with: "Please wait..." }
``` | The problem was caused by invalid HTML code. See [<div> breaks <form>](https://stackoverflow.com/q/21813561/2779926)
`disable_with` works now |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | use
```
submit_tag "Submit", id: "foo-submit", data: { disable_with: "Please wait..." }
``` | Since it is an ajax call, the resultant js.erb file from the corresponding action will be triggered.
The disable-on-click algorithm can be placed inside this js.erb file.
```
# in the controller
def foo_method
...
# will render js.erb for ajax call
# assuming there is no .html view file in the directory
end
# in fo... |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | use
```
submit_tag "Submit", id: "foo-submit", data: { disable_with: "Please wait..." }
``` | An alternative to the `submit_tag` is the `button_tag`. The `button_tag` allows you to add a font awesome spinner.
```
<%= button_tag 'Submit', class: 'btn btn-primary',
data: { disable_with: "<i class='fa fa-refresh fa-spin'>
</i> Submitting Changes..."} %>
``` |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | Since it is an ajax call, the resultant js.erb file from the corresponding action will be triggered.
The disable-on-click algorithm can be placed inside this js.erb file.
```
# in the controller
def foo_method
...
# will render js.erb for ajax call
# assuming there is no .html view file in the directory
end
# in fo... | The problem was caused by invalid HTML code. See [<div> breaks <form>](https://stackoverflow.com/q/21813561/2779926)
`disable_with` works now |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | An alternative to the `submit_tag` is the `button_tag`. The `button_tag` allows you to add a font awesome spinner.
```
<%= button_tag 'Submit', class: 'btn btn-primary',
data: { disable_with: "<i class='fa fa-refresh fa-spin'>
</i> Submitting Changes..."} %>
``` | The problem was caused by invalid HTML code. See [<div> breaks <form>](https://stackoverflow.com/q/21813561/2779926)
`disable_with` works now |
21,812,230 | I have a `form_tag(foo_path(@foo), remote: true, id: 'foo-form'` form and a submit button `submit_tag ("Submit", :id => "foo-submit")`
I'd like to disable the submit button after it has been clicked. Obviously, I cannot use something like `onlick="jQuery(this).prop('disabled', true);"` because it would break the remo... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21812230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779926/"
] | An alternative to the `submit_tag` is the `button_tag`. The `button_tag` allows you to add a font awesome spinner.
```
<%= button_tag 'Submit', class: 'btn btn-primary',
data: { disable_with: "<i class='fa fa-refresh fa-spin'>
</i> Submitting Changes..."} %>
``` | Since it is an ajax call, the resultant js.erb file from the corresponding action will be triggered.
The disable-on-click algorithm can be placed inside this js.erb file.
```
# in the controller
def foo_method
...
# will render js.erb for ajax call
# assuming there is no .html view file in the directory
end
# in fo... |
16,026,436 | I have a backbone view which is associated with model. View is listening for change method and it calls render if model is changed.
```
this.listenTo(this.model, 'change', this.render);
```
I'm having a problem that my backbone view's render method is getting called multiple times. I'm trying to debug this problem. ... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16026436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870109/"
] | The change event passes the `model` and a hash of `options`
In backbone [sources](http://documentcloud.github.io/backbone/docs/backbone.html#section-48):
```
this.trigger('change', this, options);
```
And so in the [documentation](http://documentcloud.github.io/backbone/#Events-catalog) as *mu is too short* has co... | As far as I am aware the render function is not supposed to have any parameters pass to it
```
Event.Listen=Backbone.View.extend({
model: 'something'
initialize:function(){
this.listenTo(this.model,'change',this.render);
}
render:function(){
//is called when the ... |
16,026,436 | I have a backbone view which is associated with model. View is listening for change method and it calls render if model is changed.
```
this.listenTo(this.model, 'change', this.render);
```
I'm having a problem that my backbone view's render method is getting called multiple times. I'm trying to debug this problem. ... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16026436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870109/"
] | The change event passes the `model` and a hash of `options`
In backbone [sources](http://documentcloud.github.io/backbone/docs/backbone.html#section-48):
```
this.trigger('change', this, options);
```
And so in the [documentation](http://documentcloud.github.io/backbone/#Events-catalog) as *mu is too short* has co... | Looks like externally to the View there are other calls to render(additional to the event listener).
if you try this(listen to other method instead of render):
```
this.listenTo(this.model, 'change', this.customMethod);
```
And then declare this in the view below render:
```
customMethod: function() {
console.... |
16,026,436 | I have a backbone view which is associated with model. View is listening for change method and it calls render if model is changed.
```
this.listenTo(this.model, 'change', this.render);
```
I'm having a problem that my backbone view's render method is getting called multiple times. I'm trying to debug this problem. ... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16026436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870109/"
] | The change event passes the `model` and a hash of `options`
In backbone [sources](http://documentcloud.github.io/backbone/docs/backbone.html#section-48):
```
this.trigger('change', this, options);
```
And so in the [documentation](http://documentcloud.github.io/backbone/#Events-catalog) as *mu is too short* has co... | The event callback gets called multiple times if the binding happens multiple times i.e.
```
this.listenTo(this.model, 'change', this.render);
```
is being executed multiple times.
It can also happen if the `change` is triggered multiple times. eg. you setting each of the attributes of a model in a for loop rather ... |
28,154,975 | I'm trying to implement OAuth2 in my actual symfony2 project using the FOSOAuthServerBundle.
I've been following this [Article](http://blog.tankist.de/blog/2013/07/17/oauth2-explained-part-2-setting-up-oauth2-with-symfony2-using-fosoauthserverbundle/) to implement it.
Since i don't use FOS User bundle i had to create... | 2015/01/26 | [
"https://Stackoverflow.com/questions/28154975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3204919/"
] | I doubt if it will help but try changing factory-service,factory-method to factory\_service and factory\_method to match the Symfony documentation. | Sounds like it is the only article that describes very well how to implement FOS OAuth2 bundle, even better than their own documentation.
But for some reason, services are defined in xml which I find very weird and ugly.
Anyway, as @Cerad mentioned, if you translate the xml service to the yaml format, then you'll have... |
35,788,475 | Why window object in the browser points to window object. Mozilla Website states the reason as
>
> The point of having the window property refer to the object itself was (probably) to make it easy to refer to the global object (otherwise you'd have to do a manual `var window = this;` assignment at the top of your sc... | 2016/03/04 | [
"https://Stackoverflow.com/questions/35788475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5078226/"
] | window.window or window.window.window and so on, that's not an implementation, that's a side-effect
consider this
```
var win = {};
win.win = win;
```
now
```
win.win === win
```
and
```
win.win.win === win
```
so what they could have done is like
```
var window = this;
```
which is actually same as
```... | You can add to the `Object.prototype` like this:
```
Object.prototype.mySuperReference = {a: 42};
```
Now any object you create will have a `mySuperReference` property. For example:
```
Object.prototype.mySuperReference = {a: 42};
var z = {};
z.mySuperReference
Object {a: 42}
```
I suspect `window` does this beca... |
35,788,475 | Why window object in the browser points to window object. Mozilla Website states the reason as
>
> The point of having the window property refer to the object itself was (probably) to make it easy to refer to the global object (otherwise you'd have to do a manual `var window = this;` assignment at the top of your sc... | 2016/03/04 | [
"https://Stackoverflow.com/questions/35788475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5078226/"
] | window.window or window.window.window and so on, that's not an implementation, that's a side-effect
consider this
```
var win = {};
win.win = win;
```
now
```
win.win === win
```
and
```
win.win.win === win
```
so what they could have done is like
```
var window = this;
```
which is actually same as
```... | >
> so my question how to infinitely point an object to object and how
> that helps to avoid doing var window = this;
>
>
>
[Spec](http://www.ecma-international.org/ecma-262/6.0/#sec-global-object) says
>
> In addition to the properties defined in this specification the global
> object may have additional host... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | The compiler cannot determine if you are introducing [*undefined behavior*](https://stackoverflow.com/questions/42491544/c-how-to-avoid-access-of-members-of-a-object-that-was-not-yet-initialized/42491635#comment72122871_42491635) like shown in your example. So there's no way to determine if the pointer variable was ini... | One good practice to enforce the checks is to use [`std::optional`](http://en.cppreference.com/w/cpp/utility/optional) or [`boost::optional`](http://www.boost.org/doc/libs/1_63_0/libs/optional/doc/html/index.html).
```
class Ship
{
public:
Ship() : pContainer(nullptr) {}
std::optional<container*> Container()
... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | The compiler cannot determine if you are introducing [*undefined behavior*](https://stackoverflow.com/questions/42491544/c-how-to-avoid-access-of-members-of-a-object-that-was-not-yet-initialized/42491635#comment72122871_42491635) like shown in your example. So there's no way to determine if the pointer variable was ini... | >
> What are good practice options for passing around objects in a program, avoiding accessing non initialized member variables.
>
>
>
Good practice would be to initialize everything in the constructor.
Debatable better practice is to initialize everything in the constructor *and* provide no way of modifying any ... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | The compiler cannot determine if you are introducing [*undefined behavior*](https://stackoverflow.com/questions/42491544/c-how-to-avoid-access-of-members-of-a-object-that-was-not-yet-initialized/42491635#comment72122871_42491635) like shown in your example. So there's no way to determine if the pointer variable was ini... | It seems that you are looking for a way to make your code
```
bool info = ship1.pContainer->otherInfo;
```
work even though the `pContainer` may be null.
You can use a sentinel object, which holds some default data:
```
container default_container;
default_container.otherInfo = false; // or whatever the default is... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | The compiler cannot determine if you are introducing [*undefined behavior*](https://stackoverflow.com/questions/42491544/c-how-to-avoid-access-of-members-of-a-object-that-was-not-yet-initialized/42491635#comment72122871_42491635) like shown in your example. So there's no way to determine if the pointer variable was ini... | I found an additional solution. It is admittedly not preventing the access of uninitialized objects, but at least the program crashes AND returns an error message, that enables us to correct our mistake. (This solution is particularly for the g++ compiler.)
First of all set the compiler flag `_GLIBCXX_DEBUG`. Then ins... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | One good practice to enforce the checks is to use [`std::optional`](http://en.cppreference.com/w/cpp/utility/optional) or [`boost::optional`](http://www.boost.org/doc/libs/1_63_0/libs/optional/doc/html/index.html).
```
class Ship
{
public:
Ship() : pContainer(nullptr) {}
std::optional<container*> Container()
... | >
> What are good practice options for passing around objects in a program, avoiding accessing non initialized member variables.
>
>
>
Good practice would be to initialize everything in the constructor.
Debatable better practice is to initialize everything in the constructor *and* provide no way of modifying any ... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | One good practice to enforce the checks is to use [`std::optional`](http://en.cppreference.com/w/cpp/utility/optional) or [`boost::optional`](http://www.boost.org/doc/libs/1_63_0/libs/optional/doc/html/index.html).
```
class Ship
{
public:
Ship() : pContainer(nullptr) {}
std::optional<container*> Container()
... | It seems that you are looking for a way to make your code
```
bool info = ship1.pContainer->otherInfo;
```
work even though the `pContainer` may be null.
You can use a sentinel object, which holds some default data:
```
container default_container;
default_container.otherInfo = false; // or whatever the default is... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | One good practice to enforce the checks is to use [`std::optional`](http://en.cppreference.com/w/cpp/utility/optional) or [`boost::optional`](http://www.boost.org/doc/libs/1_63_0/libs/optional/doc/html/index.html).
```
class Ship
{
public:
Ship() : pContainer(nullptr) {}
std::optional<container*> Container()
... | I found an additional solution. It is admittedly not preventing the access of uninitialized objects, but at least the program crashes AND returns an error message, that enables us to correct our mistake. (This solution is particularly for the g++ compiler.)
First of all set the compiler flag `_GLIBCXX_DEBUG`. Then ins... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | It seems that you are looking for a way to make your code
```
bool info = ship1.pContainer->otherInfo;
```
work even though the `pContainer` may be null.
You can use a sentinel object, which holds some default data:
```
container default_container;
default_container.otherInfo = false; // or whatever the default is... | >
> What are good practice options for passing around objects in a program, avoiding accessing non initialized member variables.
>
>
>
Good practice would be to initialize everything in the constructor.
Debatable better practice is to initialize everything in the constructor *and* provide no way of modifying any ... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | I found an additional solution. It is admittedly not preventing the access of uninitialized objects, but at least the program crashes AND returns an error message, that enables us to correct our mistake. (This solution is particularly for the g++ compiler.)
First of all set the compiler flag `_GLIBCXX_DEBUG`. Then ins... | >
> What are good practice options for passing around objects in a program, avoiding accessing non initialized member variables.
>
>
>
Good practice would be to initialize everything in the constructor.
Debatable better practice is to initialize everything in the constructor *and* provide no way of modifying any ... |
42,491,581 | I've a collapsing toolbar with scrim color as my app's primary color.
That's working as expected.
Now I want to get a callback when collapsing toolbar applied scrim color where I want to change the color of title into white. I've tried onOffsetChangeListener. But I need to know at which point scrim color is being appl... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42491581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2277166/"
] | It seems that you are looking for a way to make your code
```
bool info = ship1.pContainer->otherInfo;
```
work even though the `pContainer` may be null.
You can use a sentinel object, which holds some default data:
```
container default_container;
default_container.otherInfo = false; // or whatever the default is... | I found an additional solution. It is admittedly not preventing the access of uninitialized objects, but at least the program crashes AND returns an error message, that enables us to correct our mistake. (This solution is particularly for the g++ compiler.)
First of all set the compiler flag `_GLIBCXX_DEBUG`. Then ins... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.