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
83,042
83,043
php mktime AMPM value wrong
<p>I'm trying to get the next minute value in php by doing the following.</p> <pre><code>$one_minute_later = mktime(date("g"), date("i")+1, date("s"), date("n"), date("j"), date("Y")); $send_month = date("n", $one_minute_later); // Numeric representation of a month, without leading zeros $send_day = date("j", $one_minute_later); // Day of the month without leading zeros $send_year = date("Y", $one_minute_later); $send_hour = date("g", $one_minute_later); // 12-hour format of an hour without leading zeros $send_minute = date("i", $one_minute_later); // Minutes with leading zeros 00 to 59 $send_ampm = date("A", $one_minute_later); </code></pre> <p>However, doing so ALWAYS returns the value AM for AMPM. Any idea why? For instance, when I run this code at 6:00 PM, one minute later should return 6:01 PM. However, it's returning 6:01 AM.</p>
php
[2]
2,129,688
2,129,689
Customized Toast or something else?
<p>Sorry for my bad english. I need help.</p> <p><a href="http://habrastorage.org/storage2/605/02c/601/60502c60140c90bcd61829a1cdee9af8.png" rel="nofollow">image with view component</a></p> <p>What is the element with "Drag apps to your ..." text on Adroid emulator? Customized Toast or ... what?</p>
android
[4]
2,066,326
2,066,327
How can you delete running characters at the end of a string?
<p>Say I had parsed a large number like <code>130,233,320,000,000,000</code> into <code>130,233,320,,,</code> how could I recursively delete the substring of running commas to get the output like <code>130,233,320</code></p> <p>A recursive algorithm seems easy like:</p> <pre><code>public String parseEnd(String s) { if(s.substring(s.length-1) == ",") { return s.substring(0, s.length-2); } return s; } </code></pre>
java
[1]
2,407,870
2,407,871
Google map application
<p>I am trying to do a google map related application.While doing that application i got some problems.This is my xml file</p> <pre><code> &lt; LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;com.google.android.maps.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="0uw2roKAecBgrtyYUPVL-pJ84Ez4tfHTilFZCGw"/&gt; &lt;LinearLayout android:id="@+id/zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And this is my .java file</p> <pre><code>protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapView); LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom); View zoomView = mapView.getZoomControls(); zoomLayout.addView(zoomView, new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mapView.displayZoomControls(true); } </code></pre> <p>I am getting google map view for this application but no zoom. If i change first to i am getting output with zoom options..what is the problem with the linear layout.Pls tell me friends</p>
android
[4]
1,817,064
1,817,065
PHP header in a loop
<p>Is it possible to "call" a PHP script in a loop like this ?</p> <pre><code>... while (...) { ... header("Location:myscript.php"); ... } ... </code></pre>
php
[2]
1,897,060
1,897,061
Confusing Javascript class declaration
<p>I have some third-party Javascript that has statements like this:</p> <pre><code>FOO = function() { ...functions() ... return { hash } }(); </code></pre> <p>It is working as designed but I'm confused by it. Can anybody define what this structure is doing? Is it just a weird way to create a class?</p>
javascript
[3]
4,291,900
4,291,901
Alignment in android
<p>I am new to android, currently designing a User Home Page. please let me know how to align UI controls like - Button , EditText, etc to left/right/center in Linear and List Layout. button code eg. </p>
android
[4]
5,331,335
5,331,336
Downloading Android source
<p>I am following the instructions mentioned at: <a href="http://source.android.com/source/downloading.html" rel="nofollow">http://source.android.com/source/downloading.html</a> to download the source code (master and not a specific branch) on Ubuntu 11.10 but the download is stuck at 99% (240/242) for more than 4 hours and I am not connected through proxy. I see couple of fatal errors yet the download is proceeding so, is the download taking a long time or am I doing something wrong?</p> <p>The following is the output after I fired the command, "repo sync":</p> <pre><code>Fatal: Not a git repository: '&lt;my directory&gt;/.repo/projects/bootable/bootloader/legacy.git' Fetching projects: 19% (46/242) fatal: Not a git repository: '&lt;my directory&gt;/.repo/projects/bootable/bootloader/legacy.git' Fetching projects: 40% (97/242) error: Cannot fetch platform/bootable/bootloader/legacy warn: --force-broken, continuing to sync remote: Counting objects: 201, done remote: Finding sources: 100% (108/108) remote: Getting sizes: 100% (132/132) remote: Compressing objects: 100% (39/39) remote: Total 108 (delta 62), reused 107 (delta 62) Receiving objects: 100% (108/108), 17.43 KiB, done. Resolving deltas: 100% (63/63), completed with 43 local objects. From https://Android.googlesource.com/platform/sdk 9af3fd6..d93207c master -&gt; aosp/master Fetching projects: 99% (240/242) </code></pre>
android
[4]
1,567,889
1,567,890
iPhone : Wait for users to complete or dismiss view in AppDelegate
<p>I'm in the process of adding a method that changes core application settings and as a result needs to be initiated very early in the code execution, this will only be displayed during the development phases of the application.</p> <p>I've created a view that allows the users to set / change the required settings and the 'addview' in the 'applicationdidFinishLaunchingWithOptions' method. </p> <p>What I'm struggling with is waiting/pausing the appdelegate until the user has completed and dismissed the new view, i.e. display view and wait until the 'Done' button is pressed. Are there any ways to achieve this, the application is very complex and my new view changes values in the root.plist resulting in no code changes elsewhere in the application</p>
iphone
[8]
240,960
240,961
When to use the Value keyword in C#
<p>I am using a <a href="http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx" rel="nofollow">custom serializer</a> in c# in order to serialize/deserialize an object with a dictionary. However during the deserialization the dictionary object was not being set correctly. See code:</p> <pre><code>public DictionarySerializer&lt;String, Point&gt; jointDictionary { get { return _jointDictionary; } set { _jointDictionary = jointDictionary; } } </code></pre> <p>The jointDictionary object coming back was empty however in the debugger thread I noticed a "value" object that had the contents of my dictionary. Changing my code to the following fixed my issue:</p> <pre><code>public DictionarySerializer&lt;String, Point&gt; jointDictionary { get { return _jointDictionary; } set { _jointDictionary = value; } } </code></pre> <p>I have read about the "value" keyword and understand that it is a reserved word in C# to specify the value that the client it trying to use to set the object. So my question is, why wouldn't the jointDictionary reference work as in my first attempt? And what is the correct usage for the value keyword?</p>
c#
[0]
125,568
125,569
Android How to display 1 out of 54 card images in a ImageView
<p>I'm trying to figure out the best way to display 1 of 54 bitmaps in a <code>ImageView</code> . I figured I could load in a bitmap from the assets. But I can't figure out how to size it. When it loads it from the <code>XML</code> file, it chooses 1 of 3 different bitmaps, each a different size. </p> <p>I can't figure out how to determine what size bitmap to use. I know how to get the width and height of a View, but not the whole screen. Is there a way to get the screen resolution?</p> <p>All so I know how to set the bitmap property of a <code>ImageView</code>, but I could not find anything for scaling. Is there a way to scale it, or will I need a separate bitmap for different screen sizes?</p> <p>This seems like it should be simple, but turning into something very complicated,</p> <p>Is there a way to get the screen resolution? Can I scale the bitmap a <code>ImageView</code> displays? Is there a more easy way to do this?</p>
android
[4]
141,681
141,682
What's wrong with my memcpy?
<p>I have written a function to implement memcpy</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;iostream&gt; char *memcpy(char *dest,char *src,int n){ char *ch=dest; while (n--) *ch++=*src++; return dest; } int main(){ char *src="georgia"; int n=strlen(src); char *dest=new char[n]; std::cout&lt;&lt;*memcpy(dest,src,n)&lt;&lt;std::endl; return 0; } </code></pre> <p>But it only prints a single <code>g</code>. Why?</p>
c++
[6]
5,693,095
5,693,096
How to calculate the sum of values in a list PHP
<p>I have a variable list.</p> <pre><code>echo $variable; // shows 1 5 7 8 </code></pre> <ol> <li>How can I calculate the sum of these numbers?</li> <li>How can I convert this list into an array?</li> </ol>
php
[2]
1,986,974
1,986,975
php call to undefined function (beginner on classes)
<p>I have 2 files index.php and class_lib.php.</p> <p>Here is index.php</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;title&gt;OOP in PHP&lt;/title&gt; &lt;?php include("class_lib.php"); ?&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $adrian = new person(); $jimmy = new person; $adrian = set_name('adrian de cleir'); $jimmy = set_name('jimmy darmady'); echo $adrian-&gt;get_name(); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and the file with the class</p> <pre><code>&lt;?php class person { var $name; function set_name($new_name) { $this-&gt;name = $new_name; } function get_name() { return $this-&gt;name; } } ?&gt; </code></pre> <p>When I load the page I get Fatal error: Call to undefined function set_name() in /var/www/php_learning_testing/index.php on line 15</p> <p>Thanks for the help, its something silly im sure.</p>
php
[2]
2,760,746
2,760,747
Can Python test the membership of multiple values in a list?
<p>I want to test if two or more values have membership on a list, but I'm getting an unexpected result:</p> <pre><code>&gt;&gt;&gt; 'a','b' in ['b', 'a', 'foo', 'bar'] ('a', True) </code></pre> <p>So, Can Python test the membership of multiple values at once in a list? What does that result mean?</p>
python
[7]
484,267
484,268
Reusing functionality in Javascript
<p>I created a page on which there's a red square that can be moved by a mouse. I would like to find out how I can reuse Javascript to have more than 1 square. In the following fiddle <a href="http://jsfiddle.net/sbel/utM5k/" rel="nofollow">http://jsfiddle.net/sbel/utM5k/</a> I show that in HTML on top I include the CSS, the square is a div and the Javascript has the form (function(window) {...})(window);. How can I change the Javascript to be able to simply say here is the ID of a div, apply the moving functionality to it?</p>
javascript
[3]
5,657,561
5,657,562
jquery, need similar functionality of disable for select optoins
<p>I am using coding like this:</p> <pre><code> \$(this).attr("disabled", 'disabled'); \$(this).removeAttr("disabled"); </code></pre> <p>This would only disable the option. I want to have the same accessibility and coding but I would prefer to make it invisible on the drop down menu instead.</p> <p>thanks</p>
jquery
[5]
5,211,386
5,211,387
Can I register external JS files on a page via Javascript?
<p>In my CMS I add modules to the page via Javascript, these modules may include external JS files which get registered on page load into a collaborated external file. </p> <p>When the modules are added via JS these scripts are therefore not registered until the page is reloaded. </p> <p>Is there a way for me to register these scripts dynamically via the javascript calls in the mean time?</p>
javascript
[3]
5,228,802
5,228,803
Unpredictable Output in C++
<p>Here is a sample of source code</p> <pre><code>#include &lt;iostream.h&gt; #include &lt;conio.h&gt; #include &lt;math.h&gt; int main() { int i=2,a; a= pow(10,i); int b=0; b+=a; cout&lt;&lt;b; getch(); } </code></pre> <p>The ouput I expect is <code>100</code> as it is clear. But the compiler give <code>99</code> as output. Can anyone please explain what is the problem in the code and how it can b corrected to get <code>100</code> as output.</p>
c++
[6]
1,319,781
1,319,782
State_pressed change color of a view
<p>I have this <code>selector</code> xml file which is applied to a <code>RelativeLayout</code> as a background element:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true"&gt; &lt;shape&gt; &lt;solid android:color="#449def" /&gt; &lt;stroke android:width="1dp" android:color="#2f6699" /&gt; &lt;corners android:radius="3dp" /&gt; &lt;padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /&gt; &lt;/shape&gt; &lt;/item&gt; &lt;item android:state_pressed="false"&gt; &lt;shape&gt; &lt;gradient android:startColor="#f3ae1b" android:endColor="#bb6008" android:angle="270" /&gt; &lt;stroke android:width="1dp" android:color="#bb6008" /&gt; &lt;corners android:radius="10dp" /&gt; &lt;padding android:left="0dp" android:top="10dp" android:right="0dp" android:bottom="10dp" /&gt; &lt;/shape&gt; &lt;/item&gt; &lt;/selector&gt; </code></pre> <p>My question is: Why doesnt the color of this layout change when the state is changed? </p>
android
[4]
1,734,724
1,734,725
How-To Read Address Book (Wab) Files With C#
<p>How-To Read/Extract addresses from Outlook Address Book (Wab) Files With C#</p>
c#
[0]
5,849,304
5,849,305
How can the wikipedia api hide their source code?
<p>I have a wiki api site: <a href="http://en.wikipedia.org/w/api.php" rel="nofollow">http://en.wikipedia.org/w/api.php</a></p> <p>when I save the api.php, I can't see any post or get method behind that.... but I try to write a simple php program.... like this</p> <p>test.php:</p> <pre><code>&lt;?php echo("testing"); ?&gt; </code></pre> <p>when I updated to server, and save the test.php, people can see my source code. but after I downloaded the api.php, I don't see any php source code from the api.php, but I can pass parameter to the api.php, how can they do so? Thank you.</p>
php
[2]
3,472,072
3,472,073
Add one week to Date()
<p>How do I add 1 week to a date function with separate date variables. The date needs to be separate so I can insert it into another form. If I cant do it as separate variables can i separate them afterwards?</p> <p>So:</p> <pre><code>$year = date("Y"); $month = date("m"); $day = date("d"); echo 'Current Date' . $year . '.' . $month . '.' . $day; echo 'Date 1 Week in the Future'; </code></pre>
php
[2]
4,489,648
4,489,649
Recommend Some Beginner's Books For Programming In Python
<p>I have no programming background, none at all. I don't know C/C++, Java, PHP, JS... absolutely none. But I am starting out like this: <code>Linux &gt; Python &gt; Shell Scripting &gt; PHP</code>. Does this look good?</p> <p>Okay, since I am basically starting with Python in programming, I would need the most basic, and yet authoritative book to learn. Please suggest me a good book or two.</p> <p>EDIT: And should I learn Python 2.x or 3.x?</p>
python
[7]
2,943,121
2,943,122
Changing the path of getClass().getResourceAsStream(PATH) in runtime
<p>Is it possible to change the PATH of the Java code <code>getClass().getResourceAsStream(PATH)</code> in runtime? I would like to have an edit box so that the user can specify i.e <a href="http://site.com/image.png" rel="nofollow">http://site.com/image.png</a> for the PATH.</p>
java
[1]
5,321,554
5,321,555
Serializing to JSON in jQuery
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/191881/serializing-to-json-in-jquery">Serializing to JSON in jQuery</a> </p> </blockquote> <p>I know how to serialize an object to JSON in ASP.NET Ajax, but I'm trying to do things on the client in a less Microsoft-specific way. I'm using jQuery. Is there a "standard" way to do this?</p>
jquery
[5]
927,477
927,478
Access a file within a folder with spaces in the name in PHP
<p>I would like to open a file inside a folder in PHP. The problem is that the folder that contains the file may have spaces in the name. The code I use to open the file (and doesn't work) is the following:</p> <pre><code>$myFile = "path/to the/file.txt"; $myFile = str_replace(' ', '\ ', $myFile); $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); echo $theData; </code></pre> <p>As you can see, I'm trying to solve the problem by putting a <code>\</code> in front of the space, but this doesn't solve the issue. I still receive the following error:</p> <pre><code>Warning: fopen(path/to\ the/file.txt) [function.fopen]: failed to open stream: No such file or directory in /path/to/my/website on line 49 </code></pre> <p>Any idea on how to solve this issue?</p> <p>Thanks!</p>
php
[2]
1,268,584
1,268,585
PHP readfile() adding extra bytes to downloaded file
<p>I am trying to troubleshoot an issue I am having with downloading a "zip" file from a php script. It seems that when I download the file using the following code, the downloaded file has an extra 0A09 appended to the beginning of the file, causing winzip to throw a corruption error.</p> <pre><code>&lt;?php $pagePermissions = 7; require_once ('util/check.php'); require_once ('util/file_manager.php'); $file_manager = new FileManager(); if ($_SERVER['REQUEST_METHOD'] == "GET") { if (isset($_GET['q']) &amp;&amp; $_GET['q'] == 'logout') { //require_once ('util/users.php'); //$userdata = new Userdata(); $userdata -&gt; kill_session(); header("Location: download.php"); exit ; } if (isset($_GET['q']) &amp;&amp; $_GET['q'] == 'fetch') { if (isset($_GET['name'])) { @apache_setenv('no-gzip', 1); header("Content-length: " . filesize('upload/' . $_GET['name'])); header('Content-type: application/zip'); //header("Content-Disposition: attachment; filename=\"{$_GET['name']}\" "); header("Content-Disposition: attachment; filename={$_GET['name']}"); header('Content-Transfer-Encoding: binary'); readfile('upload/' . $_GET['name']); exit(); } } } ?&gt; </code></pre> <p>Any help would be greatly appreciated, the file downloads fine through a direct link, the appended 2 bytes to the beginning of the file occurs only thorough this code. Thanks in advance</p>
php
[2]
5,239,460
5,239,461
how to reload the selected tab jquery
<p>how to reload the selected tab actually i having problem in reloading part. when i add my data i'll successfully saved in datatable but in id field in database it shows proper id but when i add the detail its not shows id in datatable.</p> <p>(before refresh the summary tab) here is example it shows something like this in datatable id patient husband age ...........so on... xyz abc 23....... so on...</p> <p>(after refreshing manually) but when i refresh my page it show successfully..like this in datatable: id patient husband age ...........so on... 13 xyz abc 23 ....... so on...</p> <p>but exactly i want when i add my detail it will automatically refresh the selected tab.</p> <p>here is my code as below:</p> <pre><code>&lt;button type="button" a href="javascript:void(0);" onclick="fnClickAddRow();"&gt;Add Summary&lt;/button&gt; function fnClickAddRow(event) { $('#table_scroll').dataTable().fnAddData( [ "",$('#patientt').val(),$('#husband').val(),$('#age').val(),$('#opu_no').val(),$('#date').val(),$('#proc').val(),$('#no_of_eggs').val(),$('#fert').val(),$('#et_date').val(),$('#et_day').val(),$('#et').val(),$('#fz').val(),$('#bioch_preg').val(),$('#clin_preg').val(),$('#fh').val(),$('#comment').val() ]); var datastring = $(Form_summary).serialize(); $.ajax({ type: "POST", url: "summaryajax.php", data: datastring, success: function(response){ alert(response); } }); </code></pre>
jquery
[5]
3,015,658
3,015,659
Intercept the fetching of properties / methods of a javascript object
<p>How/Can I intercept a request to get a method/property on an javascript object and return a custom value instead.</p> <p>For example,</p> <pre><code>var obj = { // This "get" method is where I want to replace the call to get a property of an object. get : function(propertyName) { if (propertyName == 'somePropertyThatDoesntExist') { return 1; } else { return 0; } // Something like this? }; // Either this method of access, var myValue1 = obj.somePropertyThatDoesntExist var myValue2 = obj.someOtherPropertyThatDoesntExist // Alternatively, var myValue3 = obj['somePropertyThatDoesntExist'] var myValue4 = obj['someOtherPropertyThatDoesntExist'] </code></pre> <p>So myValue1 and myValue3 will have a value of 1, and myValue2 and myValue4 will have a value of 0.</p> <p>Currently, myValue1, 2, 3, 4 would all be "undefined".</p>
javascript
[3]
2,904,895
2,904,896
Make javascript that redirects after opening a popup
<p>I have the following constantcontact form they provided, After they click on submit, it opens a constant contact page. However I would like that it redirect also to a page after they click on submit</p> <pre><code>&lt;form name="ccoptin" action="http://visitor.r20.constantcontact.com/d.jsp" target="_blank" method="post" style="margin-bottom:2;"&gt; &lt;input type="hidden" name="llr" value="cjdttecab"&gt; &lt;input type="hidden" name="m" value="1101813878050"&gt; &lt;input type="hidden" name="p" value="oi"&gt; &lt;font style="font-weight: normal; font-family:Arial; font-size:12px; color:#000000;"&gt;Email:&lt;/font&gt; &lt;input type="text" name="ea" size="20" value="" style="font-size:10pt; border:1px solid #999999;"&gt; &lt;input type="submit" name="go" value="Submit" class="submit" style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:10pt;"&gt; &lt;/form&gt; </code></pre>
javascript
[3]
5,758,492
5,758,493
iPhone replacement control for three radio buttons - opinions?
<p>I have a scenario where we need to present the user with a question that has three possible answers. Yes/No/Don't know. Normally on a web form I would use three radio buttons for this. What - in your opinions - would be the best solution for an iPhone native app...</p> <p>I looked at the segmented control but it doesn't quite seem to fit the bill (this control normally changes the view in some way I believe).</p> <p>I'm just looking for some feedback from the community before we go ahead with this...</p> <p>Thanks, Deano.</p>
iphone
[8]
3,786,795
3,786,796
How is a SyncAdapter triggered by the system?
<p>I have an application which uses a SyncAdapter to make a REST call to remote server, then use a Content Provider to persist the updates to the local SQLLite DB. </p> <p>I can trigger the call by going the Accounts &amp; Sync, then selecting my adapter, and using the Resync button to trigger the call</p> <p>How does the system know when (how often) to make the onPerformSync() call in the SyncAdapter? </p> <p>I am logging on the service to which the REST call resolves, but I am not seeing any calls unless I do it manually as described above.</p> <p>Btw, i am running in the emulator at the moment, i have not installed this on a device yet</p>
android
[4]
2,556,015
2,556,016
I cant figure out how to set my random number between 1 and 100
<p>I just want to make a basic counter and for some reason I cant figure out how to draw a random number between 1 and 100? Can someone please explain what I have to do to draw a random number between 1 and 100.</p> <p>This is what I could come up with until now:</p> <pre><code>int value; private int count = 1; Random rand; } </code></pre>
android
[4]
4,506,219
4,506,220
How to change page location at run time
<p>I have portal where lot of master page and all related page in root.</p> <p>When user register his self then it will create a folder and copy all related file into the folder.</p> <p>root master page and page url</p> <pre><code>&lt;%@ Master Language="C#" AutoEventWireup="true" CodeFile="Layoutmaster.master.cs" Inherits="Layoutmaster" %&gt; &lt;%@ Page Language="C#" MasterPageFile="~/MasterPage/Layoutmaster.master" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" Title="Home" %&gt; </code></pre> <p>Folder url of master page and page</p> <pre><code>&lt;%@ Master Language="C#" AutoEventWireup="true" CodeFile="Layoutmaster.master.cs" Inherits="Layoutmaster" %&gt; &lt;%@ Page Language="C#" MasterPageFile="~/SubDomain/1/MasterPage/Layoutmaster.master" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" Title="Home" %&gt; </code></pre> <p>I want to change the Master Page File '"~/MasterPage/Layoutmaster.master"' from MasterPageFile="~/SubDomain/1/MasterPage/Layoutmaster.master" Please help me to change the location I have no any idea.</p>
asp.net
[9]
2,969,591
2,969,592
Loading an outbuffer to a string in javascript?
<p>How to load the output buffer into a string using javascript ?</p> <p>for example in php</p> <pre><code>&lt;?php ob_start(); ?&gt; hello world ! &lt;?php $string = ob_get_contents(); ?&gt; </code></pre>
javascript
[3]
775,252
775,253
PHP SQL Query ERROR in a select statement
<pre><code>$id = $_POST['idn']; $con=mysqli_connect("localhost","root","xyz","patient"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $query = "SELECT count(*) FROM record WHERE ID='$id'"; $count = mysql_result(mysql_query($query),0); if($count &gt; '0') { id exist } else { add id &amp; record } </code></pre> <p>whats the error here it does not check for if ID exists and adds duplicate id where ID is RC50001 RC50002...... ID defined as text in table</p>
php
[2]
1,335,039
1,335,040
compare dates with time in javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/492994/compare-dates-with-javascript">Compare dates with JavaScript</a> </p> </blockquote> <p>I want to find which one is greater from 2 dates with time that is in the following format in javascript</p> <p>date1=2-11-2012 13:40:00 date2=01-11-2012 10:40:00 </p>
javascript
[3]
3,571,880
3,571,881
Jquery intersect selector
<p>I'm sure the answer exists on SO somewhere, but I'm at a loss for what terminology to search for. So apologies if this is a duplicate.</p> <p>Is there an easy way in jQuery/JS of selecting the elements that "intersect" from the following HTML?</p> <pre><code>&lt;div id="first"&gt; &lt;div id="source-AAA"/&gt; &lt;div id="source-CCC"/&gt; &lt;div id="source-EEE"/&gt; &lt;div id="source-FFF"/&gt; &lt;/div&gt; &lt;div id="second"&gt; &lt;div id="BBB"/&gt; &lt;div id="CCC"/&gt; &lt;div id="DDD"/&gt; &lt;div id="FFF"/&gt; &lt;/div&gt; </code></pre> <p>i.e. getting hold of the elements <code>#CCC</code> and <code>#FFF</code> from <code>div#second</code>, based on the fact that these two IDs are in <code>#first</code>?</p> <p>I guess the proper answer is to do the intersect on the server-side (which is possible, but painful, as the two data sets come from different components), but I thought I'd check in case anyone knows of a neat way to do it in jQuery?</p>
jquery
[5]
2,092,722
2,092,723
Looking for relevant hobby projects for getting started with C#
<p>I am an experienced software developer in other less common technologies, and now need to ramp up C# skills with VS2010. As an experienced developer, I understand the syntax and language of C# quite quickly. </p> <p>However, developing windows and web applications with C# is somewhat foreign to me. Can someone please recommend/refer me to <strong>relevant hobby projects that take around a couple of weeks</strong> each that help familiarise developers with the most common API's and approaches to building web and/or windows applications. Thanks.</p>
c#
[0]
3,661,725
3,661,726
Current date should add 12 hours more in android
<p>In my application i want to add 12 hours with the current date and time,then i have to show it in this format "yyyy-MM-dd HH:mm:ss". I wrote the code but unable to add 12 hours. How can i do? please help. </p> <p>My code is :</p> <pre><code>Calendar cal = Calendar.getInstance(); Date date = cal.getTime(); String date1 = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date); m_tvTrackEnd.setText(date1); </code></pre>
android
[4]
5,094,341
5,094,342
C#: Selecting particular index values from a list
<p>I am looking for a way to search a list that returns me an bunch of indexes based on a search i make on that list. For ex i have a comma separated string list as follows:</p> <pre><code>Blue, 3 Red, 3 Blue, 1 Blue, 9 Red, 5 </code></pre> <p>I want to make a search that returns me indexes of all elements EXCEPT any that contain the text found in a criteria list. The criteria list could contain:</p> <pre><code>Blue, 3 Red, 5 </code></pre> <p>So in pseudo code, it would be,</p> <p>ColorList.SelectIndex(!Containing(Words found in all elements of criteriaList)</p> <p>The above should return indexes 1,2,3</p> <p>Thanks</p>
c#
[0]
4,911,623
4,911,624
get/set Accessors the correct scope
<p>i created a class called ProfileHelper, and I can't seem to get my get/set accessors correct; instead, I'm getting red lines on both get and set. Here is the code I am trying to use:</p> <pre><code>public static String UserName(string columnName) { get { using (SqlConnection cn = new SqlConnection(SiteConfig.ConnectionString)) { string sSql = ("SELECT UserName , LoweredUserName FROM aspnet_Users WHERE UserId = @UserId"); using (SqlCommand cm = new SqlCommand(sSql, cn)) { cm.Parameters.AddWithValue("@UserId", Membership.GetUser().ProviderUserKey.ToString()); cn.Open(); using (SqlDataReader rd = cm.ExecuteReader()) { while (rd.Read()) { return columnName; } rd.Close(); } cn.Close(); } } return columnName; } set { using (SqlConnection cn = new SqlConnection(SiteConfig.ConnectionString)) { string sSql = ("UPDATE [aspnet_ Users] SET UserName = @UserName, LoweredUserName = @LoweredUserName WHERE UserId = @UserId"); using (SqlCommand cm = new SqlCommand(sSql, cn)) { cm.Parameters.AddWithValue("@UserId", Membership.GetUser ().ProviderUserKey.ToString()); cn.Open(); cm.ExecuteNonQuery(); cn.Close(); } } } } </code></pre>
c#
[0]
3,309,785
3,309,786
Addition of textarea (int) values
<p>I'm facing a little problem with my jQuery / Javascript code.</p> <p>I have several values on a page, like :</p> <pre><code>checkbox EXAMPLE EXAMPLE 150 checkbox EXAMPLE EXAMPLE 300 checkbox EXAMPLE EXAMPLE 300 </code></pre> <p>I have this little code, which basically just add the numerical values (150, 300, 300) to an array, and then, sum the array in the "total" variable. (Well, at least this is what I'm trying to do...)</p> <p>Here's the code :</p> <pre><code> $('.pack_check').click(function() { var cout = []; total = 0; $('#services_pack input:checked').each(function() { cout.push(this.cout); $.each(cout,function() { total += parseInt(this); }); }); }); }); </code></pre> <p>My problem is, that when I click on my first checkbox, it's ok, total = 150 But, if I click on the second checkbox, total = (150 + 150 + 300) which is a bit annoying...</p> <p>Anyone ?</p> <p>Thanks in advance !</p>
jquery
[5]
2,219,648
2,219,649
Which is Faster and better, Switch Case or if else if?
<p>Which is the better and fastest methods : if or switch ?</p> <pre><code>if(x==1){ echo "hi"; }else (x==2){ echo "bye"; } switch(x){ case 1 ... break; default; } </code></pre>
php
[2]
1,472,607
1,472,608
Passing different number of arguments into function
<p>I have a function:</p> <pre><code>def save(self, text, *index): file.write(text + '\nResults:\n') if index == (): index = (range(len(self.drinkList))) for x in index: for y in self.drinkList[x].ing: file.write('min: ' + str(y.min) + ' max: ' + str(y.max) + ' value: ' + str(y.perc) + '\n') file.write('\n\n') file.write('\nPopulation fitness: ' + str(self.calculatePopulationFitness()) + '\n\n----------------------------------------------\n\n') </code></pre> <p>Now, when I pass one argument as an index the function works as it is supposed to, but when I pass a tuple of 2 indices I get an TypeError: list indices must be integers, not tuple. What should I change?</p>
python
[7]
4,131,703
4,131,704
Why is return value of queue:front() valid after queue::pop()
<p>I am new to C++ and ran into following <em>supposedly</em> bug, but somehow my program just works.. Here is the code</p> <pre><code>#include&lt;iostream&gt; #include&lt;queue&gt; #include &lt;string&gt; int main() { string s ("cat"); queue&lt;string&gt; _queue; _queue.push(s); string &amp; s1 = _queue.front(); _queue.pop(); // at this time s1 should become invalid as pop called destructor on s std::cout &lt;&lt; s1 &lt;&lt; std::endl; return 0; } </code></pre> <p>It just works, even though s1 is a reference to an invalid object. Is there a way i can assert that s1 truely refers to an invalid object?</p>
c++
[6]
2,226,108
2,226,109
How to integrtate skype in android app?
<p>Am developing and android app and i want to integrate skype in my application can you please help me?</p> <p>thanks in advance</p>
android
[4]
2,547,765
2,547,766
how to count application successfull launches programmatically android?
<p>I want to count my application launches and after some launches i need to request user to give feed back.So how to count launches?</p>
android
[4]
950,865
950,866
Library used to make CCleaner
<p>What kind of library has been used to make CCleaner?</p>
c++
[6]
5,612,930
5,612,931
Insert each array into separate divs
<p>I just need some advise before i start this. Basically I have an array of data of books from mysql - ID,Name,genre,ratings they are print out in an array like this</p> <pre><code>Array ( [book] =&gt; Array ( [0] =&gt; 1 [1] =&gt; book one [2] =&gt; horror [3] =&gt; 8.9 ) ) Array ( [book] =&gt; Array ( [0] =&gt; 2 [1] =&gt;book two [2] =&gt; Comedy [3] =&gt; 8.3 ) ) Array ( [book] =&gt; Array ( [0] =&gt; 3 [1] =&gt;book three [2] =&gt; Comedy [3] =&gt; 8.7 ) ) </code></pre> <p>And so on.. How do i put each array in seperate divs?</p> <p>PS PHP code to fetch data</p> <pre><code>$query=mysql_query("SELECT*FROM book "); while($row = mysql_fetch_array($query)) { $book= Array("book" =&gt; Array($row['id'], $row['name'],$row['genre'],$row['ratings']));echo"&lt;br&gt;"; print_r( $book); </code></pre> <p>Thanks</p>
php
[2]
2,648,055
2,648,056
How to persist data in a broadcast receiver
<p>I have a simple broadcast receiver which receives some data which I would like to store for the application to use on next launch. It is just a few strings so simplicity is the goal. Normally I'd just write to to a file or sharedPreferences but not being an activity that seems incorrect.</p> <p>Thoughts?</p> <p>-- Henry</p>
android
[4]
5,200,588
5,200,589
C# Array of Controls
<p>Basically I have 3 arrays of different types:</p> <pre><code>control = new Control[2] { txtRecordDelimeter, txtFieldDelimeter }; name = new string[2] { "Record Delimiter", "Field Delimiter" }; exists = new bool[2] { false, false }; </code></pre> <p>...essentially I would like to create a loop that checks whether the string existed in an object passed into a constructor, if did, set the bool of the respective index to true and then ammend the respective control with a new value.</p> <p>Originally I had a bunch of if statements and repeating code so I wanna cut that out with a for loop.</p> <p>However, for example, when I attempt to reference control[0].<em>whatever</em> I get the same list from IntelliSense regardless of whether or not the control is a text box or a combo box etc.</p> <p>I'm guessing I'm missing something simple here like not referencing an instance of the control per se, but I'd be greatful if someone could explain what I'm doing wrong or suggest a better way to achieve this!</p> <p>Thanks :]</p>
c#
[0]
274,645
274,646
Determining if a set of points are inside or outside a square
<p>I have two of these:</p> <pre><code>bool isPointOnShape(int a, int b) { } bool isPointInShape(int a, int b) { } </code></pre> <p>Say I have a square, first point (bottom left corner) is x,y (0,0) second point (top left) is (0,2), third is (2,2) and fourth is (0,2).</p> <p>The Points on shape would be (0,1) (1,2) (2,1) (1,0) and Points in shape is (1,1)</p> <p>How do I find out the points on shape / in shape and return a true value so that I can store it somewhere?</p>
c++
[6]
4,515,231
4,515,232
How to count how many inputs collect this function?
<p>How to count how many inputs collect this function and if is not 4 then displays alert with some information?</p> <pre><code> $('#dialog').on('show', function () { $('form#form_save_account input:visible').each(function(idx, $input) { $('#dialog .bank-data .' + $input.name + ' .value').text($input.value); }); }); </code></pre>
jquery
[5]
36,456
36,457
How to export to excel jquery grid data using jquery
<p>Can any one help me out how to export the jquery grid data to excel?</p> <p>i have inserted one button call export?</p> <pre><code>$("#Export").click(function(){ I am little confuse what should I write? }); </code></pre> <p>thanks</p>
jquery
[5]
2,186,719
2,186,720
sms forwarding without accessing the main mobile
<p>Is there any way , to get someones text-messages forwarded to my phone number without physically accessing the first phone or main phone ? Is there any script in php that could do this?</p>
php
[2]
1,606,295
1,606,296
Displaying my 2D array code
<p>Requirements:</p> <p>1.How to display the stored data for each individual month without having to copy and paste code several times for the DisplayMonthData() method?</p> <p>2.Is my code for summing up all the values for each month correct in DisplayMonthData()?</p> <p>Thanks in advance.</p> <pre><code> static void MonthData() { try{ for(int i=0;i&lt;10;i++){ System.out.print("Enter item "+(i+1)+" &lt;Press ENTER to exit&gt; : "); monthItems[m][i] = input.next(); if (monthItems[m][i].length() == 0){ return; } else { System.out.print("Enter amount : $"); amount[m][i] = input.nextDouble(); System.out.println(""); } } }catch(Exception e){ System.out.println(""); } } static void DisplayMonthData() { if(months[m]=="Jan"){ for(int row=1;row&lt;amount.length;row++){ for(int column=0;column&lt;amount[row].length;column++){ //janItems[]+=monthItems[1][0]; if(amount[row][column]!=0){ System.out.println(monthItems[row][column]+"\t$"+fmt.format(amount[row][column])); }else{} } } sum[L]+=amount[1][0]; System.out.println(); System.out.println("Total amount spent for the month of January is $"+fmt.format(sum[L])); L++; } } </code></pre>
java
[1]
1,629,712
1,629,713
Using commons-beanutils throws ClassNotFoundException on org.apache.commons.logging.LogFactory
<p>I have same code</p> <pre><code>import org.apache.commons.beanutils.PropertyUtils; public class Reflection { private double []masElement = {3,5,2,5}; public double getValue(int i){ if (masElement.length&gt;i){ return masElement[i]; } return 0; } public void setValue(int i, int value){ if (masElement.length&gt;i){ masElement[i]=value; } } public static void main(String[] args) { Reflection n = new Reflection(); try { System.out.println(PropertyUtils.getProperty(n, "masElement[0]")); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } </code></pre> <p>I have problem and i don't understand why?</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.apache.commons.beanutils.ConvertUtilsBean.&lt;init&gt;(ConvertUtilsBean.java:157) at org.apache.commons.beanutils.BeanUtilsBean.&lt;init&gt;(BeanUtilsBean.java:117) at org.apache.commons.beanutils.BeanUtilsBean$1.initialValue(BeanUtilsBean.java:68) at org.apache.commons.beanutils.ContextClassLoaderLocal.get(ContextClassLoaderLocal.java:153) at org.apache.commons.beanutils.BeanUtilsBean.getInstance(BeanUtilsBean.java:80) at org.apache.commons.beanutils.PropertyUtilsBean.getInstance(PropertyUtilsBean.java:114) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426) at same.home.reflection.Reflection.main(Reflection.java:39) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 8 more </code></pre>
java
[1]
1,914,754
1,914,755
How can I find all tables cells which only contain a non breaking space with jQuery?
<p>I need to only find the cells in the table which contain <code>&amp;nbsp;</code> using jQuery. </p> <pre><code> &lt;table&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;Something&lt;/td&gt; &lt;td&gt;something else&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Any ideas?</p>
jquery
[5]
583,704
583,705
Weakly typed language type conversion of meaning where, why use. For example JavaScript
<p>Weakly typed language type conversion is not necessary, can directly use it, why type conversion.</p>
javascript
[3]
5,626,126
5,626,127
Pythonic way to "flatten" object hierarchy to nested dicts?
<p>I need to "flatten" objects into nested dicts of the object's properties. The objects I want to do this with are generally just containers for basic types or other objects which act in a similar way. For example:</p> <pre><code>class foo(object): bar = None baz = None class spam(object): eggs = [] x = spam() y = foo() y.bar = True y.baz = u"boz" x.eggs.append(y) </code></pre> <p>What I need to "flatten" this to is:</p> <pre><code>{ 'eggs': [ { 'bar': True, 'baz': u'boz' } ] } </code></pre> <p>Is there anything in the stdlib which can do this for me? If not, would I have to test <code>isinstance</code> against all known base-types to ensure I don't try to convert an object which can't be converted (eg: bool)?</p> <p><strong>Edit:</strong></p> <p>These are objects are being returned to my code from an external library and therefore I have no control over them. I could use them as-is in my methods, but it would be easier (safer?) to convert them to dicts - especially for unit testing.</p>
python
[7]
1,103,307
1,103,308
Creating Remote database in Android
<p>This is my first post in stackoverflow. I am beginner in Android app development and trying to make an app with Signup screen with username and email-id.</p> <p>1.I want to store these details at some remote database so that user can also login from "other" android device and thus SQlite can't be used for the purpose.</p> <p>How can i accomplish this ?</p> <p>2.Suppose i have a website and want to use the website's database to authenticate and register clients via login/Signup.</p> <p>What are possible ways to do this ?</p> <p>Thanks for any reply.</p>
android
[4]
4,617,440
4,617,441
I'm trying to creating a Queue class, but keep getting an error seemingly to do with generics. Why am I getting this error?
<p>I have a LinkedList class, which serves as the base for a Queue class, which serves as the base for a PrintQueue class.</p> <p>Here's my PrintQueue class:</p> <pre><code>public class PrintQueue&lt;T&gt; { private Queue&lt;T&gt; queue; public PrintQueue() { queue = new Queue&lt;T&gt;(); } public void lpr(String owner, int jobID) { queue.enqueue(new Job(owner, jobID)); } } </code></pre> <p>The <code>queue.enqueue(...)</code> line, three from the bottom is resulting in an error:</p> <blockquote> <p>The method enqueue(T) in the type Queue is not applicable for the arguments (Job)</p> </blockquote> <p>PrintQueue is a queue of Job objects.</p> <p>The enqueue method in my Queue class looks like this:</p> <pre><code> public void enqueue(T item) { queue.addToEnd(item); } </code></pre> <p>And the addToEnd method looks like this:</p> <pre><code>public void addToEnd(T item) { Node&lt;T&gt; itemnode = new Node&lt;T&gt;(item, null); if (isEmpty()) { head = itemnode; } else { Node&lt;T&gt; curr = head; while (curr.getNext()!=null) { curr= curr.getNext(); } curr.setNext(itemnode); } count++; } </code></pre> <p>Why isn't this working? All three classes (PrintQueue, Queue and LinkedList) are generic classes .</p>
java
[1]
3,356,164
3,356,165
Resize event not getting called or probably some other issue
<p>I am trying to have jQuery append a Wide.css stylesheet to the page whenever the browser window is over 1360px and remove the file whenever it is less then that.</p> <p>Currently, the main stylesheet only has wrapper defined with gray background and 900px width and the other, Wide.css, has background red and wrapper width 1300px.</p> <p>The problem I am facing is that it works fine with refreshing the page, however, whenever the window is simply resized, the function does not get called(or there is some other issue with the code).</p> <p>The script:</p> <pre><code>$(document).ready(function () { stylesheetToggle(); $(window).resize(stylesheetToggle); }); function stylesheetToggle() { if ($('body').width() &gt; 1360) { $('&lt;link rel="stylesheet" href="Content/Stylesheets/Wide.css" type="text/css" /&gt;').appendTo('head'); } else { $('link[href=Content/Stylesheets/Wide.css]').remove(); } } </code></pre>
jquery
[5]
4,491,226
4,491,227
contextmenu for particular line in a multi-line view listview
<p>I have a listview with each item in the list having 2 lines .I want to create a context menu for it such that the header of the context menu should be the text in the first line of the selected item.How to achieve this.Here the name "dfsflk" was hardcoded.I want the program to identify the selected item and display the name as the title.</p> <pre><code>@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.contextmenu, menu); menu.setHeaderTitle( "dfsdlk"); } </code></pre>
android
[4]
4,041,473
4,041,474
slideDown behaviour on hover with inner divs being absolute
<p>Here is something that I can't figure it out.</p> <p>Here is a simple example: <a href="http://jsfiddle.net/MrkMZ/" rel="nofollow">http://jsfiddle.net/MrkMZ/</a></p> <p>HTML:</p> <pre><code>&lt;div id="box"&gt; &lt;div id="top"&gt;&lt;a href="#"&gt;top text&lt;/a&gt;&lt;/div&gt; &lt;div id="bottom"&gt;&lt;a href="#"&gt;bottom text&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>#box { width: 200px; height: 200px; background-color: yellow; position: relative; } #top { position: absolute; top: 0; left: 0; width: 200px; height: 50px; background-color: #ff0000; } #top a { margin-top: 20px; display: inline-block; } #bottom { position: absolute; bottom: 0; left: 0; width: 200px; height: 30px; background-color: #ff0000; } </code></pre> <p>JS:</p> <pre><code>$('#box').hover( function(){ $(this).find('#top, #bottom').slideUp(300); }, function(){ $(this).find('#top, #bottom').slideDown(300); } ); </code></pre> <p>As you can see, on box hover the top and bottom divs slide correctly but the text inside the top and bottom divs behave differently when sliding. The top text stays while the bottom text slides down with the div.</p> <p>Anyway to make even the top text slide? Or make the bottom text stay instead of sliding.</p> <p>On slideDown/slideUp jQuery changes the height of the element.</p> <p>The only difference is that one has top: 0 and bottom one has bottom: 0. That alone makes this weird effect.</p> <p>What am I missing here?</p>
jquery
[5]
5,199,059
5,199,060
How to declare a generic type Multi-Dimensional array in java
<p>I want to store an array of 100 int elements in rows ie 1 row of 100 int datatypes.And every single element contains an array of 100 objects.How to do this in java or android. </p>
java
[1]
3,884,726
3,884,727
Best UI element for displaying results of XML parsing
<p>i am a student and also new to iphone SDK.i want to do xml parsing which has image URL and Data,it is a XML file about news.i have to show it .can i use table view or navigation controller? which is the best way?i have to show images and titles in first page.when i click it,it shows other page to show full news with image. is there any tutorial for what i need?</p>
iphone
[8]
415,531
415,532
Not getting Logs in logcat
<p>In my application after a particular Activity the logcat stops working with the following Error message. <strong>Segmentation fault logcat -v long</strong></p> <p>After that i have to start the Emulator again then only it shows the logs.</p> <p>Can anyone pls help?</p>
android
[4]
3,094,599
3,094,600
Python Getting date online?
<p>How can I get the current date, month &amp; year online using Python? Thanks!</p> <p>EDIT-By this I mean, rather than getting it from the computer's date-visit a website &amp; get it, so it doesn't rely on the computer.</p>
python
[7]
4,238,213
4,238,214
Images not displaying in gridview for API Level 17
<p>I am displaying images from a <code>php server</code> to <code>gridview</code>. The images are displaying on devices when the API level is below <code>10</code> but I want to display the images on devices from API level <code>8</code> to <code>17</code></p> <p>My code is </p> <pre><code>try { myFileUrl = new URL(fileUrl); conn = (HttpURLConnection) myFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); int length = conn.getContentLength(); is = (InputStream) conn.getInputStream(); //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(conn.getInputStream(),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int REQUIRED_HIGHT=HIGHT; //Find the correct scale value. It should be the power of 2. int scale=1; while(o.outWidth/scale/2&gt;=REQUIRED_WIDTH &amp;&amp; o.outHeight/scale/2&gt;=REQUIRED_HIGHT) scale*=2; //Decode with inSampleSize BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize=scale; Bitmap img = BitmapFactory.decodeStream(conn.getInputStream(), null, o2); is.close(); </code></pre>
android
[4]
604,189
604,190
Deleting An item from a List Box from a Database
<p>Hi Im trying to delete an item from the listbox which the user selects here you can find my code and a screenshot tnx.</p> <p>Code:</p> <pre><code>public void deleteEvent(ListBox list_event) { int i = list_event.SelectedIndex; ds.Tables["tblEvents"].Rows[i].Delete(); da.Update(ds.Tables["tblEvents"]); } </code></pre> <p>Im getting Object reference not set to an instance of an object Exception.</p> <p>ScreenShot: <img src="http://i.stack.imgur.com/1cRTj.jpg" alt="enter image description here"></p>
c#
[0]
5,182,389
5,182,390
Imports in python are static, any solution?
<p>foo.py :</p> <pre><code>i = 10 def fi(): global i i = 99 </code></pre> <p>bar.py :</p> <pre><code>import foo from foo import i print i, foo.i foo.fi() print i, foo.i </code></pre> <p>This is problematic. Why does <code>i</code> not change when <code>foo.i</code> changes?</p>
python
[7]
5,833,371
5,833,372
Wifi reports as "enabled" even though it's not
<p>I'm not sure if this is a Galaxy Tab specific issue or if I'm not utilizing some relevant method of the WifiManager library, but my application correctly reports that the Wifi is disabled at launch, but then as soon as I enable it, it deems itself as enabled, even though it's still in the process of connecting.</p> <p>So, I have a thread in which I'm waiting for the enabled state</p> <pre><code>//at THIS line it claims to be WIFI_STATE_DISABLED so I turn it on with... wifiManager.setEnabled(true); //and at this line it reports as 3 (which according to the doc is WIFI_STATE_ENABLED, even though it clearly isn't while(wifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED || wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING){ </code></pre> <p>but it never never enters the loop, it just jumps right past even though it is NOT enabled</p> <p>I'm hoping there's some other mechanism that I'm missing, or maybe I'm misunderstanding what "enabled" means?</p>
android
[4]
5,676,045
5,676,046
Why is isNaN(null) == false in JS?
<p>This code in JS gives me a popup saying "i think null is a number", which I find slightly disturbing. What am I missing?</p> <pre><code>if (isNaN(null)) { alert("null is not a number"); } else { alert("i think null is a number"); } </code></pre> <p>I'm using Firefox 3. Is that a browser bug?</p> <p>Other tests:</p> <pre><code>null == NaN; // false isNaN("text"); // true NaN == "text" // false </code></pre> <p>So, the problem seems not to be an exact comparison with NaN?</p> <p><i><b>Edit:</b> Now the question has been answered, I have cleaned up my post to have a better version for the archive. However, this renders some comments and even some answers a little incomprehensible. Don't blame their authors. Among the things I changed was:</p> <ul> <li>Removed a note saying that I had screwed up the headline in the first place by reverting its meaning</li> <li>Earlier answers showed that I didn't state clearly enough why I thought the behaviour was weird, so I added the examples that check a string and do a manual comparison. </i></li> </ul>
javascript
[3]
3,509,923
3,509,924
How to execute commands in Command Prompt using c#
<p>I want to execute these steps in CMD using c#</p> <p>1 - CD C:\MySQL\MySQL Server 5.0\bin</p> <p>2 - mysqldump -uroot -ppassword sample> d:\Test\222.sql</p> <p>On manually doing this, i will get file named "222.sql"</p> <p>I am using the below code to do it, but missing something.. Nothing Happens</p> <pre><code>public void CreateScript_AAR() { string commandLine = @"CD C:\MySQL\MySQL Server 5.0\bin\mysqldump -uroot -ppassword sample&gt; d:\Test\222.sql"""; System.Diagnostics.ProcessStartInfo PSI = new System.Diagnostics.ProcessStartInfo("cmd.exe"); PSI.RedirectStandardInput = true; PSI.RedirectStandardOutput = true; PSI.RedirectStandardError = true; PSI.UseShellExecute = false; System.Diagnostics.Process p = System.Diagnostics.Process.Start(PSI); System.IO.StreamWriter SW = p.StandardInput; System.IO.StreamReader SR = p.StandardOutput; SW.WriteLine(commandLine); SW.Close(); } </code></pre>
c#
[0]
2,552,065
2,552,066
Count the number of '8's Problem in Java
<p>Im stuck with the below problem.</p> <p><strong>Problem Statement:</strong></p> <p>Given a non-negative int n, return the count of the occurrences of 8 as a digit, except that an 8 with another 8 immediately to its left counts double, so 8818 yields 4.</p> <p>Note: mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). </p> <p><strong>The above problem has to be solved without using Recursion and without the usage of any formulas.</strong></p> <p>The function signature is <code>public int count8(int n)</code></p> <p>Examples are:</p> <pre><code>count8(8) → 1 count8(818) → 2 count8(8818) → 4 </code></pre> <p>I got this problem from one of the Programming Forums. I dont know how to start with this problem, I want to solve it, but I am really confused on where to begin.</p>
java
[1]
5,484,186
5,484,187
Can I generate an array based on url path?
<p>I have a path like:</p> <p>/blog/2/post/45/comment/24</p> <p>Can I have an array depends on what I have on url, like :</p> <pre><code>$arr = array('blog'=&gt;'2','post'=&gt;'45','comment'=&gt;'24'); </code></pre> <p>But it should depend on variable passed:</p> <pre><code>/blog/2 should produce $arr = array('blog'=&gt;'2'); </code></pre> <p>Is this possible to create dynamic array?</p>
php
[2]
3,522,121
3,522,122
A NullPointerException in the code
<p>When I am trying to execute the code below, in the project it gives an error <code>manual array copy to collection</code>. On the other hand, when I execute the project in the JSP using NetBeans, it is showing <code>NPE</code> at a <code>for-loop</code>. Any idea?</p> <pre><code>ArrayList courseNames=new ArrayList(); String []values=request.getParameterValues("ToList"); for(int i=0;i&lt;values.length;i++) courseNames.add(values[i]); </code></pre>
java
[1]
4,343,781
4,343,782
Format and echo datetime string received from MySQL?
<p>how would I format a datetime string received from MySQL? For example, when I do </p> <pre><code>echo $info['start_datetime'] </code></pre> <p>I get <em>2012-03-18 21:00:00</em>, but I would like to Turn it into Sunday, March 18, 2012. I looked at the php documentation where it showed the different formats, but not specifically when they're retrieved from MySQL.</p> <p>Thanks everyone!</p>
php
[2]
5,852,319
5,852,320
In Javascript, how to conditionally add a member to an object?
<p>I would like to create an object with a member added conditionally. The simple approach is:</p> <pre><code>var a = {}; if (someCondition) a.b = 5; </code></pre> <p>Now, I would like to write a more idiomatic code. I am trying:</p> <pre><code>a = { b: (someCondition? 5 : undefined) }; </code></pre> <p>But now, <code>b</code> is a member of <code>a</code> whose value is <code>undefined</code>. This is not the desired result.</p> <p>Is there a handy solution?</p> <p><strong>Update</strong></p> <p>I seek for a solution that could handle the general case with several members.</p> <pre><code>a = { b: (conditionB? 5 : undefined), c: (conditionC? 5 : undefined), d: (conditionD? 5 : undefined), e: (conditionE? 5 : undefined), f: (conditionF? 5 : undefined), g: (conditionG? 5 : undefined), }; </code></pre>
javascript
[3]
3,361,690
3,361,691
Omission of form tag and security concerns. Advice please
<p>I want to use straight JQuery to submit a form and omit the form tag all together. If I do this, are there any security issues that I need to be concerned with?</p> <p>Apart from the user not being able to use the site if his javascript is turned off, should I be concerned?</p>
jquery
[5]
2,865,639
2,865,640
Scope variable inside if
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2049330/c-sharp-variable-scoping">C# Variable Scoping</a> </p> </blockquote> <p>I thought I may declare two variables with the same name if in different scope: </p> <pre><code>namespace IfScope { class Demo { public static void Main() { bool a = true; if ( a ) { int i = 1; } string i = "s"; } } } </code></pre> <p>The compiler says something else: </p> <pre><code>$ csc Var.cs Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1 Copyright (C) Microsoft Corporation. All rights reserved. Var.cs(13,20): error CS0136: A local variable named 'i' cannot be declared in this scope because it would give a different meaning to 'i', which is already used in a 'child' scope to denote something else </code></pre> <p>That would mean <code>i</code> declared inside the if is visible outside ( that's what I understood ) </p> <p>But if I try to use it then I get this.</p> <pre><code>$ cat Var.cs namespace IfScope { class Demo { public static void Main() { bool a = true; if ( a ) { int i = 1; } i = "s"; } } } Var.cs(13,14): error CS0103: The name 'i' does not exist in the current context </code></pre> <p>Obviously, but what's going on here?</p>
c#
[0]
342,241
342,242
JavaScript: scroll position (Webkit engine)
<p>I'm currently trying to use JavaScript to find out how far down the page the user has scrolled; for Firefox 8.0, the keyword is <em>pageYOffset</em>.</p> <p>To say things mechanically:</p> <ol> <li><p>The <strong>page</strong> has a certain height. In Firefox, the useful object is <em>document.documentElement.scrollHeight</em>.</p></li> <li><p>The <strong>browser's visible area</strong> also has a certain height. In Firefox, the object is <em>window.innerHeight</em>; in IE8, <em>document.documentElement.clientHeight</em>.</p></li> <li><p>I need to know where the user is in the page vertically; in other words, <strong>how many pixels down the page</strong> the user has scrolled.</p></li> </ol> <p><strong>Does Webkit have a DOM object that refers to the current scroll position?</strong></p> <p>Thank you.</p>
javascript
[3]
5,998,095
5,998,096
What is the best way to reuse pages from one website in another?
<p>I'm developing a new ASP .NET website which is effectively a subset of the pages in another site we've just released. Two or three of the pages will need minor tweaks but nothing significant.</p> <p>The obvious answer is to simply copy all of the code and markup files into the new project, make the aforementioned tweaks, and consider the job done. However I'm not keen on this at all due to the amount of duplicated code it will create.</p> <p>My next idea was to move the code for the pages (i.e. the code-behind file) into a separate assembly which can then be referenced from both sites. This is a little awkward however as if you don't take the designer file with it, you get a lot of build errors relating to missing controls. I don't think moving the designer file is a good idea though as this will need to be regenerated each time the markup is altered.</p> <p>Does anyone have any suggestions for a clean solution to this problem?</p>
asp.net
[9]
189,226
189,227
How to change the icon color on a android osm mapview
<p>How to change the icon color on a osm map view in android</p>
android
[4]
1,245,854
1,245,855
javascript date reference or value
<p>I'm storing a date in a global variable called <code>MyDate</code>. If I write this:</p> <pre><code>var TheDate = MyDate; for (var i = 5; i &gt; 0; i--) { TheDate = TheDate - i; } </code></pre> <p>Am I just changing <code>TheDate</code> or am I also changing <code>MyDate</code>?</p> <p>Thanks.</p>
javascript
[3]
2,700,267
2,700,268
Getting a list of all subdirectories in the current directory
<p>Is there a way to return a list of all the subdirectories in the current directory in python?</p> <p>I know you can do this with files, but I need to get the list of directories instead.</p>
python
[7]
123,338
123,339
Copy constructor invocation for member objects
<p>C++ says that to create a copy constructor for a class that uses composition, the compiler recursively calls the copy constructors for all the member objects. I tried that same thing in the below code:</p> <pre><code>class A { public: A(){cout&lt;&lt;"A constructor called"&lt;&lt;endl;} A(const A&amp;){cout&lt;&lt;"A copy constructor called"&lt;&lt;endl;} }; class B { public: B(){cout&lt;&lt;"B constructor called"&lt;&lt;endl;} B(const B&amp;){cout&lt;&lt;"B copy constructor called"&lt;&lt;endl;} }; class C { A a; B b; public: C(){cout&lt;&lt;"C constructor called"&lt;&lt;endl;} C(const C&amp;){cout&lt;&lt;"C copy constructor called"&lt;&lt;endl;}// If you comment this line, you will get output: Case 1 (see below) and if you don't comment, you will get o/p: case 2(see below) }; void main() { C c; cout&lt;&lt;endl; C c2 = c; }` </code></pre> <p>Case 1:</p> <blockquote> <p>A constructor called</p> <p>B constructor called </p> <p>C constructor called</p> <p>A copy constructor called</p> <p>B copy constructor called</p> </blockquote> <p>Case 2:</p> <blockquote> <p>A constructor called</p> <p>B constructor called </p> <p>C constructor called</p> <p>A constructor called</p> <p>B constructor called</p> <p>C copy constructor called</p> </blockquote> <p>My doubt is that the o/p for case 2 should be: A, B, C, constructor called and then.. A, B, C copy constructor called. But it is not happening. Please help.</p>
c++
[6]
3,060,180
3,060,181
How to debug uninitialized variables in VC++
<p>How to debug uninitialized variables in release mode in C++.</p>
c++
[6]
1,888,554
1,888,555
Hiding a class from outside when use is only for inside an API in C++
<p>In languages like Java, you can declare a class without a modifier so it will only be visible inside the same package. I need to do something similar in C++. I am trying to create an API that will be a library to be used in other applications. After asking <a href="http://programmers.stackexchange.com/questions/132403/should-i-use-friend-classes-in-c-to-allow-access-to-hidden-members">this</a> question on programmers Stackexchange, I have decided to use some sort of handle, which will just be an unsigned integer that is passed to an API function, which will then pass it to a class that will look it up in some sort of table and return a pointer to the object the handle represents, back to the function. The API function will then be allowed to operate on the pointer, but without the public ever having access to the pointer. </p> <p>The problem is, I would like the class that handles the handles to not be visible to the public (even though the public won't have an instance of the class that contains the handles), as it is only needed inside the API functions. Also, I wanted this handle class to be a template (only needed for compiling the API), because I would most likely have handles representing different types of classes (although I could probably get away with one table containing void pointers, but it seems a little unsafe). I cant hide the class in a .cpp file, because it would be needed in multiple .cpp files that compose the API.</p> <p>Also, I was thinking about using the pimpl idiom in any classes that have public functions, that way if there were any private functions in them that needed a parameter related to one of my classes hidden from the public, a header file including hidden classes would not need to be included with the API libraries for the API user to be able to compile the program.</p> <p>So what would be the best way to hide classes that are only needed among other classes (spread across multiple .h and .cpp files) inside the API its self, from the outside world?</p>
c++
[6]
2,965,072
2,965,073
Why doesn't JavaScript let you call methods on numbers directly?
<p>In Ruby, you can do this:</p> <pre><code>3.times { print "Ho! " } # =&gt; Ho! Ho! Ho! </code></pre> <p>I tried to do it in JavaScript:</p> <pre><code>Number.prototype.times = function(fn) { for (var i = 0; i &lt; this; i++) { fn(); } } </code></pre> <p>This works:</p> <pre><code>(3).times(function() { console.log("hi"); }); </code></pre> <p>This doesn't</p> <pre><code>3.times(function() { console.log("hi"); }); </code></pre> <p>Chrome gives me a syntax error: "Unexpected token ILLEGAL". Why?</p>
javascript
[3]
4,477,778
4,477,779
Common method for comparing any two Java objects
<p>I want to compare two Java objects <strong>without overriding equals method</strong>. Since I need to override equals method in n number of Classes I have, I am in need of a common utility method where we can compare two Java objects.</p> <p>Something <em>like</em>:</p> <pre><code>A a1,a2; B b1,b2; C c1,c2; ----- ----- boolean isEqual1 = new ObjectComparator().isEquals(a1 , a2); boolean isEqual2 = new ObjectComparator().isEquals(b1 , b2); boolean isEqual3 = new ObjectComparator().isEquals(c1 , c2); </code></pre> <p>Please help me out to write a common utility for comparing any Java objects</p> <p>Hope by using <code>Field</code> class, and <code>getClass</code> method we can achieve it. Please guide me.</p>
java
[1]
4,724,055
4,724,056
How to define class-specific << operator in C++
<p>Given a class such as:</p> <pre><code>class Person { private: char *name; public: Person() { name = new char[20]; } ~Person() { delete [] name; } } </code></pre> <p>I want to print to print the name from an instance of this, using a statement like the following:</p> <pre><code>cout &lt;&lt; myPerson &lt;&lt; endl; </code></pre> <p>What do I need to do to define the <code>&lt;&lt;</code> output operator for this class?</p>
c++
[6]
417,770
417,771
Memory leakage on event handling
<p>I've been reading about memory leakages lately and haven't yet wrapped my head around all of it and have some questions regarding my own style of writing. Specifically, I'm not really sure if the way I handle events might be a source of leaking. Consider the following code </p> <pre><code>function Wrapper(text) { this.text = text; this.bindHandlers(); }; Wrapper.prototype.onClick = function (e) { alert(this.text); }; Wrapper.prototype.bindHandlers = function () { var t = this, div = $('&lt;div&gt;' + this.text + '&lt;/div&gt;'); var reallyHugeArray = [1,2,3...]; // an array of 100000 elements for example div.click(function (e) { // all variables of the parent function are in scope for this function, including reallyHugeArray t.onClick(e); }); $(document).append(div); }; var a = new Wrapper('testString'); // had enough fun with the Wrapper, now let's nullify it a = null; </code></pre> <p>As you can see, I like to use an anonymous functions as the event handler so that it would be more convenient to have access to instance specific variables (in this case <code>this.text</code> in the <code>onClick</code> function) and functions. However, if I understood correctly, having an anonymous function inside a function (as is the event handler), which has access to the local scope, disables the garbage collector from removing the local variables, therefore creating a leak. </p> <p>So my question is whether this method of event handling can create memory leakages and if it does, is there any way to prevent it, but still have a similarily convenient way to access the instance variables and functions?</p> <p>(Off-topic: a function inside a function inside a function makes Javascript sound like Inception)</p>
javascript
[3]
4,754,690
4,754,691
PHP condition for matching exact characters string
<p>I have the following code which makes sure the text entered in the "captcha" text box is at least 3 characters long or else an error is received. How do i set it so the text entered has to be "abcd" or else an error occurs?</p> <pre><code> if(strlen($_POST['captcha']) &lt; 3) { $error_message .= 'Please ensure the captcha entered is at least 3 characters long'; </code></pre>
php
[2]
5,615,335
5,615,336
Java code understanding
<p>Hi I am a bit new to programming and recently I have been given a piece of code that I must understand of a monopoly game written in Java.</p> <p>I have never tried to understand someone else's code so naturally I don't even know where to start. </p> <p>My boss asked me after I understand the code and it's functionality to reproduce it.Easier said than done since the game has about 3000 lines of code.</p> <p>I have tried to start from the main class but this seems to be getting me nowhere because I keep being sent to a dozen different classes.</p> <p>What I wanted to ask is if there is a software that shows what pieces of code are running during the time the game is turned on.</p> <p>If such software doesn't exist, where in the code do you guys recommend me to start and what tips can you give me to make this go well?</p>
java
[1]
4,538,891
4,538,892
What is a benefit of having source code for ICS?
<p>People are so happy the source code of Ice Cream Sandwich became available for syncing. Why is that cool?</p>
android
[4]
2,108,831
2,108,832
ASP.NET Forms Parameters on Links
<p>Ok, let me start this with I am more of an MVC person. I have a result set that I am trying to add paging. All I really want is a previous and next button on my page which are Link controls. I need these controls to post back to the same page, but have a query parm like page=4. How do I add these links? I see the PostBackUrl property on the link. Should I just use Request.Url and stuff it into PostBackUrl? Then I have to do string searches on the parm... it gets nasty. Is that the only way? I have tried ViewState, please dont suggest that... it is unpredictable garbage as far as I am concerned.</p>
asp.net
[9]