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
1,584,401
1,584,402
php best practices
<p>i came across this page on php structure at <a href="http://www.odi.ch/prog/design/php/guide.php" rel="nofollow">here</a>. i tho it was good but i wanna know what others think about this and is there any improvement that can be implemented??</p>
php
[2]
4,742,729
4,742,730
Stop LocationManager Updates
<p>I'm trying to have GPS coordinates sent to a text message. This code works, but every time the GPS updates location, it tries to send a new text message. I can't figure out how to stop the location updates. This is what I have currently...I realize it may not be the most efficient way to do it.</p> <p>Any help would be appreciated!</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); LocationListener mlocListener = new MyLocationListener(); mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener); } public void GPSDisable() { LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); LocationListener mlocListener = new MyLocationListener(); mlocManager.removeUpdates(mlocListener); } public class MyLocationListener implements LocationListener { @Override public void onLocationChanged(Location loc) { loc.getLatitude(); loc.getLongitude(); double latitude = loc.getLatitude(); double longitude = loc.getLongitude(); Intent smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setType("vnd.android-dir/mms-sms"); smsIntent.putExtra("address", "5555555555"); smsIntent.putExtra("sms_body", "Location:"+latitude+","+longitude); GPSDisable(); startActivity(smsIntent); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } } @Override public void onLocationChanged(Location location) { // TODO Auto-generated method stub } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } </code></pre> <p>}</p>
android
[4]
2,103,164
2,103,165
Android TextView carry text by letters
<p>Is there any way to carry text in TextView by letters in Android?</p> <p>If no settings have been set – TextView carries text by words and situation is possible when with too long word you have big whitespace in TextView.</p> <p>Example – what I’m talking about: <img src="http://i.stack.imgur.com/LRxbV.png" alt="Carry text by words"></p>
android
[4]
3,048,256
3,048,257
jQuery - how can I find if an id has a specific string?
<p>I have a table and I want to know if its last td its id contains a certain string. For example, if my last td has id "1234abc", I want to know if this id contains "34a". And I need to do that in a 'if' statement.</p> <p>if(myLastTdId Contains "blablabla"){ do something }</p> <p>Thanks!!!</p>
jquery
[5]
267,634
267,635
C# System.NullReferenceException
<p>For some reason this gives me a "System.NullReferenceException: Object reference not set to an instance of an object" error. What could cause this?</p> <pre><code>public class Font { private PrivateFontCollection MyFonts = new PrivateFontCollection(); public Font() { string resource = "zig_____"; Stream fontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource); System.IntPtr data = Marshal.AllocCoTaskMem((int)fontStream.Length);//this is the line that causes the error byte[] fontdata = new byte[fontStream.Length]; fontStream.Read(fontdata, 0, (int)fontStream.Length); Marshal.Copy(fontdata, 0, data, (int)fontStream.Length); MyFonts.AddMemoryFont(data, (int)fontStream.Length); fontStream.Close(); Marshal.FreeCoTaskMem(data); } } </code></pre>
c#
[0]
4,781,536
4,781,537
Use of setInterval on javaScript
<p>As always, I would appreciate very much if somebody out there could help me a little bit with this code.</p> <p>I have the following lines of code:</p> <pre><code>var count = 0; var limit = 2000; function liveCount(){ var increment = count + 10; count = increment; if(count &lt;= limit){ document.getElementById('showCount').textContent=count; }else{ clearInterval(); } } var counter = setInterval('liveCount()', 10); </code></pre> <p>What this code does is simulate a counter from 0 to X as a chronometer would do. It works perfect when I use it stand-alone, it starts counting and updates the count in 10 miliseconds intervals until it reaches the limit and then it stops.<br> So far so good.<br> My problem is that when I nest this code inside another function, which is the one that will provide the value for the "count and limit" variables, I get an error saying that the "liveCount()" is not defined, refering to the parameter of the "setInterval()". </p> <p>I have tried everything I can think of and I cant get it to work.<br> Any ideas what am I missing or doing wrong? </p> <p>Thank you all.</p>
javascript
[3]
1,798,495
1,798,496
Does signing the app protect against tampering with the file?
<p>I'm not familiar with the idea of signing files, and I can't find a satisfactory answer so far, so I think I'd better ask:</p> <p>What I want to know is when signing a binary file (for Android), does the signing tool assign some sort of checksum to the file so that when a hacker changed something in the apk file, the program would refuse to start because the checksum doesn't match. Does this mechanism exist in Android's signing tool?</p> <p>Well, I understand when a hacker has the binary, he can disable anything he wants, including the checksum check. But the question is: Does Android's signing tool provide this level or protection in the first place?</p> <p>Thank you for reading, and answering!</p>
android
[4]
5,640,871
5,640,872
How to detect if a variable has changed?
<p>I have found myself wanting to do certain things in my programs only if a variable has changed. I have so far been doing something like this: </p> <pre><code>int x = 1; int initialx = x; ...//code that may or may not change the value of x if (x!=initialx){ doOneTimeTaskIfVariableHasChanged(); initialx = x; //reset initialx for future change tests } </code></pre> <p>Is there a better/simpler way of doing this?</p>
java
[1]
2,772,445
2,772,446
Android scaledrawable doesn't seems to work
<p>I'm trying out the android <a href="http://developer.android.com/guide/topics/resources/drawable-resource.html#Scale">ScaleDrawable</a></p> <p>But it doesn't seem to work... I created the xml as in the documentation example and I have a logo.png in the drawable folder</p> <p><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;scale xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/logo" android:scaleGravity="center_vertical|center_horizontal" android:scaleHeight="80%" android:scaleWidth="80%" /&gt; </code></p> <p>I saved this as logo2.xml in the drawable folder then I have a LinearLayout with an ImageView and set the src of the ImageView to "@drawable/logo2" but the logo doesn't appear...Am I doing something wrong here? How do you actually use the scale element?</p> <p>Thanks,</p> <p>Stephen</p>
android
[4]
5,456,048
5,456,049
How to set the WebChromeClient to open the new page in the same view?
<p>I load the url in the WebView but, when the user click some button the new url is loaded in the android browser not in my webview. What should I do?</p> <p>Thanks in advance.</p>
android
[4]
3,956,412
3,956,413
UITableView Push to Multiple Views with Different URL Data
<p>I'm relatively new to iPhone Development and I'm trying to create an app that's using a UITableView that needs to push to different Views. Right now I'm designing it to push to a different page each time a cell is clicked. It seems that from other posts that I've read that it's not a good idea as there will be a lot of individual View pages. I'm not sure how to accomplish this as I am designing each View to have a phone number, email, web site and SMS that goes to different sources/destinations. I've designed everything up to this point and it works, but need this final step in order to finalize the app. Any help or tutorial that someone could be point me to would be appreciated.</p> <p>I'll try to be more specific. I have a main menu of categories that navigates to a submenu of other categories. Each category that the submenu navigates to has a phone link, email link, SMS link, and web link. Do I have to make separate pages/views for each category or is there a way to make a NSDictionary that will house all of the data for each category that has the URL links?</p>
iphone
[8]
2,860,052
2,860,053
Access information of containing list in python
<p>I'm writing a script that can help me documenting our network rooms.</p> <p>The idea behind that script is that a room is a list, that contains several lists for the racks. The rack lists contain lists called module with the servers/switches/etc. in the module list are the actual ports with the cable numbers.</p> <p>For example:</p> <pre><code>[04/02, [MM02, [1, #1992, 2, #1993, 3, #1567 ....], MM03, [1, #1234 .....]], 04/03, [MM01, .........]]] </code></pre> <p><code>04/02</code> = First Rack</p> <p><code>MM02</code> = First module in that rack</p> <p><code>1</code> = Port number</p> <p><code>#1992</code> = Cable number</p> <p>I hope you get the idea.</p> <p>The script I wrote compares the cable numbers in the room list, and looks if there are duplicates. Now it gets tricky: It should then replace the cable number with the rack and module of the other port. That should be pretty easy, because module and rack are the first elements of those lists that contain the port, but I don't know how to get access to the information. (I'm a noob in programming)</p>
python
[7]
5,290,468
5,290,469
Why is there a Java radix limit?
<p>I noticed that the max limit for a radix in Java is base 36. Is this an arbitrary limit, or does Java have reason for limiting the radix in this way?</p>
java
[1]
910,512
910,513
It keeps duplicating textboxes when using jquery .on() function
<p>I have 2 problem that needs to be addressed.</p> <p>Problem 1:</p> <p>In my jsfiddle I have a feature where the user opens a grid and selects an option, after the user selects an option then if they click on the "Add question" button, then this will be displayed in the new table row.</p> <p>The only thing though is that I want the user to be able to open the grid and select an option from the table row (working exactly the way as select an option from above) just in case the user changes their mind and wants to select a different option within a row. I am using the .on() functions.</p> <p>Does anyone know why it is not opening the grid?</p> <p>Problem 2:</p> <p>If the user adds a row by clicking on the "Add Question", it shows the option textbox once for the first row, if the user adds another row then it shows 2 options textboxes, then it shows 4 textboxes if 3rd row is added and etc.</p> <p>Why is it doing this?</p> <p>my code is in jsfiddle, click <a href="http://jsfiddle.net/f8cKm/5/" rel="nofollow">here</a></p> <p>If anybody wants to look at the code then access the jsfiddle, if anybody knows the solution or wants to try the solution, they can use the jsfiddle.</p> <p>Thank You</p>
jquery
[5]
1,277,651
1,277,652
choice a python web framework
<p>I want to develop a CMS with Python and I want to use a web framework for it. But this framework should be installed on all web hosts that support python or it should can used just by copying in host an adding the path in sys.path.</p> <p>Help me to choose a framework </p>
python
[7]
4,393,513
4,393,514
Producer Consumer Problem
<pre><code>public class Main { public static void main(String[] args){ XClass x = new XClass(); ProduceX prodx = new ProduceX(x); PrintX printx = new PrintX(x); prodx.start(); printx.start(); } } class XClass { private int x; private boolean produced = false; public XClass(){ this.x = 0; } public synchronized int modifyX(){ while(produced==true){ try{ wait(); } catch(InterruptedException ie){} } x=x+1; produced = true; notifyAll(); return x; } public synchronized void printX(){ while(produced==false){ try{ wait(); } catch(InterruptedException ie){} } produced = false; System.out.println(Thread.currentThread().getName()+" prints "+x); notifyAll(); } } class PrintX extends Thread{ private XClass x; public PrintX(XClass x){ this.x = x; } public void printX(){ for(int i=0;i&lt;10;i++){ x.printX(); } } } class ProduceX extends Thread{ private XClass x; public ProduceX(XClass x){ this.x = x; } public void run(){ for(int i=0;i&lt;10;i++){ x.modifyX(); System.out.println(Thread.currentThread().getName()+" increases x to "+ x.modifyX()); } } } </code></pre> <p>The problem is similar to producer consumer. Here producex will increase x by 1, and will increase again until x is printed by printx. But, seems no result. Where is the bug?</p>
java
[1]
414,397
414,398
Reconnect to the internet automatically
<p>I'm developing an Android chat application. On startup the application launches a service. The service connects to the chat server. If for some reason the connection goes down, the user can click a button and the reconnect() function gets called.</p> <p>The application runs on a mobile device. The application connects to the Internet via Wi-Fi. If the user, walking with his phone, goes out of the Wi-Fi coverage area, the connection goes down. I want my application to automatically try to reconnect to the Internet in such cases. What's the best way to do this in your opinion?</p>
android
[4]
384,020
384,021
scrollTop and doctype
<p>I'm looking for at solution to make document.body.scrollTop return the right values when using a doctype</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; </code></pre> <p>now this only works with chrome and not in ff and ie</p> <pre><code>alert('scrollTop = '+document.body.scrollTop); </code></pre>
javascript
[3]
479,681
479,682
Where does one go to find a JQuery programmer?
<p>I write server code but have little to almost no JQ experience. I have a project that I'm working on right now that requires a small amount of JQuery. Can someone tell me where I can find someone that really, truly knows their stuff that might be looking to make a few extra bucks for the holiday season?</p> <p>I'm working on a POS that requires a keypad as well as updating a div for inventory entered. This module should also handle the simple subtraction, addition as well as the calculation of duplicate items.</p> <p>Thanks.</p>
jquery
[5]
4,918,035
4,918,036
Android google map routing by reading KML
<p>How to draw route path on MapView Google API. I have two ordinates. Please tell options to draw path between these two points </p>
android
[4]
5,761,739
5,761,740
How to use ApplicationErrorReport.CrashInfo class?
<p>I am working on <a href="http://stackoverflow.com/questions/11190469/android-app-crashes-suddenly-while-running-heap-may-be-wedged">this</a> problem, while working on that I came across <a href="http://developer.android.com/reference/android/app/ApplicationErrorReport.CrashInfo.html" rel="nofollow">ApplicationErrorReport.CrashInfo</a>, I thought that may be some what helpful to me. However I have no clue how to use it. </p> <p>How can I implement that (ApplicationErrorReport.CrashInfo) so that I can know the cause of any crash of my App ?</p> <p>A clean answer will be also helpful for others in future.. </p>
android
[4]
3,905,501
3,905,502
Using a variable as both an integer and a string (Python)
<p>I would like to use a variable as an integer and a string in the same statement. In BASIC, it would look like this:</p> <pre><code>cnt = 0 while cnt &lt; 10: cnt = cnt + 1 print cnt + " + 1 = " + cnt + 1 </code></pre> <p>I understand it's a bit different with Python (integers have to be converted before you print them as strings, but here using a function such as "cnt = str(cnt)" doesn't seem to work very well). What would be the easy way to do this?</p>
python
[7]
5,270,866
5,270,867
Create a new file in Android emulator path /data/
<p>I want to create a file in emulator android storage path /data/...</p> <p>but it seems I can't create a new file by programs,</p> <p>I should upload an empty file to /data/... and then write the file,</p> <p>Can anyone help here?</p> <p>openFileOutput("file.txt", MODE_PRIVATE) seems can create a new file in /data/data/Package/files/...</p> <p>but it can't create in path /data/...</p> <p>Thank you so much !</p>
android
[4]
327,578
327,579
setwidth of a dynamic textview
<p>Actually my code is:</p> <pre><code> LinearLayout ll = new LinearLayout(this); ll.setId(i); ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); ll.setPadding(0, 0, 0, 5); //ll.setClickable(false); TextView tv = new TextView(this); tv.setWidth(5); tv.setId(++i); tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); final TextView name = new TextView(this); name.setText(user_chat.get(j).toString()); name.setWidth(60); name.setId(++i); //name.setClickable(false); name.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); Log.v("TextView name",""+name.getText()); TextView msg = new TextView(this); msg.setText(user_chat.get(++j).toString()); msg.setWidth(100); msg.setId(++i); //msg.setClickable(false); msg.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); TextView time= new TextView(this); time.setText(user_chat.get(++j).toString()); time.setId(++i); //time.setClickable(false); time.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); ll.addView(tv); ll.addView(name); ll.addView(msg); ll.addView(time); lay.addView(ll); </code></pre> <p>In this name,msg,time text fields I am displyed.I want name msg and time in proper order I mean same line. But the width is not adjusted to both android and droid. What can I do?Thanks in advance</p>
android
[4]
2,163,141
2,163,142
Copy a file and paste it to the desired location
<p>I want to copy a file from say /mnt/sdcard/Pictures and paste to the location /mnt/sdcard/Pictures/myselection.. how to code it?? </p>
android
[4]
5,330,356
5,330,357
javascript instance sharing in nested functions
<p>In the js code specified below -</p> <pre><code>var tclass = function(){ this.func2=function(){console.log('func2')}; this.b={ func1: function(){console.log('func1')} } } </code></pre> <p>how do i call func2 inside func1 on the same instance?</p>
javascript
[3]
4,434,522
4,434,523
Why does HttpContext.Response.Cookies["foo"] add a cookie?
<p>I have just spent half a day tracking down a bug due to the following behaviour: -</p> <p>Imagine that there is <strong>not</strong> a cookie called "foo" in either the Http request's or response's cookie collections. The following code returns null</p> <pre><code>A) HttpContext.Current.Request.Cookies["foo"] </code></pre> <p>The following code creates a new cookie called "foo" (with path="/" and blank value), adds it to the response's cookie collection and returns that</p> <pre><code>B) HttpContext.Current.Response.Cookies["foo"] </code></pre> <p>So (B) has the side effect that any pre-existing cookie called "foo" is overwritten on the client's browser.</p> <p>This is not a bug. Someone actually coded this deliberately. Here is the disassembly of the Get method (the Item[string name] indexer delegates to this method.</p> <pre><code> public HttpCookie Get(String name) { HttpCookie cookie = (HttpCookie)BaseGet(name); if (cookie == null &amp;&amp; _response != null) { // response cookies are created on demand cookie = new HttpCookie(name); AddCookie(cookie, true); _response.OnCookieAdd(cookie); } return cookie; } </code></pre> <p>Obviously the MSDN docs do not mention this behaviour (although some users have added comments at the bottom of the docs that describe this behaviour).</p> <p>My question is can someone explain to me the rational why the <code>HttpCookieCollection</code> class has this behaviour.</p>
asp.net
[9]
2,869,137
2,869,138
change the caller's number during an incoming call
<p>First I found a way to modify the called number during an outgoing call. I tried the same for the caller's number during an incoming call, but the only thing I can do is read the caller's number, not change it. Can someone give me a hint?</p> <p>My code in on receive so far:</p> <pre><code>Bundle b = intent.getExtras(); Log.d(TAG, "Phone State: "+ b.getString(TelephonyManager.EXTRA_STATE)); incomingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER); Log.d(TAG, "incoming number: "+ incomingNumber); </code></pre> <p>How could I proceed?</p>
android
[4]
2,252,164
2,252,165
ASP.Net HyperLink and Download directly?
<p>want to have a Hyperlink-Button in a gridView in which I can display a Link for a direct download of files.</p> <p>So far I am okay, but when I link the file in the NavigateURL, I don't get the file via click, I must right click -> Save as! That I don't want. Any help?</p>
asp.net
[9]
371,112
371,113
how to click a link with jquery contains
<p>I have a link that i am trying to emulate a click on. I am using the following code but nothing happens when I execute the script. Any ideas?</p> <p>Code</p> <pre><code>$("a:contains('somewebsite')").click(); </code></pre> <p>Link</p> <pre><code> &lt;a href="http://somewebsite.com/radio.php"&gt;Radio&lt;/a&gt; </code></pre>
jquery
[5]
1,766,941
1,766,942
how to access android phone connected to remote machine
<p>I need to access the android phone connected to remote windows/linux machine to run automation script. is there any way we can execute adb commands? Please suggest me..</p>
android
[4]
6,003,488
6,003,489
Why does iterating over jQuery objects with .each() not give me jQuery objects?
<p>The following works as expected:</p> <pre><code>$(".foo").first().text("hi!") </code></pre> <p>...because <a href="http://api.jquery.com/first/" rel="nofollow"><code>first()</code></a> returns a jQuery object.</p> <p>However, if I want to work with the <a href="http://api.jquery.com/text/" rel="nofollow"><code>text()</code></a> method for all matches, I need to do:</p> <pre><code>$(".foo").each( function(idx, obj) { $(obj).text("hi!") } ) </code></pre> <p>...because <a href="http://api.jquery.com/each/" rel="nofollow"><code>each()</code></a> gives you DOM objects.</p> <p>What is the design reason behind this baffling difference? How can I avoid having to build a jQuery object for each match?</p>
jquery
[5]
5,388,348
5,388,349
To save webpage as image for web application
<p>I got a link <a href="http://stackoverflow.com/questions/2715385/convert-webpage-to-image-from-asp-net">Convert webpage to image from ASP.NET</a> which does required functionality for me but the problem is it doesn't work on server(it goes in indefinite loop and the page just keeps on loading), possibly because they are using windows functions. Could any one help me to rewrite the same code so that it should possibly work on server. Any alternative suggestions are welcome.</p>
c#
[0]
4,315,160
4,315,161
billboard.js is not working in safari
<p>I have a billboard.js script running on a simple php file and for some reason it works fine in FF and IE but not Safari. I checked source code it and is pulling the content but the scrolling feature does not work when you click. Can someone please help me. Here is the link to try: <a href="http://www.luc.edu/test/cabplan/soc/test.php" rel="nofollow">www.luc.edu/test/cabplan/soc/test.php</a></p>
javascript
[3]
2,146,316
2,146,317
How to iterate through each xml file in root of a jar
<p>during runtime of my app I need to iterate through each xml file which lies in the root of my jar. </p> <p>I know that I can access a concrete file like this</p> <pre><code>InputStream in = this.getClass().getClassLoader().getResourceAsStream( "filename.xml" ); </code></pre> <p>But how can I receive the list of files which are in the root of the jar?</p> <p>Thanks</p>
java
[1]
4,259,850
4,259,851
Can you make a C# program which can not access to any local file system other than the folder it is installed?
<p>Let me ask whether you can make a C# program which can not access to any local file system other than the folder/sub folders it is installed? And how if the answer is yes. For details if it is necessary and possible, users are supposed to accept the program runs under a special user account which is restricted the file access only to the folder it is installed and to sub folders.</p> <p>Thank you very much in advance.</p> <p>Edit : Let me add context. I want users do not change their accounts. And as a programmer I do not have complete control over the program for some reasons.</p>
c#
[0]
2,004,626
2,004,627
Submit a POST variable with Javascript?
<p>Is there anyway to submit a POST variable, with name, to another page? I.e. form submission, as IF a button were clicked, but without having to click a button.</p>
javascript
[3]
3,663,609
3,663,610
ASP.NET: Writing web-accessible temp files without application restart
<p>My ASP.Net application used to restart unpredictably during requests, ruining my state, session data etc. I determined that the problem was caused by a control that writes and deletes some files in <code>Temp</code> folder that it creates near <code>bin</code> folder, so the web directory looks like this:</p> <pre><code>bin Temp .... Default.aspx web.config </code></pre> <p>ASP.Net apparently reacts to changes inside <code>Temp</code> folder the same way it reacts to changes inside <code>bin</code> or in web.config - it restarts the application.</p> <p>I could partially solve the problem by moving the <code>Temp</code> outside the site directory. That way the application doesn't get restarted every time something temporary is written\deleted, so this part works well. The problem is that some of the files inside <code>Temp</code> directory should be web-accessible - like images generated on the fly and such.</p> <hr> <p>So my question is actually threefold:</p> <ol> <li>Should ASP.Net application get restarted even if the changes are made not in the <code>bin</code> directory, but in another directory at the same level? Or is there something wrong with my configuration?</li> <li>Where and how do I create a temporary folder so it's web-accessible but it doesn't cause application restart?</li> <li>How do I turn off restart on directory change from code or web.config (both in IIS and ASP.Net development server)?</li> </ol>
asp.net
[9]
2,685,930
2,685,931
C++: how do I convert a string into a float where the starting char can change?
<p>I have this kinda of input:</p> <pre><code>x4.9 x.25 C400 </code></pre> <p>What is the best way to drop the first char and convert to float?</p>
c++
[6]
2,858,968
2,858,969
Dynamic DOM elements not accessible?
<p>I can see a DOM element with an ID of Foo by using the debug inspector.</p> <p>This DOM element is inserted dynamically by a script that I do not have access to.</p> <p>Because of this you can not see it when you do View->Source.</p> <p>When I try to access the element using</p> <p><code>document.getElementById('Foo')</code>, it returns a null b.c. it can not find it.</p> <p>Verified this in the debug console as well.</p> <p>Is it possible to get elements that are inserted dynamically?</p> <p>I ask b.c. I would like to remove the node.</p>
javascript
[3]
4,440,793
4,440,794
How to retrieve try/catch error
<p>how can I find the error</p> <pre><code>try { undef } catch (e){ console.log(e) console.dir(e) } </code></pre> <p>the information bust be there somewhere, because the console.log (in firebug) includes:</p> <pre><code>ReferenceError: undef is not defined </code></pre> <p>but when I browse the <code>e</code> object, I can't find it.</p> <p>How do I find out what the error is programmatically, so I can handle the error accordingly?</p> <p>Edit: <img src="http://i.stack.imgur.com/ihaRw.png" alt="screenshot showing error object"></p>
javascript
[3]
5,449,717
5,449,718
How to create .txt file in Temporary Internet folder?
<p>I want to create a .txt file inside Temporary Internet folder.For that I am reading registry.I am reading <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User</code> Shell Folders\Cache. But this give me path <code>**%USERPROFILE%\Local Settings\Temporary Internet Files**.</code> Here I need a absolute path like <code>C:\Documents and Settings\UserName\Local Settings\Temporary Internet Files</code>, so that I can create my .txt file ? Can anybody tell me how to do that ? Please Help me.....</p>
c++
[6]
1,237,149
1,237,150
Any advide on transfering iphone contacts to itunes?
<p>So here's the thing, I accidently spilled water on my iphone 4, although it has been fixed, it still get kind of "unstable", sometimes it just suddenly shut itself down. Now I'm saving money for the new iphone 5, but I have a pile of important contacts saved on my watered iphone 4 and I'm so afraid that they'll be gone with the damaged phone right before I could get a new one. But if I can copy these contacts to itunes, then next time I'll be able to transfer them to the new iphone,right? Or just copy to computer? Any difference? Anyway, I just want the contacts to be backuped, any good idea? I don't mind if I have to pay for something but it would be the best if there's a free and easy way.Help me please.</p>
iphone
[8]
1,081,312
1,081,313
String to raw byte array
<p>I have a string which contains binary data (<strong>non-text data</strong>).</p> <p>How do I convert this to a raw byte array?</p>
c#
[0]
3,835,642
3,835,643
Sending SMS messages to Email with Android APIs
<p>I have search for a solution and I have not been able to find one.</p> <p>Is it possible to send a text message (SMS) to and email address? If so how do you do it with Android APIs?</p>
android
[4]
4,865,657
4,865,658
Script doesn't download large images
<p>i use <a href="http://stackoverflow.com/questions/257409/download-image-file-from-the-html-page-source-using-python">this</a> script to download images from the same html page. But if images large enough, this script doesnt download properly - all images are 1,15 Kb and dont display. How can i fix it? what's wrong? </p>
python
[7]
2,536,499
2,536,500
How to cast object to another where base is 'higher'?
<p>There are two classes. Class B dervied from A.</p> <pre><code>class A { } class B : A { public B() { } public int Number { get; private set; } } </code></pre> <p>This gives me the error 'unable to cast from A to B'.</p> <pre><code>void Test() { var a = new A(); var b = (B)a; // &lt;== unable to cast. } </code></pre> <p>How can I cast the object in variable A to class B? </p> <p>Thank you.</p>
c#
[0]
1,447,626
1,447,627
Java Comparable issue
<p>I want to sort objects by a string they have. Just wondering does this make sense? Before now I have only used <code>Arrays.sort(BlahList);</code> But now I could have many objects and not just an arraylist of strings.</p> <pre><code>public class Contact implements Comparable { private string name; public compareTo (Contact Contact1) { return this.name.compareTo(Contact1.name); } } </code></pre> <p>and in the main method I have:</p> <pre><code>Collections.sort(ContactList); </code></pre> <p>I would also like to know if this would work for integers if the name was age?</p>
java
[1]
911,875
911,876
Java member initialization
<p>What is the difference between:</p> <pre><code>public class A { private int x = 1; A() {} } </code></pre> <p>and</p> <pre><code>public class A { private int x; A() { x = 1; } } </code></pre> <p>, if any?</p>
java
[1]
5,349,661
5,349,662
How to properly add an Android library to a previously made Android project?
<p>I'm trying to add a 2.2 sdk to my project and can't seem to figure out how. I tried adding it as an external JAR in the Android sdk folder but ive encountered some errors. How could I add another Android sdk to a previously made Android project? </p>
android
[4]
828,718
828,719
Data binding on combo box
<p>I am adding items to a combo box as given below:</p> <pre><code> readonly Dictionary&lt;string, string&gt; _persons = new Dictionary&lt;string, string&gt;(); .... //&lt;no123, Adam&gt;, &lt;no234, Jason&gt; etc.. foreach (string key in _persons.Keys) { //Adding person code cmbPaidBy.Items.Add(key); } </code></pre> <p>I want make the combo box more readable by displaying the values from dictionary (ie Names). But I need the person codes (no123 etc) for fetching from the database based on user input. </p> <p>What is the right way to do this? How can I bind both value and key to combo box item?</p>
c#
[0]
5,367,678
5,367,679
Is there a way in Visual C# to get the maximum of two number?
<p>Is there a function like this in Visual C#?</p> <pre><code>int max(int a, int b) { if(a &gt; b) return a; return b; } </code></pre>
c#
[0]
5,274,264
5,274,265
Can any one tell me the difference between volatile and static in java
<p>I'm little confusion difference between volatile and static in java, Can any one explain me.</p>
java
[1]
2,627,452
2,627,453
Javascript replace for all instances
<p>I found a nice bit of code to add some 'normal' text links (i.e. rather than a button) to share a page on social media sites:</p> <pre><code>&lt;a href="https://twitter.com/share?url=[url]"onclick="this.href = this.href.replace('[url]',window.location)" target="_blank" title="Share on Twitter"&gt;Twitter&lt;/a&gt; </code></pre> <p>Which works great. But for Pinterest I need the url to placed twice, for the page url and for the pin image:</p> <pre><code>&lt;a href="http://pinterest.com/pin/create/button/?url=[url]&amp;media=[url]pin.jpg" onclick="this.href = this.href.replace('[url]',window.location)" target="_blank"&gt;Pinterest&lt;/a&gt; </code></pre> <p>In this case just the first url gets added.</p> <p>Not that hot on javascript. There must be an easy way to replace all instances of [url], right?</p>
javascript
[3]
1,494,484
1,494,485
Return element at index in a vector
<p>How can I remove an element at a specified index in a vector, and then return that element? Is there a method for that?</p>
c++
[6]
4,582,531
4,582,532
python: is it possible to attach a console into a running process
<p>I just want to see the state of the process, is it possible to attach a console into the process, so I can invoke functions inside the process and see some of the global variables.</p> <p>It's better the process is running without being affected(of course performance can down a little bit)</p>
python
[7]
2,578,779
2,578,780
Pymedia installation on Windows with Python 2.6
<p>I am trying to install latest version of Pymedia from sources. I have Python2.6 and there is no binary available. </p> <p>Started with:</p> <pre><code>python setup.py build </code></pre> <p>and got the following messages:</p> <pre><code>Using WINDOWS configuration... Path for OGG not found. Path for VORBIS not found. Path for FAAD not found. Path for MP3LAME not found. Path for VORBISENC not found. Path for ALSA not found. Continue building pymedia ? [Y,n]:Y </code></pre> <p>After putting the source code for OGG and VORBIS in a directory where I had put the pymedia source code, it was able to find those libs But when I put the source code libmp3lame-3.95 in that dir, it couldn't find it.</p> <p>After reading setup.py file of pymedia , I also tried putting a dll for this library under libmp3lame/Release but it was still unable to locate it. </p> <p>Can someone help? Is there a binary distribution available for Pymedia using Python 2.6 or higher? </p>
python
[7]
2,854,656
2,854,657
Member defined more than once
<p>I am new to the whole get and set thing, but this seems pretty straightforward, don't I set something but just calling <code>this.Var = value</code>?</p> <pre><code>public LoginView LoginView1 { get; set; } void Page_Load(Object sender, EventArgs e) { this.LoginView1 = (LoginView)FindControls.FindControlRecursive(Page, "LoginView1"); RadGrid RadGrid3 = (RadGrid)LoginView1.FindControl("RadGrid3"); RadGrid RadGrid4 = (RadGrid)LoginView1.FindControl("RadGrid4"); UpdatePanel UpdatePanel1 = (UpdatePanel)LoginView1.FindControl("UpdatePanel1"); LoadData(); } </code></pre> <p>My error is saying that <code>LoginView1</code> is defined more than once. All I want to do is set the global variable on Page Load.</p>
c#
[0]
3,243,005
3,243,006
how to append two strings in javascript without space?
<p>I have two strings one brings me a time ie:</p> <pre><code>var gettime= $("#select-choice-2 :selected").text(); </code></pre> <p>it gives me time in 24 hr format like this</p> <pre><code>17:45 </code></pre> <p>but i want my time to be in a format like</p> <pre><code>17:45:00.000 </code></pre> <p>for which i made a string</p> <pre><code>var ext=':00.000'; </code></pre> <p>I want these two strings to concatenate in such a way to give me proper result.</p> <p><strong>I see now whats the problem is my "gettime" is not a proper string, i tried it to show in alertbox but nothing happens, so please tell me how to convert gettime into a string.</strong></p> <p><strong>I got it "gettime" is a local variable and ext is using in some other function thats why "gettime" was not appearing in alertbox, stupid ehh :p</strong></p>
javascript
[3]
1,426,559
1,426,560
Null Pointer exception while uploading images from a camera in Android
<p>This is my current code: </p> <pre><code>public void onClick(View v) { final Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY); final Intent gallIntent=new Intent(Intent.ACTION_GET_CONTENT); gallIntent.setType("image/*"); final Intent camIntent = new Intent("android.media.action.IMAGE_CAPTURE"); pickIntent.putExtra(Intent.EXTRA_INTENT, camIntent); pickIntent.putExtra(Intent.EXTRA_INTENT, gallIntent); pickIntent.putExtra(Intent.EXTRA_TITLE, "Select Source"); startActivityForResult(pickIntent, 0); if (bitmap == null) { Toast.makeText(getApplicationContext(), "Please select image", Toast.LENGTH_SHORT).show(); } else { dialog = ProgressDialog.show(CreatePod.this, "Uploading", "Please wait...", true); //new ImageUploadTask().execute(); } } }); } protected void onActivityResult(int requestCode, int resultCode, Intent data){ super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CANCELED) { Toast toast = Toast.makeText(this,"camera cancelled", 10000); toast.show(); return; } // lets check if we are really dealing with a picture if (requestCode == 0 &amp;&amp; resultCode == RESULT_OK) { Bundle extras = data.getExtras(); Bitmap b = (Bitmap) extras.get("data"); //setContentView(R.layout.main); imgView.setImageBitmap(b); // save image to gallery String timestamp = Long.toString(System.currentTimeMillis()); MediaStore.Images.Media.insertImage(getContentResolver(), b, timestamp, timestamp); } } </code></pre> <p>This gives the options Gallery and Camera(Actually, it shows an unsupported device in the place of camera. If I click on it, it gives NullPointerException and crashes. Is this the right way to do it? Or should I use PackageManger? If Yes, then how? </p>
android
[4]
511,796
511,797
Vibration effect on ipod
<p>How to make vibration effect in ipod.</p> <p>Can any one help me?</p> <p>Thanks in advance..</p>
iphone
[8]
3,238,316
3,238,317
Is there another way to validate $_POST data?
<p>Usually I use <code>trim()</code> PHP function to check, if data is not empty. Also for MySQL I use <code>mysql_real_escape_string()</code>. Is this enough,or do I need to perform additional checks?</p>
php
[2]
2,417,901
2,417,902
How to check if an input passed in $_POST is not empty?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/9154719/check-whether-post-value-is-empty">Check whether $_POST-value is empty</a> </p> </blockquote> <p>I am using this code to validate if the passed input is not empty, but this fails when I use "white space" in the input. It does pass the empty() check.</p> <pre><code>if (empty($_POST['r_user'])) { $data['error'] = 'Please pick a username to continue.'; $data['errorID'] = 'r_user'; } </code></pre> <p>What is the proper method to check an empty string in PHP?</p>
php
[2]
5,842,443
5,842,444
Choosing a random integer from a list of ranges in Java
<p>I have a list of ranges in Java</p> <pre><code>public class Range { private int min, max; //constructor, getters, setters go here } </code></pre> <p>So, a list may look like this</p> <pre><code>ranges = [[3,9], [18,45], [90,112]] </code></pre> <p>And I need to make the following function</p> <pre><code>public int getRandomValueWithinRanges() { //returns a value which is contained inside a range inside the ranges ArrayList } </code></pre> <p>How can I do this? Each value within those ranges should have an equal probability of being chosen, and it should be done efficiently (i.e. making a list of all the values inside the ranges and then choosing randomly from that list is <em>not</em> efficient)</p>
java
[1]
2,702,162
2,702,163
How can I develop an app which will not appear in launching menu of android
<p>How i can develop an app which will not appear in launching menu (neither its icon nor launcher). I will launch it by some other ways.</p>
android
[4]
3,744,531
3,744,532
Would this be a good way to do private functions?
<p>Just saw some interesting code while doing a typo in coffee-script. I got the following code</p> <pre><code>var Mamal, mam; Mamal = (function() { var __priv_func; function Mamal() {} Mamal.prototype.simple_var = 5; Mamal.prototype.test = function() { return __priv_func(this); }; __priv_func = function(instance) { return alert(instance.simple_var); }; return Mamal; })(); mam = new Mamal(); mam.simple_var = 10; mam.test(); </code></pre> <p>Now I've read alot about the module pattern in javascript and why its a bad thing (takes more memory, longer to create...) but of course the upside is having truly private functions/variables. Wouldn't the above code be a good way to create private functions (this wouldn't work for variables, unless you wanted static private variables) as the function is only created once in the closure?</p> <p>One of the upsides of the module pattern is also the execution speed of functions as the code doesn't have to look up the prototype chain. Would this theoretically give the same speed improvements?</p>
javascript
[3]
4,218,215
4,218,216
Android adb sort of works but can't load to device
<p>I have a zenithink zt-180 tablet connected to my usb port. I can use adb (from the command line) to get a shell command, reboot the tablet, and stuff like that, though I do have to kill and start the server first on the initial connect.</p> <p>I can also run ddms and it shows me the device threads and statistics and so forth for the tablet.</p> <p>However, whenever I try to load the helloAndroid example adb and ddms hang. To recover I have to cntr-C out of them, kill the server and then start the server. I can then do the above stated operations, just not load. In Eclips I get an error saying "failed to install HelloAndroid on device 0123456.... : timeout when i try to debug on the device.</p> <p>I know the application can run because I loaded it onto a USB stick and installed it on the tablet. It ran fine.</p> <p>What is it about the load program command that is hanging up adb???</p> <p>Note: USB debugging is enabled in the device. I make sure that only one DDMS and adb are running. All eclips components and the USB driver were loaded two days ago. The tablet is running android 2.1.1</p>
android
[4]
4,132,247
4,132,248
Unlimited number of tables getting produces
<p>I have this code:</p> <pre><code>for ($i = 0; $i &lt;= 47; $i++) { echo "&lt;tr&gt;"; for ($i = 0; $i &lt;= 11; $i++) { echo "&lt;td class=\"tableContents color3\"&gt;&lt;/td&gt;"; } echo "&lt;/tr&gt;"; } </code></pre> <p>When I execute it, it just keeps executing while it is supposed to stop execution after 47 loops. Any ideas on what's wrong and any better methods to achieve the same thing?</p> <p>Thank you all.</p>
php
[2]
3,507,196
3,507,197
jQuery prepopulate and format a text field
<p>This is confusing me. </p> <p>I have a PHP app with a text field, the client wants the field to be prepopulated with 896- and followed by user input of only five numeric values, so it would be like 896-12569. I</p> <p>I would like to do this in jqeury, is this possible, if so how?</p>
jquery
[5]
5,985,190
5,985,191
Java - Converting between numbers using methods
<p><img src="http://i.stack.imgur.com/er6h8.jpg" alt="enter image description here"></p> <p>This is a question from a past paper, i'm not really sure what to do. i have done this so far, any help is appreciated. My code may be confusing as i try to comment what i need to do then try to do it</p> <pre><code>public class NumberConvert { public NumberConvert(int from, int to) { } public String convert(String input) { if(input==null){ return ""; }else{ return "FF";//Not sure what to do here } } public static Integer valueOf(String s, int radix) throws NumberFormatException { try {//if radix is out of range (not sure what the range is) }catch(NumberFormatException e){ System.out.println(e.getMessage()); } return 0;// to complete } public static String toString(int i, int radix) { return "";//need to complete } public static void main (String[] args){ } } </code></pre>
java
[1]
40,273
40,274
how can i dynamically add a div to my page after the body tag?
<p>i wrote the following code, only problem it places the div before the closing tag and i want it to be at the beginning.</p> <pre><code>&lt;script type="text/javascript" language="javascript"&gt; window.onload = function createDiv1() { var divTag1 = document.createElement("div"); divTag1.id = "mid section"; divTag1.setAttribute("align", "center"); divTag1.className = "dynamicDivmid"; divTag1.innerHTML = "pp"; document.body.appendChild(divTag1); } </code></pre>
javascript
[3]
4,257,111
4,257,112
How do you get a value onClick from outside the anchor that is clicked?
<p>Assuming the following HTML:</p> <pre><code>&lt;tr id="record_1" &gt; &lt;td id="name_1"&gt;&lt;a href="#" id="logNameAndValue"&gt;Charles Dickens&lt;/a&gt;&lt;/td&gt;&lt;td id="value_1"&gt;A Christmas Carol&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>How can I print out <code>name=Charles Dickens value=A Christmas Carol</code> by partially using the following jQuery: </p> <pre><code>$('#logNameAndValue').click( function(event){ name=? value=? console.log("name=" + name + " value=" + value); }); </code></pre>
jquery
[5]
4,837,557
4,837,558
Understanding default variables in functions in Python
<p>I found this example in "Code Like Pythonista" by David Goodger at <a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#default-parameter-values" rel="nofollow">http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#default-parameter-values</a>. I'm a little bit confused here. According to this example when bad_append() is called several times new_item will be appended to a_list. I don't understand why a_list will not be reset every time function is called. </p> <pre><code>def bad_append(new_item, a_list=[]): a_list.append(new_item) return a_list &gt;&gt;&gt; print bad_append('one') ['one'] &gt;&gt;&gt; print bad_append('two') ['one', 'two'] </code></pre>
python
[7]
406,515
406,516
Jquery highlight words in editable div
<p>I have an editable div and would like to highlight (apply a css class) to certain words WHILE the user is still typing in the div.</p> <p>How would I do this using Jquery? </p> <p>I tried using the <code>div.html().replace()</code> etc but it replaces it and then moves the cursor all the way back to the beginning.</p>
jquery
[5]
4,385,742
4,385,743
PHP preg_replace without eval
<p>Am trying to use something like:</p> <pre><code>$newdata = preg_replace($pattern, $replacement, $data); </code></pre> <p>Now my replacement is something like</p> <pre><code>$pattern = "/START(.*?)END/is"; $replacement = "START $config END"; </code></pre> <p>Now, $config contains contents like</p> <pre><code>array('Test\\\'s Page') </code></pre> <p>The problem is that after I write the content, $newdata becomes</p> <pre><code>START array('Test\\'s Page') END </code></pre> <p>As you see above a single \ goes missing because it gets evaluated. How do I avoid that?</p>
php
[2]
5,036,521
5,036,522
how to handle properly multiple exception thrower objects
<p>I want to handle exceptions on higher level not in this method but I want to be sure that object a &amp; b closed properly.</p> <p>close() method can also throw an exception.</p> <p>Is this template the proper solution for this or there is a smarter/simpler solution?</p> <pre><code>public void foo() throws Exception { A a = null; B b = null; try { a = new A(); b = new B(); ... } catch(Exception e) { throw e; } finally { Exception ex = null; try { if (a != null) a.close(); } catch(Exception x){ ex = x; } try { if (b != null) b.close(); } catch(Exception x) { ex = x; } if (ex != null) throw ex; } </code></pre>
java
[1]
5,649,865
5,649,866
Javascript - Multiple external files
<p>I have a page which receives data from multiple sources and I need to create a set of handlers files to configure and display the different kinds of data. There could be 10-15 different kinds of data, each with it's own display logic. Each handler would be fairly large and not just 1 or two methods. </p> <p>I'm trying to figure out what would be the best way deliver an application like this, the only two options I can see are:</p> <blockquote> <p>1) Create an individual handler file for each type of data and externally load it in when the page loads. The problem with this is obviously including 10-15 different javascript files probably isn't a smart idea. Would I need to compress all the handlers into one file, minify it and deliver it compressed? </p> </blockquote> <p>or</p> <blockquote> <p>2) Do all the configurations on the server before pushing the data to the user. Here the problem is that the JSON data pushed back could be very large (plus would include HTML) and put a lot of strain on the server.</p> </blockquote> <p>Can anyone shed any light on how best to deliver complex javascript apps?</p>
javascript
[3]
4,284,845
4,284,846
Activity.findViewById returning null sporadically
<p>From the crash logs that I am getting from the Android market, I can see that some of my users are getting Force Closes caused by NullPointerExceptions when my code tries to access views that are in my application. In one example, my activity makes a call to findViewById() in onCreate() after I call setContentView(). I get an NPE when I try to access the view after the call to findViewById() (still in onCreate). What has me really scratching my head is that this does not happen all of the time (in fact most of the time the code acts as I would expect), but enough to have me concerned.</p> <p>I could add code to <em>always</em> check for null and avoid the NPE, but I would like to understand what could be causing the sporadic behavior.</p> <p>Does anyone know what could be causing this?</p>
android
[4]
876,393
876,394
selectors not working entirely
<p>I am populating a <code>&lt;div&gt;</code> with the <code>html()</code> function, after a link is clicked. Basically, I don't want the page to refresh, but put stuff inside the <code>&lt;div&gt;</code>. </p> <p>That works fine. However, I am passing a link into the <code>&lt;div&gt;</code>, and trying to select that too! It literally takes me to a different page, rather than populating the next <code>&lt;div&gt;</code>, as I expected.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $(".link1").click(function(){ $("#div1").html("&lt;a href='#' class='link2'&gt;click here&lt;/a&gt;"); return false; }); $(".link2").click(function(){ $("#div2").html("Just Text"); return false; }); }); &lt;/script&gt; &lt;div id="div1"&gt;&lt;/div&gt; &lt;div id="div2"&gt;&lt;/div&gt; </code></pre>
jquery
[5]
822,306
822,307
Scripting - Value Types - how to approach this?
<p>I am writing my own scripting language and need to handle value types somehow.</p> <p>I need to define a variable values in my script like in the snippet below</p> <pre><code>#Var #Name="Alpha" #Class="Float" #Value=1.0 #Var #Name="Beta" #Class="Int" #Value=1 #Var #Name="Delta" #Class="Vector2" #Value=(1.0,2.0) #Var #Name="Echo" #Class="String" #Value="abcdefgh" </code></pre> <p>As you can see, each #Var has a #Class defining what <strong>type</strong> of value to expect.</p> <p>The problem is i don't know how to approach it 'easily' so that i can manage the values later on in a simple manner:</p> <pre><code>float fAlpha = GetVar("Alpha")-&gt;GetValue(); fAlpha = 150.0f; GetVar("Alpha")-&gt;SetValue(fAlpha); </code></pre> <p>...</p> <pre><code>CVector2 vDelta = GetVar("Delta")-&gt;GetValue(); vDelta=CVector2(10.0,20.0); GetVar("Delta")-&gt;SetValue(vDelta) </code></pre> <p>I can check for #Var #Class all over the time, but i am looking for something more clear/OO.</p> <pre><code>if(GetVar("Alpha")-&gt;GetClass() == "Float") { float fAlpha = GetVar("Alpha")-&gt;GetValue(); } </code></pre> <p>Can somebody shed a bit of light on how do you approach this ?</p> <p>Thanks.</p>
c++
[6]
3,301,336
3,301,337
How would i do "Box entends Cube"
<p>I want to extend a Cube from Box. My program has three parts first i do a rectangle class then i use it to extend a Box class then i extend a Cube. I am stuck at the Cube part. This is what my instructions say :</p> <p>Assessment Instructions a. A Cube is a Box where the length, width, and height all have the same values. b. You won’t have to add any additional instance variables or methods, but you will have to set up the Cube’s constructor to ensure that length, width, and height all have the same values.</p> <p>Rectangle:</p> <pre><code> public class Rectangle { // instance variables private int length; private int width; /** * Constructor for objects of class rectangle */ public Rectangle(int l, int w) { // initialise instance variables length = l; width = w; } // return the height public int getLength() { return length; } public int getWidth() { return width; } } </code></pre> <p>Box:</p> <pre><code>public class Box extends Rectangle { // instance variables private int height; /** * Constructor for objects of class box */ public Box(int l, int w, int h) { // call superclass super(l, w); // initialise instance variables height = h; } // return the height public int getHeight() { return height; } } </code></pre> <p>And the main one Cube:</p> <pre><code>class Cube extends Box{ // instance variables private int height; private int length; private int width; public Cube(int h,int w,int l){ super(h,w,l); } public double getheight(){ return height; } public double getlength() { return length; } public double getwidth() { return width; } } </code></pre> <p>I need to know if I did the Cube one right or not. If i didn't do it right please help me fix it.</p>
java
[1]
1,497,734
1,497,735
strip_tags() function blacklist rather than whitelist
<p>I recently discovered the <code>strip_tags()</code> function which takes a string and a list of accepted html tags as parameters.</p> <p>Lets say I wanted to get rid of images in a string here is an example:</p> <pre><code>$html = '&lt;img src="example.png"&gt;'; $html = '&lt;p&gt;&lt;strong&gt;This should be bold&lt;/strong&gt;&lt;/p&gt;'; $html .= '&lt;p&gt;This is awesome&lt;/p&gt;'; $html .= '&lt;strong&gt;This should be bold&lt;/strong&gt;'; echo strip_tags($html,"&lt;p&gt;"); </code></pre> <p>returns this:</p> <pre><code>&lt;p&gt;This should be bold&lt;/p&gt; &lt;p&gt;This is awesome&lt;/p&gt; This should be bold </code></pre> <p>consequently I gotten rid of my formatting via <code>&lt;strong&gt;</code> and perhaps <code>&lt;em&gt;</code> in the future.</p> <p>I want a way to blacklist rather than whitelist something like:</p> <pre><code>echo blacklist_tags($html,"&lt;img&gt;"); </code></pre> <p>returning:</p> <pre><code>&lt;p&gt;&lt;strong&gt;This should be bold&lt;strong&gt;&lt;/p&gt; &lt;p&gt;This is awesome&lt;/p&gt; &lt;strong&gt;This should be bold&lt;strong&gt; </code></pre> <p>Is there any way to do this?</p>
php
[2]
4,338,788
4,338,789
strange HtmlElement error
<p>I am using HtmlElement in .net framework to parser a webpage, first I find an element in the page, let's name it as x HtmlElement, then I tried to run some code and check the return.</p> <p>strange things happened:</p> <pre><code>x.TagName return "SPAN" x.Parent.Children.Count return 1 x.Parent.Children[0].TagName return "DIV" </code></pre> <p>while I think the third line should return "SPAN" cause x is the only one element in it's parent element, does any one know the reason? is this a bug of .net framework?</p> <p>my vs is 2008 and the webpage url is: <a href="http://zu.sz.soufun.com/house-a085/" rel="nofollow">http://zu.sz.soufun.com/house-a085/</a> I got my x element through one of the links in the list, let's say it's a A element named y, and then I set x=y.Parent.Parent.Parent.Parent.Parent.Parent;</p> <p>if this is not clear, please let me know and I will explain more</p> <p>note the content is not in English, </p>
c#
[0]
325,380
325,381
Javascript encoded syntax?
<p>I'm adding a unit converter to my website from this link: <a href="http://www.unitconversion.org/faq.html" rel="nofollow">http://www.unitconversion.org/faq.html</a></p> <p>And as I was looking at the code I ran across code that looked like this in the JS file:</p> <pre><code>\x00@4\f*0(_\b!\x00Y\x00Q1%\nB;\bTY)\x0b TDD m2&amp;Nw\t&amp;P(cHH;dlA,M\b,L&lt;-A\bQ\b\n+|kL2\x00HGW \ra-+\fA@7d%1H5\"\x00,@~fi\x00t 2Bc&amp;8GeWE\x00j1\ </code></pre> <p>It's javascript as its in the JS file but I've never seen syntax like that</p> <p>From what I can tell, part of the code starts and ends when there <code>\</code> is shown.</p> <p>Can anyone shed some light?</p>
javascript
[3]
1,249,191
1,249,192
Is there any way to get the content from doc file php
<p>my Q is there any way to get the word count or the content of Microsoft word file in <strong>PHP</strong>? </p>
php
[2]
5,201,798
5,201,799
highlight all text in textarea
<p>I want to select all of the text inside of a textarea when a user clicks the textarea. I tried <code>onclick="this.focus()"</code>, but this didn't do anything. I tried <code>onclick="this.highlight()"</code>, but this caused an error. What should I do?</p>
javascript
[3]
5,168,044
5,168,045
While downloading some content from a website after few times i got exception webexception 502 Bad gateway what could make that?
<p>This is the download code:</p> <pre><code>private string downloadContent() { WebRequest request = WebRequest.Create(url); request.Method = "GET"; response = request.GetResponse(); Stream stream = response.GetResponseStream(); reader = new StreamReader(stream); string content = reader.ReadToEnd(); return content; } </code></pre> <p>The exception was on the line:</p> <pre><code>response = request.GetResponse(); </code></pre> <p>This is the Exception:</p> <pre><code>system.Net.WebException was unhandled by user code Message=The remote server returned an error: (502) Bad Gateway. Source=System StackTrace: at System.Net.HttpWebRequest.GetResponse() at ChatrollLogger.Form1.downloadContent() in D:\C-Sharp\ChatrollLogger\ChatrollLogger\ChatrollLogger\Form1.cs:line 228 at ChatrollLogger.Form1.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e) in D:\C-Sharp\ChatrollLogger\ChatrollLogger\ChatrollLogger\Form1.cs:line 112 at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument) InnerException: </code></pre> <p>What could be the problem ? Im downloading the ocntent from the site each n seconds. Most of the times no problems so far i got this exception once only.</p> <p>Line 112 is: </p> <pre><code>string content = downloadContent(); </code></pre> <p>And line 228 is:</p> <pre><code>response = request.GetResponse(); </code></pre>
c#
[0]
4,393,035
4,393,036
android runtime command problem
<p>i'm trying to reboot my android device (doing android porting) for test.</p> <p>my code :</p> <pre><code>try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("reboot"); InputStream is = proc.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; while ((line = br.readLine()) != null) { Log.i("runtime","line : " + line); } } catch (Throwable t) { t.printStackTrace(); } </code></pre> <p>but the device didn't reboot itself. </p> <p>if i change the command to </p> <pre><code>Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("ls"); </code></pre> <p>it ran fine , show all dir. </p> <p>and when i input "reboot" in adb shell , it also worked. why???</p> <p>reboot is just one of toolbox commands, I also run other command which can work from shell. But, none of them can work from rt.exec except 'ls'. Could some one tell me how to make it works from android runtime ? Thanks</p>
android
[4]
1,721,686
1,721,687
Counteract a javascript redirect?
<p>I am loading an external page in an iFrame that redirects after a counter. I want to disable the redirect.I used firebug to locate the redirect.</p> <pre><code>if(!counter) self.iframe.src=self.vars["someurl"]; </code></pre> <p>So how do I stop this redirect from happening?</p> <p>Thank you, Todd</p>
javascript
[3]
4,137,567
4,137,568
When and where should I use an interface
<p>When and where should I use an interface ?</p>
java
[1]
3,188,430
3,188,431
Android-Replace one image by another image
<p>I am new to android.I have a image which is declared in xml file using imageView.The problem is onRuntime I want to replace that with any image from gallery when the image is long clicked.what should I have to do.Thanks in advance</p>
android
[4]
1,482,763
1,482,764
PDF file doesnt display in the listview c# 2008
<p>I try to display the PDF files in the Listview as LargeIcon. But it doesnt display.</p> <p>I can display the all image formats.</p> <p>How to display the PDF file in the listview C#.2008?</p> <p>thanks in advance.</p> <p>I tried like this only, like image display.</p> <pre><code>enter code here private void import(string path) { ListView1.Items.Clear(); ImageList imageList = new ImageList(); imageList.Images.Clear(); imageList.ImageSize = new Size(170, 140); imageList.ColorDepth = ColorDepth.Depth32Bit; int i = 0; ////ArrayList to hold the files with the certain extensions ArrayList files1 = new ArrayList(); if (Directory.Exists(path).Equals(true)) { string validExtensions = "*.pdf"; //create a string array of our filters by plitting the //string of valid filters on the delimiter string[] extFilter = validExtensions.Split(new char[] { ',' }); //loop through each extension in the filter foreach (string extension in extFilter) { files1.AddRange(Directory.GetFiles(path, extension)); files = (string[])files1.ToArray(typeof(String)); } string[] pathes = new string[files.Length]; foreach (string file in files) { pathes[i] = file; i++; } foreach (string path1 in pathes) { imageList.Images.Add(Bitmap.FromFile(path1)); FileInfo fileInfo = new FileInfo(path1); String strDir = fileInfo.Name; ListView1.Items.Add(strDir); ListView1.TileSize = new System.Drawing.Size(100, 80); } for (int j = 0; j &lt; pathes.Length; j++) { this.ListView1.Items[j].ImageIndex = j; } this.ListView1.View = View.LargeIcon; this.ListView1.LargeImageList = imageList; ListView1.Focus(); ListView1.Items[0].Selected = true; } } </code></pre>
c#
[0]
4,881,607
4,881,608
How to prevent two actions at a time in android
<p>I have a textview and a listview in my page,If we click an item in listview or textview it will take us to diffrent different views.My problem is am able to click both textview and listview item at a time,How to block this?</p>
android
[4]
1,939,249
1,939,250
Problem writing to a text file C#
<p>Here is my program:</p> <pre><code>protected int CheckExisting(string item_id) { StreamReader sr = new StreamReader(@"D:\ItemID.txt"); string line = sr.ReadLine(); while (line != null) { if (0 == string.Compare(line, item_id)) return 1; line = sr.ReadLine(); } sr.Close(); return 0; } protected void WriteNewLog(string item_id) { using (StreamWriter sw = File.AppendText(@"D:\ItemID.txt")) { sw.WriteLine(item_id); } } protected void xHandler(int num) { for(int i= 0; i&lt; num; i++) if (0 == CheckExisting(item_id)) { WriteNewLog(item_id); } } </code></pre> <p>When o run the program, an exception unhandled occur: <strong>"The process cannot access the file 'D:\ItemID.txt' because it is being used by another process."</strong> Can u guys help me fix that? Thanks so much!</p>
c#
[0]
5,934,745
5,934,746
Help with a delimited string
<p>I have several strings that I need to parse. The string is supposed to be delimited with a carrot character, however, if the maximum number of allowed characters in the string is reached, the carrot character is omitted. I need to find a way to deal with this.</p> <p>Here is an example.</p> <p>The rule is that there can be no more than a maximum of 13 characters in it. In the following string, there is an "S" where there should be a carrot character. </p> <pre><code>MASSYBU HILLSMARY </code></pre> <p>This is an example of a string that has not reached the 13 character limit</p> <pre><code>CYPRUS^TOM </code></pre> <p>How can I deal with strings that have reached the 13 character limit where there is no delimiter as in the first example?</p>
php
[2]
4,793,984
4,793,985
C++: Binary to Decimal Conversion
<p>I am trying to convert a binary array to decimal in following way: </p> <pre><code>uint8_t array[8] = {1,1,1,1,0,1,1,1} ; int decimal = 0 ; for(int i = 0 ; i &lt; 8 ; i++) decimal = (decimal &lt;&lt; 1) + array[i] ; </code></pre> <p>Actually I have to convert 64 bit binary array to decimal and I have to do it for million times.</p> <p>Can anybody help me, is there any faster way to do the above ? Or is the above one is nice ?</p>
c++
[6]
1,804,328
1,804,329
What's wrong with this PHP Recursive Function?
<p>I have a database table with the following data:</p> <pre><code>categoryId categoryName parentCategory men Men root women Women root shoes Shoes root mensshirts Men's Shirts men menspants Men's Pants men mensjeans Men's Jeans men mensvests Men's Vests men womensshirts Women's Shirts women womenpants Women's Pants women </code></pre> <p>I'm using a recursive function to print out a tiered menu. The code is below.</p> <pre><code>function display_children($parent) { global $connect; $query = "SELECT categoryId, categoryName FROM categories WHERE parentCategory='$parent'"; $result = mysqli_query($connect,$query); if ( $result === false ) { printf("Query Error: %s\n", mysqli_error($connect)); exit(); } echo "&lt;ul&gt;"; while ($row = mysqli_fetch_assoc($result)) { extract($row); echo "&lt;li&gt;".$categoryName."&lt;/li&gt;"; display_children($categoryId); } echo "&lt;/ul&gt;"; mysqli_close($connect); } display_children('root'); </code></pre> <p>As a result, I get this printed out on screen:</p> <ul> <li>Men <ul> <li>Men's Shirts</li> <li>Men's Pants</li> <li>Men's Jeans</li> <li>Men's Vests</li> </ul></li> <li>Women</li> <li>Shoes</li> </ul> <p>The recursive function is not printing out the rest of the subcats, and I'm not sure why. My testing/debugging has confirmed that after mensvests is passed as a categoryId into the function, the next categoryId passed is women, which should locate the last subcats. Any ideas?</p>
php
[2]
542,149
542,150
Help, im new to C++ i need some advice
<pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int main() { cout &lt;&lt; "Input a Sentence: "; cin &gt;&gt; x; { char* string = x; int letter_count[26]; // Initialization for(int i=0; i&lt;26; letter_count[i++]=0); // Counting the number of letters for(int i = 0; string[i] != '\0'; i++) { if(string[i] &gt; 64 &amp;&amp; string[i] &lt; 91) letter_count[string[i]-65]++; else if (string[i] &gt; 96 &amp;&amp; string[i] &lt; 123) letter_count[string[i]-97]++; else if (string[i] == '.') break; } // Show the result for(int i=0; i &lt; 26; i++) if (letter_count[i] != 0) std::cout &lt;&lt; letter_count[i] &lt;&lt; " "&lt;&lt; char(i+97) &lt;&lt; std::endl; } } </code></pre> <p>Why doesn't this program compile?</p>
c++
[6]
372,935
372,936
How to dismiss previous activities in android at a certain point?
<p>I have activities A -> B -> C where A and B are for login and verification purpose. When a user reaches activity C, A and B are not necessary any more. That means if a user press BACK in C, the application should not go thru A and B, instead it should go back to HOME screen.</p> <p>What's the conventional way to implement this in android? Thanks.</p> <p>EDIT: to clarify a bit, user should be able to go back to A from B during login/verification phase, but not from C to A or B once the user reaches C.</p>
android
[4]
737,828
737,829
Get last 'N' quarters in C#
<p>Suppose the current quater is 3 and the year is 2011. How can I get the last 5 quarters</p> <p>Desired output:</p> <pre><code>Q3-2011 Q2-2011 Q1-2011 Q4-2010 Q3-2010 </code></pre> <p>The Q and '-' is appended.</p> <p>I am trying as under</p> <pre><code>int generateQuater = 5; int currentQuater = 3;//GetQuarter(DateTime.Now.Month); int currentYear = DateTime.Now.Year; List&lt;string&gt; lstQuaterYear = new List&lt;string&gt;(); lstQuaterYear.Add(string.Concat('Q',currentQuater, '-', currentYear)); for (int i = generateQuater; i &gt; 0; i++) { //code to be placed } </code></pre> <p>Thanks</p>
c#
[0]