Unnamed: 0
int64 65
6.03M
| Id
int64 66
6.03M
| Title
stringlengths 10
191
| input
stringlengths 23
4.18k
| output
stringclasses 10
values | Tag_Number
stringclasses 10
values |
---|---|---|---|---|---|
4,935,003 | 4,935,004 |
How can I tell if my mobile network is available or not on the iPhone?
|
<p>i have one application in iphone in which i have to show notification when mobile SIM network is not present .i want also notification when network back .</p>
<p>and how can also i know how much other network available ?</p>
|
iphone
|
[8]
|
5,636,043 | 5,636,044 |
Set Cursor Position in custom edittext
|
<p>I have a custom EditText which is empty and I want to set the cursor position using the co-ordinates(x,y) i get from ontouch event. Wherever I touch i should be able to move the cursor to that position and should be able to type the text from there. Help me out...</p>
|
android
|
[4]
|
4,522,456 | 4,522,457 |
I am looking for an example of DataColumnsWithJoins usage?
|
<p>I am looking for an example of <a href="http://d.android.com/reference/android/provider/ContactsContract.DataColumnsWithJoins.html" rel="nofollow">DataColumnsWithJoins</a> usage? Do you know any?</p>
|
android
|
[4]
|
5,370,796 | 5,370,797 |
Extending a Java class
|
<p>There are two classes </p>
<pre><code>public class Account
{
public Acconut()
{
//constructor
}
}
public class SavingsAccount extends Account
{
}
</code></pre>
<p>while doing the inheritance i have got an error message "cannont find symbol Symbol: constructor Account()" what might be the error in my code...??</p>
|
java
|
[1]
|
2,844,695 | 2,844,696 |
Returning a reference can work?
|
<p>I used to think returning a reference is bad as our returned reference will refer to some garbage value. But this code works (<code>matrix</code> is a class):</p>
<pre><code>const int max_matrix_temp = 7;
matrix&get_matrix_temp()
{
static int nbuf = 0;
static matrix buf[max_matrix_temp];
if(nbuf == max_matrix_temp)
nbuf = 0;
return buf[nbuf++];
}
matrix& operator+(const matrix&arg1, const matrix&arg2)
{
matrix& res = get_matrix_temp();
//...
return res;
}
</code></pre>
<p>What is <code>buf</code> doing here and how does it save us from having garbage values?</p>
|
c++
|
[6]
|
824,671 | 824,672 |
What do I need to add to my .htaccess so <? gets recognised as <?php?
|
<p>It seems my server is not responding to <code><?</code>, and needs <code><?php</code>. How can I make it recognise <code><?</code> as well?</p>
|
php
|
[2]
|
4,914,960 | 4,914,961 |
Assign an additional parameter to the the C# class object
|
<p>I have a method GetProduct, which returns a Product Object and say, i want to return an additional parameter along with the object, how can i implement it? In my below example , how can i return 'isExists '?</p>
<pre><code>public Product GetProduct()
{
---
----
bool isExists = true
return new Product();
}
</code></pre>
<p>I don't want to add that parameter as a property in the Product Class.</p>
<p>Any help on this is much appreciated!</p>
<p>Thanks,
Kan</p>
|
c#
|
[0]
|
4,162,635 | 4,162,636 |
Installing different versions of the same iPhone project?
|
<p>While I'm prototyping games, I frequently need to go back to compare with older versions, to better get a feel of if I'm on the right track or not. But it's a lenghty process to have to check out the old version and re-export everytime I need to check a specific version. It'd be so much smoother if I could simply launch different versions.</p>
<p>How can I have multiple versions of the same project installed on the device?</p>
|
iphone
|
[8]
|
2,884,994 | 2,884,995 |
textview not updating as expected
|
<p>I have multiple <code>TextView</code> and <code>EditText</code> fields in two different activities. When I go to my Edit screen, I can input values and the corresponding <code>TextViews</code> are updated. The problem is that if I were to edit just one <code>TextView</code>, then the other <code>TextViews</code> go blank and only the ones I edited will show the correct info. Any suggestions? Attached is a snippet of code. So basically, I only want the <code>TextView</code> info to change when the <code>EditText</code> field is changed and not when the <code>EditText</code> is just selected or scrolled through.</p>
<p>The <code>EditText</code> code:</p>
<pre class="lang-java prettyprint-override"><code>editTextName.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v1, int keyCode1, KeyEvent event1) {
if ((event1.getAction() == KeyEvent.ACTION_DOWN) && (keyCode1 == KeyEvent.KEYCODE_ENTER)) {
getSharedPreferences("myprefs", 0).edit().putString("editTextName", editTextName.getText().toString()).commit();
return true;
}
return false;
}
});
</code></pre>
<p>The corresponding <code>TextView</code>:</p>
<pre class="lang-java prettyprint-override"><code>String newName = getSharedPreferences("myprefs", 0).getString("editTextName", this.getString(R.string.name) );
textViewName.setText("Name: "+newName);
</code></pre>
|
android
|
[4]
|
1,580,498 | 1,580,499 |
Security issue accessing microsoft interop dll sending email
|
<p>We have a simple piece of code here that recently stopped working and I have tried many 'things' to try and resolve the error.</p>
<p>The code</p>
<p><code>Application outLook = new Application();</code> :)</p>
<p>The error</p>
<blockquote>
<p>Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following
error: 80070005. Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack
trace for more information about the error and where it originated in
the code. </p>
<p>Exception Details: System.UnauthorizedAccessException: Retrieving the
COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following
error: 80070005. </p>
<p>ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request
identity. ASP.NET has a base process identity (typically
{MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if
the application is not impersonating. If the application is
impersonating via , the identity will be
the anonymous user (typically IUSR_MACHINENAME) or the authenticated
request user. </p>
<p>To grant ASP.NET access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add
the appropriate user or group. Highlight the ASP.NET account, and
check the boxes for the desired access.</p>
</blockquote>
<p>Now whilst the error is quite obvious I cannot resolve it.</p>
<p>The application is a .net 2.0 web application and the server is windows 2008 r2 standard using IIS 7.0</p>
<p>Thanks</p>
|
asp.net
|
[9]
|
5,516,930 | 5,516,931 |
lock-less technique to pass double update from one thread to another
|
<p>Assume I have shared <code>double</code> variable. Thread <code>A</code> updates it several thousands times per second. In another thread <code>B</code> I want to be notified somehow about "update" every time this happens.</p>
<p>I was tried to avoid notifications completely and just use <code>while(true)</code> loop but this introduced significant slowdowns into my program <a href="http://stackoverflow.com/questions/11392169/lock-free-calc-how-to-sum-n-double-numbers-that-are-changing-by-other-threads">lock-free calc: how to sum N double numbers that are changing by other threads?</a> probably because of that "Meanwhile you keep on loading that same array from memory over and over which is not really good for performance since memory bandwith is limited."</p>
<p>I've also tried using <code>Monitor</code> class but it was also pretty slow and I've seen up to 1-2 ms delays when <code>Monitor.TryEnter</code> return <code>false</code>.</p>
<p>I now think that I need to do notifications using lock-free technique, probably using <code>SpinLock</code> or something else?</p>
|
c#
|
[0]
|
4,834,440 | 4,834,441 |
how to make dynamic year in select option
|
<p>pls help me how could i make a dynamic year inside the select option.
heres my code and this one gives me a result of separated year. how could i make the result just in one select option?</p>
<pre><code> $yrnw = date("Y");
$lyr = 1;
$lstyr = $yrnw - $lyr ;
$sy = 10 + $yrnw;
for($i=$yrnw; $i<$sy ; $i++){
$lst = $i -1;
echo "<tr><td>SY:</td></tr><tr><td><select name= 'sy'>
<option value=''>$lst-$i<br/></option>
"; }
</code></pre>
|
php
|
[2]
|
1,769,358 | 1,769,359 |
string.format conundrum
|
<p>for me where the following simple string.format() doesn't work !!</p>
<pre><code>return string.format(Resources.ABCSTRING, fieldName, fieldType);
</code></pre>
<p>where Resouces.ABCSTRING is</p>
<pre><code> {1} _{0};
internal {1} {0}
{
get { return _{0}; }
set
{
_{0} = value;
UpdateRowValue(myObj, "{0}", value);
}
}
internal void SetNull{0}()
{
UpdateRowValue(myObj, "{0}", DBNull.Value);
}
</code></pre>
<p>It's obviously something basic but i don't see it !! any help ?</p>
|
c#
|
[0]
|
1,323,079 | 1,323,080 |
Error While Reading the file /C:/Users/Lulzim/Cities.txt (No such file or directory)
|
<p>what about this code, this is not working too??
What is wrong here??</p>
<pre><code>FileInputStream fis;
final StringBuffer storedString = new StringBuffer();
try {
fis = openFileInput("C:/Users/Lulzim/Cities.txt");
DataInputStream dataIO = new DataInputStream(fis);
String strLine = null;
while ((strLine = dataIO.readLine()) != null) {
storedString.append(strLine);
System.out.println("reading...");
}
dataIO.close();
fis.close();
}
catch (Exception e) {
System.out.println("error reading file...");
}
}}
</code></pre>
<p>this one is not working as well...</p>
|
android
|
[4]
|
389,513 | 389,514 |
How to read a musical file using python and identify the various frequency levels of the notes?
|
<p>please help me with the python...this is my project topic...</p>
|
python
|
[7]
|
2,216,841 | 2,216,842 |
How to "include" third party modules into my python script to make it portable?
|
<p>I've developed a little script that searches through a wallpaper database online and download the wallpapers, I want to give this script to another person that isn't exactly good with computers and I'm kinda starting with python so I don't know how to include the "imports" of the third party modules in my program so it can be 100% portable, Is there something that can help me do this? or I will have to enter and analize my third party modules and copy&paste the functions that I use?</p>
<p>Thanks for your help in advance. Sorry for my bad English. :)</p>
|
python
|
[7]
|
4,925,156 | 4,925,157 |
explicit filepath to file in parent directory
|
<p>I have a situation where I have two config files.<br>
A base config which resides in a parent directory, and a sibling config in a sibling directory.<br>
To date, the sibling looks to the parent with a simple </p>
<pre><code>require_once "../parent_config.php";
</code></pre>
<p>However I now want to pass the sibling into a new class system. I can pass an explicit filepath for the sibling no problem, but obviously run into issues with the above call to the parent.<br>
I'm trying something along the line of the following but I'm getting it wrong somewhere (I'm trying to say take the explicit filepath, up one)</p>
<pre><code>require_once (dirname(__FILE__) . "../parent_config.php");
</code></pre>
<p>I'd appreciate your comments.<br>
Thanks<br>
Giles</p>
|
php
|
[2]
|
3,605,606 | 3,605,607 |
javascript prototyping: why doesn't this work?
|
<p>I'm looking at trying the following code:</p>
<pre><code>var classA = function() {};
classA.prototype = { x: 4, y: 6 };
classA.prototype.prototype = { z: 10 };
var foo = new classA();
alert(foo.z);
</code></pre>
<p>Why does the alert come back as undefined? Shouldn't javascript follow the prototype chain to find z?</p>
|
javascript
|
[3]
|
2,629,092 | 2,629,093 |
Best practice to reference the parent activity of a fragment?
|
<p>I've been working a lot with fragments lately and I was just curious as to what the best practice is for using a reference to a fragment's parent activity. Would it be better to keep calling getActivity() or have a parentActivity variable initialized on the onActivityCreated callback.</p>
|
android
|
[4]
|
3,057,741 | 3,057,742 |
is it possible to not reload user control when redirect to a page?
|
<p>I have created a user control for side menu navigation and when user clicks on one of the item on a menu, it displays details of the company and information. Now it is redirecting to different page for each company using passing parameter (ex. company.aspx?ID=10) and everytime when I clicked, it refreshes whole page. I would like to keep side menu user control without refresh as there is a live search option. </p>
<p>Is this possible? or should I change opposite way to do it? should be the side menu in a page and company info in a user control??</p>
|
asp.net
|
[9]
|
3,227,899 | 3,227,900 |
Interface builder and memory management
|
<pre><code>@property (nonatomic, retain)IBOutlate UITextField *userName;
</code></pre>
<p>this property is to connect with TextField in IB.</p>
<ol>
<li><p>Can we write <code>[userName release]</code> in <code>dealloc</code> to free the memory or it will be handled by IB.</p></li>
<li><p>Can i write <code>@property(nonatomic, copy)IBOutlate UITextField *userName;</code></p></li>
</ol>
|
iphone
|
[8]
|
5,231,658 | 5,231,659 |
Print value of number (int) spelled out
|
<p>is there an out-of-box way to spell out an int in C#? For example if I have:</p>
<pre><code>int a = 53;
</code></pre>
<p>I want to print:</p>
<pre><code>"fifty three"
</code></pre>
<p>not</p>
<pre><code>"53"
</code></pre>
<p>If not, does anybody have any examples on how to accomplis this?</p>
<p>Thanks!</p>
|
c#
|
[0]
|
3,628,061 | 3,628,062 |
<img /> scale to closest fit aspect ratio
|
<p>I want to make the logo (in the top left corner) always keep its aspect ratio, but I also want it to stay in the right place, for <em>any</em> browser. Here's my code:</p>
<pre><code><body>
<img src="/home/istom/Dropbox/bcs logo border.png" width="25%" height="25%" style="position:absolute;top:6%;left:9.7%;z-index:1" />
<div style="position:absolute;top:12.5%;left:12.5%;width:75%;height:75%;border-style:solid;border-color:#6699cc;border-width:3px;background-image:url('/home/istom/Downloads/BCHands.jpg');background-position:95% 50%;background-repeat:no-repeat;background-size:60% auto;">
<div style="float:left;position:relative;top:25%;left:5%;">Hello</div>
</div>
</code></pre>
<p></p>
<p>If you use this code, and resize your window, you'll see the logo is stretched infuriatingly out of shape. How can I make sure it keeps it's aspect ratio?</p>
<p>PS: If anyone can tell me how to do the same for the background-image that would great.
PS: As little jQuery as possible (still, if jQuery is the only way...)!</p>
|
javascript
|
[3]
|
3,172,498 | 3,172,499 |
Set link href based on link text with jQuery
|
<p>I have:</p>
<pre><code><a class='special' href='#'>something</a>
<a class='special' href='#'>anything</a>
</code></pre>
<p>I need to make it with page load:</p>
<pre><code><a class='special' href='something'>something</a>
<a class='special' href='anything'>anything</a>
</code></pre>
<p>Something like: </p>
<pre><code>$('a.special').attr('href', $(this).text());
</code></pre>
<p>How it can be done?</p>
|
jquery
|
[5]
|
1,675,555 | 1,675,556 |
Looping through with dates syntax issue
|
<p>I have created a fixture generator for football/ soccer games...</p>
<pre><code> for ($round = 0; $round < $totalRounds; $round++) {
for ($match = 0; $match < $matchesPerRound; $match++) {
$home = ($round + $match) % ($teams - 1);
$away = ($teams - 1 - $match + $round) % ($teams - 1);
// Last team stays in the same place while the others
// rotate around it.
if ($match == 0) {
$away = $teams - 1;
}
$rounds[$round][$match] = "$user[$home]~$team[$home]@$user[$away]~$team[$away]~$roundDates[$round]";
}
}
</code></pre>
<p>I am altering the question as I am almost there.</p>
<pre><code>$roundDates[$round]
</code></pre>
<p>This piece of code, i need $round-1.
What is the correct syntax for this?
Cheers</p>
|
php
|
[2]
|
256,345 | 256,346 |
Allow only 3 numbers
|
<p>I want to make a javascript (or jquery) function that works onChange and allow only to write 3 numbers : 5, 15 or 25 </p>
<p>If the user write an other value (example 3 or 4...), the input have to be reset to 0</p>
<p>How can I do that?</p>
|
javascript
|
[3]
|
838,731 | 838,732 |
Sorting a particular column of datatable of string type that contains numeric data
|
<p>I have a datatable (.Net) with multiple columns. One of the columns say RollNo is of string type but contains numeric data. Eg. <strong>1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14</strong>. I am trying to sort using the following:</p>
<pre><code>string sql =
"Select StudentID, RollNo, AdmissionID,(FirstName + Space(1) + Isnull(MiddleName,'') + Space(1) + Isnull(LastName,'')) as Name," +
" PermState as State from Students where ClassId = '" + ddlClass.SelectedValue + "'" +
" order by RollNo";
DataTable dt = bl.GetDataSet(sql);
dt.DefaultView.Sort = "RollNo";
</code></pre>
<p>But after sorting I get the result as <strong>1, 10, 11, 12, 13, 14, 2, 3, 4, 5, 6, 7, 8, 9.</strong></p>
<p>How to solve it? </p>
|
c#
|
[0]
|
1,072,389 | 1,072,390 |
create one activity application
|
<p>I want to create an activity that uses the intent action for Screen_off - is there an easy way to do this? I keep getting lost as to where I should start - does the screen_off activity need to be defined somewhere and then referred to?</p>
|
android
|
[4]
|
983,096 | 983,097 |
How to animate a set of jQuery objects one at a time (instead of all at once)
|
<p>I'm trying to build a picture slider. (I know there are tons of plug-ins out there, but this is more for educational purposes).</p>
<p>Basically, I have a set of images with z-index: 0. What I am trying to do is take the set of images, then select each one of the images and change the index to 1, animate the opacity, and then put it back at 0, so that the next image will do the same thing.</p>
<p>This is the first part, but the problem I have is that when I am testing this part, all the images do the animation at the same time. Instead of doing one after the other.
I know that you can use callback functions such as:</p>
<pre><code>image1.animate(the animation, function({
image2.animation(the animation, function({
image3.animation(the animation, function}) etc...
</code></pre>
<p>})</p>
<p>But if I had more images it would become more complicated. I am trying to find a more efficient way of doing this, but I am not finding the answer.</p>
<p>This is what I have tried:</p>
<pre><code>images.each(function () {
$(this).css({
"opacity" : "0.0",
"z-index" : "1"
}).animate({
opacity: "1.0"
}, 3000);
});
</code></pre>
<p>but it doesn't work. All the images do the animation at the same time. I even tried with a "for" loop, but I get the same thing:</p>
<pre><code>for (var i=0; i<images.length; i++){
images.eq(i).css({
"opacity" : "0.0",
"z-index" : "1"
}).animate({
opacity: "1.0"
}, 3000);
}
</code></pre>
<p>I know I am doing something wrong, but I can't figure out what it is. If anyone has any help it would be greatly appreciated!</p>
|
jquery
|
[5]
|
2,626,711 | 2,626,712 |
set a random string for a variable in PHP
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4233407/get-random-item-from-array">Get random item from array</a> </p>
</blockquote>
<p>I need a code to set a random string for a variable.
of course I have the string and they are not generated.
I can put the strings in the array</p>
<pre><code>$strings= array('one', 'two', 'yes', 'no', 'yeaa');
$random_str = ????
</code></pre>
<p>I need $random_str to be one or no or maybe two.
Totally randomly from $strings.</p>
<p>rand and shuffle function didn't do that for me simply, and I'm beginner in php, so I need your help.
so thank you guys for helping me</p>
|
php
|
[2]
|
3,596,545 | 3,596,546 |
How can I capture androids scrollstop event natively? (without using jQuery Mobile)
|
<p>I've got access to the full-on jQuery, not mobile. It would seem that putting in code like;</p>
<pre><code>$(document).on("scrollstop", function(){
alert(1);
});
</code></pre>
<p>isn't going to help me without jQuery Mobile. Is there any other way I can capture the scroll event consistently in Android? (2.x and up)</p>
|
android
|
[4]
|
5,792,621 | 5,792,622 |
Slide show effect in iphone
|
<p>I want to create on slide show in my iphone application which open if the user don't touch the screen for 30 second , for that i have made on method which reset the time when user touch the screen . </p>
<p>I have used nstimer class to handle timer event .</p>
<p>my problem is that even if invalidating the timer the event has been fire after the time interval my reset timer method is as per below </p>
<pre><code>-(void) resetTimer {
if(timerForScreenSaver != nil)
{
timerForScreenSaver = nil;
[timerForScreenSaver invalidate];
NSLog(@"timer is invalidate %@ ",timerForScreenSaver);
}
timerForScreenSaver = [NSTimer scheduledTimerWithTimeInterval:15.0 target:self selector:@selector(showScreenSaver) userInfo:nil repeats:NO];
NSLog(@"timer is set");
}
</code></pre>
<p>can any one help me to reset the timer .</p>
<p>Thanks and Regard<br>
Kunal Patel</p>
|
iphone
|
[8]
|
1,659,568 | 1,659,569 |
feeding dynamic variable names into $_POST
|
<pre><code>isset($_POST['"$daysofweek[i]"'])
</code></pre>
<p>I tried different variations but i can't get it to detect. I have an array with all the days of the week and I want to check every POST variable. </p>
<p>It's probably really simple, but im stuck.</p>
<p>Thanks</p>
|
php
|
[2]
|
5,471,030 | 5,471,031 |
Difference between char* and char[]
|
<p>I know this is a very basic question. I am confused as to why and how are the following different. </p>
<pre><code>char str[] = "Test";
char *str = "Test";
</code></pre>
|
c++
|
[6]
|
1,878,586 | 1,878,587 |
BaseAdapter not allow INTENT action
|
<p>An extended class with <code>BaseAdapter</code> will not allow me to jump from one activity to the second ::
it give me syntax error :: </p>
<pre><code>holder.capture.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
intent_request = new Intent(this, SaxParser2.class);
}
</code></pre>
<p><strong>Screen</strong> </p>
<p><img src="http://i.stack.imgur.com/tmXmp.png" alt="enter image description here"></p>
|
android
|
[4]
|
3,838,932 | 3,838,933 |
Bind a DropDownList to IEnumerable
|
<p>I have a method:</p>
<pre><code>public static IEnumerable<Datarow> getInfo (string test)
{
some functionality and adds two columns in datatable dt.
now how can i return dt from this method (question 1)
}
</code></pre>
<p>I have to bind the method returned value to a dropdown list named <code>ddlist</code> .</p>
<p>How can i make it possible </p>
<p>(question no 2.)
.. when i tried i get the message that can not bind ienumerable . . . .</p>
<p>please help me out.</p>
|
asp.net
|
[9]
|
5,032,745 | 5,032,746 |
jquery "everyTime" function
|
<p>I'm trying to refresh my recent list every 5 seconds. I was looking at ajax and found jquery.</p>
<p>I found a function known as "everyTime"</p>
<p>This is what I have so far, I don't really know how to get it to work... It's not working:\</p>
<pre><code><html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).everyTime(5s, function(i) {
<?php include "recent.php";?>
}, 0);
</script>
</head>
<body>
<div id="testDiv">
<h2>This is default. Waiting for refresh</h2>
</div>
</body>
</code></pre>
|
jquery
|
[5]
|
2,576,046 | 2,576,047 |
Issues regarding scrollTop in JavaScript
|
<p>I want the Alert message <code>hello</code> to be displayed when the vertical scrolling on the page exceeds 100px. I tried doing but it didn't work.</p>
<p>JavaScript Code:</p>
<pre><code>function fixSearch(body) {
var a=body.scrollTop;
if(a>100)
{
alert("Hello");
}
}
</code></pre>
<p>HTML Code</p>
<pre><code><body onscroll="fixSearch(this)">
---------------------------
---------------------------
---------------------------
</body>
</code></pre>
|
javascript
|
[3]
|
5,300,782 | 5,300,783 |
Changing URL displayed in address bar
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1039725/how-to-url-re-writing-in-php">How to: URL re-writing in PHP?</a><br>
<a href="http://stackoverflow.com/questions/7088651/how-can-i-keep-the-same-url-in-the-address-bar-for-every-page">How can I keep the same url in the address bar for every page?</a> </p>
</blockquote>
<p>I am using a query string to pass information to a page but do not want the string to appear in the browser address bar.</p>
<p>www.mysite.co.uk?lp=catlist</p>
<p>is loaded but I just want the address bar to show</p>
<p>www.mysite.co.uk</p>
<p>Is there a way of doing this?</p>
<p>Thanks</p>
|
php
|
[2]
|
2,651,750 | 2,651,751 |
Numbers in Javascript and effective range
|
<p>All numbers in Javascript are 64bit (8 bytes) floating point numbers
but why the effective range of JavaScript is 5e-324 (negative) to 1.7976931348623157e+308 (positive)?</p>
|
javascript
|
[3]
|
3,337,071 | 3,337,072 |
Run PHP Function once
|
<p>Is there a way to run a PHP FUNCTION "fun();" only once when a logged in user accesses a page multiple times?</p>
<p>here is the function.</p>
<pre><code><?php
$connect = //connect to database
function fun()
{
//loop declare begin
$quer = "SELECT * FROM sffedorvsdan WHERE username = '$_SESSION[username]'";
if($quer_run = mysql_query($quer))
{
while($row = mysql_fetch_assoc($quer_run))
{
$pick1 = $row['pick1'];
$pick2 = $row['pick2'];
$pick3 = $row['pick3'];
$pick4 = $row['pick4'];
$pick5 = $row['pick5'];
$pick6 = $row['pick6'];
//loop end EXCEPT CLOSE
$user = $_SESSION['username'];
if($pick1 == '11')
{
$score = mysql_query("
UPDATE stats SET score = (score + 10), mmascore = (mmascore + 10),
wins = (wins + 1), games = (games + 1)
WHERE username = '$user'
");
return $score;
}
else if($pick1 == '21')
{
$score2 = mysql_query("
UPDATE stats SET score = (score - 5), mmascore = (mmascore - 5),
games = (games + 1)
WHERE username = '$user'");
return $score2;
}
}
}else{
echo mysql_error();
}
}
?>
</code></pre>
|
php
|
[2]
|
4,125,040 | 4,125,041 |
Set StringBuilder before use?
|
<p>Does a StringBuilder variable need to be initialized to lets say string.empty in case you don't end up appending anything in the end and need to return something?</p>
<pre><code> public static string ToSemiColonList<T>(this IEnumerable<T> list, Func<T, string> func)
{
StringBuilder sb = new StringBuilder();
foreach (T item in list)
{
if (sb.Length > 0)
sb.Append(";");
string elem = func(item);
sb.Append(elem);
}
return sb.ToString();
}
</code></pre>
<p>In this case it may never enter the foreach. So my guess is since every local variable in a method scope is set to no value in C#, to set it to an empty string since we need to give something back if this foreach is not hit.</p>
<p>Maybe it's better to check the stringbuilder length then if zero, return string.empty or am I going overboard (doing the same work twice) and it's fine like I have it?</p>
|
c#
|
[0]
|
320,056 | 320,057 |
Insert in multiple relative tables
|
<p>I have two tables:
<strong>eventcategory</strong>
<img src="http://i.stack.imgur.com/PUh3T.png" alt="enter image description here"></p>
<p><strong>initplayer</strong>
<img src="http://i.stack.imgur.com/xD3Iu.png" alt="enter image description here"></p>
<p>What i want is to insert the table initplayer.</p>
<p>In order to do that:
First, i return a query and create an associate array</p>
<p>$dbResult = mysql_query("select * from eventcategory");</p>
<pre><code>function array_push_assoc($array, $key, $value){
$array[$key] = $value;
return $array;
}
$arrEventCategory = array();
while ($info = mysql_fetch_array($dbResult)) {
$arrEventCategory = array_push_assoc($arrEventCategory,$info['id'],$info['eventCategory']);
}
print_r($arrEventCategory);
$ga->requestAccountData();
foreach($ga->getResults() as $result)
{
$ga->requestReportData('30191592', array('eventCategory', 'eventAction'), array('totalEvents'), $sort_metric = null, $filter = 'eventAction==InitPlayer', $start_date = $startDate, $end_date = $startDate);
foreach($ga->getResults() as $result2)
{
$key = array_search($result2->geteventCategory(), $arrEventCategory);
$mysql->query("insert into initplayer values(" . $result->getProfileId() . ",'" . $result . "','".$result2->gettotalEvents()."','".$startDate."',".$key.")");
}
}
</code></pre>
<p><img src="http://i.stack.imgur.com/4PuBu.png" alt="enter image description here"></p>
<p>What i want to do to insert db id's according to eventCategory :S</p>
|
php
|
[2]
|
5,236,986 | 5,236,987 |
Android Autocomplete textview multilines
|
<p>I want to show 2 lines in autocomplete textview suggestion list. I have customer information such as customerid, customername and address. I want to show customername in first line and customer address in 2nd line. Is it possible to show multilines in Autocomplete textview?</p>
<p>thank you</p>
|
android
|
[4]
|
4,757,668 | 4,757,669 |
Stub out network on android device
|
<p>I need to stub out the GSM network on a test android device for testing some parts of an application. Is this possible?</p>
<p>Thanks</p>
|
android
|
[4]
|
4,337,895 | 4,337,896 |
value of decoded json
|
<p>I try to get item from dict, which was decoded by json:</p>
<pre><code>data = [ { 'a':'A', 'b':(2, 4), 'c':3 } ]
data_string = json.dumps(data)
decoded = json.loads(data_string)
decoded['c']
</code></pre>
<p>So it shows the next:</p>
<pre>
Traceback (most recent call last):
File "", line 1, in
TypeError: list indices must be integers, not str
</pre>
<p>I try to print the value of c on screen <br/>
So I try to see 3 after decoded['c'] <br/>
How can I do this ?</p>
<p>Thanks!</p>
|
python
|
[7]
|
1,062,324 | 1,062,325 |
How to convert SESSION Variable to Integer Type in C#
|
<p>I am using C#</p>
<p>I am trying to check whether my login attempt is not more than 3, I mean with below condition</p>
<pre><code>if (((int)Session["LoginAttempt"]) != 3)
{
}
</code></pre>
<p>In Login failed condition I am doing increment like below:</p>
<pre><code>Session["LoginAttempt"] = ((int) Session["LoginAttempt"]) + 1;
</code></pre>
<p>But it is giving me error <strong>"Object reference not set to an instance of an object."</strong></p>
<p>Please suggest!</p>
|
c#
|
[0]
|
1,878,959 | 1,878,960 |
Joining Lists using Linq returns different result than corresponding SQL query?
|
<p>I have 2 tables</p>
<p>TableA:</p>
<pre class="lang-none prettyprint-override"><code>TableAID int,
Col1 varchar(8)
</code></pre>
<p>TableB:</p>
<pre class="lang-none prettyprint-override"><code>TableBID int
Col1 char(8),
Col2 varchar(40)
</code></pre>
<p>When I run a SQL query on the 2 tables it returns the following number of rows</p>
<pre class="lang-sql prettyprint-override"><code>SELECT * FROM tableA (7200 rows)
select * FROM tableB (28030 rows)
</code></pre>
<p>When joined on col1 and selects the data it returns the following number of rows</p>
<pre><code>select DISTINCT a.Col1,b.Col2 FROM tableA a
join tableB b on a.Col1=b.Col1 (6578 rows)
</code></pre>
<p>The above 2 tables on different databases so I created 2 EF models and retried the data separately and tried to join them in the code using linq with the following funtion. Surprisingly it returns 2886 records instead of 6578 records. Am I doing something wrong?
The individual lists seems to return the correct data but when I join them SQL query and linq query differs in the number of records.</p>
<p>Any help on this greatly appreciated.</p>
<pre><code>// This function is returning 2886 records
public List<tableC_POCO_Object> Get_TableC()
{
IEnumerable<tableC_POCO_Object> result = null;
List<TableA> tableA_POCO_Object = Get_TableA(); // Returns 7200 records
List<TableB> tableB_POCO_Object = Get_TableB(); // Returns 28030 records
result = from tbla in tableA_POCO_Object
join tblb in tableB_POCO_Object on tbla.Col1 equals tblb.Col1
select new tableC_POCO_Object
{
Col1 = tblb.Col1,
Col2 = tbla.Col2
};
return result.Distinct().ToList();
}
</code></pre>
|
c#
|
[0]
|
2,555,253 | 2,555,254 |
Can you give me a Programming problem in java
|
<p>I am learning java on my own. I have books to read. but i feel i am not really coding anything significant . Can you guys give me any programming problem that would really help me get more practical experience rather than a theoretical experience with java ?</p>
<p>Appreciate it.</p>
<p>silverkid</p>
|
java
|
[1]
|
5,024,085 | 5,024,086 |
customErrors mode="Off" in web.config but still Server Error in '/' Application
|
<p>I deployed an asp.net website to a shared server..... </p>
<p>I got the error </p>
<p><code>Server Error in '/' Application.</code></p>
<p><strong>Runtime Error</strong></p>
<p><code>Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.</code></p>
<p>Here is my page <a href="http://static3.nextgenits.com/Forms/Homepage.aspx" rel="nofollow">http://static3.nextgenits.com/Forms/Homepage.aspx</a></p>
|
asp.net
|
[9]
|
173,077 | 173,078 |
A way to get at non-static information from Static Context
|
<p>I know you can't static members from instance members.</p>
<p>But lets say I have in one assembly this:</p>
<pre><code>public class ClassA
{
public List<order> GetOrders(int orderID)
{
...
}
}
</code></pre>
<p>Then in another assembly this:</p>
<pre><code>public static ClassB
{
private static void DoSomethingElse(int orderID)
{
List<order> orderList = ClassA.GetOrders(orderID);
...rest of code
}
}
</code></pre>
<p>Is there any way to still get at that method in Class A some other way...some work around to this?</p>
|
c#
|
[0]
|
2,445,057 | 2,445,058 |
getListenerList or getListeners
|
<p>I'm curious about which method should be used to retrieve the list of listeners from an EventList. The Oracle docs example shows getListenerList and then traversing backwards through it in the fireXXXEvent method, but I'm wondering if getListeners would be a better choice?</p>
<p>Thanks</p>
|
java
|
[1]
|
3,220,337 | 3,220,338 |
Using Type.GetType() function to get the type of the class from the different namespace
|
<p>I want to call a class and its method with the name of the class and the method name will be known at run time. the class i want to call is a in a different project ClassLibrary. .The namespace of the class which is to be called i have added reference of it to my current project. and wrote the following code to call.</p>
<pre><code>Type CalledType = Type.GetType("ClassLibraryLocation." + ClassName);
MethodInfo info = CalledType.GetMethod(FunctionName);
Object new_obj = Activator.CreateInstance(CalledType);
Object retval = info.Invoke(new_obj, new object[] { "ABC" });
Console.WriteLine(retval);
//ClassLibraryLocation is an anather namespace for which the reference is added.
//ClassName is the name of the class present in the ClassLibraryLocation namespace
//FunctionName is the name of the function present in the ClassName Class
</code></pre>
<p>But The Type.GetType() Method returns Null CalledType</p>
<p>Please Help</p>
<p>Thanks</p>
|
c#
|
[0]
|
3,407,748 | 3,407,749 |
How to perform Redo Undo operation in EditText
|
<p>I want to know is there any method or any link or tutorial to perform redo undo operation in Android edittext. If any one knows than please let me know.</p>
|
android
|
[4]
|
5,225,779 | 5,225,780 |
Export a excel file witout any dialog+asp.net,c#
|
<p>I am exporting a excel file from "c:Test\data.xls" using the responce object
like:</p>
<pre><code>response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
</code></pre>
<p>it is opening a dialog box.But Now we don't need the dialog box.we want to directly open file without dialog.
Can any body help me out </p>
|
asp.net
|
[9]
|
1,161,516 | 1,161,517 |
Origin null is not allowed by Access-Control-Allow-Origin (Synchronous, no jQuery)
|
<p>The first thing I would like to say is that I looked around for an answer to this for quite some time, but everything I found was about jQuery. This is not about jQuery. </p>
<p>I have some code (below), but when I ran it in Firefox then Firebug gave me this big, incomprehensible exception. I tried it in Google Chrome and got something a bit more useful: "XMLHttpRequest cannot load <a href="http://www.wikipedia.org/" rel="nofollow">http://www.wikipedia.org/</a>. Origin null is not allowed by Access-Control-Allow-Origin." (If you'd like to know why I was trying to access Wikipedia, I often use it as a test site.)
Here is my code:</p>
<pre><code>function requestSite(url) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", url, false);
xmlhttp.send();
return xmlhttp;
}
</code></pre>
<p>All I tried to do with it was access Wikipedia. Then Google, which gave me the same result. Perhaps it is worth noting that when I triggered the function with a button on the page, it gave me this, while using the console was exactly the same, but without the error message. Another thing that may or may not be worth mentioning is that I was running this file from my local filesystem.</p>
|
javascript
|
[3]
|
4,440,447 | 4,440,448 |
How do I add items to an array in JQuery
|
<pre><code>var list = [];
$.getJSON("json.js", function(data) {
$.each(data, function(i, item) {
console.log(item.text);
list.push(item.text);
});
});
console.log(list.length);
</code></pre>
<p>list.length always returns 0. I've browsed the json in firebug and it well formed; everything looks fine. I just can't seem to add an item to the array. What am I missing?</p>
<p>Thanks,
Nathan</p>
|
jquery
|
[5]
|
5,750,976 | 5,750,977 |
Why is a default ctor needed for this inner (nested) struct?
|
<p>I am trying to compile code similar to the snippet below:</p>
<pre><code>class System
{
private:
struct Configuration
{
Configuration(/*params*/);
Configuration(const Configuration&);
Configuration& operator=(const Configuration&);
~Configuration();
/* member variables */
} m_config;
explicit System(const Configuration& cfg);
// Non copyable constructable, non assignable
System(const System&);
System& operator= (const System&);
public:
System();
~System();
}
//Implementation
System::System()
{
m_config = Configuration(/*default params*/);
// ....
}
</code></pre>
<p>Compiler error: <strong>no matching function for call to ‘System::Configuration::Configuration()’</strong></p>
<p>When I provide (even merely a declaration not a definition of) a default constructor for the nested struct, the error dissapears - WHY?!</p>
<p>Misc Details:
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)</p>
|
c++
|
[6]
|
4,248,412 | 4,248,413 |
Can I split jQuery into two files?
|
<p>As you know, the max MTU for TCP is 1500. The iPhone doesn't cache files bigger than 25kb.</p>
<p>Has anybody tried to split jQuery into two separate files?</p>
<p><img src="http://i.stack.imgur.com/h5CK4.png" alt="enter image description here"></p>
<p>jQuery 1.5.2 is 29.1kb. How can I split jQuery 1.5.2 into two files?</p>
<p>I have two files:</p>
<ul>
<li>jquery1.js ~15kb</li>
<li>jquery2.js ~15kb</li>
</ul>
<p>File will be cached on iPhone. Page will be open faster - 156ms</p>
<hr>
<p>OK i move some function 'jquery.extend to external file
just put eval();</p>
<p>asd = 'code'; -- neede remove white spaces escape ' " new lines by eq yuicompressor.jar</p>
|
jquery
|
[5]
|
5,445,513 | 5,445,514 |
Python class structure ... prep() method?
|
<p>We have a metaclass, a class, and a child class for an alert system:</p>
<pre><code>class AlertMeta(type):
"""
Metaclass for all alerts
Reads attrs and organizes AlertMessageType data
"""
def __new__(cls, base, name, attrs):
new_class = super(AlertMeta, cls).__new__(cls, base, name, attrs)
# do stuff to new_class
return new_class
class BaseAlert(object):
"""
BaseAlert objects should be instantiated
in order to create new AlertItems.
Alert objects have classmethods for dequeue (to batch AlertItems)
and register (for associated a user to an AlertType and AlertMessageType)
If the __init__ function recieves 'dequeue=True' as a kwarg, then all other
arguments will be ignored and the Alert will check for messages to send
"""
__metaclass__ = AlertMeta
def __init__(self, **kwargs):
dequeue = kwargs.pop('dequeue',None)
if kwargs:
raise ValueError('Unexpected keyword arguments: %s' % kwargs)
if dequeue:
self.dequeue()
else:
# Do Normal init stuff
def dequeue(self):
"""
Pop batched AlertItems
"""
# Dequeue from a custom queue
class CustomAlert(BaseAlert):
def __init__(self,**kwargs):
# prepare custom init data
super(BaseAlert, self).__init__(**kwargs)
</code></pre>
<p>We would like to be able to make child classes of BaseAlert (CustomAlert) that allow us to run dequeue and to be able to run their own <code>__init__</code> code. We think there are three ways to do this:</p>
<ol>
<li>Add a prep() method that returns True in the BaseAlert and is called by <code>__init__</code>. Child classes could define their own prep() methods.</li>
<li>Make dequeue() a class method - however, alot of what dequeue() does requires non-class methods - so we'd have to make those class methods as well.</li>
<li>Create a new class for dealing with the queue. Would this class extend BaseAlert?</li>
</ol>
<p>Is there a standard way of handling this type of situation?</p>
|
python
|
[7]
|
3,865,237 | 3,865,238 |
PHP dom - How to get the contents within a span tag that includes a hyperlink
|
<p>I've done this before but can't find my code snippet.</p>
<p>I'd like to parse an html file and pull everything into my browser that sits between some span tags. There are other span tags in the html that I do not want so I figured I would limit the parsing to just the span tags that have the same css class. Can someone please give me an example of how to do this? Thanks.</p>
<pre><code>$tags = $doc->getElementsByTagName('span');
</code></pre>
<p><hr></p>
<p>This is a single row of the html I am trying to parse</p>
<pre><code><span class='close'><a href="bla.com/test.htm">test row</a></span>
</code></pre>
|
php
|
[2]
|
2,092,856 | 2,092,857 |
How do I reference an object instance from a class initialization?
|
<p>Here is a small example. I want to reuse the mongodb object in many other methods in this class, without initializing it within each function.</p>
<p>Or is there a better approach in general?</p>
<pre><code> <?php
class Model_Users extends Model
{
public static function _init()
{
$mongodb = \Mongo_Db::instance('content');
}
public static function get_user($name)
{
$user = $mongodb->get('users', array( 'name' => $name ));
return $user;
}
}
</code></pre>
|
php
|
[2]
|
342,012 | 342,013 |
Accessing theme customizer farbtastic object instances
|
<p>I have multiple individual color pickers set up in the theme customizer, which results in several instances of the farbtastic color picker.</p>
<p>I am trying to find the jQuery/JavaScript instance variable for each of these, just can't seem to find a reference to them anywhere. I want to be able to set each farbtastic color manually, i.e. I need to access the color pickers setColor() method.</p>
<p>As a test, I can set a global JS var in customize-controls.js, in the color picker section, and can access this via Chrome console easy enough. But I need to do the same thing by accessing the default farbtastic instances. I just can't find them!</p>
|
javascript
|
[3]
|
3,624,452 | 3,624,453 |
Jquery Find Replace
|
<p>I have following HTML code</p>
<pre><code><a href="javascript:void(0);" onClick="javascript:OpenNewWindow('/help_email.asp?ProductCode=122030', 350, 250);" class="pricecolor colors_productprice"><b><span class="PageText_L657n"><br><input type="Button" font face="arial" size="2" color="#ffbb00" value="submit best offer"> </Button>
</code></pre>
<p>What i want to do is FIND ALL occurrences of help_email.asp and replace it with help_email.php.</p>
|
jquery
|
[5]
|
1,654,340 | 1,654,341 |
search for innerHTML value in a table
|
<p>how can I search in a table for a row with a specifik innerHTML value?</p>
<pre><code><table>
<tr><td>test</td><td>100</td></tr>
<tr><td>test</td><td>200</td></tr>
<tr><td>test</td><td>300</td></tr>
</table>
</code></pre>
<p>I need the index for the row (tr) where the second td is 200</p>
<p>here the index has to give 1</p>
<pre><code>$('table tr'). something??
</code></pre>
<p>EDIT:</p>
<p>and I also need a version that select the index before a give value is bigger (asc) than 200 (if it exists)</p>
|
jquery
|
[5]
|
4,876,091 | 4,876,092 |
How to rectify transformer exception
|
<p>I am doing application with parsing XML file. I used TransformerFactory to modify XML file. when i use TransformerFactory in android 2.2 version its working fine, at the same time when using TransformerFactory in android version 2.1 i am getting Transformer exception. Can anybody know how to rectify transformer exception</p>
|
android
|
[4]
|
2,855,090 | 2,855,091 |
Console information to window
|
<p>I already know how to catch standard output of a console window, BUT my problem is the case when I get the process with GetProcesses/orByName and do not Start() it myself. Here is the code:</p>
<pre><code>public ProcessCaller(ISynchronizeInvoke isi, Process MárFutóAlkalmazás)
: this(isi)
{
//alapbeállítások
FileName = MárFutóAlkalmazás.StartInfo.FileName;
Arguments = MárFutóAlkalmazás.StartInfo.Arguments;
WorkingDirectory = MárFutóAlkalmazás.StartInfo.WorkingDirectory;
//egyedi beállítások
process = MárFutóAlkalmazás;
process.EnableRaisingEvents = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
new MethodInvoker(ReadStdOut).BeginInvoke(null, null);
new MethodInvoker(ReadStdErr).BeginInvoke(null, null);
//események
StdErrReceived += new DataReceivedHandler(Loggolás);
StdOutReceived += new DataReceivedHandler(Loggolás);
//kilépés jelzése
process.Exited += new EventHandler(OnKilépés);
}
</code></pre>
<p>So this method gets and already running application as MárFutóAlkalmazás parameter. Sets some internal properties, then hooks to Output. However when it comes to</p>
<pre><code>StdOutReceived += new DataReceivedHandler(Loggolás);
</code></pre>
<p>and the program runs the Loggolás method to take the console data, it says that the StandardOut is not set, or the process is not started.</p>
<p>Well:</p>
<ul>
<li>StandardOut is set</li>
<li>Process is running, since I get it by GetProcesses</li>
<li>In this routine I do NOT use process.Start() - since it is started already</li>
</ul>
<p>Looking for help. Thank yas:
Péter</p>
|
c#
|
[0]
|
154,311 | 154,312 |
which return comply with C++ standard
|
<pre><code>class A {};
class B
{
public:
B(const A& a, int i = 10) : m_a(a), m_i(i) {}
private:
int m_i;
A m_a;
};
B getB(void)
{
//return B(A()); // Method one
//return A(); // Method two
}
</code></pre>
<p>Both method one and method two pass the compilation of VS2010.</p>
<p><strong>Question 1</strong>> Which one is better?</p>
<p><strong>Question 2</strong>> Is it true that an implicit constructor supports more than one pass-in parameters if all except the first parameters have default values?</p>
<p>Thank you</p>
|
c++
|
[6]
|
3,519,558 | 3,519,559 |
How to find out the Encoding of a File? C#
|
<p>Well i need to find out which of the files i found in some directory is UTF8 Encoded either ANSI encoded to change the Encoding in something else i decide later. My problem is.. how can i find out if a file is UTF8 or ANSI Encoded? Both of the encodings are actually posible in my files.</p>
|
c#
|
[0]
|
3,236,998 | 3,236,999 |
Traversing directories to count number of files with a specific string
|
<p>I have a directory with several levels of sub-directories. All the files in the directories are html files (approx. 500 in total), and I'd like to go through each file to see if if contains a "sub_middle_1col" division. I found a great tutorial at palewire.com and have used that as my base. The two difficulties I am having are 1) the code broke when it hit a sub-directory (thinking it was a file), and 2) it would not traverse sub-directories -- that is, it only looks at files not in any sub-directory. I may have solved the first problem by adding in a line (noted below), but can't figure out how to integrate other solutions I've seen (e.g., os.walk) into the code in order to solve the second problem. Any ideas? Thanks in advance for any advice.</p>
<pre><code>import os
path = "./Industries"
my_library = os.listdir(path)
out = open("out.txt", "w")
for page in my_library:
file = os.path.join(path, page)
if os.path.isfile(file) and file.endswith('.html'): #I ADDED THIS LINE
text = open(file, "r")
hit_count = 0
for line in text:
if 'sub_middle_1col' in line:
hit_count = hit_count + 1
print >> out, page + " => " + str(hit_count)
print page + " => " + str(hit_count)
text.close()
</code></pre>
|
python
|
[7]
|
260,343 | 260,344 |
How can i store audio file in sqlite..?
|
<p>I want to save recorded file and after that i want to save in sqlite database. How it possible?
Give me some proper guideline on that..
Ayn suggestion welcomes...</p>
|
iphone
|
[8]
|
2,505,655 | 2,505,656 |
How to append dom with a item count
|
<p>I have to insert dom object with a count of times like <code>$('ul').append('<li>',5); //5 times</code></p>
<p>I know how to do that with for loop but i am looking elegant way.</p>
|
jquery
|
[5]
|
223,581 | 223,582 |
How can I get co-ordinates of transperent portion from Image
|
<p>I use an image . I made some portion of the image transparent. Now How can I find the co-ordinates of the transparent portion of the image so that I am able to find the actual area of the non-transparent area.. I want some methodical way to find..</p>
<p>please do needful</p>
|
android
|
[4]
|
2,169,542 | 2,169,543 |
PHP: display in "Today" only, not in "Yesterday" too
|
<pre><code>$today = time() - (3600*24);
$Yday = time() - (3600*48);
$getMsgsToday = mysql_query("SELECT * FROM users_msgs WHERE uID = '$USER' AND date > $today");
$countToday = mysql_num_rows($getMsgsToday);
$getMsgsYday = mysql_query("SELECT * FROM users_msgs WHERE uID = '$USER' AND date > $Yday");
$countYday = mysql_num_rows($getMsgsYday);
</code></pre>
<p>This is my code for displaying messages latest 24 hours and 48 hours(yesterday).</p>
<p>I got two while for the queries(yesterday and today). </p>
<p>Now if you have something within 24 hours, it will also display in the yesterday while().</p>
<p>I only wish to show yesterday´s messages, with this I mean the 24 hours before today´s 24 hours.</p>
<p>How can I do this, so I dont get these duplicates?</p>
|
php
|
[2]
|
2,358,781 | 2,358,782 |
PHP - assigning function return to variable
|
<p>I have a PHP script that returns a random password. How do I echo out the password that is generated?</p>
<pre><code><?php
function generatePassword($length=9, $strength=0) {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength & 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength & 2) {
$vowels .= "AEUY";
}
if ($strength & 4) {
$consonants .= '23456789';
}
if ($strength & 8) {
$consonants .= '@#$%';
}
$password = '';
$alt = time() % 2;
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$alt = 0;
} else {
$password .= $vowels[(rand() % strlen($vowels))];
$alt = 1;
}
}
return $password;
}
?>
</code></pre>
|
php
|
[2]
|
2,380,500 | 2,380,501 |
How to make script paths inside user control independent of page hierarchy
|
<p>My website is organized in the following folder structure</p>
<pre><code>Root
Pages
CustomerManagement
DepartMentManagement
Script
UserControls
</code></pre>
<p>Now i have a user control inside userControl Folder. I have to use a external js file. So i use it this way</p>
<pre><code><script type="text/javascript" language="javascript" src="../Script/slider.js"></script>
</code></pre>
<p>My understanding is that since both are under root so i have used a single ..
Now what happens is that when this usercontrol is used inside DepartMentManagement it checks for script folder inside CustomerManagement as .. refers to one hierarchy above and script file is not found.Even using a ~ doesnot work.</p>
<p>I want to make this script path independent of the path where this control is used. I don't want to move script reference code to the page as control requires script mot page.Please tell me how to achieve this.</p>
|
asp.net
|
[9]
|
2,087,010 | 2,087,011 |
How to read and update row in file with Java
|
<p>currently i creating a java apps and no database required
that why i using text file to make it
the structure of file is like this</p>
<pre><code>unique6id username identitynumber point
unique6id username identitynumber point
</code></pre>
<p>may i know how could i read and find match unique6id then update the correspond row of point ?</p>
<p>Sorry for lack of information
and here is the part i type is</p>
<pre><code>public class Cust{
string name;
long idenid, uniqueid;
int pts;
customer(){}
customer(string n,long ide, long uni, int pt){
name = n;
idenid = ide;
uniqueid = uni;
pts = pt;
}
FileWriter fstream = new FileWriter("Data.txt", true);
BufferedWriter fbw = new BufferedWriter(fstream);
Cust newCust = new Cust();
newCust.name = memUNTF.getText();
newCust.ic = Long.parseLong(memICTF.getText());
newCust.uniqueID = Long.parseLong(memIDTF.getText());
newCust.pts= points;
fbw.write(newCust.name + " " + newCust.ic + " " + newCust.uniqueID + " " + newCust.point);
fbw.newLine();
fbw.close();
</code></pre>
<p>this is the way i text in the data
then the result inside Data.txt is</p>
<pre><code>spencerlim 900419129876 448505 0
Eugene 900419081234 586026 0
</code></pre>
<p>when user type in 586026 then it will grab row of eugene
bind into Cust
and update the pts (0 in this case, try to update it into other number eg. 30)</p>
<p>Thx for reply =D</p>
|
java
|
[1]
|
2,614,415 | 2,614,416 |
ASP.NET masterpage public variables error
|
<p>I have public variable 'MessagePlaceholder' on MasterPage and a Class that accesses this property like that setting it's value to string from getMessage();</p>
<pre><code>((HttpContext.Current.Handler as System.Web.UI.Page).Master as MasterPage).MessagePlaceholder = getMessage();
</code></pre>
<p>which gives me an error like this one</p>
<p>Error 3 'System.Web.UI.MasterPage' does not contain a definition for 'MessagePlaceholder' and no extension method 'MessagePlaceholder' accepting a first argument of type 'System.Web.UI.MasterPage' could be found (are you missing a using directive or an assembly reference?)</p>
<p>What should i do ?</p>
|
asp.net
|
[9]
|
124,803 | 124,804 |
Should C++ 'interfaces' have a virtual destructor
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2691611/destructors-for-c-interface-like-classes">Destructors for C++ Interface-like classes</a> </p>
</blockquote>
<p>Consider a simple example of a C++ abstract class, used to model an interface:</p>
<pre><code>class IAnimal
{
virtual void walk()=0;
virtual ~IAnimal(){}
};
</code></pre>
<p>Is it better to have the destructor, or not? I don't think the destructor can be pure virtual, at least my tests give linker errors, so should an empty destructor be included?</p>
<p><strong>EDIT:</strong> sorry, typo. It's a destructor not a constructor.</p>
|
c++
|
[6]
|
3,988,863 | 3,988,864 |
getting an index of a character
|
<p>I'm having a problem getting an index of the character '-' of a string. Let me explain my problem.
First I have to read a line from a text file. The only line in the text file is "Beta = 62.5 * (Sigma – Delta) / 125"</p>
<pre><code>StreamReader rdr = new StreamReader(openPath, Encoding.Default);
while (rdr.Peek() != -1)
{
string strInput = rdr.ReadLine();
}
</code></pre>
<p>then I need to get the index of char '-'.</p>
<pre><code>int col = strInput.IndexOf('-');
</code></pre>
<p>After the above line 'col' is equal to -1. But as you can see the '-' character is in the above mentioned string which read from the text file.
I couldn't figure out why I'm getting -1 as the index of '-'. help me...</p>
|
c#
|
[0]
|
4,997,974 | 4,997,975 |
Can not access the mBuffer
|
<p>I use the below code:</p>
<pre><code>Bitmap myBmp = Bitmap.createBitmap( 720, 1280, Config.ARGB_8888 );
byte []data = myBmp.mBuffer ????
</code></pre>
<p>But I find that the mBuffer of android.graphics.Bitmap can not be accessed. And there is no hint for this in Eclipse. </p>
<p>How to solve this?</p>
|
android
|
[4]
|
4,141,935 | 4,141,936 |
Split comma-separated input box values into array in jquery, and loop through it
|
<p>I have a hidden input box from which I'm retrieving the comma-separated text value (e.g. <code>'apple,banana,jam'</code>) using:</p>
<pre><code>var searchTerms = $("#searchKeywords").val();
</code></pre>
<p>I want to split the values up into an array, and then loop through the array.</p>
|
jquery
|
[5]
|
2,444,785 | 2,444,786 |
Insert html before the head tag (not in or between them) using JavaScript
|
<p>I need to insert a comment before the html tag and before the doctype tag (if present) like..</p>
<pre><code><!-- HelloWord -->
</code></pre>
<p>From a previous quest the following code did the job where an attribute was to be inserted "inside" a tag, however this quest is different...</p>
<pre><code>document.getElementsByTagName("html")[0].setAttribute("id", "something");
</code></pre>
<p>How to insert "before" the nominated tag? </p>
|
javascript
|
[3]
|
3,993,587 | 3,993,588 |
parse rss feed using javascript
|
<p>I am parsing an RSS feed using PHP and JavaScript. First I created a proxy with PHP to obtain the RSS feed. Then get individual data from this RSS feed using JavaScript. My issue with with the JavaScript. I am able to get the entire JavaScript document if I use <code>console.log(rssData);</code> with no errors. If I try to get individual elements within this document say for example: <code><title></code>, <code><description></code>, or <code><pubDate></code> using <code>rssData.getElementsByName("title");</code> it gives an error "Uncaught TypeError: Object....has no method 'getElementsByName'". So my question is how to I obtain the elements in the RSS feed?</p>
<p><strong>Javascript (Updated)</strong></p>
<pre><code>function httpGet(theUrl) {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false);
xmlHttp.send(null);
return xmlHttp.responseXML;
}
// rss source
var rssData = httpGet('http://website.com/rss.php');
// rss values
var allTitles = rssData.getElementsByTagName("title"); // title
var allDate = rssData.getElementsByTagName("pubDate"); // date
</code></pre>
|
javascript
|
[3]
|
2,842,068 | 2,842,069 |
Help with basic Python function
|
<p>I have a function to connect to a database. This code works:</p>
<pre><code>def connect():
return MySQLdb.connect("example.com", "username", "password", "database")
</code></pre>
<p>But this doesn't:</p>
<pre><code>def connect():
host = "example.com"
user = "username"
pass = "password"
base = "database"
return MySQLdb.connect(host, user, pass, base)
</code></pre>
<p>Why so?</p>
|
python
|
[7]
|
85,099 | 85,100 |
How do I check if an array element exists?
|
<p>I'm looking for Java's equivalent of PHP's <a href="http://php.net/manual/en/function.isset.php" rel="nofollow">isset()</a>;</p>
<pre><code>int board[][]=new int[8][8];
...
if(isset(board[y][x]))
// Do something with board[y][x]
</code></pre>
<p>Does such a function exist in Java?</p>
<p>Edit: Sorry, what I meant is that I want to check if <code>board[100][100]</code> exists or not. <code>if(board[100][100])</code> would result in an array out of bounds error.</p>
|
java
|
[1]
|
1,000,504 | 1,000,505 |
Is the constructor of a class called if you declare a object of that class as an instance variable of another class?
|
<p>For example, if i have a class like this;</p>
<pre><code>#import "B.h"
class A
{
B object;
};
</code></pre>
<p>would B's constructor get called when I created a A object?</p>
|
c++
|
[6]
|
3,759,738 | 3,759,739 |
The steps to becoming an iPhone Developer
|
<p>First some background:</p>
<p>The company I work for have decided to create an iPhone App for our main product and nominated me to do this work. I've been a professional C# developer for over 5 years and although I have used other languages (Java, C++ etc), I have not used them to a professional standard and not for many years. As for Mac/iPhone development I have never even used a Mac and have an Android phone.</p>
<p>My company are happy for me to go on any needed courses, buy any required books etc, to speed up the learning curve.</p>
<p>My first task is researching what I need (equipment, IDE's, SDKs) and what learning material to use (books, forums, courses - we're London based but if the course is good enough they might put me on a plane).</p>
<p>Of course I will be trawling the internet for some of these answers but I thought I can't hurt to consult the considerable knowledge of stack overflow (kissing ass I know!). Plus I'm sure there will be many people like me who could do with pointing in the right direction.</p>
<p>Thanks in advance.</p>
|
iphone
|
[8]
|
117,863 | 117,864 |
Noninterrupting keyevents while preserving individual keystrokes
|
<p>I am designing a keyboard interface through javascript, and I want to define keystroke combinations, like shift+rightkey or ctrl+tab. But after tinkering with javascript, as seen <strong><a href="http://jsfiddle.net/Arcym/ENUj2/7/" rel="nofollow">here</a></strong>, I've noticed that all keyevents are interrupting. In the provided example, if you go to hit the shiftkey while holding down the rightkey, the functionality of the rightkey is interrupted!</p>
<pre><code>v = 1; /*v is the variable of velocity.*/
window.addEventListener("keydown", function(event)
{
if(event.keyCode == 39) /*39 is the keycode of rightarrowkey.*/
{
//moves an element by the velocity.
var keystroke = document.getElementById("keystroke");
keystroke.style.left = parseInt(keystroke.style.left.slice(0,-2))+v+"px";
}
if(event.keyCode == 16) /*16 is the keycode of shift.*/
{
//increases the velocity of the element by four.
document.getElementById("keystroke").style.borderColor = "red";
v = 4;
}
}, false); //but hitting the shiftkey while hitting the rightkey interrupts..!
</code></pre>
<p>I also experimented with recording all keystrokes through an object which is then iterated through at a designated interval for defined keystrokes, as seen <strong><a href="http://jsfiddle.net/Arcym/kjkCc/3/" rel="nofollow">here</a></strong>. But this system of handling the keyboard doesn't <em>preserve</em> the individual keystrokes; if I hit a key too fast, it may not be considered, or if I hold a key for too long, it may be overconsidered!</p>
|
javascript
|
[3]
|
4,570,544 | 4,570,545 |
Strange Javascript behaviour
|
<p>I am using JQuery to append images, like this:</p>
<pre><code>$('#event_list_main').append('<img class="listed_event" id="event_'+event_counter+'" data-count="'+event_counter+'" src="final_tutorial_buttons/event.png" height="50" width="50" onclick="highlight();" />');
</code></pre>
<p>I am assign a <code>highlight</code> function to each image I create and append! The problem is that the highlight function does not execute.</p>
<pre><code>//Highlight function
function highlight()
{
var indicator = $(this).data("count");
alert(indicator);
}
</code></pre>
<p>the "this" part doesnt seem to work.I want this to refer to each event created.</p>
<p>for example if I created 3 events</p>
<p>event_1
event_2
event_3</p>
<p>and I click on "image event_2" then "this" must refer to "image-event_2"</p>
|
javascript
|
[3]
|
2,648,678 | 2,648,679 |
How to add a map as a class field?
|
<p>I want to add a dictionary that maps an object to a list of objects as an instance variable to a class. What is the idiomatic way to do it in Python? Here's how I've done it:</p>
<pre><code>class MyClass:
def __init__(self):
self.myDict = { None : [None] }
</code></pre>
|
python
|
[7]
|
1,191,943 | 1,191,944 |
How often do you find javascript disabled on browsers?
|
<p>I have started using ajax/jQuery in our websites / application. There are many plugins that support degrading the javascript to browsers that dont have javascript enabled and techniques to support this. What are peoples thoughts on javascript support, we build applications rather than just websites and are looking to just support javascript enabled browsers as a pre-requisite assuming that most people or companies have javascript enabled.
Do you find most people have javascript? do you monitor the percentage of javascript/non-javascript browsers (I guess this can be done with website stats) and what are the numbers regarding this?</p>
|
javascript
|
[3]
|
4,936,709 | 4,936,710 |
Can I call a jquery function from a click?
|
<p>I am trying to do something similar to the alert box that we get here on SO when we get new comments and answers, the orange box that sticks to the top of the screen, I have something similar but I am trying to get an X close link on it, to close it on click</p>
<p>Here is what I have but it is giving me errors saying the close_error_click() is not defined?</p>
<pre><code><script type="text/javascript" >
function close_error_click(){
$("#notify-container").fadeOut("slow", function () {
$("#notify-container").remove();
}
</script>
<div id="notify-container">
some other code here
<a onclick="close_error_click" title="dismiss this notification">×</a>
</div>
</code></pre>
|
jquery
|
[5]
|
2,456,575 | 2,456,576 |
Formatting a number with leading zeros in PHP
|
<p>I want have a variable which contains the value 1234567.</p>
<p>I want it to contain exactly 8 digits i.e. 01234567.</p>
<p>Is there a PHP function for that?</p>
|
php
|
[2]
|
3,025,452 | 3,025,453 |
PHP 5.3 pass function by reference
|
<p>Is it possible to pass functions by reference?</p>
<p>Something like this:</p>
<pre><code>function call($func){
$func();
}
function test(){
echo "hello world!";
}
call(test);
</code></pre>
<p>I know that you could do <code>'test'</code>, but I don't really want that, as I need to pass the function by reference.</p>
<p>Is the only way to do so via anonymous functions?</p>
<p>Clarification: If you recall from C++, you could pass a function via pointers:</p>
<pre><code>void call(void (*func)(void)){
func();
}
</code></pre>
<p>Or in Python:</p>
<pre><code>def call(func):
func()
</code></pre>
<p>That's what i'm trying to accomplish. </p>
|
php
|
[2]
|
4,081,500 | 4,081,501 |
search certain characters in an if statement
|
<p>.what i want to do is search for certain Initials inside a retrieved record from a database. for example i have a record like this.. "SGA, MNFA, JGA" how do I code an If statement that will search if SGA is present inside the record. If it is found then proceed, if not, then an else statement will be performed.</p>
<p>sample:</p>
<pre><code>if($x == "what is the code needed to be placed here to search if SGA is present?")
{
.some code..
}
else
{
.some code..
}
</code></pre>
<p>.TIA guys! More power!</p>
|
php
|
[2]
|
1,452,347 | 1,452,348 |
How to optimize the login option in android?
|
<p>HI,</p>
<p>I want to create Login option in my application , so that once a person gets login that device creates token which is saved over server. From next time whenever he/she operates the application, directly goes to next label by checking that token keyvalue pair over server.IT requires login page only when that keyvalue pair is deleted from the server. </p>
<p>Can anyone help me from this.I will be very grateful to you.
Looking for reply.</p>
<p>Regards,
Praween</p>
|
android
|
[4]
|
3,872,674 | 3,872,675 |
UITableView cell background color
|
<p>how to set different background colors for cells in a UITableView
(specifically rainbow color for seven cells)</p>
|
iphone
|
[8]
|
2,938,965 | 2,938,966 |
Calculation results not displaying in totals table javascript
|
<p>I'm trying to create a paycheck calculator, but when I enter the hourly rate and number of hours and hit calculate, all I'm getting is <em>undefined</em> in my totals table. Here is my javascript:</p>
<pre><code>var $ = function (id) {
return document.getElementById(id);
}
function updateTotal () {
var rate;
var hours = parseFloat( $("numHours").value);
var regularHours;
var overtime;
var doubletime;
//begin determine hourly rate
function checkJob () {
if ($('job').value == 'job0') {
rate = 0;
}
if ($('job').value == 'job1') {
rate = 12;
}
if ($('job').value == 'job2') {
rate = 10;
}
if ($('job').value == 'job3') {
rate = 11;
}
}
//calculate hours breakdown
function checkHours () {
if (hours.value <= 40) {
regularHours = hours.value;
overtime = 0;
doubletime = 0;
}
if (hours.value < 60) {
regularHours = 40;
overtime = hours.value-40;
doubletime=0;
}
if (hours.value >=60) {
regularHours = 40;
overtime = 20;
doubletime = hours.value-60;
}
}
checkJob();
checkHours();
var salary = (regularHours * rate) + (overtime * (rate * 1.5)) + (doubletime * (rate * 2))
//display amounts
$('regularHours').innerHTML = regularHours;
$('overtime').innerHTML = overtime;
$('doubletime').innerHTML = doubletime;
$('salary').innerHTML = "$ " + salary;
}
</code></pre>
<p>I'm sure I'm missing something silly, but I've been staring at this code for days and can't figure out what I'm doing wrong. Thanks for looking!</p>
|
javascript
|
[3]
|
3,722,205 | 3,722,206 |
Detect intent-filter received by app
|
<p>I'm building an app that is registered for the intent filters IMAGE_CAPTURE (Camera) & PICK (Gallery).</p>
<p>For the Activity, how do I detect which intent filter was received?</p>
|
android
|
[4]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.