qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
33,095,072 | How can I launch a new Activity to a Fragment that is not the initial fragment? For example, the following code is wrong. I want to launch the MainActivity.class AT the SecondFragment.class. Seems simple enough but cannot find an answer anywhere. All help is greatly appreciated!
```
public void LaunchSecondFragment(Vi... | 2015/10/13 | [
"https://Stackoverflow.com/questions/33095072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4950598/"
] | So, before starting an activity you have to do something like:
```
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("launchSecondFragment", true)
startActivity(intent)
```
and in your MainActivity onCreate()
```
if(getIntent().getBooleanExtra("launchSecondFragment", false)) {
//do fragment tran... | When user clicks button and your `MainActivity` opens, its `onCreate()` will be get called.
You should add fragment transaction in `onCreate()` to launch `SecondFragment` :
```
FragmentTransaction ft = getFragmentManager().beginTransaction();
SecondFragment secondFragment = new SecondFragment();
ft.replace(R.id.cont... |
33,095,072 | How can I launch a new Activity to a Fragment that is not the initial fragment? For example, the following code is wrong. I want to launch the MainActivity.class AT the SecondFragment.class. Seems simple enough but cannot find an answer anywhere. All help is greatly appreciated!
```
public void LaunchSecondFragment(Vi... | 2015/10/13 | [
"https://Stackoverflow.com/questions/33095072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4950598/"
] | Try this to start the activity:
```
Intent intent = new Intent(this, MainActivity.class);
int fragmentIndex = 2;
intent.putExtra("fragment_index", fragmentIndex);
startActivity(intent);
```
and this for the MainActivity's onCreate
```
Bundle extras = getIntent().getExtras();
int fragmentIndex;
if(extras != null)... | When user clicks button and your `MainActivity` opens, its `onCreate()` will be get called.
You should add fragment transaction in `onCreate()` to launch `SecondFragment` :
```
FragmentTransaction ft = getFragmentManager().beginTransaction();
SecondFragment secondFragment = new SecondFragment();
ft.replace(R.id.cont... |
33,095,072 | How can I launch a new Activity to a Fragment that is not the initial fragment? For example, the following code is wrong. I want to launch the MainActivity.class AT the SecondFragment.class. Seems simple enough but cannot find an answer anywhere. All help is greatly appreciated!
```
public void LaunchSecondFragment(Vi... | 2015/10/13 | [
"https://Stackoverflow.com/questions/33095072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4950598/"
] | So, before starting an activity you have to do something like:
```
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("launchSecondFragment", true)
startActivity(intent)
```
and in your MainActivity onCreate()
```
if(getIntent().getBooleanExtra("launchSecondFragment", false)) {
//do fragment tran... | Try this to start the activity:
```
Intent intent = new Intent(this, MainActivity.class);
int fragmentIndex = 2;
intent.putExtra("fragment_index", fragmentIndex);
startActivity(intent);
```
and this for the MainActivity's onCreate
```
Bundle extras = getIntent().getExtras();
int fragmentIndex;
if(extras != null)... |
39,787,004 | ```
<%
if(session == null) {
System.out.println("Expire");
response.sendRedirect("/login.jsp");
}else{
System.out.println("Not Expire");
}
%>
<%
HttpSession sess = request.getSession(false);
String email = sess.getAttribute("email").toString();
Connection conn = Database.getC... | 2016/09/30 | [
"https://Stackoverflow.com/questions/39787004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5533485/"
] | TimeSpan can be negative. So just substract the TimeSpan for 4PM with current [TimeOfDay](https://msdn.microsoft.com/en-us/library/system.datetime.timeofday), if you get negative value, add 24 hours.
```
var timeLeft = new TimeSpan(16, 0, 0) - DateTime.Now.TimeOfDay;
if (timeLeft.Ticks<0)
{
timeLeft = timeLeft.Ad... | The answer is really simple, I should have seened this earlier. The solution to these kind of problems is basically modular arithmetic. The client requirment was the popup to show 24+ time to next 4 pm (Don't ask i don't know) so if:
program runs at 13:00 then the clock should display 24 +3 = 27
when 16:00 it should ... |
39,787,004 | ```
<%
if(session == null) {
System.out.println("Expire");
response.sendRedirect("/login.jsp");
}else{
System.out.println("Not Expire");
}
%>
<%
HttpSession sess = request.getSession(false);
String email = sess.getAttribute("email").toString();
Connection conn = Database.getC... | 2016/09/30 | [
"https://Stackoverflow.com/questions/39787004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5533485/"
] | Based on your code:
```
DateTime now = DateTime.Now;
DateTime today4pmDateTime= new DateTime(now.Year, now.Month, now.Day, 16, 0, 0);
//Will hold the next 4pm DateTime.
DateTime next4pmDateTimeOccurrence = now.Hour >= 16 ? today4pmDateTime : today4pmDateTime.AddDays(1);
//From here you can do all the calculations... | The answer is really simple, I should have seened this earlier. The solution to these kind of problems is basically modular arithmetic. The client requirment was the popup to show 24+ time to next 4 pm (Don't ask i don't know) so if:
program runs at 13:00 then the clock should display 24 +3 = 27
when 16:00 it should ... |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | Try simplifying it a little bit:
```
print htmlentities(file_get_contents("http://www.arstechnica.com"));
```
The above outputs instantly on my webserver. If it doesn't on yours, there's a good chance your web host has some kind of setting in place to throttle these kind of requests.
**EDIT**:
Since the above happ... | If my memory doesn't fails me doing a HEAD request in CURL changes the HTTP protocol version to 1.0 (which is slow and probably the guilty part here) try changing that to:
```
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT... |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | Try simplifying it a little bit:
```
print htmlentities(file_get_contents("http://www.arstechnica.com"));
```
The above outputs instantly on my webserver. If it doesn't on yours, there's a good chance your web host has some kind of setting in place to throttle these kind of requests.
**EDIT**:
Since the above happ... | You have to remember that HEAD is only a suggestion to the web server. For HEAD to do the right thing it often takes some explicit effort on the part of the admins. If you HEAD a static file Apache (or whatever your webserver is) will often step in an do the right thing. If you HEAD a dynamic page, the default for most... |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | Try simplifying it a little bit:
```
print htmlentities(file_get_contents("http://www.arstechnica.com"));
```
The above outputs instantly on my webserver. If it doesn't on yours, there's a good chance your web host has some kind of setting in place to throttle these kind of requests.
**EDIT**:
Since the above happ... | This:
```
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
```
I wasn't trying to get headers.
I was just trying to make the page load of some data not take 2 minutes similar to described above.
That magical little options has dropped it down to 2 seconds. |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | Try simplifying it a little bit:
```
print htmlentities(file_get_contents("http://www.arstechnica.com"));
```
The above outputs instantly on my webserver. If it doesn't on yours, there's a good chance your web host has some kind of setting in place to throttle these kind of requests.
**EDIT**:
Since the above happ... | I used the below function to find out the redirected URL.
```
$head = get_headers($url, 1);
```
The second argument makes it return an array with keys. For e.g. the below will give the `Location` value.
```
$head["Location"]
```
<http://php.net/manual/en/function.get-headers.php> |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | You have to remember that HEAD is only a suggestion to the web server. For HEAD to do the right thing it often takes some explicit effort on the part of the admins. If you HEAD a static file Apache (or whatever your webserver is) will often step in an do the right thing. If you HEAD a dynamic page, the default for most... | If my memory doesn't fails me doing a HEAD request in CURL changes the HTTP protocol version to 1.0 (which is slow and probably the guilty part here) try changing that to:
```
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT... |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | If my memory doesn't fails me doing a HEAD request in CURL changes the HTTP protocol version to 1.0 (which is slow and probably the guilty part here) try changing that to:
```
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT... | This:
```
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
```
I wasn't trying to get headers.
I was just trying to make the page load of some data not take 2 minutes similar to described above.
That magical little options has dropped it down to 2 seconds. |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | You have to remember that HEAD is only a suggestion to the web server. For HEAD to do the right thing it often takes some explicit effort on the part of the admins. If you HEAD a static file Apache (or whatever your webserver is) will often step in an do the right thing. If you HEAD a dynamic page, the default for most... | This:
```
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
```
I wasn't trying to get headers.
I was just trying to make the page load of some data not take 2 minutes similar to described above.
That magical little options has dropped it down to 2 seconds. |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | You have to remember that HEAD is only a suggestion to the web server. For HEAD to do the right thing it often takes some explicit effort on the part of the admins. If you HEAD a static file Apache (or whatever your webserver is) will often step in an do the right thing. If you HEAD a dynamic page, the default for most... | I used the below function to find out the redirected URL.
```
$head = get_headers($url, 1);
```
The second argument makes it return an array with keys. For e.g. the below will give the `Location` value.
```
$head["Location"]
```
<http://php.net/manual/en/function.get-headers.php> |
770,179 | I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.
For example, requesting `http://www.arstechnica.com` takes about two minutes. I've tried the same request using another web site that does the same basic t... | 2009/04/20 | [
"https://Stackoverflow.com/questions/770179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | I used the below function to find out the redirected URL.
```
$head = get_headers($url, 1);
```
The second argument makes it return an array with keys. For e.g. the below will give the `Location` value.
```
$head["Location"]
```
<http://php.net/manual/en/function.get-headers.php> | This:
```
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
```
I wasn't trying to get headers.
I was just trying to make the page load of some data not take 2 minutes similar to described above.
That magical little options has dropped it down to 2 seconds. |
41,292,734 | First off, this is my first post, so if I incorrectly posted this in the wrong location, please let me know.
So, what we're trying to accomplish is building a powershell script that we can throw on our workstation image so that once our Windows 10 boxes are done imaging, that we can click on a powershell script, have... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41292734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7332516/"
] | Two things as per my observation:
```
(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey | out-file c:\license.txt
```
I don't think that it is returning any value to your license.txt.
If yes, then I would like you to see if there is any space before and after the license key. You... | Found out that the key from `Get-WmiObject` has whitespace on the end. The original command will work if a `.Trim()` is added. Also not running as administrator will result in the same error.
```
(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey | out-file c:\license.txt
$computer ... |
23,567,099 | I have an query related to straight join the query is correct but showing error
```
SELECT table112.id,table112.bval1,table112.bval2,
table111.id,table111.aval1
FROM table112
STRAIGHT_JOIN table111;
```
Showing an error can anybody help out this | 2014/05/09 | [
"https://Stackoverflow.com/questions/23567099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3612276/"
] | There is missing the join condition.
```
SELECT table112.id,table112.bval1,table112.bval2,
table111.id,table111.aval1
FROM table112
STRAIGHT_JOIN table111 ON table112.id = table111.id
``` | ```
SELECT table112.id, table112.bval1, table112.bval2, table111.id,table111.aval1 FROM table112
```
That is not a join
```
Select * from table112 join table111 ON table112.id = table111.id
```
That is how a join works.
What are you trying to do? I might be able to help more than. |
35,219,203 | ```
import iAd
@IBOutlet weak var Banner: ADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
Banner.hidden = true
Banner.delegate = self
self.canDisplayBannerAds = true
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
return true... | 2016/02/05 | [
"https://Stackoverflow.com/questions/35219203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3843135/"
] | Your connection string looks like it's not in line with what's specified in the [documentation](https://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx).
Try changing your connection string from:
```
"jdbc:sqlserver://localhost:1433;sa;VMADMIN#123;"
```
To:
```
"jdbc:sqlserver://localhost:1433;user=sa;p... | try this it will definitely work
```
Connection con = DriverManager
.getConnection("jdbc:sqlserver://localhost:1433;databaseName=<name of your database>;user=sa;password=VMADMIN#123");
``` |
29,804,680 | I am working with `ViewPager` i.e on top of the `MainActivity` class and the `Viewpager` class extends fragment.
The problem is that, normally when we need a class to return some `result` then while passing the `intent` we use `startActivityforresult(intent,int)` hence it passes the result captured in the secondactivi... | 2015/04/22 | [
"https://Stackoverflow.com/questions/29804680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4578454/"
] | Some suggested improvements:
```
BEGIN {
split("KS .07 MO .08",tmp)
for (i=1;i in tmp;i+=2)
taxRate[tmp[i]] = tmp[i+1]
fmtS = "%12s%s\n"
fmtF = "%12s$%.2f\n"
}
NR>1 {
name=$1" "$2
state=$3
payRate=$4
hoursWorked=$5
overtime=$6
grossPay=(hoursWorked+(overtime*1.5))*payRa... | Thanks to zzevann here's my final code
```
#!/bin/awk -f
#Skips the first line
NR==1{next;}
{
name=$1" "$2
state=$3
payRate=$4
hoursWorked=$5
overtime=$6
grossPay=(hoursWorked+(overtime*1.5))*payRate
if (state == "KS")
tax = grossPay* .07
... |
6,030,137 | I am trying to build a WCF service that allows me to send large binary files from clients to the service.
However I am only able to successfully transfer files up to 3-4MB. (I fail when I try to transfer 4.91MB and, off course, anything beyond)
**The Error I get if I try to send the 4.91MB file is:**
**Exception Mes... | 2011/05/17 | [
"https://Stackoverflow.com/questions/6030137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/402186/"
] | *(While I agree that [streaming transfer](http://msdn.microsoft.com/en-us/library/ms789010.aspx) would be preferrable, the below should make it work without any other changes)*
You also need to increase the maximum message length in the Web.config:
```
<configuration>
<system.web>
<httpRuntime maxMessageLength="4... | Have you had a look at using Streaming Transfer?
>
> Windows Communication Foundation (WCF)
> can send messages using either
> buffered or streamed transfers. In the
> default buffered-transfer mode, a
> message must be completely delivered
> before a receiver can read it. In
> streaming transfer mode, the rec... |
6,030,137 | I am trying to build a WCF service that allows me to send large binary files from clients to the service.
However I am only able to successfully transfer files up to 3-4MB. (I fail when I try to transfer 4.91MB and, off course, anything beyond)
**The Error I get if I try to send the 4.91MB file is:**
**Exception Mes... | 2011/05/17 | [
"https://Stackoverflow.com/questions/6030137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/402186/"
] | As pointed out, try using [Streaming Transfer](http://msdn.microsoft.com/en-us/library/ms789010.aspx), here's some example code showing both sending and receiving (possibly) large amounts of data using streamed transfer.
Use a **binding** like this, notice the `MaxReceivedMessageSize` and `TranferMode` settings.
```
... | Have you had a look at using Streaming Transfer?
>
> Windows Communication Foundation (WCF)
> can send messages using either
> buffered or streamed transfers. In the
> default buffered-transfer mode, a
> message must be completely delivered
> before a receiver can read it. In
> streaming transfer mode, the rec... |
6,030,137 | I am trying to build a WCF service that allows me to send large binary files from clients to the service.
However I am only able to successfully transfer files up to 3-4MB. (I fail when I try to transfer 4.91MB and, off course, anything beyond)
**The Error I get if I try to send the 4.91MB file is:**
**Exception Mes... | 2011/05/17 | [
"https://Stackoverflow.com/questions/6030137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/402186/"
] | Have you had a look at using Streaming Transfer?
>
> Windows Communication Foundation (WCF)
> can send messages using either
> buffered or streamed transfers. In the
> default buffered-transfer mode, a
> message must be completely delivered
> before a receiver can read it. In
> streaming transfer mode, the rec... | I'll echo what others have said and say that using a Streaming Transfer is the way to go when using Windows Communication Foundation. Below is an excellent guide that explains all of the steps in order to stream files over WCF. It's quite comprehensive and very informative.
Here it is: [Guide on Streaming Files over W... |
6,030,137 | I am trying to build a WCF service that allows me to send large binary files from clients to the service.
However I am only able to successfully transfer files up to 3-4MB. (I fail when I try to transfer 4.91MB and, off course, anything beyond)
**The Error I get if I try to send the 4.91MB file is:**
**Exception Mes... | 2011/05/17 | [
"https://Stackoverflow.com/questions/6030137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/402186/"
] | *(While I agree that [streaming transfer](http://msdn.microsoft.com/en-us/library/ms789010.aspx) would be preferrable, the below should make it work without any other changes)*
You also need to increase the maximum message length in the Web.config:
```
<configuration>
<system.web>
<httpRuntime maxMessageLength="4... | As pointed out, try using [Streaming Transfer](http://msdn.microsoft.com/en-us/library/ms789010.aspx), here's some example code showing both sending and receiving (possibly) large amounts of data using streamed transfer.
Use a **binding** like this, notice the `MaxReceivedMessageSize` and `TranferMode` settings.
```
... |
6,030,137 | I am trying to build a WCF service that allows me to send large binary files from clients to the service.
However I am only able to successfully transfer files up to 3-4MB. (I fail when I try to transfer 4.91MB and, off course, anything beyond)
**The Error I get if I try to send the 4.91MB file is:**
**Exception Mes... | 2011/05/17 | [
"https://Stackoverflow.com/questions/6030137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/402186/"
] | *(While I agree that [streaming transfer](http://msdn.microsoft.com/en-us/library/ms789010.aspx) would be preferrable, the below should make it work without any other changes)*
You also need to increase the maximum message length in the Web.config:
```
<configuration>
<system.web>
<httpRuntime maxMessageLength="4... | I'll echo what others have said and say that using a Streaming Transfer is the way to go when using Windows Communication Foundation. Below is an excellent guide that explains all of the steps in order to stream files over WCF. It's quite comprehensive and very informative.
Here it is: [Guide on Streaming Files over W... |
6,030,137 | I am trying to build a WCF service that allows me to send large binary files from clients to the service.
However I am only able to successfully transfer files up to 3-4MB. (I fail when I try to transfer 4.91MB and, off course, anything beyond)
**The Error I get if I try to send the 4.91MB file is:**
**Exception Mes... | 2011/05/17 | [
"https://Stackoverflow.com/questions/6030137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/402186/"
] | As pointed out, try using [Streaming Transfer](http://msdn.microsoft.com/en-us/library/ms789010.aspx), here's some example code showing both sending and receiving (possibly) large amounts of data using streamed transfer.
Use a **binding** like this, notice the `MaxReceivedMessageSize` and `TranferMode` settings.
```
... | I'll echo what others have said and say that using a Streaming Transfer is the way to go when using Windows Communication Foundation. Below is an excellent guide that explains all of the steps in order to stream files over WCF. It's quite comprehensive and very informative.
Here it is: [Guide on Streaming Files over W... |
4,608,257 | I evaluated the integral as follow, $$\int\_0^\pi \cos^3x dx=\int\_0^\pi(1-\sin^2x)\cos xdx$$
Here I used the substitution $u=\sin x$ and $du=\cos x dx$ and for $x\in [0,\pi]$ we have $\sin x\in [0,1]$ Hence the integral is,
$$\int\_0^11-u^2du=u-\frac{u^3}3\large\vert ^1\_0=\small\frac23$$But the answer I got is wrong ... | 2022/12/30 | [
"https://math.stackexchange.com/questions/4608257",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/794843/"
] | The substitution rule can only be applied if the substitution is by a monotonous function. This is not the case for the sine on $[0,\pi]$. You would have to split the domain and apply the substitution rule separately on the intervals $[0,\frac\pi2]$ and $[\frac\pi2,\pi]$.
In the other way you computed the primitive or... | Else Use $\int\_{0}^a f(x) dx=\int\_{0}^a f(a-x) dx$
$I=\int\_{0}^{\pi} \cos^3x~ dx=-I \implies 2I =0 \implies I=0$ |
44,887,617 | I'm trying to make a code that's verified if someone (1) is checking out his name but it does not really
```
<?php if($usrn['verified'] == 1): { ?>
<i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i>
<?php } endif; ?>
<?php
$usern ... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44887617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8248870/"
] | Those "3 Dots" are the "Overflow" menu, and is created when you establish a menu using a file in the menu resources directory.
If you have buttons or functionality you are wanting to expose via you action bar, you will need to have the overflow buttons (or instead, you can choose to have your buttons exposed at the to... | I think you are speaking about the [options menu](https://developer.android.com/guide/topics/ui/menus.html#options-menu), to get rid of it remove the override of the method onCreateOptionsMenu |
44,887,617 | I'm trying to make a code that's verified if someone (1) is checking out his name but it does not really
```
<?php if($usrn['verified'] == 1): { ?>
<i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i>
<?php } endif; ?>
<?php
$usern ... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44887617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8248870/"
] | Just Remove Override Method like this
```
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_and_add, menu);
return true;
}
```
This Override Method is responsible to for creating three dote as you mention it's really `OptionMenu`. If you don't want it, don't ov... | I think you are speaking about the [options menu](https://developer.android.com/guide/topics/ui/menus.html#options-menu), to get rid of it remove the override of the method onCreateOptionsMenu |
44,887,617 | I'm trying to make a code that's verified if someone (1) is checking out his name but it does not really
```
<?php if($usrn['verified'] == 1): { ?>
<i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i>
<?php } endif; ?>
<?php
$usern ... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44887617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8248870/"
] | Those "3 Dots" are the "Overflow" menu, and is created when you establish a menu using a file in the menu resources directory.
If you have buttons or functionality you are wanting to expose via you action bar, you will need to have the overflow buttons (or instead, you can choose to have your buttons exposed at the to... | In your `menu` folder the `xml`file that is used by your activity, change the `app:showAsAction="never"` to `app:showAsAction="always"` or some other you can see the options that are availabe by pressing `ctrl+space`.
Or else to get rid of it completely just remove the whole code and it's corresponding usages. |
44,887,617 | I'm trying to make a code that's verified if someone (1) is checking out his name but it does not really
```
<?php if($usrn['verified'] == 1): { ?>
<i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i>
<?php } endif; ?>
<?php
$usern ... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44887617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8248870/"
] | Just Remove Override Method like this
```
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_and_add, menu);
return true;
}
```
This Override Method is responsible to for creating three dote as you mention it's really `OptionMenu`. If you don't want it, don't ov... | In your `menu` folder the `xml`file that is used by your activity, change the `app:showAsAction="never"` to `app:showAsAction="always"` or some other you can see the options that are availabe by pressing `ctrl+space`.
Or else to get rid of it completely just remove the whole code and it's corresponding usages. |
44,887,617 | I'm trying to make a code that's verified if someone (1) is checking out his name but it does not really
```
<?php if($usrn['verified'] == 1): { ?>
<i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i>
<?php } endif; ?>
<?php
$usern ... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44887617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8248870/"
] | Just Remove Override Method like this
```
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_and_add, menu);
return true;
}
```
This Override Method is responsible to for creating three dote as you mention it's really `OptionMenu`. If you don't want it, don't ov... | Those "3 Dots" are the "Overflow" menu, and is created when you establish a menu using a file in the menu resources directory.
If you have buttons or functionality you are wanting to expose via you action bar, you will need to have the overflow buttons (or instead, you can choose to have your buttons exposed at the to... |
49,438,437 | I am working on this game on checkio.org. Its a python game and this level I need to find the word between two defined delimiters. The function calls them. So far I have done alright but I can't get any more help from google probably because I don't know how to ask for what i need.
Anyways I am stuck and I would like... | 2018/03/22 | [
"https://Stackoverflow.com/questions/49438437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | `expand` method is equivalent to flatMap in Dart.
```
[1,2,3].expand((e) => [e, e+1])
```
What is more interesting, the returned `Iterable` is lazy, and calls fuction for each element every time it's iterated. | *Coming from Swift, [`flatMap`](https://developer.apple.com/documentation/swift/sequence/2905332-flatmap) seems to have a little different meaning than the OP needed. This is a supplemental answer.*
Given the following two dimensional list:
```dart
final list = [[1], [2, 2], [3, 3, 3], [4, 4, 4, 4]];
```
You can co... |
18,383,773 | I'm facing the problem described in [this question](https://stackoverflow.com/questions/4031857/way-to-make-java-parent-class-method-return-object-of-child-class) but would like to find a solution (if possible) without all the casts and @SuppressWarning annotations.
A better solution would be one that builds upon the ... | 2013/08/22 | [
"https://Stackoverflow.com/questions/18383773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/586682/"
] | One approach is to define an abstract method `getThis()` in `Parent` class, and make all the `Child` classes override it, returning the `this` reference. This is a way to recover the type of `this` object in a class hierarchy.
The code would look like this:
```
abstract class Parent<T extends Parent<T>> {
protec... | One solution is to override the method in the child class and change the return type to a more specific one, ie. the child type. This requires casting. Instead of using the typical `(Child)` cast, use the [`Class#cast(Object)`](http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#cast%28java.lang.Object%29) me... |
18,383,773 | I'm facing the problem described in [this question](https://stackoverflow.com/questions/4031857/way-to-make-java-parent-class-method-return-object-of-child-class) but would like to find a solution (if possible) without all the casts and @SuppressWarning annotations.
A better solution would be one that builds upon the ... | 2013/08/22 | [
"https://Stackoverflow.com/questions/18383773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/586682/"
] | No cast, no @SuppressWarning, few lines only:
```java
public abstract class SuperClass<T extends SuperClass<T>> {
protected T that;
public T chain() {
return that;
}
}
public class SubClass1 extends SuperClass<SubClass1> {
public SubClass1() {
that = this;
}
}
public class SubClas... | One solution is to override the method in the child class and change the return type to a more specific one, ie. the child type. This requires casting. Instead of using the typical `(Child)` cast, use the [`Class#cast(Object)`](http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#cast%28java.lang.Object%29) me... |
18,383,773 | I'm facing the problem described in [this question](https://stackoverflow.com/questions/4031857/way-to-make-java-parent-class-method-return-object-of-child-class) but would like to find a solution (if possible) without all the casts and @SuppressWarning annotations.
A better solution would be one that builds upon the ... | 2013/08/22 | [
"https://Stackoverflow.com/questions/18383773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/586682/"
] | No cast, no @SuppressWarning, few lines only:
```java
public abstract class SuperClass<T extends SuperClass<T>> {
protected T that;
public T chain() {
return that;
}
}
public class SubClass1 extends SuperClass<SubClass1> {
public SubClass1() {
that = this;
}
}
public class SubClas... | One approach is to define an abstract method `getThis()` in `Parent` class, and make all the `Child` classes override it, returning the `this` reference. This is a way to recover the type of `this` object in a class hierarchy.
The code would look like this:
```
abstract class Parent<T extends Parent<T>> {
protec... |
45,993,468 | I'm using angular 4 and I try to get data from 2 endpoints but I have a problem understanding rxjs.
with this code I can only get list of students and users only.
```
getStudent() {
return this.http.get(this.url + this.student_url, this.getHeaders()).map(res => res.json());
}
getUsers() {
return this.http... | 2017/09/01 | [
"https://Stackoverflow.com/questions/45993468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8525484/"
] | You can use the `switchMap` operator (alias of `flatMap`) in the following code :
```
// Observables mocking the data returned by http.get()
const studentObs = Rx.Observable.from([
{"ID" : 1 , "SchoolCode": "A150", "UserID": 1 },
{"ID" : 5 , "SchoolCode": "A140" , "UserID": 4},
{"ID" : 9 , "SchoolCode": "C140"... | You could try the following:
```
import { forkJoin } from 'rxjs/observable/forkJoin';
interface Student {
id: number;
schoolCode: string;
userId: number;
}
interface User {
id: number;
name: string;
familyName: string;
}
interface Merged {
id: number;
schoolCode: string;
name: string;
familyNam... |
23,130,785 | I have a query as follows
```
SELECT s.`uid` FROM `sessions` s
```
(this was an extended query with a LEFT JOIN but to debug i removed that join)
FYI the full query was
```
SELECT s.`uid`, u.`username`, u.`email` FROM `sessions` s LEFT JOIN `users` u ON s.`uid`=u.`user_id`
```
There are three results in the ses... | 2014/04/17 | [
"https://Stackoverflow.com/questions/23130785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/780128/"
] | You can add a meta tag to your page header to prevent mobile safari turning telephone numbers into links
```
<meta name="format-detection" content="telephone=no">
``` | I believe you can use [`dataDetectorTypes`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIWebView/dataDetectorTypes) to tell the web view what links to ignore.
```
webview.dataDetectorType = UIDataDetectorTypeNone;
```
See the [... |
23,130,785 | I have a query as follows
```
SELECT s.`uid` FROM `sessions` s
```
(this was an extended query with a LEFT JOIN but to debug i removed that join)
FYI the full query was
```
SELECT s.`uid`, u.`username`, u.`email` FROM `sessions` s LEFT JOIN `users` u ON s.`uid`=u.`user_id`
```
There are three results in the ses... | 2014/04/17 | [
"https://Stackoverflow.com/questions/23130785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/780128/"
] | You can add a meta tag to your page header to prevent mobile safari turning telephone numbers into links
```
<meta name="format-detection" content="telephone=no">
``` | You can put the text-decoration:none in that class also. |
23,130,785 | I have a query as follows
```
SELECT s.`uid` FROM `sessions` s
```
(this was an extended query with a LEFT JOIN but to debug i removed that join)
FYI the full query was
```
SELECT s.`uid`, u.`username`, u.`email` FROM `sessions` s LEFT JOIN `users` u ON s.`uid`=u.`user_id`
```
There are three results in the ses... | 2014/04/17 | [
"https://Stackoverflow.com/questions/23130785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/780128/"
] | You can add a meta tag to your page header to prevent mobile safari turning telephone numbers into links
```
<meta name="format-detection" content="telephone=no">
``` | Remove text decorations.
```
<span text-decorations="none" class="order1-button">999-120-9191</span>
``` |
23,130,785 | I have a query as follows
```
SELECT s.`uid` FROM `sessions` s
```
(this was an extended query with a LEFT JOIN but to debug i removed that join)
FYI the full query was
```
SELECT s.`uid`, u.`username`, u.`email` FROM `sessions` s LEFT JOIN `users` u ON s.`uid`=u.`user_id`
```
There are three results in the ses... | 2014/04/17 | [
"https://Stackoverflow.com/questions/23130785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/780128/"
] | I believe you can use [`dataDetectorTypes`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIWebView/dataDetectorTypes) to tell the web view what links to ignore.
```
webview.dataDetectorType = UIDataDetectorTypeNone;
```
See the [... | Remove text decorations.
```
<span text-decorations="none" class="order1-button">999-120-9191</span>
``` |
23,130,785 | I have a query as follows
```
SELECT s.`uid` FROM `sessions` s
```
(this was an extended query with a LEFT JOIN but to debug i removed that join)
FYI the full query was
```
SELECT s.`uid`, u.`username`, u.`email` FROM `sessions` s LEFT JOIN `users` u ON s.`uid`=u.`user_id`
```
There are three results in the ses... | 2014/04/17 | [
"https://Stackoverflow.com/questions/23130785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/780128/"
] | You can put the text-decoration:none in that class also. | Remove text decorations.
```
<span text-decorations="none" class="order1-button">999-120-9191</span>
``` |
10,701,493 | I need to get div id and its child class name by using div name . But div Id will be different and unique all the time.
**HTML**
```
<div class="diagram" id="12" >
<div class="121">
...
</div>
</div>
<div class="diagram" id="133" >
<div class="33">
...
</div>
</div>
<div class="diagram" id="199" ... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10701493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1383645/"
] | ```
$('div.diagram').each(function() {
// this.id -> get the id of parent i.e div.diagram
// $('div:first', this) -> get the first child of diagram, here this refers to diagram
// $('div:first', this).attr('class') -> get the class name of child div
o.circle(this.id, $('div:first', this).attr('class'));
});
... | You can use this.It is working fine for me.
```
$('div.diagram').on('event_name', function() { // use click, hover, change, focus at the place of event_name whatever you need
o.circle(this.id, $('div:first', this).attr('class'));
});
``` |
19,588,606 | I am using this code to search for a specific file pattern recursively in a given directory:
```
if (file.isDirectory()) {
System.out.println("Searching directory ... "
+ file.getAbsoluteFile());
if (file.canRead()) {
System.out.println("Can read...");
if (file.l... | 2013/10/25 | [
"https://Stackoverflow.com/questions/19588606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1506071/"
] | Try this:
```
if (file.isDirectory()) {
System.out.println("Searching directory ... "
+ file.getAbsoluteFile());
if (file.canRead()) {
System.out.println("Can read...");
if (file.listFiles() == null) {
System.out.println("yes it is null");
... | from javaDoc:
>
>
> ```
> An array of abstract pathnames denoting the files and
> directories in the directory denoted by this abstract
> pathname. The array will be empty if the directory is
> empty. Returns <code>null</code> if this abstract pathname
> does not denote a directory, or if an I/O error occurs.... |
19,588,606 | I am using this code to search for a specific file pattern recursively in a given directory:
```
if (file.isDirectory()) {
System.out.println("Searching directory ... "
+ file.getAbsoluteFile());
if (file.canRead()) {
System.out.println("Can read...");
if (file.l... | 2013/10/25 | [
"https://Stackoverflow.com/questions/19588606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1506071/"
] | ```
if (file.listFiles() == null) {
System.out.println("yes it is null");
continue;
}
```
When you find that the directory does not contain any files then just `continue` to the start of loop and check other directory.
So using this when your logic finds that any directory does not contain any files you ... | from javaDoc:
>
>
> ```
> An array of abstract pathnames denoting the files and
> directories in the directory denoted by this abstract
> pathname. The array will be empty if the directory is
> empty. Returns <code>null</code> if this abstract pathname
> does not denote a directory, or if an I/O error occurs.... |
45,433,817 | I try to make server-side processing for [DataTables](https://datatables.net) using Web API. There are two actions in my Web API controller with same list of parameters:
```
public class CampaignController : ApiController
{
// GET request handler
public dtResponse Get(int draw, int start, int length)
{
... | 2017/08/01 | [
"https://Stackoverflow.com/questions/45433817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7914637/"
] | The only workaround is to get the keycode and cast it to String:
```
var str = '';
var el = document.getElementById('#test');
document.addEventListener('keypress', function(event) {
const currentCode = event.which || event.code;
let currentKey = event.key;
if (!currentKey) {
currentKey = String.fromCharCode(... | Since there is no character representation for control characters like up, down, left or right, you need to hardcode the character implementation in the code itself. I used **Window.event.KeyCode** event from **document.onkeydown** event listener and it works.
Here is my solution:
```
window.onload = function() {
tr... |
177,528 | I downloaded and enabled translations for my Drupal core and modules using these Drush commands:
```
drush dl l10n_update && drush en -y $_
drush language-add lt && drush language-enable $_
drush l10n-update-refresh
drush l10n-update
```
I got almost everything translated, and in "Administration » Configuration » Re... | 2015/10/14 | [
"https://drupal.stackexchange.com/questions/177528",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/50624/"
] | Here is a custom function I use in update hooks, to translate some missing translations, just in case you want to do this programmatically:
```php
function translateString($source_string, $translated_string, $langcode) {
$storage = \Drupal::service('locale.storage');
$string = $storage->findString(array('source' =... | Identify what template it is using with [Themer](https://www.drupal.org/project/devel_themer). Override it and use t() function to wrap those strings needed to be translated. |
177,528 | I downloaded and enabled translations for my Drupal core and modules using these Drush commands:
```
drush dl l10n_update && drush en -y $_
drush language-add lt && drush language-enable $_
drush l10n-update-refresh
drush l10n-update
```
I got almost everything translated, and in "Administration » Configuration » Re... | 2015/10/14 | [
"https://drupal.stackexchange.com/questions/177528",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/50624/"
] | Here is a custom function I use in update hooks, to translate some missing translations, just in case you want to do this programmatically:
```php
function translateString($source_string, $translated_string, $langcode) {
$storage = \Drupal::service('locale.storage');
$string = $storage->findString(array('source' =... | My solution:
I tried Devel Themer module as suggested, but I was not able to find function source to copy and change it for my needs. After unsuccessfull tries to add my translations via template.php and by creating custom tpl.php in templates folder of my theme, I decided to use this method:
>
> *! Before proceedin... |
5,914,978 | I am currently in the planning stages for a fairly comprehensive rewrite of one of our core (commercial) software offerings, and I am looking for a bit of advice.
Our current software is a business management package written in Winforms (originally in .NET 2.0, but has transitioned into 4.0 so far) that communicates d... | 2011/05/06 | [
"https://Stackoverflow.com/questions/5914978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82187/"
] | *(I am working on the assumption that by "stateful" you mean session-based).*
I guess one big question is: Do you want to use SOAP in your messaging stack?
You may be loathe to, as often there is no out-of-box support for SOAP on mobile platforms (see: [How to call a web service with Android](https://stackoverflow.co... | 1) consider stateful utility services using singletons, but keep the request/response pattern at the facade level stateless.
2) consider distributed caching, perhaps Windows Server AppFabric Cache. |
14,530,617 | I am new to CSS/HTML and I am having some trouble adjusting the width of my page. I'm sure the solution is very simple and obvious lol.
On this page: <http://www.bodylogicmd.com/appetites-and-aphrodisiacs> - I am trying to set the width to 100% so that the content spans the entire width of the page. The problem I am ... | 2013/01/25 | [
"https://Stackoverflow.com/questions/14530617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2012426/"
] | ```
#main, #content, .landing-wrapper, #column2 .box2 {width: auto;}
#column2 {width: auto; float: none;}
```
You should be able to place this in the head of your template's index.php, though I would personally add it to the bottom of the theme's main stylesheet. How long it's there isn't a factor. | you need to find the #main selector and set it wider there. The body is always going to be 100% wide unless you explicitly set it otherwise. In your case the #main container is the wrapper around the whole page, this is what you want to set. I'd also recommend looking up the "box model" and understanding how that works... |
14,530,617 | I am new to CSS/HTML and I am having some trouble adjusting the width of my page. I'm sure the solution is very simple and obvious lol.
On this page: <http://www.bodylogicmd.com/appetites-and-aphrodisiacs> - I am trying to set the width to 100% so that the content spans the entire width of the page. The problem I am ... | 2013/01/25 | [
"https://Stackoverflow.com/questions/14530617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2012426/"
] | ```
#main, #content, .landing-wrapper, #column2 .box2 {width: auto;}
#column2 {width: auto; float: none;}
```
You should be able to place this in the head of your template's index.php, though I would personally add it to the bottom of the theme's main stylesheet. How long it's there isn't a factor. | try adding inline .css {width: 100%; (or auto)} to :
- #main
- #content
- .landing-wrapper
- #column2 .box2 |
36,096,204 | How do I create a Custom Hook Method in a Subclass?
No need to duplicate Rails, of course -- the simpler, the better.
My goal is to convert:
```
class SubClass
def do_this_method
first_validate_something
end
def do_that_method
first_validate_something
end
private
def first_validate_something; ... | 2016/03/19 | [
"https://Stackoverflow.com/questions/36096204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5298869/"
] | Here's a solution that uses `prepend`. When you call `before_operations` for the first time it creates a new (empty) module and prepends it to your class. This means that when you call method `foo` on your class, it will look first for that method in the module.
The `before_operations` method then defines simple metho... | You can alias the original method to a different name (so `:do_this_something` becomes `:original_do_this_something`) and then define a new `:do_this_something` method that calls `:first_validate_something` and then the original version of the method Something like this...
```
class ActiveClass
def self.before_opera... |
36,096,204 | How do I create a Custom Hook Method in a Subclass?
No need to duplicate Rails, of course -- the simpler, the better.
My goal is to convert:
```
class SubClass
def do_this_method
first_validate_something
end
def do_that_method
first_validate_something
end
private
def first_validate_something; ... | 2016/03/19 | [
"https://Stackoverflow.com/questions/36096204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5298869/"
] | You can alias the original method to a different name (so `:do_this_something` becomes `:original_do_this_something`) and then define a new `:do_this_something` method that calls `:first_validate_something` and then the original version of the method Something like this...
```
class ActiveClass
def self.before_opera... | This is a way of writing the code that does not make use of aliases. It includes a class method `validate` that specifies the validator method and the methods that are to call the validator method. This method `validate` can be invoked multiple times to change the validator and validatees dynamically.
```
class Activ... |
36,096,204 | How do I create a Custom Hook Method in a Subclass?
No need to duplicate Rails, of course -- the simpler, the better.
My goal is to convert:
```
class SubClass
def do_this_method
first_validate_something
end
def do_that_method
first_validate_something
end
private
def first_validate_something; ... | 2016/03/19 | [
"https://Stackoverflow.com/questions/36096204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5298869/"
] | Here's a solution that uses `prepend`. When you call `before_operations` for the first time it creates a new (empty) module and prepends it to your class. This means that when you call method `foo` on your class, it will look first for that method in the module.
The `before_operations` method then defines simple metho... | This is a way of writing the code that does not make use of aliases. It includes a class method `validate` that specifies the validator method and the methods that are to call the validator method. This method `validate` can be invoked multiple times to change the validator and validatees dynamically.
```
class Activ... |
30,065,899 | I know the logic/syntax of the code at the bottom of this post is off, but I'm having a hard time figuring out how I can write this to get the desired result. The first section creates this dictionary:
```
sco = {'human + big': 0, 'big + loud': 0, 'big + human': 0, 'human + loud': 0, 'loud + big': 0, 'loud + human': 0... | 2015/05/06 | [
"https://Stackoverflow.com/questions/30065899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4652988/"
] | The actual problem is that, instead of adding 1 to the values, you're doubling them:
```
sco[i][1] += sco[i][1]
```
And no matter how many times you add 0 to 0, it's still 0.
To add 1, just use `+= 1`.
---
But you've got another problem, at least in the code you posted. Each `sco[i]` value just a number, not a li... | In addition to what @abarnert replied, Dictionaries behave like this:
```
>>> D1 = { 'thing1': [1,2,3 ], 'thing2': ( 1, 2,3), 'thing3':'123' }
>>> D1['thing1']
#[1, 2, 3]
>>> D1['thing2']
#(1, 2, 3)
>>> D1['thing3']
#'123'
>>> thing4 = 1
>>> D2 = { thing4:D1 }
>>> D2[thing4]
#{'thing1': [1, 2, 3], 'thing2': (1,... |
30,065,899 | I know the logic/syntax of the code at the bottom of this post is off, but I'm having a hard time figuring out how I can write this to get the desired result. The first section creates this dictionary:
```
sco = {'human + big': 0, 'big + loud': 0, 'big + human': 0, 'human + loud': 0, 'loud + big': 0, 'loud + human': 0... | 2015/05/06 | [
"https://Stackoverflow.com/questions/30065899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4652988/"
] | The actual problem is that, instead of adding 1 to the values, you're doubling them:
```
sco[i][1] += sco[i][1]
```
And no matter how many times you add 0 to 0, it's still 0.
To add 1, just use `+= 1`.
---
But you've got another problem, at least in the code you posted. Each `sco[i]` value just a number, not a li... | Solution with using defaultdict and grouping by item in tuple:
```
import itertools
from collections import defaultdict
sho = ('human', 'loud', 'big')
sco = {}
for a, b in itertools.permutations(sho, 2):
sco["{0} + {1}".format(a, b)] = 0
cnt = [('human', 'ron g.'), ('loud', 'ron g.'), ('big', 'kim p.'), ('human', ... |
17,143,401 | What I'm having is that this error is displayed when I wanted to copy a exe debug project that I have created (which works witout any problems) to another machine (the error message is displayed).
According to the [question posted previously](https://stackoverflow.com/questions/7904213/msvcp100d-dll-missing), the best... | 2013/06/17 | [
"https://Stackoverflow.com/questions/17143401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2441175/"
] | MSVCP100.dll is part of the Microsoft Visual Studio 10 runtime. MSVCP100d.dll is the debug build of the same dll - useful for running your program in debug mode.
<http://www.microsoft.com/en-us/download/details.aspx?id=5555>
Basically it is a relatively new package and is not guaranteed to be on all systems, especial... | MSVCP100D.dll and MSVCP100.dll is part of the Microsoft Visual Studio 10 runtime, so if someone compile her/his programs with this package, then uninstall the package and install another one for example Microsoft Visual Studio 12 (2013).
When trying to run her/his programs , then her/his will get the message that 'so ... |
17,143,401 | What I'm having is that this error is displayed when I wanted to copy a exe debug project that I have created (which works witout any problems) to another machine (the error message is displayed).
According to the [question posted previously](https://stackoverflow.com/questions/7904213/msvcp100d-dll-missing), the best... | 2013/06/17 | [
"https://Stackoverflow.com/questions/17143401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2441175/"
] | You've probably added include paths for OpenCV to your project file. Unfortunately, Visual Studio by default makes such changes ONLY to the active configuration, which in your case was debug.
This rarely makes sense. Adding a logging library would be such a rare case, but you probably needs OpenCV in both debug and r... | MSVCP100D.dll and MSVCP100.dll is part of the Microsoft Visual Studio 10 runtime, so if someone compile her/his programs with this package, then uninstall the package and install another one for example Microsoft Visual Studio 12 (2013).
When trying to run her/his programs , then her/his will get the message that 'so ... |
40,298,290 | In MSDN, "For **reference types**, an explicit cast is required if you need to convert from a base type to a derived type".
In wiki, "In programming language theory, a **reference type is a data type that refers to an object in memory**. A pointer type on the other hand refers to a memory address. Reference types can... | 2016/10/28 | [
"https://Stackoverflow.com/questions/40298290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3902173/"
] | First of all don't try to write all your code in a single statement. Its is easier to debug using multiple statements:
```
itemCode.setText((String)showItem.getValueAt(showItem.getSelectedRow(), 0));
```
Can easily be written as:
```
Object value = showItem.getValueAt(rowCount, 0);
itemCode.setText( value.toString(... | Maybe you should check this.
[How do I convert from int to String?](https://stackoverflow.com/questions/4105331/how-do-i-convert-from-int-to-string)
for
```
itemCode.setText((String)showItem.getValueAt(showItem.getSelectedRow(), 0));
``` |
40,298,290 | In MSDN, "For **reference types**, an explicit cast is required if you need to convert from a base type to a derived type".
In wiki, "In programming language theory, a **reference type is a data type that refers to an object in memory**. A pointer type on the other hand refers to a memory address. Reference types can... | 2016/10/28 | [
"https://Stackoverflow.com/questions/40298290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3902173/"
] | First of all don't try to write all your code in a single statement. Its is easier to debug using multiple statements:
```
itemCode.setText((String)showItem.getValueAt(showItem.getSelectedRow(), 0));
```
Can easily be written as:
```
Object value = showItem.getValueAt(rowCount, 0);
itemCode.setText( value.toString(... | You can't cast an `Integer` to `String`, because `Integer` *is not* a `String`, that is, `Integer` is not a subclass of `String`. However, you can pass the `Integer` to a `String`, since all `Object` have the `toString()` method.
```java
Integer a = new Integer( 10 );
String myString = "" + a;
//Is the same as String... |
7,900 | [The Axis of Awesome](http://en.wikipedia.org/wiki/The_Axis_of_Awesome) has a song called "4 Chords", a medley of various songs all written, or so it's claimed, using the same four chords.
Now, from what I understand, a chord is just a bunch of tones played at the same time so they sound like one. For example, a 300 H... | 2012/11/27 | [
"https://music.stackexchange.com/questions/7900",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/400/"
] | **tl;dr - your definition of chord is wrong.**
Your initial assumption
>
> a 300 Hz note and a 500 Hz note played simultaneously will be a 100
> Hz sound
>
>
>
is unfortunately incorrect.
When you play a 300Hz note and a 500Hz note what you will get is a 300Hz note, and a 500Hz note, **and** a 200Hz note (the ... | Well, I don't know about all this hertz stuff, that's never interested me as a musician. A chord is a harmony that is created with a SET of usually three or four different notes (tones) that are not repeated. It does not matter which order you play them as long as they are played simulataneously.
Now sometimes a band... |
7,900 | [The Axis of Awesome](http://en.wikipedia.org/wiki/The_Axis_of_Awesome) has a song called "4 Chords", a medley of various songs all written, or so it's claimed, using the same four chords.
Now, from what I understand, a chord is just a bunch of tones played at the same time so they sound like one. For example, a 300 H... | 2012/11/27 | [
"https://music.stackexchange.com/questions/7900",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/400/"
] | The chords are I, IV, V, and vi (not in that order) which together contain every note in the key. So any extra notes could be considered to be part of one of those chords. Regardless though the idea is not that the keyboardist plays only a specific set of notes. It's that four chords (in the broader sense Dr Mayhem men... | Well, I don't know about all this hertz stuff, that's never interested me as a musician. A chord is a harmony that is created with a SET of usually three or four different notes (tones) that are not repeated. It does not matter which order you play them as long as they are played simulataneously.
Now sometimes a band... |
56,606,827 | Currently working on a very basic three table/model problem in Laravel and the proper Eloquent setup has my brain leaking.
COLLECTION -> coll\_id, ...
ITEM -> item\_id, coll\_id, type\_id, ...
TYPE -> type\_id, ...
I can phrase it a thousand ways but cannot begin to conceptualize the appropriate Eloquent relationsh... | 2019/06/15 | [
"https://Stackoverflow.com/questions/56606827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11558094/"
] | `HasManyThrough` isn't the right relationship between Collection and Type. `HasManyThrough` is kind of like chaining 2 `HasMany` relationships together:
```
Country -> State -> City
```
Notice how the arrows all go one way. That's because City has a foreign key to State, and State has a foreign key to Country.
Your... | You can call the item first then get the item type through your relationship.
```
public function getCollectionOfItemsBaseOnType($type){
$collections = Collection::all();
$items = [];
foreach($collections as $collection){
if($collection->item->type == $type){
array_push($items, $collection->item);
... |
58,545,828 | I know that JAWS, by default, will ignore `<span/>` tags. My team got around that issue. Now, however, we have some content that is displayed using `<span/>` tags where the text displayed for sighted users doesn't play well with JAWS reading the information out. In our specific case, it would be international bank acco... | 2019/10/24 | [
"https://Stackoverflow.com/questions/58545828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/394484/"
] | The technical answer is always the same, and has been repeated many times here and elsewhere: **aria-label has no effect if you don't also assign a role**.
Now, for the more user experience question, I'm blind myself, and I can tell you, it may not be a good idea to force a spell out of each digit individually.
* We ... | Quentin has given a very good answer that covers 99.9% of all scenarios.
However there are some less proficient screen reader users who may benefit from having things read back letter by letter.
**This should be an optional toggle on the field.**
The way to implement a letter by letter read out is as follows but *... |
44,878,541 | I have a few activities:
* Splash screen
* Login
* Registration
* Dashboard
If the user has never logged in, it will go like this:
>
> Splash screen > Login > Registration > Dashboard
>
>
>
When I `back` from the Dashboard, it should exit the app, skipping through the other activities.
`noHistory` on the Logi... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44878541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1402526/"
] | Java defines two types of streams, byte and character.
The main reason why System.out.println() can't show Unicode characters is that System.out.println() is a byte stream that deal with only the low-order eight bits of character which is 16-bits.
In order to deal with Unicode characters(16-bit Unicode character), yo... | try to use utf8 character set -
```
Charset utf8 = Charset.forName("UTF-8");
Charset def = Charset.defaultCharset();
String charToPrint = "u0905";
byte[] bytes = charToPrint.getBytes("UTF-8");
String message = new String(bytes , def.name());
PrintStream printStream =... |
44,878,541 | I have a few activities:
* Splash screen
* Login
* Registration
* Dashboard
If the user has never logged in, it will go like this:
>
> Splash screen > Login > Registration > Dashboard
>
>
>
When I `back` from the Dashboard, it should exit the app, skipping through the other activities.
`noHistory` on the Logi... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44878541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1402526/"
] | try to use utf8 character set -
```
Charset utf8 = Charset.forName("UTF-8");
Charset def = Charset.defaultCharset();
String charToPrint = "u0905";
byte[] bytes = charToPrint.getBytes("UTF-8");
String message = new String(bytes , def.name());
PrintStream printStream =... | I ran into the same problem wiht Eclipse. I solved my problem by switching the Encoding format for the console from ISO-8859-1 to UTF-8. You can do in the Run/Run Configurations/Common menu.
<https://eclipsesource.com/blogs/2013/02/21/pro-tip-unicode-characters-in-the-eclipse-console/> |
44,878,541 | I have a few activities:
* Splash screen
* Login
* Registration
* Dashboard
If the user has never logged in, it will go like this:
>
> Splash screen > Login > Registration > Dashboard
>
>
>
When I `back` from the Dashboard, it should exit the app, skipping through the other activities.
`noHistory` on the Logi... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44878541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1402526/"
] | try to use utf8 character set -
```
Charset utf8 = Charset.forName("UTF-8");
Charset def = Charset.defaultCharset();
String charToPrint = "u0905";
byte[] bytes = charToPrint.getBytes("UTF-8");
String message = new String(bytes , def.name());
PrintStream printStream =... | Unicode is a unique code which is used to print any character or symbol.
You can use unicode from --> <https://unicode-table.com/en/>
Below is an example for printing a symbol in Java.
```
package Basics;
/**
*
* @author shelc
*/
public class StringUnicode {
... |
44,878,541 | I have a few activities:
* Splash screen
* Login
* Registration
* Dashboard
If the user has never logged in, it will go like this:
>
> Splash screen > Login > Registration > Dashboard
>
>
>
When I `back` from the Dashboard, it should exit the app, skipping through the other activities.
`noHistory` on the Logi... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44878541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1402526/"
] | Java defines two types of streams, byte and character.
The main reason why System.out.println() can't show Unicode characters is that System.out.println() is a byte stream that deal with only the low-order eight bits of character which is 16-bits.
In order to deal with Unicode characters(16-bit Unicode character), yo... | Your `myString` variable contains the perfectly correct value. The problem must be the output from `System.out.println(myString)` which has to send some bytes to some output to show the glyphs that you want to see.
`System.out` is a PrintStream using the "platform default encoding" to convert characters to byte sequen... |
44,878,541 | I have a few activities:
* Splash screen
* Login
* Registration
* Dashboard
If the user has never logged in, it will go like this:
>
> Splash screen > Login > Registration > Dashboard
>
>
>
When I `back` from the Dashboard, it should exit the app, skipping through the other activities.
`noHistory` on the Logi... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44878541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1402526/"
] | Your `myString` variable contains the perfectly correct value. The problem must be the output from `System.out.println(myString)` which has to send some bytes to some output to show the glyphs that you want to see.
`System.out` is a PrintStream using the "platform default encoding" to convert characters to byte sequen... | I ran into the same problem wiht Eclipse. I solved my problem by switching the Encoding format for the console from ISO-8859-1 to UTF-8. You can do in the Run/Run Configurations/Common menu.
<https://eclipsesource.com/blogs/2013/02/21/pro-tip-unicode-characters-in-the-eclipse-console/> |
44,878,541 | I have a few activities:
* Splash screen
* Login
* Registration
* Dashboard
If the user has never logged in, it will go like this:
>
> Splash screen > Login > Registration > Dashboard
>
>
>
When I `back` from the Dashboard, it should exit the app, skipping through the other activities.
`noHistory` on the Logi... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44878541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1402526/"
] | Your `myString` variable contains the perfectly correct value. The problem must be the output from `System.out.println(myString)` which has to send some bytes to some output to show the glyphs that you want to see.
`System.out` is a PrintStream using the "platform default encoding" to convert characters to byte sequen... | Unicode is a unique code which is used to print any character or symbol.
You can use unicode from --> <https://unicode-table.com/en/>
Below is an example for printing a symbol in Java.
```
package Basics;
/**
*
* @author shelc
*/
public class StringUnicode {
... |
44,878,541 | I have a few activities:
* Splash screen
* Login
* Registration
* Dashboard
If the user has never logged in, it will go like this:
>
> Splash screen > Login > Registration > Dashboard
>
>
>
When I `back` from the Dashboard, it should exit the app, skipping through the other activities.
`noHistory` on the Logi... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44878541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1402526/"
] | Java defines two types of streams, byte and character.
The main reason why System.out.println() can't show Unicode characters is that System.out.println() is a byte stream that deal with only the low-order eight bits of character which is 16-bits.
In order to deal with Unicode characters(16-bit Unicode character), yo... | I ran into the same problem wiht Eclipse. I solved my problem by switching the Encoding format for the console from ISO-8859-1 to UTF-8. You can do in the Run/Run Configurations/Common menu.
<https://eclipsesource.com/blogs/2013/02/21/pro-tip-unicode-characters-in-the-eclipse-console/> |
44,878,541 | I have a few activities:
* Splash screen
* Login
* Registration
* Dashboard
If the user has never logged in, it will go like this:
>
> Splash screen > Login > Registration > Dashboard
>
>
>
When I `back` from the Dashboard, it should exit the app, skipping through the other activities.
`noHistory` on the Logi... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44878541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1402526/"
] | Java defines two types of streams, byte and character.
The main reason why System.out.println() can't show Unicode characters is that System.out.println() is a byte stream that deal with only the low-order eight bits of character which is 16-bits.
In order to deal with Unicode characters(16-bit Unicode character), yo... | Unicode is a unique code which is used to print any character or symbol.
You can use unicode from --> <https://unicode-table.com/en/>
Below is an example for printing a symbol in Java.
```
package Basics;
/**
*
* @author shelc
*/
public class StringUnicode {
... |
24,662,079 | I am trying to make all the table cells equal to the image size, but for some reason, they won't be set to it.
<http://jsfiddle.net/gzkhW/>
HTML(shortened a bit)
```
<table>
<tr>
<td><img src="http://i.imgur.com/CMu2qnB.png"></td>
<td></td>
<td></td>
<td></td>
<td></td>
... | 2014/07/09 | [
"https://Stackoverflow.com/questions/24662079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077972/"
] | You would like to do these:
1. You can directly select using `.slide`.
2. Check the length of `nextUp` instead.
Try this, seems to be a workaround:
**JS**
```
$('.next').click(function() {
var current = $('.slide');
var nextUp = $('.slide').next('.hello');
if( nextUp.length == 0 ) {
$('div.hell... | You code have some issues. First, `.has` check if the element has descendant that match the selector. You just need to combine the selector to `.hello.slide`.
```
var current = $('.hello.slide');
```
---
You can then reuse that variable to target the next element.
```
var nextUp = current.next('.hello');
```
---... |
24,662,079 | I am trying to make all the table cells equal to the image size, but for some reason, they won't be set to it.
<http://jsfiddle.net/gzkhW/>
HTML(shortened a bit)
```
<table>
<tr>
<td><img src="http://i.imgur.com/CMu2qnB.png"></td>
<td></td>
<td></td>
<td></td>
<td></td>
... | 2014/07/09 | [
"https://Stackoverflow.com/questions/24662079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077972/"
] | You would like to do these:
1. You can directly select using `.slide`.
2. Check the length of `nextUp` instead.
Try this, seems to be a workaround:
**JS**
```
$('.next').click(function() {
var current = $('.slide');
var nextUp = $('.slide').next('.hello');
if( nextUp.length == 0 ) {
$('div.hell... | Here is working fiddle: <http://jsfiddle.net/c4ZNm/10/>
instead of
```
$('.hello').has('.slide')
```
use
```
$('.hello.slide')
```
When there is no more next element, nextUp wont be '', its length will be 0.
I added count to count all .hello divs - 1 for indexication. because :last-child is your "a" tag elemen... |
17,373,866 | I wrote an android library for some UI utilities. I have a function that return ImageView. But, my problem is that I want that the resource of the drawable image, will be in the project that contains the library. I will explain...
I want that the ImageView will always take the drawable with the source name: `R.drawabl... | 2013/06/28 | [
"https://Stackoverflow.com/questions/17373866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1725836/"
] | I found the answer. You need to create a file called `drawables.xml` in the library. Then inside it write:
```
<resource>
<item name="ic_img_logo" type="drawable" />
</resource>
```
Its make fake resource `R.drawable.ic_img_logo`. Then if the project that include the library have drawable called `ic_img_logo`. T... | If the drawable is not in the library, then it's not a resource.
An alternative would be accessing it from the assets, like this:
```
Drawable d = Drawable.createFromStream(getAssets().open(path_in_assets), null);
```
Where the `path_in_assets` would be a constant. |
17,373,866 | I wrote an android library for some UI utilities. I have a function that return ImageView. But, my problem is that I want that the resource of the drawable image, will be in the project that contains the library. I will explain...
I want that the ImageView will always take the drawable with the source name: `R.drawabl... | 2013/06/28 | [
"https://Stackoverflow.com/questions/17373866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1725836/"
] | I found the answer. You need to create a file called `drawables.xml` in the library. Then inside it write:
```
<resource>
<item name="ic_img_logo" type="drawable" />
</resource>
```
Its make fake resource `R.drawable.ic_img_logo`. Then if the project that include the library have drawable called `ic_img_logo`. T... | you have to name the file ic\_img\_logo |
60,817,243 | I have large data files formatted as follows:
```
1 M * 0.86
2 S * 0.81
3 M * 0.68
4 S * 0.53
5 T . 0.40
6 S . 0.34
7 T . 0.25
8 E . 0.36
9 V . 0.32
10 I . 0.26
11 A . 0.17
12 H . 0.15
13 H . 0.12
14 W . 0.14
15 A . 0.16
16 F . 0.13
17 A . 0.12
18 I . 0.12... | 2020/03/23 | [
"https://Stackoverflow.com/questions/60817243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441735/"
] | There are several way to perform this.
One solution is to read the file line by line. I advise you to have a look at this very good [tutorial](https://stackabuse.com/read-a-file-line-by-line-in-python/) on how to read file.
Once you did it, you can try the following:
* Iterate over each line of the file:
+ If the... | Since people are running to answer, this one uses a generator to generate ranges:
```
def find_ranges(fn):
with open(fn) as f:
start = None
for line_no, line in enumerate(f):
if start is None:
if '*' in line:
start = line_no + 1 # start of a range
... |
19,056,546 | I want to create an HTML Message to send an email in PHP.
```
$message = $mess0 . "</br>" . $mess1 . "</br>" . $mess2 . "</br>" . $mes1 . "</br></br>" . $mes2 . "</br>" . $mes23 . "</br></br>" . $mes3 . "</br></br>" . $mes4 . "</br>" . $mes5 . "</br>" . $mes6 . "</br>" . $mes7 . "</br>" . $mes8 . "</br>" . $mes9 ... | 2013/09/27 | [
"https://Stackoverflow.com/questions/19056546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1921872/"
] | Add HTML tags between double quotes.
```
$message = "<html><body><p>".$message."</p></body></html>";
``` | Where are the double quotes see below
```
$message = "<html><body><p>$message</p></body></html>";
``` |
19,056,546 | I want to create an HTML Message to send an email in PHP.
```
$message = $mess0 . "</br>" . $mess1 . "</br>" . $mess2 . "</br>" . $mes1 . "</br></br>" . $mes2 . "</br>" . $mes23 . "</br></br>" . $mes3 . "</br></br>" . $mes4 . "</br>" . $mes5 . "</br>" . $mes6 . "</br>" . $mes7 . "</br>" . $mes8 . "</br>" . $mes9 ... | 2013/09/27 | [
"https://Stackoverflow.com/questions/19056546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1921872/"
] | Add HTML tags between double quotes.
```
$message = "<html><body><p>".$message."</p></body></html>";
``` | There are two possible ways to hold HTML in PHP variable. You can use single quote or double quotes. You also need to put a dot(.) before and after single/double quotes. Your PHP string could be constructed in following two ways:
```
$message = '<html><body><p>'.$message.'</p></body></html>';
```
or like this,
```... |
23,859,259 | I would like to ask a question about "foreach loop" in PHP. Towards the bottom of the code below, the "while" loop accesses elements from an array individually. How can I rewrite the BODY of the while loop using a "foreach" loop?
```
<?php
require_once('MDB2.php');
$db = MDB2::connect("mysql://mk:mk@shark.compa... | 2014/05/25 | [
"https://Stackoverflow.com/questions/23859259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975787/"
] | If you dereference a `char **`, you should get a pointer to `char`. There are no pointers in a `char[3][10]`. They're just not interchangeable.
It works for a one-dimensional `char *` array because the array name implicitly converts to a pointer to the first element in this context, and if you dereference a `char *` y... | A `type**` is by definition a pointer to a pointer, or an array of pointers.
When used in a function declaration, `type[][]` is inteligible with `type**` as in:
```
int main(int argc, char argv[][]) { ...
```
But it is not when declaring variables. When you do this:
```
char var[a][b] = { ... }
```
This is a mat... |
1,300,792 | In Windows I would like to be able to run a script or application that starts an another application and sets its size and location. An example of this would be to run an application/script that starts notepad and tells it to be 800x600 and to be in the top right corner. Does anyone have any ideas regardless of languag... | 2009/08/19 | [
"https://Stackoverflow.com/questions/1300792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143074/"
] | Do you mean something like this:
```
$ xterm -geometry 135x35+0+0
```
which puts an xterm at the top-left of the screen (`+0+0`) and makes it 135 columns by 35 lines? Most X apps take a -geometry argument with the same syntax (though often in pixels, not characters like xterm), and you can obviously put that in a sh... | Some OSs or desktops allow to set the size and location of a window in a config dialog, for example [KDE](http://www.kde.org/). |
1,645,166 | image naturalWidth return zero... that's it, why ?
```
var newimage = new Image();
newimage.src = 'retouche-hr' + newlinkimage.substring(14,17) + '-a.jpg';
var width = newimage.naturalWidth;
alert (width);
```
HELP, i dont know why !
\*\*\* that path is good, the image show up ! | 2009/10/29 | [
"https://Stackoverflow.com/questions/1645166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71830/"
] | I'd guess it's because you're not waiting for the image to load - try this:
```
var newimage = new Image();
newimage.src = 'retouche-hr' + newlinkimage.substring(14,17) + '-a.jpg';
newimage.onload = function()
{
var width = this.naturalWidth;
alert(width);
}
``` | Here is the FINAL WORKING CODE... in case somebody wants to know. It's all a matter of waiting until the images have loaded!
```
<script type="text/javascript">
$(function() {
$("#thumb").jCarouselLite({
btnNext: "#down",
btnPrev: "#up",
vertical: true,
visib... |
1,645,166 | image naturalWidth return zero... that's it, why ?
```
var newimage = new Image();
newimage.src = 'retouche-hr' + newlinkimage.substring(14,17) + '-a.jpg';
var width = newimage.naturalWidth;
alert (width);
```
HELP, i dont know why !
\*\*\* that path is good, the image show up ! | 2009/10/29 | [
"https://Stackoverflow.com/questions/1645166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71830/"
] | I'd guess it's because you're not waiting for the image to load - try this:
```
var newimage = new Image();
newimage.src = 'retouche-hr' + newlinkimage.substring(14,17) + '-a.jpg';
newimage.onload = function()
{
var width = this.naturalWidth;
alert(width);
}
``` | For me the following works ...
```
$('<img src="mypathtotheimage.png"/>').load(function () {
if (!isNotIe8) {
// ie8 need a fix
var image = new Image(); // or document.createElement('img')
var width, height;
image.onload = function () {
width... |
1,645,166 | image naturalWidth return zero... that's it, why ?
```
var newimage = new Image();
newimage.src = 'retouche-hr' + newlinkimage.substring(14,17) + '-a.jpg';
var width = newimage.naturalWidth;
alert (width);
```
HELP, i dont know why !
\*\*\* that path is good, the image show up ! | 2009/10/29 | [
"https://Stackoverflow.com/questions/1645166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71830/"
] | Here is the FINAL WORKING CODE... in case somebody wants to know. It's all a matter of waiting until the images have loaded!
```
<script type="text/javascript">
$(function() {
$("#thumb").jCarouselLite({
btnNext: "#down",
btnPrev: "#up",
vertical: true,
visib... | For me the following works ...
```
$('<img src="mypathtotheimage.png"/>').load(function () {
if (!isNotIe8) {
// ie8 need a fix
var image = new Image(); // or document.createElement('img')
var width, height;
image.onload = function () {
width... |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | How to *skip*, *ignore* and/or *reject* git credentials prompts
===============================================================
The answers above only worked partly for me when using Git-for-Windows: *two* different applications there were vying for my attention from the automated git pull/push scripts:
* git-credent... | ```
GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existing-repo
```
Work for me on Mac. |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | ```
GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existing-repo
```
Work for me on Mac. | Depending on how you're running git, redirecting stdin or stdout so that they are not connected to terminals will stop git from prompting for details and just cause it to error.
This would also allow you to surface errors (or at least logs) to the webservice. |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | In git version 2.3 there's an environment variable `GIT_TERMINAL_PROMPT` which when set to `0` will disable prompting for credentials.
You can get more info about it in `man git` (after updating to git version `2.3`) or in [this blog post on github](https://github.com/blog/1957-git-2-3-has-been-released).
Examples:
... | ```
GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existing-repo
```
Work for me on Mac. |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | In git version 2.3 there's an environment variable `GIT_TERMINAL_PROMPT` which when set to `0` will disable prompting for credentials.
You can get more info about it in `man git` (after updating to git version `2.3`) or in [this blog post on github](https://github.com/blog/1957-git-2-3-has-been-released).
Examples:
... | When you only have control over the git configuration:
```
git config --global credential.helper '!f() { echo quit=1; }; f'
```
Gives
```
$ git clone https://github.com/edx/drf-extensions.git/
Cloning into 'drf-extensions'...
fatal: credential helper '!f() { echo quit=1; }; f' told us to quit
```
The [idea](https... |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | In git version 2.3 there's an environment variable `GIT_TERMINAL_PROMPT` which when set to `0` will disable prompting for credentials.
You can get more info about it in `man git` (after updating to git version `2.3`) or in [this blog post on github](https://github.com/blog/1957-git-2-3-has-been-released).
Examples:
... | Depending on how you're running git, redirecting stdin or stdout so that they are not connected to terminals will stop git from prompting for details and just cause it to error.
This would also allow you to surface errors (or at least logs) to the webservice. |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | How to *skip*, *ignore* and/or *reject* git credentials prompts
===============================================================
The answers above only worked partly for me when using Git-for-Windows: *two* different applications there were vying for my attention from the automated git pull/push scripts:
* git-credent... | Working from git version 1.8.3.1;
`git clone -c core.askPass $echo url/or/path/to/git/repo`
The configuration [`core.askPass`](https://git-scm.com/docs/gitcredentials) works by passing the control of handling credentials to the aforementioned program. However since `$echo` cant do anything except output, the clone at... |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | If you are using ssh authentication, and on linux, then you can create an ssh command replacement to disable this.
Create a file called "sshnoprompt.sh" with:
`ssh -oBatchMode=yes $@`
Make this file executable with `chmod +x sshnoprompt.sh`
Then when starting git:
`GIT_SSH="sshnoprompt.sh" git clone foo@dummyserve... | Working from git version 1.8.3.1;
`git clone -c core.askPass $echo url/or/path/to/git/repo`
The configuration [`core.askPass`](https://git-scm.com/docs/gitcredentials) works by passing the control of handling credentials to the aforementioned program. However since `$echo` cant do anything except output, the clone at... |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | If you are using ssh authentication, and on linux, then you can create an ssh command replacement to disable this.
Create a file called "sshnoprompt.sh" with:
`ssh -oBatchMode=yes $@`
Make this file executable with `chmod +x sshnoprompt.sh`
Then when starting git:
`GIT_SSH="sshnoprompt.sh" git clone foo@dummyserve... | Depending on how you're running git, redirecting stdin or stdout so that they are not connected to terminals will stop git from prompting for details and just cause it to error.
This would also allow you to surface errors (or at least logs) to the webservice. |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | How to *skip*, *ignore* and/or *reject* git credentials prompts
===============================================================
The answers above only worked partly for me when using Git-for-Windows: *two* different applications there were vying for my attention from the automated git pull/push scripts:
* git-credent... | Depending on how you're running git, redirecting stdin or stdout so that they are not connected to terminals will stop git from prompting for details and just cause it to error.
This would also allow you to surface errors (or at least logs) to the webservice. |
544,156 | When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).
How do I make git just fail (preferably with a sensible erro... | 2013/10/06 | [
"https://serverfault.com/questions/544156",
"https://serverfault.com",
"https://serverfault.com/users/109581/"
] | In git version 2.3 there's an environment variable `GIT_TERMINAL_PROMPT` which when set to `0` will disable prompting for credentials.
You can get more info about it in `man git` (after updating to git version `2.3`) or in [this blog post on github](https://github.com/blog/1957-git-2-3-has-been-released).
Examples:
... | How to *skip*, *ignore* and/or *reject* git credentials prompts
===============================================================
The answers above only worked partly for me when using Git-for-Windows: *two* different applications there were vying for my attention from the automated git pull/push scripts:
* git-credent... |
2,963,436 | I have the following:
```
echo time()."<br>";
sleep(1);
echo time()."<br>";
sleep(1);
echo time()."<br>";
```
I wrote the preceding code with intention to echo `time()."<br>"` ln 1,echo `time()."<br>"` ln 4, wait a final second and then echo the final `time()."<br>"`. Altough the time bieng echoed is correct when ... | 2010/06/03 | [
"https://Stackoverflow.com/questions/2963436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/98204/"
] | You have output buffering turned on.
It is more efficient for PHP to buffer up output and write it all to the browser in one go than it is to write the output in small bursts. So PHP will buffer the output and send it all in one go at the end (or once the buffer gets to a certain size).
You can manually flush the buf... | You can usually use `ob_flush()`, but it's definitely not reliable. And unfortunately, there's no other option. |
34,458,383 | Sorry if the Question Title is a bit off, couldn't think of something more descriptive.
So I have 2 Domains: `aaa.com` and `bbb.com`.
I want my second domain `bbb.com` to redirect always to `aaa.com` EXCEPT IF it has a certain path: `bbb.com/ct/:id`
Both domains right now hit the same Heroku App.
So in my `Applicat... | 2015/12/24 | [
"https://Stackoverflow.com/questions/34458383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1609496/"
] | I prefer to do your redirects in an actual controller and not in the route file so you can write a controller spec for it.
```
# app/controllers/application_controller.rb
before_action :redirect_bbb_to_aaa
def redirect_bbb_to_aaa
if request.host == "http://bbb.com"
redirect_to some_aaa_path unless request.url ... | You can create a rack middleware to do the redirects. One such example is here <https://github.com/gbuesing/rack-host-redirect/blob/master/lib/rack/host_redirect.rb>
OR
Use constraint in routes.rb.
Note: I have not tested it.
```
get "*path" => redirect("http://aaa.com"), constraint: lambda { |request| !request.url... |
28,374,712 | I have a class:
```
public class NListingsData : ListingData, IListingData
{
private readonly IMetaDictionaryRepository _metaDictionary;
//Constructor.
public NListingsData(IMetaDictionaryRepository metaDictionary)
{
_metaDictionary = metaDictionary;
}
... | 2015/02/06 | [
"https://Stackoverflow.com/questions/28374712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/475882/"
] | Just add an additional private, parameterless, constructor. This will get picked by Dapper. | In F#, add a
```
[<CliMutable>]
```
attribute to your DTO. |
203,829 | We have a point-of-sale system that was developed using ado.net, our current concern is to make the application real fast in creating transactions (sales). Usually there are no performance concerns with high end PCs but with with low end PCs, the transactions take really slow.
The main concern is on saving transaction... | 2013/07/05 | [
"https://softwareengineering.stackexchange.com/questions/203829",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/79820/"
] | I would like to point out that Entity Framework (full name: [ADO.NET Entity Framework](http://msdn.microsoft.com/en-us/library/bb399572.aspx)) is an ORM (Object Relational Mapper) that uses ADO.NET under the hood for connecting to the database. So the question "should we use ADO.NET or EF?" doesn't really make sense in... | If you are looking for performance stay away from EF. It is the slowest ORM out there and uses a lot of memory to keep the database metadata. Most [benchmarks](http://www.servicestack.net/benchmarks/) out there show that - |
203,829 | We have a point-of-sale system that was developed using ado.net, our current concern is to make the application real fast in creating transactions (sales). Usually there are no performance concerns with high end PCs but with with low end PCs, the transactions take really slow.
The main concern is on saving transaction... | 2013/07/05 | [
"https://softwareengineering.stackexchange.com/questions/203829",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/79820/"
] | If you are looking for performance stay away from EF. It is the slowest ORM out there and uses a lot of memory to keep the database metadata. Most [benchmarks](http://www.servicestack.net/benchmarks/) out there show that - | How necessary is it that each transaction require a database call?
At what point is the db insertion being performed? Is there one call per transaction or is it inserting with every addition to the order causing a major lag throughout the user's interaction?
Can the db call be handled through private HTTP requests to... |
203,829 | We have a point-of-sale system that was developed using ado.net, our current concern is to make the application real fast in creating transactions (sales). Usually there are no performance concerns with high end PCs but with with low end PCs, the transactions take really slow.
The main concern is on saving transaction... | 2013/07/05 | [
"https://softwareengineering.stackexchange.com/questions/203829",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/79820/"
] | I would like to point out that Entity Framework (full name: [ADO.NET Entity Framework](http://msdn.microsoft.com/en-us/library/bb399572.aspx)) is an ORM (Object Relational Mapper) that uses ADO.NET under the hood for connecting to the database. So the question "should we use ADO.NET or EF?" doesn't really make sense in... | You say you are calling a "lot of stored procedures". If every call includes a seperate trip to the database, that is your performance issue, because trips to the database are always expensive, no matter what they do. You should have one stored procedure to save a transaction. If that procedure has to call other proced... |
203,829 | We have a point-of-sale system that was developed using ado.net, our current concern is to make the application real fast in creating transactions (sales). Usually there are no performance concerns with high end PCs but with with low end PCs, the transactions take really slow.
The main concern is on saving transaction... | 2013/07/05 | [
"https://softwareengineering.stackexchange.com/questions/203829",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/79820/"
] | I would like to point out that Entity Framework (full name: [ADO.NET Entity Framework](http://msdn.microsoft.com/en-us/library/bb399572.aspx)) is an ORM (Object Relational Mapper) that uses ADO.NET under the hood for connecting to the database. So the question "should we use ADO.NET or EF?" doesn't really make sense in... | How necessary is it that each transaction require a database call?
At what point is the db insertion being performed? Is there one call per transaction or is it inserting with every addition to the order causing a major lag throughout the user's interaction?
Can the db call be handled through private HTTP requests to... |
203,829 | We have a point-of-sale system that was developed using ado.net, our current concern is to make the application real fast in creating transactions (sales). Usually there are no performance concerns with high end PCs but with with low end PCs, the transactions take really slow.
The main concern is on saving transaction... | 2013/07/05 | [
"https://softwareengineering.stackexchange.com/questions/203829",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/79820/"
] | You say you are calling a "lot of stored procedures". If every call includes a seperate trip to the database, that is your performance issue, because trips to the database are always expensive, no matter what they do. You should have one stored procedure to save a transaction. If that procedure has to call other proced... | How necessary is it that each transaction require a database call?
At what point is the db insertion being performed? Is there one call per transaction or is it inserting with every addition to the order causing a major lag throughout the user's interaction?
Can the db call be handled through private HTTP requests to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.