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
2,707,808
2,707,809
ViewPagers in ListView: onItemClickListener
<p>I have a <code>ListView</code> which shows <code>ViewPager</code>s as row elements. I want to use an <code>OnItemClickListener</code>, but the <code>ViewPager</code> prevents <code>onItemClick</code> from being called. How can I do this?</p>
android
[4]
5,442,519
5,442,520
Programming Modular software
<p>I stand in front of a little problem; <em>I want to create a modular software.</em></p> <p>Let's make it more general and not specific for my case. What I want to create is a software which loads dlls and those dlls adds features to the software.</p> <p>Think of the dlls as xvid, divx or whatever additional codec, feature to your favorite video-player. I want a more custom modular program though, in my case I'm creating a software to handle Customers, Invoices and Products and different users might have different needs and therefore I need to handle this somehow!</p> <p>However, re-compiling the software and specificly sending the new files to each different user is "stupid" I would rather create a modular software ( don't actually know if this is the correct term ).</p> <p>So what I was thinking is that I begin creating a pattern of which my DLL's should follow.</p> <p>Then I create a Module handler in my software which loads the actuall DLL and calls the method in it ( here's where the pattern come in! ).</p> <p>What I'd like to know is; Am I on the right track?</p> <p>Might you guys give me some pointers or examples on this matter?</p> <p>This is all in C#, but would of course be interesting to see how it would differ in Java, Python or C++ too.</p>
c#
[0]
138,282
138,283
python - while loop question
<p>Please look at the code. I'm using a robot car to draw a letter and in this code, when I type b, it will still draw small case a.</p> <pre><code>import create # Draw a: def drawa(): #create robot robot = create.Create(4) #switch robot to full mode robot.toFullMode() for i in range(1280): robot.go(20,30) robot.stop() robot.move(-40,20) # Draw b: def drawb(): #create robot robot = create.Create(4) #switch robot to full mode robot.toFullMode() robot.move(-100,20) for i in range(1270): robot.go(20,-30) robot.stop() # Draw c: def drawc(): #create robot robot = create.Create(4) #switch robot to full mode robot.toFullMode() for i in range(700): robot.go(20,30) robot.stop() # Define Main Function def main(): # While loop while(True): # Prompt user to enter a letter letter = raw_input("Please enter the letter you want to draw: ") # If user enters the letter a, draw a if letter=="A" or "a": drawa() # If user enters the letter b, draw b elif letter=="B" or "b": drawb(); # If user enters the letter c, draw c elif letter=="C" or "c": drawc(); # If user enters anything other than a letter from a-z, # ask them to enter a valid input else: print("Please enter a letter from a-z.") main() </code></pre> <p>please help.</p>
python
[7]
4,392,925
4,392,926
Android: Refresh Activity
<p>I have a problem ! I have 3 Activities, DB, and WebServer. Let say that every 20 min server clean my DB and fill it up with new Data. Every Activity use data from DB. How to refresh active activity automaticaly when new refresh of DB was done. Thanks.</p>
android
[4]
1,735,996
1,735,997
Order of list obtained by dictionary's keys()
<p>Can I expect the keys() to remain in the same order? </p> <p>I plan to use them for a dropdown box and I dont want them to shift if I add or delete items from the dictionary.</p>
python
[7]
1,741,792
1,741,793
Examples solicited: who is using C# for anything besides Windows front ends?
<p>As an outgrowth of "Why should I learn C++ rather than C# question, here is a poll: who is using C# for things that are not related to Windows GUI? Web programming qualifies, even if I think it's borderline. Ideal example would be a back-end application where you chose C# specifically because of its language features, and not because that's the only thing used at your shop.</p>
c#
[0]
4,112,074
4,112,075
In the onDraw() method, why does the supplied Canvas already have scale?
<p>In a current test project I have a custom View, that I have named SVGView, that simply paints some vector graphics (Paths, etc.) to the Canvas. </p> <p>The XML layout file consists of nothing more than a FrameLayout, which contains a single child SVGView. The <code>android:layout_width</code> and <code>android:layout_height</code> attributes for the SVGView in the current example are both set to <code>300px</code> (which the containing FrameLayout has more than enough room to accommodate). In the SVGView's <code>onMeasure()</code>, the call to <code>setMeasuredDimension()</code> is given the arguments 300, 300. </p> <p>When the <code>onDraw()</code> method is called to draw the graphics to the Canvas object, I find that the Canvas doesn't have an identity matrix; rather, the Canvas has some amount of scale transformation already applied. What's the reason for this? I (wrongly) assumed that the Canvas would have a scaling of 1, because the actual dimensions of the View, its Canvas, and its representation on the screen all match. </p> <p>I'm asking this in relation to the problem I have described in detail in my earlier question here: <a href="http://stackoverflow.com/questions/6278509/canvas-drawing-cache-bitmap-is-slightly-blurred-or-has-anti-alias">Canvas drawing cache bitmap is slightly blurred or has anti-alias</a>. I'm finding that when I draw the cache bitmap back to the Canvas, it's slightly blurred compared to the original vector graphics, despite the fact that I'm drawing the bitmap back using no rescaling and using a Paint with anti-alias turned off. I'm now just absolutely convinced there there has to be <em>some</em> scaling process that I'm unaware of causing this to happen to the bitmap. To discover that the Canvas argument to onDraw() has some scaling transformation already applied is possibly a big clue to solving this problem -- but I can't understand why it has such scaling, when surely the Canvas' dimensions perfectly match the area of the screen it's ultimately painting to.</p> <p>Thanks,</p> <p>Trev</p>
android
[4]
788,403
788,404
Is file empty check
<p>how do i check if a file is empty in C#?</p> <p>need something like:</p> <pre><code>if (file is empty) { //do stuff } else { //do other stuff } </code></pre>
c#
[0]
1,909,552
1,909,553
Should we use native API to share instead of Intent
<p>I experiment out with Intent, to share text and image both. However, I realize sharing through intent is almost unusable, although my image size is less than 100kb. I experiment the following problem.</p> <ul> <li>GMail - OK</li> <li>Twitter - I can see there is text and picture in composer. However, I can never post successfully unless I remove the picture from composer. Not sure why. I only get message "Tweet not sent, saved to drafts."</li> <li>Facebook - Only picture. No text.</li> <li>Google Plus - I always get error message "Can't create post. Try again later."</li> <li>Yahoo Mail - No picture attachment.</li> </ul> <p>I was wondering, whether you all encounter similar problem as mine? Do you guys solve this by using native API provided by Facebook and Twitter?</p> <p>I just really figure out how my Intent sharing code can get wrong.</p> <pre><code>private void share() { final String share_subject = getString(R.string.share_subject); final String share_content = getString(R.string.share_content); final String share_intent_title = getString(R.string.share_intent_title); File file = mainView.getScreenshotFile(); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpeg"); intent.putExtra(Intent.EXTRA_SUBJECT, share_subject); intent.putExtra(Intent.EXTRA_TEXT, share_content); // http://stackoverflow.com/questions/5214764/how-to-share-photo-with-caption-via-android-share-intent-on-facebook intent.putExtra(Intent.EXTRA_TITLE, share_content); // http://stackoverflow.com/questions/9023116/sharing-an-image-with-google-app-using-intent-action-send-and-intent-extra-stre ContentValues values = new ContentValues(2); values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); values.put(MediaStore.Images.Media.DATA, file.getAbsolutePath()); Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent.putExtra(Intent.EXTRA_STREAM, uri); //intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); startActivity(Intent.createChooser(intent, share_intent_title)); } </code></pre>
android
[4]
465,689
465,690
BufferedReader.readLine is not working
<p>My program kind of gets stuck after the readLine call, the if statements don't work. What am i doing wrong? #java-first-timer</p> <pre><code>import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; public class nums { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Number Mania!!!"); System.out.println("Pick your favourite number from 1 to 5"); String favNum = br.readLine(); if (favNum=="3"){ System.out.println("Your favourite number is three!"); } else{ System.out.println("hi!"); } } } </code></pre>
java
[1]
3,523,837
3,523,838
What's a good sleep time to avoid java.net.SocketExeption: Unexpected end of file from server?
<p>Okay, so I'm using over 300 threads that use buffer readers to get information from over 300 sites at a reasonable speed. So basically, it spams this exception a whole bunch of times each second. Meanwhile, it's only ending up getting less than 50% of the information from the sites. So, I was wondering what would be a good sleep time to wait until starting a new thread.</p>
java
[1]
4,235,739
4,235,740
Delete a member of a structure, and remake it as a copy of something else without using new
<p>So I'm working with an API which really isn't as functional as it could be. (Quickhaptics to be specific) In order to make something that I have work, I need to delete an object within a structure, create it again, (without using new, because the constructor for the object doesn't work the way I need it to) then set it to something. </p> <p>I'm trying to do something along the lines of</p> <pre><code>delete data.cursor; Cursor* data.cursor = (Cursor*)malloc(sizeof(Cursor)); data.cursor = data.cursors[index]; </code></pre> <p>But this causes a crash(EDIT sorry, it doesn't compile is what I meant to say, but I don't understand the compiler errors)</p> <p>Additional info: The way the API works, I need to send it a pointer to an item, which it takes initially and writes information to throughout execution. I'm trying to update the mesh on a cursor type object. It provides update functions to load in new meshes, but they are very expensive and can only run at ~3 fps. My solution is to load the objects into an array at startup, then just switch out the object that the program looks for as a cursor. </p> <p>I'm generally new to C++, and my experience is all from sitting down and typing with no instruction, so there may be some basic C++ thing that I'm missing.</p> <p>EDIT: Just to be clear, doing this works, just very slowly</p> <pre><code>delete data.cursor; data.cursor = new Cursor("filename"); </code></pre> <p>where data.cursors[index] was declared in teh same exact way at startup</p>
c++
[6]
5,542,569
5,542,570
When upgrade the iOS to 6.0 then local DB data get lost
<p>I have uploaded one iphone application on iTunes. There is one local SQlite database in the application. When i upgrade the iOS of the device to iOS 6.0 then the database get blank. I didn't get the data which i have saved in older iOS version (i.e. 5.0).</p> <p>Please help.</p>
iphone
[8]
3,702,549
3,702,550
i need a little help on foreach
<p>This is my cats in mysql</p> <pre><code>cats_id cats_position cats_parentid 1 1&gt; 0 2 1&gt;2&gt; 1 3 3&gt; 0 4 1&gt;2&gt;4&gt; 2 </code></pre> <p>and i am trying to create a navigation like: </p> <p>index > cars > fiat > punto </p> <p>from</p> <pre><code>cat=4&amp;parent=2&amp;position=1&gt;2&gt;4&gt; </code></pre> <p>I end up getting:</p> <p>Index carcarcarcar</p> <p>and my php knowledge is not enough to finish this code. can you help me please.</p> <pre><code>&lt;?php $position = trim($_GET['position']); $pieces = explode("&gt;", $position); $i=0; foreach($pieces as $piece){ $result = mysql_query("SELECT * FROM cats WHERE cats_id='".$pieces[$i]."'"); while($row = mysql_fetch_array($result)) { $piecesid[$i] = $row['cats_id']; $piecesname[$i] = $row['cats_name']; $piecesposition[$i] = $row['cats_position']; } $i++; } ?&gt; &lt;a href="index.php"&gt;Index&lt;/a&gt; &lt;?php $i=0; foreach($pieces as $piece){ if($i=0) $parent=0; else $parent=$placesid[$i-1]; echo '&lt;a href="cats.php?cat='.$piecesid[$i].'&amp;parent='.$parent.'&amp;position='.$piecesposition[$i].'"&gt;'.$piecesname[$i]; } </code></pre>
php
[2]
4,785,464
4,785,465
Retrieve sharedPreferences of another application
<p>I have an application( com.example.MyApplication ) which saves the current location like this</p> <pre><code>SharedPreferences settings = getSharedPreferences(PREFERENCES, 0); SharedPreferences.Editor editor = settings.edit(); editor.putString("City", city); editor.commit(); </code></pre> <p>Now i would like to make another application (com.example.SecondApplication) and retrieve the city string from the other application, how can i do that?</p>
android
[4]
3,362,924
3,362,925
What is the purpose of the statement "(void)c;"?
<p>Sorry for the vague title, but not really sure how to phrase it. So I was looking through the innards of boost::asio (trying to track down some ridiculous delays), and I notice code like this dotted about:</p> <pre><code> op_queue&lt;operation&gt; completed_ops; task_cleanup c = { this, &amp;lock, &amp;completed_ops }; (void)c; // EH? </code></pre> <p>Now from the name of the struct that is being initialized, I'm guessing it's using RAII to do some steps on destruction - fine, but what is the purpose of the last line? Have I just missed something completely funky?</p>
c++
[6]
528,609
528,610
How to use the !! expression?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/784929/what-is-the-not-not-operator-in-javascript">What is the !! (not not) operator in JavaScript?</a><br> <a href="http://stackoverflow.com/questions/9549780/reference-what-does-this-symbol-mean-in-javascript">Reference - What does this symbol mean in JavaScript?</a> </p> </blockquote> <p>I find the js code write like this : !!undefined , !!false;</p> <p>the jquery source code (jQuery 1.7.0.js: Line 748):</p> <pre><code>grep: function( elems, callback, inv ) { var ret = [], retVal; inv = !!inv; // Go through the array, only saving the items // that pass the validator function for ( var i = 0, length = elems.length; i &lt; length; i++ ){ retVal = !!callback( elems[ i ], i ); if ( inv !== retVal ) { ret.push( elems[ i ] ); } } return ret; } </code></pre>
javascript
[3]
4,895,131
4,895,132
Setting a cookie in an iPhone App
<p>Is it possible to set a cookie in an iPhone Application that persists, so that later when the user is in Mobile Safari, that cookie can be sent to a webserver?</p>
iphone
[8]
2,401,899
2,401,900
Avoid permutations when searching for coincident data
<p>I have this data:</p> <pre><code>1, 0., 0., 1500. . . 21, 0., 2000., 1500. 22, 0., 2100., 1500. </code></pre> <p>which I already appended to a list called nodes: nodes[node ID, coord. x, coord. y, coord. z].</p> <p>Now I want to find the coincident nodes. So I've tried:</p> <pre><code>for data in nodes: for data2 in nodes: if data2[1]==data[1] and data2[2]==data[2] and data2[3]==data[3] and data[0]&lt;&gt;data2[0]: coincident_nodes.append((data[0],data2[0])) </code></pre> <p>what happens is that I get for instance: (31, 32) and (32, 31) and I only want (31, 32) or (32, 31), just one combination.</p> <p>Many thanks.</p>
python
[7]
4,935,159
4,935,160
testing for element tag name
<p>When a user enters a bookmark using form['f3'] (a url and a title) it is immediately entered in via the dom - visually the title and the favicon are seen by the user. Each bookmark is a link and and image under div Bb1c. The insert is done alphabetically. Basically, I need to insert the new image and link after the previous one.</p> <p>The loop portion was created before I had added in favicons so it loops through all the child elements, but it only needs to loop through the tags. How do I check to make sure that it is an element of type a before doing a compare? My for loop needs an &amp;&amp; added to it.</p> <p>This is rough draft code so if there anything else - contstructive criticism</p> <pre><code> var a=document.getElementById('Bb1c'), b=document.createElement('a'), e=document.createElement('img'); c=document.forms['f3'].elements, d=a.firstChild, b.innerHTML=c[1].value; b.href=c[2].value; b.name="a1"; b.className="b"; e.src=b.hostname + '/favicon.ico'; e.onerror=function() { e.src = 'http://www.archemarks.com/favicon.ico'; } while(d=d.nextSibling) { if(b.innerHTML&lt;d.innerHTML) { break; } } a.insertBefore(b,d); return 1; } </code></pre>
javascript
[3]
5,615,375
5,615,376
Pass the data the user enters into our URL, receive the XML
<p>'pass the data the user enters into our URL, receive the XML ' How this can be implement</p>
iphone
[8]
2,332,992
2,332,993
Are there apps that let you code ON the iPhone (not FOR the iphone)?
<p>I'm just wondering if anybody knows of any simple IDEs or interpreters or anything that lets you play around with code on your iPhone.</p>
iphone
[8]
471,344
471,345
Fastest way to convert file from latin1 to utf-8 in python
<p>I need fastest way to convert files from latin1 to utf-8 in python. The files are large ~ 2G. ( I am moving DB data ). So far I have</p> <pre><code>import codecs infile = codecs.open(tmpfile, 'r', encoding='latin1') outfile = codecs.open(tmpfile1, 'w', encoding='utf-8') for line in infile: outfile.write(line) infile.close() outfile.close() </code></pre> <p>but it is still slow. The conversion takes one fourth of the whole migration time.</p> <p>I could also use a linux command line utility if it is faster than native python code.</p>
python
[7]
5,618,954
5,618,955
Generate integers with leading 0's
<p>I have a project where I have to generate random numbers from 00000 till 99999. The randomizing isn't where I get stuck, but the fact that it always needs 5 characters is. So when it generates the number 14, I want it as 00014.</p> <p>What is the best way to achieve this?</p>
php
[2]
5,445,975
5,445,976
how to create url slug with certain words(root directory names) excluded?
<p>I am allowing my website user's to specify their own slug for the page they create for better seo purpose. what I am trying to do is I want to restrict the user from specifying the directory names present in the root. e.g. I am having dir with name 'abc' then user should not be able to use this name as slug e.g. www.mywebsite.com/abc should be flagged as invalid because 'abc' is directory name present at my project root level. what could be the good approach for avoiding root directory names as slug?</p>
php
[2]
2,798,601
2,798,602
Handling Spaces in Application.ExecutablePath
<p>I am getting a string variable for the Application.ExecutablePath and then passing the variable to a command line via ProcessStartInfo with some arguments. My code works fine as long as the "ExecutablePath" does not contain spaces, but if it does such as C:\documents and settings\jsmith\desktop, C# processes the spaces as escapes and I don't get results from the command line.</p> <p>Here is how I am getting the Path and also sending the command "lmutil"</p> <pre><code>string execName = Application.ExecutablePath; FileInfo execFileInfo = new FileInfo(execName); execPath = execFileInfo.DirectoryName; string lmUtil = @"\lmutil"; lmExec = execPath + lmUtil; This is the method in which I need to handle quotes in paths GetLicStats(lmExec + " lmstat -a -c " + licport + "@" + curAdd); </code></pre> <p>How can I make sure that lmExec is handled correctly if it contains spaces.</p>
c#
[0]
5,427,491
5,427,492
Pointer becomes NULL immediately
<p>I have the following LLVM code. The strange thing is that the <code>si</code> variable of type <code>StoreInst</code> becomes null(0) immediately after it is allocated with new instruction outside the if block, whereas I have declared it at an outer scope. What is going on here?</p> <pre><code> Value *OldVal = NULL; StoreInst* si = NULL; if ( ... ) { if ( ... ) { .... if ( ... ) { ... StoreInst* si = new StoreInst(...); errs() &lt;&lt; "si = " &lt;&lt; si &lt;&lt; "\n"; // Get some address here } errs() &lt;&lt; "--&gt;SI = " &lt;&lt; si &lt;&lt; "\n"; // Here I get NULL, why? } ... } </code></pre> <p>I get an output like this,</p> <pre><code>si = 0x1822ba0 --&gt;SI = 0x0 </code></pre>
c++
[6]
3,093,807
3,093,808
subclassing MatchObject in python
<p>I have been playing around with regular expressions and was trying to subclass the MatchObject that is returned from re.search.</p> <p>I have had no luck getting access to the MatchObject class.</p> <p>I assume enter code herethat the actual type of this object is not called "MatchObject":</p> <pre><code>&gt;&gt;&gt; re.search ("a", "a") &lt;_sre.SRE_Match object at 0x100427a58&gt; </code></pre> <p>However, I am not able get access to this object:</p> <pre><code>import _sre dir (_sre) ['CODESIZE', 'MAGIC', '__doc__', '__name__', '__package__', 'compile', 'copyright', 'getcodesize', 'getlower'] &gt;&gt;&gt; dir(_sre.SRE_Match) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; AttributeError: 'module' object has no attribute 'SRE_Match' </code></pre> <p>What am I missing?</p>
python
[7]
1,564,414
1,564,415
Accessibility: TYPE_NOTIFICATION_STATE_CHANGED state
<p>I've written an app using an accessibilityService.</p> <p>I've found that I can detect when notifications appear in the notification bar, but cannot work out how to trigger when they get cleared.</p> <p>According to the android api docs:</p> <blockquote> <p>TYPE_NOTIFICATION_STATE_CHANGED "Represents the event showing/hiding a Notification. "</p> </blockquote> <p>..so I'm confused to why the onAccessibilityEvent only ever seems to get fired when showing an event, but not hiding one.</p> <p>I'm registering the service with the following:</p> <pre><code> AccessibilityServiceInfo localAccessibilityServiceInfo = new AccessibilityServiceInfo(); localAccessibilityServiceInfo.eventTypes = AccessibilityEvent.TYPES_ALL_MASK; //monitor all, then we can localAccessibilityServiceInfo.notificationTimeout = 80L; localAccessibilityServiceInfo.feedbackType = AccessibilityServiceInfo.DEFAULT; setServiceInfo(localAccessibilityServiceInfo); </code></pre> <p>Does anyone know why this would not pick up on the hiding of a notification?</p>
android
[4]
4,598,787
4,598,788
android - how to store images into local database
<p>In my app, one issue is there. i.e, downloading the images from the web and these images are stored in the local db. i am new to this concept. i don't know how to store these images into the local database. please can anybody help me</p> <p>thanks</p>
android
[4]
1,516,463
1,516,464
Reduce multiple image size
<p>Edit I am young programmer with ability to learn more, I am create public site, where user can upload many picture at a time, the code function successfully and insert into mysql. as I improved the code further by reduce the size of many uploaded picture at once, only a picture was uploaded into the folder and mysql.<br> could any one please elite me more. Is there any style or code to reduce size of multi image upload by user? </p> <p>DS in my code is DIRECTORY_SEPARATOR define in initialize file. </p> <p>Please I real like to know more. this is my code which uploaded in php folder and mysql. how can I reduce the size of multiple image uploaded by single user.</p> <pre><code>if(isset($_POST['submitImage'])){ $file = $_FILES['upload']; $errors = array(); if(empty($file)){ $errors[] = ' The file could not be empty '; }else{ foreach( $file['name'] as $key =&gt; $value ){ $extensions = array("jpeg","jpg","png"); $file_ext=explode('.',$file['name'][$key]) ; $file_ext=end($file_ext); //$file_ext=strtolower(end(explode('.',$file['name'][$key]))); if(in_array($file_ext,$extensions ) === false){ $errors[]="extension not allowed"; }else{ $filetmp = $file['tmp_name'][$key]; $terget_path = SITE_ROOT.'j2reimage'.DS.'image'.DS; $dat = strftime("%Y-%m-%d %H:%M:%S", time()); if(file_exists($terget_path)){ move_uploaded_file( $filetmp, $terget_path.'/'.$file['name'][$key]); mysql_query("insert into 4j2memberimage values ('', $memmem-&gt;id,'{$file['name'][$key]}', '$dat')"); //end of if file_exists }else{ $errors[] = ' Upload extention could not be locate'; } } //redirect_to('inb.php'); } } } </code></pre>
php
[2]
2,371,346
2,371,347
are the parameters in a function executed sequentially?
<p>in C# if I have function that prints the two values it gets assumed its called print... in the following case what is the output </p> <pre><code>int i=0; public int current_I(){return i;} public int next_I(){return ++i;} //--------- print(next_I(),current_I()); </code></pre> <p>in other words can we know which function will execute first {current_I or next_I} or its just like the C++ we can never know the sequence of execution of the parameters ? </p>
c#
[0]
1,647,496
1,647,497
Does it make sense to use === for string comparison in JavaScript?
<p>While it's clear how using the <code>===</code> operator for e.g. numbers is useful (<code>0</code>, <code>null</code> and <code>undefined</code> all being falsy values, which can lead to confusion), I'm not sure if there are benefits to using <code>===</code> for string comparisons. </p> <p>Some of my team mates use this operator for all comparisons, but does it really make sense? Is there at least some minor performance impact?</p>
javascript
[3]
3,335,806
3,335,807
Dynamic Marquee in asp.net
<p>How I can create dynamic marquee in c#.net? That means I want to display announcements in home page, direction from top to bottom in allotted space, only two announcenets at a time, it should come dynamically.Thanks.</p>
asp.net
[9]
4,613,151
4,613,152
is there any other way of creating an object without using "new" keyword in java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/95419/what-are-all-the-different-ways-to-create-an-object-in-java">What are all the different ways to create an object in Java?</a> </p> </blockquote> <p>as we can create array object without using "new" keyword as example. just curious to know whether we can create any other type of object without using "new" keyword.</p>
java
[1]
2,721,250
2,721,251
jQuery: How to modify form field before submit
<p>But without the ugly effect that the new value is displayed in the the form.</p> <p>if i do:</p> <pre><code>$('#submit_button').click(function(){ $('#field1').val('newval'); $('#form1').submit(); }); </code></pre> <p>The #field1 will display (for a split second) the new value which is kind of ugly..</p>
jquery
[5]
226,824
226,825
Regular expression for replacement operation
<p>Is there any regular expression that will replace everything except alphanumeric? My attempt (not working)</p> <pre><code>string str = "This is a string;;;; having;;; and It also 5555 777has dot (.) Many dots(.....)"; Regex rgx2 = new Regex("^[a-zA-Z0-9]+"); string result1 = rgx2.Replace(str, ""); </code></pre>
c#
[0]
5,382,693
5,382,694
Reply to multiple clients using server
<p>Here is the server code i put this under the button click event. How can i do this program is closed after sending data with one client and restart or refresh again and connect with next client.</p> <pre><code>string val; Process[] pname = Process.GetProcessesByName("chrome"); if (pname.Length == 0) { MessageBox.Show("Application is not running"); val = "Not Running"; } else { MessageBox.Show("Application is running"); val = " Running"; } TcpListener tcpListener = new TcpListener(10); tcpListener.Start(); Socket socketForClient = tcpListener.AcceptSocket(); if (socketForClient.Connected) { label1.Show(); label1.Text="Client connected"; //MessageBox.Show("Client connected"); NetworkStream networkStream = new NetworkStream(socketForClient); System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(networkStream); System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream); string data_var; data_var = textBox1.Text; string theString =val; streamWriter.WriteLine(theString); try { streamWriter.Flush(); theString = streamReader.ReadLine(); label1.Text = theString; //MessageBox.Show(theString); streamReader.Close(); networkStream.Close(); streamWriter.Close(); } catch { label1.Text = "Not flushed"; } } try { socketForClient.Close(); //MessageBox.Show("Exiting..."); label1.Text = "EXIT"; Application.Restart(); } catch { } </code></pre>
c#
[0]
689,535
689,536
How to add serach bar in navigation bar for iPhone
<p>How to add serach bar in navigation bar for iPhone? right now I added to table view?</p>
iphone
[8]
3,910,858
3,910,859
strange behavior in PHP temp var
<pre><code>foreach ($arr1 as $v){ ... } foreach ($arr2 as $v){ ... } </code></pre> <p>then, the two <code>$v</code> will have some strange behavior. If i replace the second <code>$v</code> with <code>$v2</code>, then everything is ok.</p>
php
[2]
2,775,990
2,775,991
Test if collections.Mapping is equal to other mapping, or dict
<p>I have written a custom mapping class that inherits from collections.Mapping. Is there an easy way to test if an instance's data is equal to another mapping object, e.g. a dict?</p>
python
[7]
2,138,018
2,138,019
How to delay mouse hover time?
<p>I'm making an application in C#. Whenever I hover cursor on a button message should be displayed. Also if I hover for about 3 seconds again a message should be displayed that 'Your mouse has been hovering for 3 seconds' on button.</p>
c#
[0]
4,071,379
4,071,380
Why should I use references to a base class, I can't understand the difference
<p>Can someone explain what is the main difference between those two part of code, and why or when I should use a reference to a base class, as for me it is the same thing.</p> <pre><code>internal class MyBaseClass { public string Field = "Hello"; public void Print() { Console.WriteLine("This is the base class."); } } internal class MyDerivedClass : MyBaseClass { public string FieldDerived = "Coucou"; public new void Print() { Console.WriteLine("This is the derived class."); } public new void Print2() { Console.WriteLine("This is the derived class."); } } internal class Program { private static void Main() { MyDerivedClass derived = new MyDerivedClass(); MyBaseClass mybc = (MyBaseClass) derived; // ↑ // Cast to base clas } } </code></pre> <p>And this is the code, that for me do the exactly same thing :</p> <pre><code>internal class MyBaseClass { public string Field = "Hello"; public void Print() { Console.WriteLine("This is the base class."); } } internal class MyDerivedClass : MyBaseClass { public string FieldDerived = "Coucou"; public new void Print() { Console.WriteLine("This is the derived class."); } public new void Print2() { Console.WriteLine("This is the derived class."); } } internal class Program { private static void Main() { MyDerivedClass derived = new MyDerivedClass(); MyBaseClass mybc = new MyBaseClass(); // ↑ // Use the base class } } </code></pre>
c#
[0]
3,609,574
3,609,575
Can you set the internal [[Class]] property of an ECMAScript object?
<p>Can you set <a href="http://ecma262-5.com/ELS5_HTML.htm#Section_8.6.2" rel="nofollow">the internal [[Class]] property</a> of an ECMAScript object?</p>
javascript
[3]
649,424
649,425
Javascript object name usage issue.. i think
<p>So i'm setting up an object with private and public methods. Basically using the following format:</p> <pre><code>var Utility = function() { var prive1, priv2, priv3; function privateMethod1() { //do something } return { publicFunc1: function() { //do something different } publicFunc2: function() { //do something else } } } </code></pre> <p>But i'm worried about some of the situations i'm coming across where publicFunc2 needs to call publicFunc1. For Example the way I would do this atm is:</p> <pre><code>publicFunc2: function() { Utility.publicFunc1(); //then do something else } </code></pre> <p>is this OK? It runs, but it seems weird and VS2010 doesn't give me . I believe that if someone was to change the line var Utility = function() { --> to --> var Utility2 = function() {} then essentially everything would be broken from within the object and that seems wrong... but i'm at a loss on what i should actually be changing. Should i be making all methods basically private and then mapping to a public function? EX:</p> <pre><code>{ function privateFunc1() {} return { publicFunc1 : privatefunc1 } } </code></pre> <p>or should i have a completely different approach to accomplish the idea of private and public methods and variables?</p>
javascript
[3]
3,080,747
3,080,748
C# DynamicMethod Could not load type
<p>I am trying to use DynamicMethod with a Type from another assembly. The assembly is loaded and I can use the Type perfectly fine. But when I try to use it in a DynamicMethod it throws an exception.</p> <p>Could not load type 'TheClass' from assembly 'SomeModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'</p>
c#
[0]
5,355,742
5,355,743
Sorting Associative Array in Javascript
<p>I am new to this board have been fishing for info here for a long time and this is my first time posting here. I am in sort of a jam right now I have an array in javascript that looks like this. Each ID is accociated with a persons name</p> <pre><code> Array ( [230] =&gt; Smith, Marc-Andre [11369] =&gt; Smith, Wayne [12561] =&gt; Smith, Diane [12637] =&gt; Smirnova, Natalie ) </code></pre> <p>Right now the array is sorted by the index which is the ID of the person. I am wondering if its possible to sort it alphabetically such that the array now looks like </p> <pre><code> Array ( [12637] =&gt; Smirnova, Natalia [12561] =&gt; Smith, Diane [230] =&gt; Smith, Marc-Andre [11369] =&gt; Smith, Wayne ) </code></pre> <p>So far I tried using array.sort() it does sort alphabetically but the ID is lost it gives me </p> <pre><code> Array ( [0] =&gt; Smirnova, Natalia [1] =&gt; Smith, Diane [2] =&gt; Smith, Marc-Andre [3] =&gt; Smith, Wayne ) </code></pre> <p>This is my first time programming javascript so thanks for all the help in advance. </p>
javascript
[3]
1,921,369
1,921,370
saving an image from the browser issue
<p>I'm using code to print an image without showing the real path for it. But I have a problem when I want to save that image to my computer because its always show the PHP file name as the name for the image.</p> <pre><code>$id = intval($_REQUEST["id"]); $getimage = $db-&gt;query("select id,img from bbup where id='$id'"); $fetch_image = $db-&gt;fetch($getimage); $filename = $fetch_image['img']; if (!$id) { echo "Wrong Id"; exit; } if (!file_exists($filename)) { echo "Image not found."; exit; } $aaa = SITE_URL . $filename; $imginfo = getimagesize($aaa); header("Content-type: " . $imginfo['mime']); readfile($aaa); </code></pre> <p>The php file is <code>ppupload.php</code> and when I want to save the image (let's say it is a PNG image) in the dialog box the name of the file show ( ppupload.php.png ) and I want it to be the image itself.</p> <p>The image path stored into the database like this: <code>folder/folder/filename.ext</code>.</p>
php
[2]
2,055,003
2,055,004
jquery form validate not allow space for username field?
<p>I have used <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">http://bassistance.de/jquery-plugins/jquery-plugin-validation/</a></p> <p>my form validate :</p> <pre><code>$("#form_person").validate({ rules: { username: { required: true, minlength: 2, maxlength:15 }, password: { required: true, minlength: 2 }, confirm_password: { required: true, minlength: 2, equalTo: "#password" }, email: { required: true, email: true } }, messages: { username: { required: "Please enter a username", maxlength:"max length 15 digits", minlength: "Your username must consist of at least 2 characters" }, password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long" }, confirm_password: { required: "Please provide a confirm password", minlength: "Your password must be at least 5 characters long", equalTo: "Please enter the same password as above" } }); </code></pre> <p>Anybody help me to validate not allow space on username?</p> <p>thanks</p>
jquery
[5]
4,576,960
4,576,961
Can i have two DispatcherTimer objects in the same WPF app?
<p>I have a WPF app and i need update to timers in asynchronous way, one timers updates system time and the oder one updates the duration of an item both do this on the user interface. I implemented this with two DispatcherTimer for each, but sometimes i got an ObjectDisposedException. I do not have any idea about what is going on</p> <p>Does any body can help me?</p> <p>Can i have two DispatcherTimer objects in the same WPF app?</p>
c#
[0]
4,221,149
4,221,150
call generic handler in aspx without jquery
<p>Can i call Generic handler in aspx without using jQuery?</p>
javascript
[3]
5,639,634
5,639,635
Why some variables are parameters and others aren't?
<p>What could be the reason for having this:</p> <pre><code>public function __construct($host, $port, $timeout = 5){ $errnum = 0; $errstr = ''; </code></pre> <p>Instead of this:</p> <pre><code>public function __construct($host, $port, $errnum = 0, $errstr = '', $timeout = 5){ </code></pre> <p>?</p> <p>Why some are params and others aren't ?</p> <p>Thanks a lot, MEM</p>
php
[2]
2,630,407
2,630,408
craft custom network packets
<p>i want to craft 802.11s packets on android to send some data to another mesh network. Since this is not nativly supported, i would like to know if it is even possible on android e.g. to alter a 802.11 packet to a 802.11s packet.</p> <p>Thanks in advance.</p>
android
[4]
2,898,394
2,898,395
What is wrong with this Python code?
<p>Can anyone tell me what is wrong with this? I'm getting a syntax error after the 2nd quote on the <code>print</code> line... It seems like this should work perfectly fine. Thanks</p> <pre><code>def main(): print "blah" return main() </code></pre>
python
[7]
4,937,970
4,937,971
How would i set two coordinates for two different words on screen?
<p>I want to set two different coordinates for two words. Im using <code>COORD pos = {20,20}</code> for one word i tried using </p> <pre><code>COORD position = {10,10} SetConsoleCursorPosition(screen, pos) cout &lt;&lt; "word A" &lt;&lt; endl SetConsoleCursorPosition(screen, position) cout &lt;&lt; "word B" &lt;&lt; endl </code></pre> <p>for the other but no luck </p>
c++
[6]
674,930
674,931
What is the best way to pass a method (with parameters) to another method in python
<p>What's the best way to pass a method and a method parameter to another method?</p> <p>Is there a better way to do the following?</p> <pre><code>def method1(name) return 'Hello ' + name def method2(methodToCall, methodToCallParams, question): greetings = methodToCall(methodToCallParams) return greetings + ', ' + question method2(method1, 'Sam', 'How are you?') </code></pre>
python
[7]
3,459,077
3,459,078
How to validate a string which contains at least one letter and one digit in javascript?
<p>No matter how many letter and digits. But string should contains both.</p> <p>Jquery function <code>$('#sample1').alphanumeric()</code> will validate given string is alpha numeric or not. I want validation like it contains both.</p>
javascript
[3]
1,977,720
1,977,721
Filter incoming calls in iPhone
<p>Hi folks Is there any ways to filter incoming calls in iPhone. Suppose I am getting a call from unknown number then I want that this call will go to my voice mail.If calls from any of group within my address book then busy ringtone.etc.... Is this possible in iPhone programatically. Any help.</p> <p>Thanks in Advance.</p>
iphone
[8]
3,686,754
3,686,755
Regarding Map having an value of type arraylist
<p>I have an method that return array list in a class named abc, as shown below,</p> <pre><code>public List&lt;abcinfo&gt; getobjectslists(String fileId) { //return array list } </code></pre> <p>Now I need to access this the contents return by this method in different class named bgh , so I need to invoke the method of first on the object of class abc, I have tried in this way in the class bgh</p> <pre><code>abc b1 = new abc (); b1.getobjectslist(tr); </code></pre> <p>now the query is that I have an map whose key is fght and i want its value should be of type array list , and that arraylist which is return by above method getobjectlist(tr) , please advise how to achieve this</p> <pre><code> Map&lt;String, Object&gt; atta = new HashMap&lt;String, Object&gt;(); atta.put(fght, &lt;arraylist return by method getobjects(tr)&gt;); </code></pre> <p>please let me know one thing more if this method is in same class let say within bgh class itself and as a seprate method and I have to access this method within the same class inside another independent method named fghjl() then how could i put in map, Please advise Thanks inadvance .</p>
java
[1]
3,524,953
3,524,954
max marks validation
<p>i have some problem in javascript validation... My requirement is user sholud enter value in text box less than 5 he sholud not allow to enter value which is more than 5 he can enter 4.25 3.10 he should not enter 5.1 how to restrict user not to do this.. what is code for this.on which event we sholud call it</p>
javascript
[3]
141,879
141,880
adapter.notifyDataSetChange() doesnt update my adapter
<p>This is my code:</p> <pre><code>public class ListasCompra extends ListActivity { private ArrayList&lt;Lista&gt; listaCompras = null; private ListaAdapter adaptador = null; private static ListasCompra instancia = null; private static Context context = null; private Button aceptar = null; private Button nueva = null; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.lista_de_listas); listaCompras = LocalService.getDbListas().getListas(); aceptar = (Button)findViewById(R.id.aceptarlistas); aceptar.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { finish(); } }); nueva = (Button)findViewById(R.id.nuevalistas); nueva.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { startActivity(new Intent(context, NuevaLista.class)); //finish(); } }); if(listaCompras!=null){ adaptador = new ListaAdapter(this, listaCompras); setListAdapter(adaptador); }else{ listaCompras = new ArrayList&lt;Lista&gt;(); adaptador = new ListaAdapter(this, listaCompras); setListAdapter(adaptador); } context = this; instancia = this; } /** * Ciclo Vida de Actividad */ @Override public void onDestroy(){ super.onDestroy(); } @Override public void onResume(){ super.onResume(); listaCompras = LocalService.getDbListas().getListas(); adaptador = new ListaAdapter(context, listaCompras); adaptador.notifyDataSetChanged(); } </code></pre> <p>What I want, is the adapter to update everytime it gets on the method "onResume", which is everytime the Activity re-appears for the user......</p> <p>My problem is that it is NOT updating using this method, anybody knows why??</p> <p>Thanks!</p>
android
[4]
3,752,931
3,752,932
Cannot Implicitly Convert Type to system.net
<p>I am having an error in my program when trying to download files from a remote server, I am using the System.Net Lib and it is having an issue converting to it.</p> <p>I am getting the error Message "Cannot implicitly convert type 'System.ComponentModel.AsyncCompletedEventHandler' to System.Net.DownloadProgressChangedEventHandler' on the last line in the code block</p> <pre><code>AsyncCompletedEventHandler(client_DownloadFileCompleted); </code></pre> <h2>Error Line ^</h2> <p>Form.cs V</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; namespace Buildcraft_Installer { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void btnStartDownload_Click(object sender, EventArgs e) { prgDownload.Visible = true; WebClient client = new WebClient(); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadProgressChanged += new AsyncCompletedEventHandler(client_DownloadFileCompleted); </code></pre> <p>I would be very grateful if anyone had a way to resolve this or a workaround to get the same result, thanks :)</p>
c#
[0]
897,114
897,115
Add a new folder when uploading files using php
<p>I want to automatically create a folder, using the users email address, if one does not already exists. This action should occur when they upload a file. </p> <p>SOLVED. I updated this code for anyone who might need it. Thanks!</p> <p>Here is my code: </p> <pre><code>if(isset($_POST["checkFile"]) &amp;&amp; $_FILES["selectFile"]["name"] != "") { $target_path_pdf = "uploads/pdfs/$email/"; if ( ! is_dir($target_path_pdf)) { mkdir($target_path_pdf); } $target_path_pdf = $target_path_pdf . str_replace(' ', '_', basename($_FILES["selectFile"]["name"])); if(move_uploaded_file($_FILES["selectFile"]["tmp_name"], $target_path_pdf)) { } else { $flag = 1; } $pdfcaption = $_POST['pdfCaption1']; } if(isset($_POST["checkPicture"]) &amp;&amp; $_FILES["selectPicture"]["name"] != "") { $target_path_pic = "uploads/pictures/$email/"; if ( ! is_dir($target_path_pic)) { mkdir($target_path_pic); } $target_path_pic = $target_path_pic . str_replace(' ', '_', basename($_FILES["selectPicture"]["name"])); if(move_uploaded_file($_FILES["selectPicture"]["tmp_name"], $target_path_pic)) { } else { $flag = 1; } $piccaption = $_POST['picCaption1']; } </code></pre>
php
[2]
2,321,086
2,321,087
PHP: linked list implementation issue with reference to object?
<p>I am creating a linklist class and have some confusion about reference to objects.</p> <p>As per my understanding by default object is copied by reference. $Obj1 = $Obj2. $Obj1 is a alias of $Obj2.</p> <p>Can someone please point out which one is correct in linkedlist implementation.</p> <pre><code>$firstNode-&gt;next = $this-&gt;first;---&gt; seems to be correct or $firstNode-&gt;next =&amp; $this-&gt;first; $this-&gt;first = $firstNode;-----&gt; seems to be correct as $firstNode is an object or $this-&gt;first = &amp; $firstNode; </code></pre> <p>code:</p> <pre><code>class Node { public $element; public $next; public function __construct($element){ $this-&gt;element = $element; $this-&gt;next = NULL; } } class Linklist { private $first; private $listSize; public function __construct(){ $this-&gt;first = NULL; $this-&gt;listSize = 0; } public function InsertToFirst($element){ $firstNode = new Node($element); $firstNode-&gt;next = $this-&gt;first; // or $firstNode-&gt;next =&amp; $this-&gt;first; $this-&gt;first = $firstNode; // or $this-&gt;first = &amp; $firstNode; } </code></pre>
php
[2]
741,238
741,239
Show Dialler : Problems
<p>I have an edit text.. I need to restrict the edit text with numbers. So i gave </p> <pre><code> EditText phoneNumber phoneNumber.setKeyListener(DialerKeyListener.getInstance()); </code></pre> <p>But in some phones..when i click the edit text 2 characters are shown in the dialler 'p' and </p>
android
[4]
1,299,941
1,299,942
how can i add a regular item to spinner adapter?
<p>i have a spinner like this:</p> <pre><code>spinner = (Spinner) findViewById(R.id.spin); _spinDb = new SpinAdapter(this); Cursor names = _spinDb.open().getAllSpin(); _adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, names, new String[] {SpinAdapter.COLUMN_NAME}, new int[] {android.R.id.text1}); _adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(_adapter); </code></pre> <p>now, i want to add a "regular" item with the text: "choose item". how can i do it? thanks.</p>
android
[4]
1,722,540
1,722,541
Is const_cast(iterator->second) safe?
<p>I want to know if this code is safe and doesnt have any undefined behavior.</p> <pre><code> QueueMap::const_iterator it = m_3playersQueue.find(s-&gt;m_GameCode); if(it == m_3playersQueue.end()) { std::deque&lt;Session*&gt; stack; stack.push_back(s); m_3playersQueue[s-&gt;m_GameCode] = stack; return; } const_cast&lt;std::deque&lt;Session*&gt;&amp;&gt;(it-&gt;second).push_back(s); QueueMap is of type std::tr1::unordered_map&lt; uint32, std::deque&lt;Session*&gt; &gt; </code></pre> <p>Thanks</p>
c++
[6]
3,360,796
3,360,797
Pascal's triangle
<p>I am looking for a Pascals triangle using python script</p> <p>I have done till here and have no idea how to add on</p> <pre><code>numstr= raw_input("please enter the height:") height = int( ) tri = [] row1 = [1] row2 = [1, 1] tri.append(row1) tri.append(row2) while len(tri) &lt; height: </code></pre>
python
[7]
3,949,540
3,949,541
how to create many point of people same this picture
<p>how to create many point of people same this picture. <a href="http://news.cnet.com/i/bto/20090203/Google_Latitude_map.jpg" rel="nofollow">http://news.cnet.com/i/bto/20090203/Google_Latitude_map.jpg</a></p> <p>I want to create application same google latitude. I wonder to find friend poisition ???</p> <p>I want the code and example to do it.</p> <p>help me please. T_<strong><em>_</em>____</strong>_T</p>
android
[4]
2,590,235
2,590,236
What are `true` and `false` and 'null'?
<p>Why aren't they key words? What are they?</p> <pre><code>true, false, null </code></pre> <p><strong>Update Quick Answer</strong></p> <p>These are reserved words but they are not keywords.</p> <p>Small technical distinction verified by spec - ES3 and ES5</p>
javascript
[3]
328,425
328,426
ReflectionTypeLoadException: Unable to load one or more of the requested types(LoaderExceptions)
<p>I have a problem with my application where I load a list of assemblies (Assembly.LoadFrom) from a path (\ \ RemoteServerDir ...) and when I try to retrieve all types of each assemblies i get errors when calling assembly.GetTypes () method.</p> <p>The message that i have is "ReflectionTypeLoadException: Unable to load one or more of the Requested types (LoaderExceptions)".</p> <p>Does someone has an idea to solve this? For information, this application is running in distributed mode who i have this probleme but in local mode it works well.</p> <p>Thank you.</p>
c#
[0]
5,445,284
5,445,285
what's wrong with this function?
<pre><code> function get_ibo_id() { if($registerquery = $this-&gt;conn-&gt;query("SELECT ibo_id FROM fasttrack WHERE count &lt; 8 &amp;&amp; flag = 1 ")){ $this-&gt;increase_count(); while ($row = $registerquery-&gt;fetch_assoc()) { return $row[ibo_id]; } } else return "No id"; } </code></pre> <p>it always enters the if block even if the condition is not satisfied... <em>going crazy</em></p>
php
[2]
1,172,845
1,172,846
handleMessage not called
<p>I have a thread that attempts to get the user location.</p> <p>When the location is received "handler.sendMessage(msg)" is called, and it returns true, but handleMessage is never called.</p> <p>There are no errors or warnings in logcat.</p> <p>The code:</p> <pre><code>public class LocationThread extends Thread implements LocationListener { // ... Other (non-relevant) methods @Override public void run() { super.run(); Looper.prepare(); mainHandler = new Handler(Looper.myLooper()) { @Override public void handleMessage(Message msg) { // This method is never called } }; locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 0, 0, this); Looper.loop(); } @Override public void onLocationChanged(Location location) { // SendMessage is executed and returns true mainHandler.sendMessage(msg); if (mainHandler != null) { mainHandler.getLooper().quit(); } locationManager.removeUpdates(this); } } </code></pre>
android
[4]
4,420,286
4,420,287
selectSingleNode not supported in Safari
<p><strong>Suggest me an alternative for selectSingleNode to support in safari browser when using XMLHttpRequest</strong></p> <pre><code>var tempNode=xmlSoapTemplate.selectSingleNode(pathString+"xmlDatasets"); </code></pre> <p>Just give me Syntax.</p>
javascript
[3]
2,442,354
2,442,355
JQuery miniColors:How do I get multiple miniColor in a web page to work properly?
<p>How do I get multiple miniColor in a web page to work properly?If I change one value all the values change?It takes the class name to change the value? <a href="http://abeautifulsite.net/blog/2011/02/jquery-minicolors-a-color-selector-for-input-controls/" rel="nofollow">http://abeautifulsite.net/blog/2011/02/jquery-minicolors-a-color-selector-for-input-controls/</a></p>
jquery
[5]
4,226,567
4,226,568
how to force a locale to widget
<p>I am working on an android app, so far I have added setting for changing the locale, so that a user can have the locale in the app different than that one on the device, now all activities are working well but the widget still uses device's locale not that one set to the app.</p> <p>Is there a way to force the widget to use other locale than that set on the device like activities?</p> <p>thanks</p>
android
[4]
5,305,032
5,305,033
Unable to create linebreak
<p>I have been trying to create line break in the body of the message but its not working. All the text in the body is coming in one line.</p> <pre><code>&lt;?php if ($_POST["email"]&lt;&gt;'') { $ToEmail = 'demo@localhost.com'; $EmailSubject = 'Site contact form'; $header = "MIME-Version: 1.0" . "\r\n"; $header .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $header .= "From: ".$_POST["email"]."\r\n"; $header .= "Reply-To: ".$_POST["email"]."\r\n"; $message = "Name: ".$_POST["name"]."\r\n"; $message .= "Email: ".$_POST["email"]."\r\n"; $message .= "Comment: ".nl2br($_POST["comment"]).""; mail($ToEmail, $EmailSubject, $message, $header) or die ("Failure"); ?&gt; Your message was sent &lt;?php } else { ?&gt; Sorry message was not sent &lt;?php }; ?&gt; </code></pre>
php
[2]
3,453,700
3,453,701
Get the value of a select box
<p>I have multiple dynamically set select boxes on my page (like over 100). I am trying to get the values of each box individually on change, but when the change takes place it iterates over every select box since they all have the same class. How can I get the values of each select box individually then do something...</p> <p><strong>Example</strong> </p> <pre><code>&lt;select id="(dynamically set, may be different every time)" class="selection"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;option value="dynamically set"&gt;1&lt;/option&gt;&lt;option value="dynamically set"&gt;2&lt;/option&gt; &lt;option value="dynamically set"&gt;3&lt;/option&gt; &lt;/select&gt; &lt;select id="(dynamically set, may be different every time)" class="selection"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;option value="dynamically set"&gt;1&lt;/option&gt; &lt;option value="dynamically set"&gt;2&lt;/option&gt; &lt;option value="dynamically set"&gt;3&lt;/option&gt;&lt;/select&gt; &lt;select id="(dynamically set, may be different every time)" class="selection"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;option value="dynamically set"&gt;1&lt;/option&gt; &lt;option value="dynamically set"&gt;2&lt;/option&gt; &lt;option value="dynamically set"&gt;3&lt;/option&gt;&lt;/select&gt; etc... </code></pre> <p>JS</p> <pre><code>&lt;script type="text/javascript"&gt; //Psuedo code $('.selection').change(function(){alert('test');}); &lt;/script&gt; </code></pre>
jquery
[5]
1,949,179
1,949,180
back back to listing in asp.net
<p>Hello Friends i have a repeater control on which i have binded product and have custom paging on in.when user select on product next page open with all other details of that product. My problem is that when i go to 7 page from paging and then click any product the next page open with details and i want a link on detail page so that i can go back to 7th page on listing</p>
asp.net
[9]
1,527,757
1,527,758
file_get_html multiple times in the same script
<p>I am using simple html dom parser. When I am requesting a page like <code>file_get_html()</code> I am getting 2 values. One is title and the other one is an url. Within this I want to do <code>file_get_html()</code> again.</p> <p>But I am getting similar data for the second traverse.</p> <p>Like this script : </p> <pre><code>foreach($urls as $value) { $html=file_get_html($value); foreach($html-&gt;find('div[class=data] a') as $content) { $url2='http://abc.com/'.$content-&gt;href; $childHtml=file_get_html($url2); echo $childHtml; //Proble is here i am getting the previous data--&gt;html } } </code></pre> <p>What am I doing wrong here?</p> <h1>This is the main crawling code</h1> <pre><code>$urls=GenerateURLS($currentmonth); $tracker=0; $urlHolderArray=array(); foreach ($urls as $value) { $html=file_get_html($value); //Here I am requesting the html dom foreach ($html-&gt;find('div[id=centrepanel] div[class=events_listing_container] div[class=events_info_container] div[class=events_image] a') as $content) { $proxyURL="http://www.junkclub.com/".$content-&gt;href; array_push($urlHolderArray,$proxyURL); } } echo '&lt;pre/&gt;'; print_r($urlHolderArray); echo '&lt;pre/&gt;'; foreach ($urlHolderArray as $link) { $htmlCon=file_get_html($link); } echo $htmlCon; </code></pre>
php
[2]
2,149,560
2,149,561
strip tags python
<p>i want the following functionality.</p> <pre><code>input : this is test &lt;b&gt; bold text &lt;/b&gt; normal text expected output: this is test normal text </code></pre> <p>i.e. remove the content of the specified tag</p>
python
[7]
1,290,517
1,290,518
std::transform behavior when iterating past container.end()
<p>Code:</p> <pre><code>static int counter = 0; int add(int x) { counter++; return ++x; } int main() { vector&lt;int&gt; b; b.push_back(1); b.push_back(1); b.push_back(1); transform(b.begin(),b.end(),b.begin()+2,add); for (vector&lt;int&gt;::iterator it = b.begin(); it != b.end(); it++) cout &lt;&lt; (*it) &lt;&lt; endl; cout &lt;&lt; "counter: " &lt;&lt; counter &lt;&lt; endl; } </code></pre> <p>For me this compiles with no warnings and prints out:</p> <pre><code>1 1 2 counter: 3 </code></pre> <p>What is happening here in the transform function? How is it that add(...) gets called 3 times but b.end() is not overwritten? Is this undefined behavior?</p>
c++
[6]
703,393
703,394
Pause scrollTop on hover
<p>Still somewhat new at jQuery, I am using the following to automatically scroll a div with the class name of .scroller when the page loads.</p> <pre><code>$(".scroller").delay(2000).animate({ scrollTop: $('.scroller')[0].scrollHeight}, 50000); </code></pre> <p>However I would like to stop any scrolling upon hover over that div and start it back when hovering out.</p> <p>Any thoughts on how to achieve this or should I be using something other than scrollTop for this?</p> <p>Thanks, Chris</p>
jquery
[5]
2,370,013
2,370,014
Pandora like database, used for finding lyrics that fit a certain mood
<p>I'm pretty new at all this stuff, I can program in php and have a decent understanding of SQL. What i'm looking to do is tag music with certain quality's, mainly the emotion that the music brings out. The bigger the database I could build the better.</p> <p>My idea is that people seem to like to post song lyrics about how they are feeling. I could run a site that would allow the person to put in some basic information about their music tastes and then feed back some lyrics to them.</p> <p>I can do the coding of the site in php, and I can handle the database. I'm just lost on how to get sounds tagged with the correct feelings. It would be cool if pandora would allow people access, but from what I have gathered they do not.</p>
php
[2]
3,016,978
3,016,979
Python: confusions with urljoin
<p>I am trying to form URLs from different pieces, and having trouble understanding the behavior of this method. For example:</p> <pre><code>from urllib.parse import urljoin &gt;&gt;&gt; urljoin('some', 'thing') 'thing' &gt;&gt;&gt; urljoin('http://some', 'thing') 'http://some/thing' &gt;&gt;&gt; urljoin('http://some/more', 'thing') 'http://some/thing' &gt;&gt;&gt; urljoin('http://some/more/', 'thing') # just a tad / after 'more' 'http://some/more/thing' urljoin('http://some/more/', '/thing') 'http://some/thing' </code></pre> <p>Can you explain the exact behavior of this method?</p>
python
[7]
891,967
891,968
How to highlight words in html using jquery
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/119441/highlight-a-word-with-jquery">Highlight a word with jQuery</a> </p> </blockquote> <p>I want to highlight certain words in html <code>&lt;body&gt;</code> tag, but I want to avoid highlighting those which are within <code>&lt;a&gt;</code> tag. How can this be done? By highlight I mean, underlining and making word bold.</p> <p>For e.g I have this html content </p> <pre><code>&lt;body&gt; &lt;p&gt; This is sample text for the purpose of highlighting searched text. Please visit &lt;a href="javascript:void(0)"&gt;www.sampleSite.com&lt;/a&gt; &lt;/p&gt; &lt;/body&gt; </code></pre> <p>Now when I search for the word "sample", I would not want to highlight the word <strong>sample</strong> contained within that anchor tag.</p>
jquery
[5]
5,437,645
5,437,646
Specify function to be called in jquery
<p>I have come across this snippet in the jquery post documentation and i am not sure what it does</p> <pre><code>$.post("test.php", { "func": "getNameAndTime" }, function(data){ console.log(data.name); // John console.log(data.time); // 2pm }, "json"); </code></pre> <p>My thinking is that test.php has a function getNameAndTime(),is this the meaning of it?.If so is this some kind of javascript pattern?.</p>
jquery
[5]
4,345,508
4,345,509
Using JRE -Xms300m cut my execution time in half?
<p>Greetings all, I was wondering if someone could provide some sort of explaination or confirm my guesses.</p> <p>I had a program with a for loop which executed several hundred of thousand times, each time adding numbers to a selection of ArrayLists. Confused as to why it was taking so long to execute I investigated further.</p> <p>It turns out that if I had </p> <pre><code>(for int i =0; i &lt; 50000; i++) </code></pre> <p>It would take almost double the time It would take if I had</p> <pre><code>(for int i=0; i &lt; 40000; i++) </code></pre> <p>Increasing <code>i</code> beyond 50000 even up to 100000 didn't actually take much extra time. There was just this large jump somewhere between 40000 and 50000</p> <p>Putting my thinking hat on, I gathered that perhaps there was an issue whereby something somewhere was running out of memory? and that more memory had to be make availble, though I'm not sure why it would take so long.</p> <p>Anyway, I found that by adding the JRE parameter -Xms300m it solved this issue. Am I right in thinking this starts the program with a heap size of 300mb, thus negating the need for extra heap space to be allocated later.</p> <p>What else I don't understand is that I created memory for the arrayLists which is more than enough. I thought the problem would happen here when I am allocating memory of the heap, not when I use the .add() method.</p> <pre><code>new ArrayList&lt;Integer&gt;(5000); </code></pre>
java
[1]
2,225,780
2,225,781
ImageButton text
<p>Hi there i am trying to do "simple" thing and cant manage to work it out</p> <p>.net, in my site i have a nav menu each item in the menu is an image</p> <p>(like here in the upper "menu" Questions..Tags..etc.. but the background color in my case is an image)</p> <p>i want to load an image and dynamically add text to it from the server side i cant manage to add text to it . what is the best approach i want to be able to do something like the follow:</p> <pre><code>&lt;asp:ImageButton ID="imgButton" runat="Server" ImageUrl="nav1.gif" **text=""**/&gt; </code></pre> <p>and from the server just to be able to write on it something like the follow:</p> <p><strong>imgButton.text="AA"</strong></p> <p>appreciate any help:) Thank Eran.</p>
asp.net
[9]
4,126,650
4,126,651
Can the time on a CountDownTimer be updated?
<p>The CountDownTimer default Constructor takes the values millisInFuture and countDownInterval. If the user stops the timer, changes his settings to a different millisInFuture length, how would I go about changing the millisInFuture value without creating a new CountDownTimer object?</p> <p>I've tried making a getMillisInFuture method in the override CountDownTimer class to no avail. Would I have to override the onStart method, or what?</p>
android
[4]
2,123,706
2,123,707
UnboundLocalError: local variable 'a' referenced before assignment
<p>if execute the following code will show error message:</p> <p><strong>UnboundLocalError: local variable 'a' referenced before assignment</strong></p> <pre><code>a = 220.0 b = 4300.0 c = 230.0/4300.0 def fun(): while (c &gt; a/b): a = a + 1 print a/b if __name__ == '__main__': fun() </code></pre> <p>but modify to :</p> <pre><code>a = 220.0 b = 4300.0 c = 230.0/4300.0 def fun(): aa = a bb = b while (c &gt; aa/bb): aa = aa + 1 print aa/bb if __name__ == '__main__': fun() </code></pre> <p>it will fine. Any advice or pointers would be awesome. Thanks a lot!</p>
python
[7]
1,035,646
1,035,647
Dynamicly loading js files (during runtime)
<p>I have been able to implant the function to load the js files, but my problem is that it seems that I can only access my variables not my functions (in the object that I load). anyone got any ideas on why this is?</p>
javascript
[3]
2,467,107
2,467,108
What is better way to compare class of two objects
<p>I can compare two different objects to know whether they belong to same class or different using both <code>==</code> operator and <code>equals</code> method also. But which one is the better approach and how? Have a look on both approach that i followed. What is better way to compare class of two objects</p> <pre><code> //r2 and r3 are two different objects //first approach Using == operator boolean firstApproach = ((Object)(r2.getClass()) ==((Object)r3.getClass())); //second approach Using equals method to compare boolean secondApproach = ((Object)(r2.getClass())).equals(((Object)r3.getClass())); System.out.println("...firstApproach ..."+firstApproach +"...secondway.."+secondway ); </code></pre>
java
[1]
5,291,889
5,291,890
what is the role of ob_start() in here
<pre><code>session_start(); ob_start(); $hasDB = false; $server = 'localhost'; $user = 'user'; $pass = 'pass'; $db = 'acl_test'; $link = mysql_connect($server,$user,$pass); if (!is_resource($link)) { $hasDB = false; die("Could not connect to the MySQL server at localhost."); } else { $hasDB = true; mysql_select_db($db); } </code></pre> <p>a) what does ob_start() exactly do.? i got to understand it will turn output buffering on. with reference to the above code what will be the benefit if i use ob_start() while trying to establish the connection with the database. what output data it will buffer?</p> <p>thank you..</p>
php
[2]
1,357,829
1,357,830
Would like to use isset(empty($sc))
<p>I want to use a combination of this <code>isset(empty($sc))</code> but am receiving this error </p> <blockquote> <p>Parse error: syntax error, unexpected T_EMPTY in /var/www/html/find.php on line 9</p> </blockquote> <p>When someone posts from the form, then the <code>$sc</code> should be checked if empty only if the form has been submitted.</p>
php
[2]
4,137,679
4,137,680
python program to sort numbers from smallest to biggest
<p>I need to make it so that the user inputs the numbers from smallest to biggest; and then the program compares the one that the user had input with the one that it has worked out, and says whether it is right or wrong. </p> <p>This is what I tried:</p> <pre><code>import random def main(): i = random.randint(1,12) print i k = random.randint(1,12) print k l = random.randint(1,12) print l m = random.randint(1,12) print m n = random.randint(1,12) print n a=[i,k,l,m,n] b=int(input('order from smallest to biggest:')) a.sort() length = len(a) count = 0 while (count &lt; length): if (a[count]==b[count]): print "true" else: print "false" count = count + 1 main() </code></pre>
python
[7]
1,644,267
1,644,268
add caption text using javascript and php
<p>I'm trying to add some caption text to a div position, named </p> <pre><code>&lt;div id="slidecaption"&gt;&lt;/div&gt; </code></pre> <p>So in my js here is the code:</p> <pre><code>slides : [ &lt;?php //query query_posts(array('post_type'=&gt;'slider', 'posts_per_page'=&gt;'20' )); //loop if(have_posts()) : while (have_posts()) : the_post(); //feature image $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $title = get_the_title(); //echo slides echo "{image : '".$large_image_url[0]."', title : '&lt;h1&gt;This is a header&lt;/h1&gt;', url : ''},"; endwhile; endif; ?&gt;] </code></pre> <p>What i need is to display the title inside the div above.. How can i do that? Thanks!</p>
javascript
[3]
1,241,952
1,241,953
What does \u003C mean?
<p>I'm looking at twitter's javascript file, and I see this in the templates hash:</p> <pre><code>Browse Interests{{/i}}\u003C/a\u003E\n \u003C/li\u003E\n {{#logged_in}}\n </code></pre> <p>What do those codes represent?</p>
javascript
[3]
5,972,218
5,972,219
std::ostringstream woes
<p>I can do</p> <pre><code>std::ostringstream oss; oss &lt;&lt; 1; oss.str(); </code></pre> <p>so why can't I do:</p> <pre><code>((std::ostringstream()) &lt;&lt; 1).str() ? </code></pre> <p>Thanks!</p>
c++
[6]
1,451,271
1,451,272
JavaScript to add table row onclick events
<p>I'm new to Javascript. I want to add onclick events to table rows. I'm not using JQuery.</p> <p>I loop thru the rows and use a closure to make sure I have the state of the outer function for each row. The looping works. Using alerts, I see the function being assigned for each iteration. But when I click the row, no alert is displayed. Below is the HTML and code that can be loaded.</p> <p>Why are the table row events not working?</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;body&gt; &lt;script&gt; function example4() { var table = document.getElementById("tableid4"); var rows = table.getElementsByTagName("tr"); for (var i = 0; i &lt; rows.length; i++) { var curRow = table.rows[i]; //get cell data from first col of row var cell = curRow.getElementsByTagName("td")[0]; curRow.onclick = function() { return function() { alert("row " + i + " data="+ cell.innerHTML); }; }; } } function init() { example4(); } window.onload = init; &lt;/script&gt; &lt;div&gt; Use loop to assign onclick handler for each table row in DOM. Uses Closure. &lt;table id="tableid4" border=1&gt; &lt;tbody&gt; &lt;tr&gt;&lt;td&gt;Item one&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Item two&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Item three&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]