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
3,170,069
3,170,070
Android :- Problem in getting response from a https request ,the second time the request is posted
<p>I'm trying to get data from a web service which is https://..... Problem is I get proper response a first time the request is made but if another request is made there is no response. The log shows only once "freeing OpenSSL session".</p> <p>Here is the postonserver code.</p> <pre><code>public static String postDataOnServer(String GETRequest) throws IOException { Log.e("Request : ", GETRequest); try { URL url = null; HttpURLConnection con = null; try { url = new URL(GETRequest); con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); con.setUseCaches(false); con.setDoOutput(true); con.setDoInput(true); con.setRequestProperty("User-Agent", "test-ssl"); con.setRequestProperty("Connection", "close"); con.connect(); } catch (IOException e) { Log.e("IOException : ", e.toString()); return "Connection not established"; } BufferedReader in = new BufferedReader(new InputStreamReader(con .getInputStream())); StringBuffer res = new StringBuffer(); char[] chBuff = new char[1000]; int len = 0; while ((len = in.read(chBuff)) &gt; 0) res.append(new String(chBuff, 0, len)); in.close(); System.gc(); Log.e("Responce :" , res.toString()); return res.toString(); } catch (SocketTimeoutException e) { Log.e("Responce :" , e.toString()); }catch (Exception e) { } return ""; } </code></pre> <p>Plz Reply ,Thank</p>
android
[4]
1,998,721
1,998,722
very basic java method
<p>I am a beginner in java and am writing a stack class using array.</p> <p>So I have a method in this class called pop</p> <pre><code> public int Pop(){ if (current_size &gt;0) { // do something return ele; } // return nothing &lt;-- ths is where error is } </code></pre> <p>Since i have the return type int.. the class is always expecting to return something. How should I tackle such cases where the method wil return something if the condition is true else it wont shouldnt return anything? Thanks</p>
java
[1]
6,011,612
6,011,613
javascript: this keyword
<p>I know <code>this</code> points to current object on which function operates. So here is the code as per the definition</p> <pre><code>function foo(){ alert(this); //output==window } </code></pre> <p>So, now function foo is equal to window.foo() but now here</p> <pre><code>function foo(){ function fo(){ alert(this); } fo(); } </code></pre> <p>so,now when <code>foo</code> gets executed output is again window object why? since the nested <code>this</code> should refer to different object.since fo() is now not operating on window object as foo()==window.foo() .so nested function should now point to different object</p> <p>see here for detail:</p> <pre><code> function foo() { alert(this); function fo(){alert(this);} as(); } </code></pre> <p>if now,var x=new foo();than "this" within the foo() method points to object object but the nested this points to global object right?now u should be clear what i meant to say</p>
javascript
[3]
4,742,984
4,742,985
Permissions with PendingIntent.getBroadcast() and AlarmManager
<p>Is there a way to enforce receiver permissions for intents broadcast by the AlarmManager? For example, I want to do this:</p> <pre><code>AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent("myapp.MY_ACTION"); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); am.setRepeating(AlarmManager.RTC_WAKEUP, now, MY_INTERVAL, pendingIntent); </code></pre> <p>But make the broadcasts sent by the AlarmManager act like this:</p> <pre><code>sendBroadcast(intent, "myapp.permission.RECEIVE_BROADCASTS"); </code></pre>
android
[4]
3,081,514
3,081,515
Python [Errno 28]
<p>I am executing a python code that generates text files and store them on the ~/Desktop path. In the middle of the execution, I got an error message " IOError: [Errno 28] no space left on device.</p> <p>i searched on the internet but couldnt find a fine answer.</p> <p>Waiting for your help please.</p> <p>Thanks in advance,</p> <p>Ahmad</p>
python
[7]
3,933,176
3,933,177
How do I use object object1 = new object on my program?
<p>I have an assignment where my program outputs a simple String using if conditions of another String, but I keep running into a problem where I cannot create a new instance(i think that is what it is called)</p> <p>anyway, here is my code</p> <pre><code> import java.util.Scanner; public class EP54 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Do you want to continue? "); **yesNoChecker check1 = new yesNoChecker();** System.out.print(EP54.yesNoChecker); } public String yesNoChecker() { if(in.equalsIgnoreCase("y") || in.equalsIgnoreCase("yes") || in.equalsIgnoreCase("Sure") || in.equalsIgnoreCase("why not")) System.out.println("OK"); else if(in.equalsIgnoreCase("y") || in.equalsIgnoreCase("yes") || in.equalsIgnoreCase("Sure") || in.equalsIgnoreCase("why not")) System.out.println("Terminating."); else System.out.println("Bad Input"); } } </code></pre> <p>Please help me! (bolded part is where I get error)</p> <p>Can anybody give me a working version of the code so I can compare it with mine?</p>
java
[1]
5,173,105
5,173,106
JQuery selectmenu set selected index on change
<p>I am trying to set the selected index of a select box / <a href="http://wiki.jqueryui.com/w/page/12138056/Selectmenu" rel="nofollow">selectMenu</a> on <em>change</em> back to the first option.</p> <p>Here is my code so far</p> <pre><code> $obj = $("&lt;select class='class1' /&gt;"); $obj.append("&lt;option value='-1' selected='selected' class='icon1'&gt;default&lt;/option&gt;"); $obj.append("&lt;option value='0' class='icon2'&gt;opt1&lt;/option&gt;"); $obj.append("&lt;option value='1' class='icon2'&gt;opt2&lt;/option&gt;"); $obj.append("&lt;option value='2' class='icon2'&gt;opt3&lt;/option&gt;"); $("#container").append($obj); $obj.selectmenu({ transferClasses: true, icons: [ {find: '.icon1', icon: 'ui-icon-flag'}, {find: '.icon2', icon: 'ui-icon-plus'} ], change: function(){ // doesn't work $(this).find("option:first").attr("selected","selected"); // doesn't work $(this).selectedIndex = 0; // doesn't work $(this).val(-1); // doesn't work $(this).val("-1"); // doesn't work $(this).val(""); } }); </code></pre> <p>Look at this <a href="http://jsfiddle.net/rlemon/GXtpC/85/" rel="nofollow">Fiddle</a>, The top dropdown menu I have altered. If you change the value, and re-open the dropdown menu the selected value 'jumps' to the one i changed it to. I want it to be there once i select any value.</p>
jquery
[5]
1,277,501
1,277,502
Message Box in ASP.NET
<p>How to display the message Box within the Content Page..? After updating profile..I want to display a Message Box in content page.. </p> <p>Please give your suggestions.. Thanks in advance.</p>
asp.net
[9]
3,119,995
3,119,996
authorization to select datetime in windows form
<p>i have datetimepicker on form , and 1 txtbox where we have name of users.</p> <p>now i want allow superuser "sa" to access full calander, but i want normal user make entry with current date in system. i have use following code but not working for me. how to resloved this?? thanks in advace please help</p> <pre><code>enter code here if (txtSupervisor.Text != "sa") { dateTimePicker1.MinDate = dateTimePicker1.MaxDate = DateTime.Now; } enter code here </code></pre>
c#
[0]
5,387,107
5,387,108
How to shuffle characters in a string
<p>How do I shuffle the characters in a string (e.g. hello could be ehlol or lleoh or ...). I don't want to use the <code>Collections.shuffle(...)</code> method, is there anything simpler?</p>
java
[1]
1,526,168
1,526,169
How to share .java file in more than one projects?
<p>I am having one .java file containing two classes out of which one is public class. I am using methods of that class in more than one java projects created in eclipse. I want to share that file keeping at fix location like referencing common .h and .cpp files in more than one projects in visual studio in more than one projects. So separate copy of that file should not be present in each project. Is there any way to do this in eclipse?</p>
java
[1]
4,032,692
4,032,693
Has Java ever been used in outer space?
<p>In response to a question about examples of Java usages, I bumped across some articles where NASA used Java for ground control in a mission to Mars but I couldn't find out if it has ever been used outside of Earth. Do you know of any such instances?</p>
java
[1]
2,879,046
2,879,047
Android command not working
<p>I am writing a code in which I am trying to open up the camera of the device but my command is not working , it is showing compiletime error , Please see that is the command correct or is it wrong and if it is wrong then please provide me the correct code , this is my code -</p> <pre><code>Camera camera= Camera.open(); </code></pre>
android
[4]
2,229,518
2,229,519
Exclude javascript from being loaded for touch screen devices
<p>I am using tinyscrollbar to replace the standard scrollbars on desktop versions of my web app. The main reason for this is so that i have a consistent and nice design across all desktop browsers. On an android, mobile ios device and windows mobile device i would just want to use the native scroller. This means that i wouldnt want to include my scroller css nor the javascript for it. If anyone has any experience with this it would be very helpful. I worry about windows 8 machines becuase they are desktops and tablets. </p>
javascript
[3]
1,469,027
1,469,028
Assign a value to a struct value-type
<p>I want to be able to create a struct, and use it like a normal built-in. For example, say I decide that the Bool should also have a FileNotFound value (as a silly example!), so I create a struct to include that - what would it take to be able to use it as a normal struct in code (ie. assign to it), as in bool b = true; or b = FileNotFound;</p> <p>The Bool is a struct, right? And you can do it with the other built-ins: int i = 32; or byte b = 123;</p> <p>I want to do my own! Anyone got any ideas...?</p> <p>Cheers - Richard</p>
c#
[0]
5,253,798
5,253,799
creating an object and initializing an object - Difference
<pre><code> ////Creating Object var Obj; // init Object Obj= {}; </code></pre> <ol> <li>What's the difference between these two?</li> <li>Is it possible to make it into a single line?</li> <li>Any Advantages of using like this?</li> </ol>
javascript
[3]
3,588,187
3,588,188
C++: Outputing Multidimensional Arrays on loop?
<p>Hi everybody I have being trying to do this the whole morning but I can't seem to make it work and is to output a multidimensional array on a loop, let me explain better with a non multidimensional one:</p> <pre><code>int j; int line[4] = {1, 2, 3, 4,}; for(j = 0; j &lt; 4; j ++) { cout &lt;&lt; line[j] &lt;&lt; endl; } </code></pre> <p>This works but when for multidimensional arrays comes its headache:</p> <pre><code>int i, j; int line[2][2]; line[0][0] = 99; line[0][1] = 98; line[1][0] = 97; line[1][1] = 96; i = 0; j = 0; for(j; j &lt;= 1; j ++) { for(i; i &lt;= j; i ++) { cout &lt;&lt; line[i][j] &lt;&lt; endl; } } </code></pre> <p>Can somebody help me?</p>
c++
[6]
3,905,940
3,905,941
Folder Creation In Windows C#
<p>I want to create dynamic folder by code in Windows C#.Suppose for each ccount holder in bank, i have to generate a folder. Thx in advance</p>
c#
[0]
3,018,570
3,018,571
Application working on emulator but not working on actual device
<p>I am testing facebook Single-Sign-On application. I am using android platform 2.2 and api level 8. I have similarly created emulator with the same configuration. It is working fine in emulator. But when i test it on actual device that is HTC Desire HD ver 2.2 froyo updated. It opens up a dialog with facebook as title and shows loading screen then disappears.</p> <p>I am unable to understand the reason for such behavior. </p> <p>Please help me on this.</p> <p>Regards,</p> <p>Pankaj</p>
android
[4]
960,573
960,574
iPhone - removing files matching a pattern
<p>Is there a way to remove all files in a given directory (not recursively) using a pattern?</p> <p>I mean, I have files like file1.jpg, file2.jpg, file3.jpg, etc., and I want something like the unix</p> <pre><code>rm file*.jpg </code></pre> <p>is there a way to do that?</p> <p>thanks</p>
iphone
[8]
484,301
484,302
normal way of using variables throughout python
<p>What is the standard way of declaring configuration variables for your program at the top of a python script? These are used throughout the program in multiple classes and functions. Is the best way:</p> <ol> <li><p>To create a mixed dictionary with the configuration options, and pass these to any classes that need them. Downside: this requires passing extra attributes. For example:</p> <pre><code>config = {'parseTags': {'title','font','p'}, 'name': 'steve', 'logFrequencies': 10, 'print_rate': False } </code></pre> <p>&nbsp;</p> <pre><code>newCustomObject = CustomClass(config) customfunction(config) print 'hi',config['name'] </code></pre></li> <li><p>Create global variables at the beginning of the file and call those throughout the program. Downside: ruins the encapsulation of the classes.</p></li> <li><p>Something else.</p></li> </ol> <p>What is the most pythonic way of doing this?</p>
python
[7]
1,715,161
1,715,162
Communicate with backend as safe as possible
<p>I'm about to start the design of an application for Android (and possibly later on iPhone, if I ever get around learning it). In this application I will need to send and retrieve various information to a backend (that me myself also will need to design and code). The information will most likely be in json format.</p> <p>How would I go about making this data as safely transmitted as possible? Is https the only anser to this? Or are there any other smart solutions to this?</p>
android
[4]
4,856,598
4,856,599
retaining variables on Response.Redirect
<p>i am very new to asp.net. when someone presses a button on default.aspx, this takes a user to default2.aspx by response.direct. there are some local variables on default.aspx that i want to carry over to the next page. i want to know what their values are. for example if someone entered text in a textbox on the default.aspx i would like to know that value on the next page. thank you so much for your time.</p>
asp.net
[9]
4,548,772
4,548,773
match all elements by class except undefined
<p>Having table</p> <pre><code> &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td class="foo"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td class="bar"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p><strong>How to get all <code>td</code> elements having any class set?</strong></p> <p>While trying </p> <pre><code>$.each($("td:not(undefined)"),function(i,v){ ... </code></pre> <p>i still get <code>undefined</code> class in result</p>
jquery
[5]
3,646,643
3,646,644
Is it possible to turn a char code (number) into a char in JavaScript?
<p>Something like:</p> <pre><code>var str = "a"; var code = str.charCodeAt(0); var str2 = "blah " + charFromCode(code); alert(str2); // "blah a" </code></pre> <p>I do not think is possible. But I'm asking just in case it is.</p> <p><strong>Edit:</strong> Weird. And I <strong>did</strong> google it!</p>
javascript
[3]
3,135,302
3,135,303
Speech introduction
<p>I'm currently working on a speech introducing an introduction to C++ programming manual. The speech itself is going to be about the topics within the manual (which are very basic concepts, such as data types, ect..) I'll be giving this speech to students who are <strong>not familiar to C++ or even programming in general</strong>, and I'm looking for an attention grabber to begin my speech with such as a fun fact or quote about C++, or an interesting statistic regarding C++. I am wanting something the students will understand, and that sparks their interest. Does anyone have any good ideas that I can use? Thanks!</p>
c++
[6]
3,858,942
3,858,943
last 5 bits of a bitmask
<p>I have a bitmask (stored as a short). For various purposes, I want to zero out all but the last 5 bits - I'm sure there is an easy to way to do this via bitwise operators, but it eludes me.</p> <pre><code>1010 01101 1011 0111 -&gt; 0000 0000 0001 0111 </code></pre> <p>Thanks</p>
c#
[0]
699,877
699,878
Why this convert into object
<p>Instead of string it is object</p> <pre><code>String.prototype.foo = function () { return this; }; typeof "hello".foo() // object ??? "hello".foo().toString(); //hello </code></pre> <p>it should return string instead i guess. </p>
javascript
[3]
5,977,823
5,977,824
What PHP version supports this kind of assigning?
<p>What PHP versions supports this:</p> <pre><code>function mytest($mVar = null) { ($mVar === null) and ($mVar = "Hello"); // &lt;--- This line echo $mVar; } </code></pre> <p>Does it work in PHP versions lower than 5.3.x ?</p>
php
[2]
4,750,485
4,750,486
How to make a function repeat itself
<p>I have a python problem, I'm reading from XML and have two spread functions set up; one finds a location, than the other function finds a location inside the first one, and returns info. my problem is that i need this to continue down the page and find other occurrences of each. I'm not sure if thats a good explanation of now so heres code:</p> <pre><code>def findEntryTag(webPage): start= webPage.find("&lt;entry&gt;") +7 end= webPage.find("&lt;/entry&gt;") slicedString=webPage[start:end] return slicedString def findEarthquake(webPage): slicedString=findEntryTag(webPage) start= slicedString.find("&lt;title&gt;") +7 end= slicedString.find("&lt;/title&gt;") eq= slicedString[start:end] return eq my Earthquake= findEarthquake(text) print (myEarthquake) </code></pre> <p>so need it to do the functions again to get another earthquake and print out the hole list of them. please help! thanks</p>
python
[7]
544,238
544,239
How to cause a form to be submitted automatically on page load in JavaScript?
<p>This may have an obvious answer, but I am very new to js so I have no idea how to do this. I would like a form on a page to be submitted automatically when that page is loaded without requiring any user action like pressing a button. How to do this?</p>
javascript
[3]
5,917,828
5,917,829
Why is it discouraged to use Resources.getIdentifier()
<p>In the Android SDK, there is a comment that says it's more efficient to retrieve resources by identifier instead of by name.</p> <p>Is this the only reason it's discouraged to use getIdentifier()?</p> <p>I need to programmatically access one of several hundred resources and so far my design makes it easier to access raw resources by name instead of identifier.</p>
android
[4]
2,357,578
2,357,579
Get a letter out of a word
<pre><code>a = ['cat','dog'] random.choice(a) </code></pre> <p>How can I choose a random word, and pull out a letter? I've searched and experimented and whatnot but can't find an answer. thanks.</p> <p>I don't want a random letter, for instances I want it to choose a word, cat. then I want someone to guess either c a or t. Kind of like hangman</p>
python
[7]
3,976,010
3,976,011
Activity in popup window outside of my application
<p>I have an activity and layout that I want to be able to start on top of whatever application is currently open on the phone or the home screen, but i want the activity to start in a semi transparent pop-like window that the user can interact with. I'm not sure where to start, any help would be great</p>
android
[4]
4,171,041
4,171,042
How do I separate my JavaScript objects into multiple files
<p>I'm trying to separate my JavaScript into nice libraries. I have 2 companies under the net top-level-domain (net.foxbomb and net.matogen)</p> <pre><code>var net = { foxbomb : { 'MyObject' : function() { console.log ("FoxBomb") } } } </code></pre> <pre><code>var net = { matogen : { 'MyObject' : function() { console.log ("Matogen"); } } } </code></pre> <pre><code>var f = new net.foxbomb.MyObject(); var m = new net.matogen.MyObject(); </code></pre> <p>Of course, I've just defined two nets - which doesn't work. What is the correct way to do this?</p>
javascript
[3]
4,936,974
4,936,975
Coming from a Visual C# Express IDE/C# programming background, is there a tutorial for creating python applications?
<p>It's very overwhelming coming from something that helps you create applications straight forward to something with somewhat convoluted documentation.</p> <p>Can someone <strong>please</strong> share a tutorial on how to create a simple Hello World application using Python. No, I don't mean command line. I mean a physical window.</p> <p>I'm trying to learn how to program in Python and so far all I find is command line applications, and I don't really find use for them unless I can visually show off my skills.</p> <p>So, where can I learn some Python GUI development. People have suggested wxWidgets, PyQT, etc. but once again, that means nothing to me, because I know diddly squat about them.</p> <p>I need an up to date tutorial. :S</p>
python
[7]
3,216,373
3,216,374
jQuery drag containment window
<p>I want to set this, (see below) , but instead of the whole window, I want the window minus a div. So I want to be able to drag it everywhere except in a div(#startcontainer). can anyone point me in the right direction?</p> <pre><code> $( "#test" ).draggable({ containment: 'window', opacity: 0.5 }); </code></pre>
jquery
[5]
4,272,858
4,272,859
Routing audio bluetooth headset
<p>I use this code for routing audio to headset - Galaxy 5 device 2.2. But this same code doesn't work in Android 2.3.3 Galaxy Y device!!! When I power on headset, the media sound stop working... </p> <pre><code>@Override public void onReceive(Context context, Intent intent) { Log.i(TAG,"onReceive - BluetoothBroadcast"); localAudioManager = (AudioManager) context.getSystemService("audio"); String TAG = "BluetoothReceiver"; String ACTION_BT_HEADSET_STATE_CHANGED = "android.bluetooth.headset.action.STATE_CHANGED"; String action = intent.getAction(); if(action.equals(ACTION_BT_HEADSET_STATE_CHANGED)) { int extraData = intent.getIntExtra(EXTRA_STATE , STATE_DISCONNECTED); if(extraData == STATE_DISCONNECTED){ localAudioManager.setBluetoothScoOn(false); localAudioManager.stopBluetoothSco(); localAudioManager.setMode(AudioManager.MODE_NORMAL); Log.i(TAG, "Bluetooth Headset Off " + localAudioManager.getMode()); }else{ localAudioManager.setMode(0); localAudioManager.setBluetoothScoOn(true); localAudioManager.startBluetoothSco(); localAudioManager.setMode(AudioManager.MODE_IN_CALL); Log.i(TAG, "Bluetooth Headset On " + localAudioManager.getMode()); } } } </code></pre> <p>Dears, please help me. </p> <p>Thanks! Mateus</p>
android
[4]
2,058,408
2,058,409
PHP Warning : cannot modify header information
<p>I have an php login function. When I try to logged in with correct user, it show the error like this : </p> <p>Warning: Cannot modify header information - headers already sent by (output started at /home/hapshou1/public_html/index.php:15) in /home/hapshou1/public_html/index.php on line 150</p> <p>-</p> <pre><code>include "config.php"; if($_SERVER["REQUEST_METHOD"] == "POST") { function antiinjection($data) { $filter_sql = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($data,ENT_QUOTES)))); return $filter_sql; } $username = antiinjection($_POST['username']); $pass = antiinjection($_POST['password']); $login=mysql_query("SELECT username, password FROM user WHERE (username='$username' OR email='$username') AND password='$pass'"); $found=mysql_num_rows($login); $r=mysql_fetch_array($login); if ((!empty($username)) &amp;&amp; (!empty($pass))) { if ($found &gt; 0) { session_register("username"); session_register("password"); $_SESSION[username] = $r[username]; $_SESSION[password] = $r[password]; date_default_timezone_set("Asia/Jakarta"); $date_log = date("j-F-Y, G:i "); mysql_query("update user set status='online', date_logged_in='$date_log' WHERE username='$_SESSION[username]'"); header('location:home'); } else { echo '&lt;div class="error_log"&gt; &lt;p&gt;Wrong username or password. Please try again.&lt;/p&gt; &lt;/div&gt;'; } } else { echo ' &lt;div class="error_log"&gt; &lt;p&gt;Username and password are required.&lt;/p&gt; &lt;/div&gt; '; } } </code></pre> <p>What's wrong with my code?</p>
php
[2]
2,517,563
2,517,564
Display image using a RSS feed
<p>I have an application in which use a RSS feed reader. My problem is that I don't know what is the best way to display an image. The closer I could get was to pull the image description (). I know I could parse this String by myself and get the image url, but I was wondering if there is a more elegant way to solve this issue. I tried using the SAX and the DOM classes, but I couldn't figure it out. </p> <p>Thanks a lot, Gratzi</p>
android
[4]
3,977,721
3,977,722
Timer even outside the app
<p>I'm trying to find a way to implement this.</p> <p>basically it's a timer say like in farm ville or such games that count even when you exit the app. </p> <p>how do I implement that?</p>
android
[4]
1,481,227
1,481,228
php code md5 hashing explanation
<p>I am working with the moodle system, but it turns out that it uses md5 salt hashing. I found some come, so maybe you could explaint it to me because I am have only basic knowledge of php.</p> <pre><code>function validate_internal_user_password($user, $password) { global $CFG; if (!isset($CFG-&gt;passwordsaltmain)) { $CFG-&gt;passwordsaltmain = ''; } $validated = false; if ($user-&gt;password === 'not cached') { // internal password is not used at all, it can not validate } else if ($user-&gt;password === md5($password.$CFG-&gt;passwordsaltmain) or $user-&gt;password === md5($password) or $user-&gt;password === md5(addslashes($password).$CFG-&gt;passwordsaltmain) or $user-&gt;password === md5(addslashes($password))) { // note: we are intentionally using the addslashes() here because we // need to accept old password hashes of passwords with magic quotes $validated = true; } else { for ($i=1; $i&lt;=20; $i++) { //20 alternative salts should be enough, right? $alt = 'passwordsaltalt'.$i; if (!empty($CFG-&gt;$alt)) { if ($user-&gt;password === md5($password.$CFG-&gt;$alt) or $user-&gt;password === md5(addslashes($password).$CFG-&gt;$alt)) { $validated = true; break; } } } } if ($validated) { // force update of password hash using latest main password salt and encoding if needed update_internal_user_password($user, $password); } return $validated; </code></pre> <p>}</p> <p>Would it be hard to change it that after entering simple text it would became hashed?</p>
php
[2]
5,705,925
5,705,926
document.location / parent.location - Can they be blocked?
<p>I am using the above 2 commands on my website. It seems they work for 95% of people visiting the page it should trigger but for others it doesn't.</p> <p>Does anyone know if these javascript commands can be blocked at all? I am having a real headache finding out why they don't work sometimes.</p> <p>p.s I am not using these for spam or anything, just for processing payments.</p> <p>Thanks.</p> <p>EDIT: I have a tag replacement for JS being disabled. I am thinking more of a random blocking that a user isn't generally aware of. None of the people who have reported the issue would be likely to install a pop up blocker</p>
javascript
[3]
5,906,373
5,906,374
The char* constant value ERROR with GNU G++ compiler
<p>I write sevaral files with the relationship like:</p> <p>file A.h:</p> <pre><code>#ifndef MACRO_HEADER #define MACRO_HEADER const char* CONST_CHAR_NAME = "name"; #endif </code></pre> <p>file B.h(B.cpp) and file C.h(C.cpp) also include this common type definition header A.h. When the g++ finally combines the obj files to lib, it gives out he redefinition error.I confess that I make a mistake and I should define the constant as:</p> <pre><code>const char* const CONST_CHAR_NAME = "name"; //This is OK </code></pre> <p>But why compiler gives me a redefinition ERROR? Is const char* not a constant value?But I use typeid.name to check the types of <code>const char *</code> and <code>cosnt char* const</code>. They are the same:<strong>char const *</strong> . I am confused with the ERROR.</p>
c++
[6]
663,305
663,306
open two different socket input stream
<p>I have a server and a client. The server receives two command strings: <code>add</code> or <code>remove</code>. If server receives <code>add</code>, it adds the object it receives from the socket to a local list. Is it acceptable to open two different streams consecutively to receive two different objects?</p> <p>Example:</p> <pre><code>/* To read the command */ BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); /* To read the object */ ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); </code></pre>
java
[1]
127,319
127,320
Do template parameters need to be forward declared or does the type definition to be known
<p>Basically I have this code, but GCC complains that the vector cannot be constructed with an empty type. Has anybody encountered this problem before? I should mention that Vertex3D is only used through pointers in the file and so there should be no reason for the whole type to be known by the compiler. I dont know how templates behave in this respect..</p> <pre><code>//#include "cgVertex3D.hpp" #include "cgDirection3D.hpp" #include "cgHandedness.hpp" class Vertex3D; // Forward declaration to avoid mutual header include class Polygon3D { // Vertices constituting this polygon vector&lt;Vertex3D*&gt; *vertices = NULL; public: ... </code></pre>
c++
[6]
4,999,894
4,999,895
How to set detect with draggable function?
<p>How to set detect with draggable function, When check the box the draggble fucntion still not work.</p> <p><a href="http://jsfiddle.net/KPnRc/" rel="nofollow">http://jsfiddle.net/KPnRc/</a></p> <p>HTML</p> <pre><code>&lt;div class="drag" style="width:100px; height:100px; background:blue;"&gt;&lt;/div&gt; Lock:&lt;input name="lock" id="lock" type="checkbox" value="0" /&gt; </code></pre> <p>JS </p> <pre><code>if($('#lock').is(':checked') == true){ $(".drag").draggable(); } </code></pre>
jquery
[5]
2,379,983
2,379,984
Php compatibility question
<p>I am trying to run cimyadmin(http://cimyadmin.net/) but i am getting a lot of helper depreciation errors and after looking around the web for answers i am convinced its a php issue.Is there a way to run php 5.0.2 or earlier but not less than php 5 code on latest distributions of php.</p>
php
[2]
3,012,000
3,012,001
How to know my code is running in "debug" mode in IDE?
<p>How can I write the code which can behavior differently in run time under "debug" mode (e.g. invoked as "Debug As Java Application" in eclipse) from under "run" mode (e.g. invoked as "Run As Java Application" in eclipse")? That is, for example, the code can print "Haha, you are in debug" when "Debug As Java Application" but print nothing when "Run As Java Application" (I don't want to append any args when invoking main method). Is there any general method to implement this which can work under any IDEs, like eclipse, IntelliJ etc?</p>
java
[1]
5,920,119
5,920,120
How to create android launcher based on Google's Launcher2
<p>I'm trying to develop a custom launcher but based on the google's Launcher2, I have the source code of Launcher2 but when I import it to the eclipse I get a bunch of errors. Form what I've searching I think that I need to compile the android source and add it to the eclipse. I have compiled the source already following this <a href="http://source.android.com/source/initializing.html" rel="nofollow">link</a> and then <a href="http://pickerwengs.blogspot.pt/2011/02/android-how-to-develop-android-launcher.html" rel="nofollow">this</a>, but I get nowhere. What do I have to do to make this work?</p>
android
[4]
3,716,085
3,716,086
To restore queue members
<p>Hi guys i have such loop:</p> <pre><code>for (int i = 0; i &lt; 5; i++) { lock (locker) { if (passwords.Count == 0) { proxy_loop = false; break; } else { password = passwords.Dequeu(); j++; } } } </code></pre> <p>When the loop ends I have to restore the content (that was on the beginning) of passwords Queue</p>
c#
[0]
2,414,532
2,414,533
Working with JavaScript prototypes and accessing base class fields.
<p>I am new to pseudo classes and prototypes in JavaScript and I am having a bit of difficulty implementing it properly. What I am trying to do is have a base 'class' with some fields then create a prototype of that base class with my methods defined as object literals. I am torn between doing it this way and just using singletons inside my base class for my methods. I think though that doing it this way is a little more elegant and I think I am actually not creating every method every time I create a new object. </p> <p>Anyways, the small issue I am having is referencing the fields of my base class in my methods. Because when I try to reference them as this.field this is referring to the current function/ scope but I want it to reference the newly create object. Is there a work around for this or should I change the way I am creating my methods. </p> <p>Below is some code that I think will make it more clear what I am doing and the problem I am having.</p> <pre><code>function BaseClass() { this.items[]; this.fieldOne = "asdasd"; } BaseClass.prototype = { methodOne: function (input) { function addElement(a. b) { var element = {}; element.prop1 = a; element.prop2 = b; //The issue I am having is that items is undefined, how can I refernce the parent class object. this.items.push(element); } function traverse() { //go through a list and add a bunch of elements addElement("ASdasd", 324); } }, methodTwo: function () { //see now fieldOne is asdasd console.log("fieldOne" + fieldOne); } } var forTest = new BaseClass(); forTest.methodTwo(); </code></pre> <p>So yeah I want to have some fields in the parent class that I can access from any method, but I would rather not just put the functions in my base class so that I do not create every method everytime I create a new object from BaseClass. Is there a work around or a better way to implement this? </p> <p>Thanks in advance for the help. </p>
javascript
[3]
1,888,220
1,888,221
Is it possible to prevent launching other applications?
<p>I am doing building an application for an app-store market. They gave me following scenario. but I'm not sure it is possible. please give me your advice and suggestions. </p> <p>This is the scenario: -User upload his application into this market. -We wrap that application with our application (I'll explain later). -Then we will put it in store</p> <p>More explanation: This wrapper should bring the ability of buying (daily, monthly and etc.) to the user. If the user had some amount of money in his account then our application should let the user download and launch the game (for example). If user download a game from market and installed it in his device, each time this game is launched we should check his account to see if it has sufficient money. if he didn't have we should prevent launching the application.</p> <p>I think it is not possible. If a game is installed in a device therefore it is installed. we can't lunch our application when user lunch other games. Am I right? Is there any way to lunch our application any time user clicks other games or applications? </p>
android
[4]
2,404,732
2,404,733
Changing server in SIPDROID
<p>I got the source code of sipdroid following the link <a href="http://code.google.com/p/sipdroid/source/checkout" rel="nofollow">http://code.google.com/p/sipdroid/source/checkout</a> using the command :: svn checkout <a href="http://sipdroid.googlecode.com/svn/trunk/" rel="nofollow">http://sipdroid.googlecode.com/svn/trunk/</a> sipdroid-read-only</p> <p>Sipdroid uses pbxes.org to tunnel voip calls. But I want to configure this and use different sipserver to make voip calls.</p> <p>As a new comer in this field I need help and suggestion about how to change this server.</p>
android
[4]
930,208
930,209
convert string to html (hyperlink)
<p>i defined ToHtml() extension for string class and convert break to <code>&lt;br/&gt;</code>. how can detect hyper link and convert to <code>&lt;a&gt;</code> element?</p> <pre><code>public static class StringExtension { public static string ToHtml(this string item) { //\r\n windows //\n unix //\r mac os return item.Replace("\r\n", "&lt;br/&gt;").Replace("\n", "&lt;br/&gt;").Replace("\r", "&lt;br/&gt;"); } } </code></pre> <p>c#, asp.net</p>
c#
[0]
2,588,048
2,588,049
Disable activity from another activity?
<p>I am using the following code to remove my app from the launcher:</p> <pre><code>if (!dialercode.getText().toString().equals("")) { getPackageManager().setComponentEnabledSetting( getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } </code></pre> <p>However, that also stops that activity being launched through other means (secret code).</p> <p>So, I have setup a separate Launcher activity that will be disabled instead (all the Launcher activity does is launch the main activity).</p> <p>However, I don't know how to go about disabling the Launcher.java activity via the main activity - IE how do I get the component name for the Launcher activity when I'm in a different activity?</p>
android
[4]
4,299,862
4,299,863
Terminate object creation in constructor
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4989807/how-to-handle-failure-in-constructor-in-c">How to handle failure in constructor in C++?</a> </p> </blockquote> <p>Is there any pattern in C++ so i could terminate object creation in constructor if something fails? And so client that invoke constructor got information about failed obj creation?</p>
c++
[6]
4,825,924
4,825,925
Python: printing a file to stdout
<p>I've searched and I can only find questions about the other way around: writing stdout to a file :)</p> <p>Is there a quick and easy way to dump the contents of a file to stdout?</p>
python
[7]
865,360
865,361
Validation of view state MAC failed
<p>Please don't mark this post as <a href="http://stackoverflow.com/questions/5647525/validation-of-viewstate-mac-failed">duplicated.</a>. Please help me to fix my issue since I am very new to <strong>asp.net</strong> I have some difficulties with understanding. </p> <p>I am working on <strong>VS 2010</strong> and try to familiarize with <strong>asp.net web site.</strong> I have two web pages called <strong>Default.aspx and Result.aspx.</strong> </p> <p><strong>Default.aspx</strong> </p> <pre><code>&lt;form id="Form1" runat="server" action="Result.aspx"&gt; //Some Controllers (Dynamically added textboxes and submit button) &lt;/form&gt; </code></pre> <p>Once I fill the form and when it is submit following error comes. </p> <p><strong>Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.</strong> </p> <p>I tried to add <code>EnableViewStateMac="false"</code> but have no luck. </p> <p>Please advice me to fix this and appreciate if you could explain me why this comes. </p>
asp.net
[9]
2,316,356
2,316,357
Javascript endWith()
<p>I'm having trouble getting the following to work</p> <pre><code>if(str.endsWith('+') { alert("ends in plus sign") } </code></pre> <p>How do I escape the plus sign, I've tried /\ +/ but it doesn't work.</p> <p>Thanks in advance Ruth</p>
javascript
[3]
1,883,942
1,883,943
CSV find max in column and append new data
<p>I asked a question about two hours ago regarding the reading and writing of data from a website. I've spent the last two hours since then trying to find a way to read the maximum date value from column 'A' of the output, comparing that value to the refreshed website data, and appending any new data to the csv file without overriding the old ones or creating duplicates.</p> <p>The code that is currently 100% working is this:</p> <pre><code>import requests symbol = "mtgoxUSD" url = 'http://api.bitcoincharts.com/v1/trades.csv?symbol={}'.format(symbol) data = requests.get(url) with open("trades_{}.csv".format(symbol), "r+") as f: f.write(data.text) </code></pre> <p>I've tried various ways of finding the maximum value of column 'A'. I've tried a bunch of different ways of using "Dict" and other methods of sorting/finding max, and even using pandas and numpy libs. None of which seem to work. Could someone point me in the direction of a decent way to find the maximum of a column from the .csv file? Thanks!</p>
python
[7]
5,519,902
5,519,903
Tree Implementation in Python
<p>I found two similar questions(infact same question) for implementing tree in python. Can anyone point me to good references to implement trees. The link given in previous answers is not working.Thanks!</p>
python
[7]
1,377,579
1,377,580
Javascript: serve text as a file
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7717851/save-file-javascript-with-file-name">Save file Javascript with file name</a> </p> </blockquote> <p>In javascript I have some data in a variable that I would like to give to the user as a file. How could I go about doing this?</p> <p><strong>Duplicate</strong> of <a href="http://stackoverflow.com/questions/7717851/save-file-javascript-with-file-name">Save file Javascript with file name</a>, sorry.</p>
javascript
[3]
1,561,568
1,561,569
jQuery - Pausing and resuming a looping animation too quickly causes the queue to go haywire
<p>I have the following code that animates forever, pauses at the end of the current animation on mouse enter, and resumes on mouse leave. It works how I want it to except for one issue.</p> <p>If I hover in and out of the element too quickly (e.g. by cutting across the corner) it causes some kind of queue build up and everything goes haywire. However when I actually check the queue there's nothing strange in it and the animations are obviously not even running in the queued order.</p> <p>Using the following code waggle your mouse in and out of the grey area. When you eventually allow the animations to resume they will go haywire (also available at <a href="http://jsfiddle.net/54YTx/" rel="nofollow">http://jsfiddle.net/54YTx/</a>).</p> <pre><code>$('body').html('&lt;div style="background: lightgrey;"&gt;Testing&lt;/div&gt;'); function do_animations() { // Always 0 or 1 console.log($('div').queue('fx').length); $('div') .delay(1000) // Hardcoded numbers mean that resuming from the bottom position takes longer but it doesn't matter in this simple example .animate({'padding-top': '100px'}, 1000) .animate({'padding-top': '0px'}, 1000) // Queue instead of callback so that clearQueue() can stop the loop reliably .queue(function() { do_animations(); $('div').dequeue(); }); }; do_animations(); $('div').hover(function() { // Don't use stop(). We want the current animation to finish $('div').clearQueue(); }, function() { do_animations(); });​ </code></pre>
jquery
[5]
5,830,136
5,830,137
Can I use jQuery to show when my Ajax query is in progress?
<p>I am using the following javascript to detect when a field is changed:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { $("select[id^='Status_'], input[id^='Position_']").change(function (e) { var type = $(this).attr('id').split('_')[0]; updateField('Account', $(this), type); }); }); &lt;/script&gt; </code></pre> <p>This then calls the following to updata data in the database:</p> <pre><code>function updateField(entity, obj, type) { var val = obj.val(); var idArr = obj.attr("id"); var idTmp = idArr.split("_"); var id = idTmp[1]; var pk = $('#Meta_PartitionKey').val(); var rk = $("div[id='rk_" + id + "']").html(); $.ajax({ cache: false, url: "/Administration/" + entity + "s/Update", data: { pk: pk, rk: rk, fld: type, val: val } }); }; </code></pre> <p>Is there some way that I could provide a visual clue to the user that the update is taking place. Something like changing the cursor and then changing it back.</p> <p>Also how can I give a message to show if the update failed to my users?</p>
jquery
[5]
3,956,115
3,956,116
How can i import html with php?
<p>This is a really simple one but it's driving me crazy.</p> <p>I want to import regular HTML code with the help of PHP.</p> <pre><code>&lt;?php get_thefile ?&gt; </code></pre> <p>Is that correct? And what shall the <code>thefile.php</code> contain to get it right except my HTML content that I want to import of course!</p> <p>More information</p> <p>In a category part of a website i want to put a sidebar that will show some information, this can be anything from html to flash. This content will change time to time so insteed of editing 100 pages i want to just edit this file, My php skill is 0,1% and i can't relly find what i shall exactly do, So what i need is </p> <p>1: The code to place in the page</p> <p>2: What i shall put in the file before ? and after ? my content that i want to import </p> <p>The file will be in the same folder on server as the main page, the page is php and it's wordpress </p>
php
[2]
1,056,782
1,056,783
Why is a WeakReference useless in a destructor?
<p>Consider the following code:</p> <pre><code>class Program { static void Main(string[] args) { A a = new A(); CreateB(a); GC.Collect(); GC.WaitForPendingFinalizers(); Console.WriteLine("And here's:" + a); GC.KeepAlive(a); } private static void CreateB(A a) { B b = new B(a); } } class A { } class B { private WeakReference a; public B(A a) { this.a = new WeakReference(a); } ~B() { Console.WriteLine("a.IsAlive: " + a.IsAlive); Console.WriteLine("a.Target: " + a.Target); } } </code></pre> <p>With the following output:</p> <pre><code>a.IsAlive: False a.Target: And here's:ConsoleApp.A </code></pre> <p>Why is it false and null? A hasn't been collected yet.</p> <p><strong>EDIT</strong>: Oh ye of little faith.</p> <p>I added the following lines:</p> <pre><code>Console.WriteLine("And here's:" + a); GC.KeepAlive(a); </code></pre> <p>See the updated output.</p>
c#
[0]
931,979
931,980
Check if element support the property using jquery
<p>Jquery newbie here.</p> <p>In a wrapped element set, is there a way to check if the element supports this property?</p> <p>I basically have this pseudocode.</p> <pre><code>$(function () { $("form").each(function(){ if("this element supports disabled"){ $(this).attr("disabled", "disabled"); } }); }); </code></pre> <p>I was thinking that if the element does not support this property then it should be skipped.</p> <p>In my example above, I was checking if the element supports the disabled attribute.</p> <p>Thanks</p>
jquery
[5]
1,788,590
1,788,591
How to apply live() like feature for JavaScript appended DOM elements
<p>How to apply <code>live()</code> like feature for JavaScript appended DOM elements?</p> <p>Like a <code>li</code> list inside <code>ul</code> which is added through JavaScript. I need to do this in plain JavaScript.</p>
javascript
[3]
2,894,404
2,894,405
finding control in grid view?
<p>in my application i am trying to get the checkbox which is in the gridview i use the foreach control but it is shoing null this is my code./..</p> <p>source</p> <p> '> ' Visible ="false" > '> ' TextMode="multiLine" > '> ' TextMode="multiLine" > <br> '> ' /> <br> </p> <p>public void getPlaylist()//i write the finding control in a method { MyplalistBL clsMyplalstBl=new MyplalistBL (); clsMyplalstBl.Userid = Session["userid"].ToString(); DataSet ds = clsMyplalstBl.getPlaylistBl(); if (ds.Tables[0].Rows.Count > 0) {</p> <pre><code> grdplaylist .DataSource =ds.Tables [0]; grdplaylist.DataBind(); foreach (GridViewRow gr in grdplaylist.Rows) { CheckBox ch = (CheckBox)gr.FindControl("chksett"); string s = ds.Tables[0].Rows[0]["settings"].ToString(); if (s == "P") { ch.Checked = true; } else if (s == "PV") { ch.Checked = false; } } } else { grdplaylist.DataSource = null; grdplaylist.DataBind(); } } </code></pre>
asp.net
[9]
2,999,545
2,999,546
Allowing connections given the number of threads in server
<p>Every connection requires one thread for each, and for now, we're allowing only certain number of connections per period. So every time a user connects, we increment the counter if we're within certain period from the last time we set the check time. </p> <pre><code>1.get current_time = time(0) 2.if current_time is OUTSIDE certain period from check_time, set counter = 0, and check_time = current_time. 3.(otherwise, just leave it the way it is) 4.if counter &lt; LIMIT, counter++ and return TRUE 5.Otherwise return FALSE </code></pre> <p>But this is independent of actually how many threads we have running in the server, so I'm thinking of a way to allow connections depending on this number.</p> <p>The problem is that we're actually using a third-party api for this, and we don't know exactly how long the connection will last. First I thought of creating a child thread and run ps on it to pass the result to the parent thread, but it seems like it's going to take more time since I'll have to parse the output result to get the total number of threads, etc. I'm actually not sure if I'm making any sense.. I'm using c++ by the way. Do you guys have any suggestions as to how I could implement the new checking method? It'll be very much appreciated. </p>
c++
[6]
1,913,665
1,913,666
Is there any wordpress plugin to upload images and captions to multiple pages once
<p>Hi I have a couple of pages that need the same images and captions, is there a wordpress plugin that would allow this on 1 upload?</p>
php
[2]
1,299,006
1,299,007
JQuery - Use hover() and on()
<p>i try to use jquery's on()-Method in combination with hover(). I want that the user hovers over a div, gets a value displayed and when moving his mouse away from that div see the old value again, but this is not working... Does anybody have a clue?</p> <pre><code>$('#content').on('hover', '.player_marktwert_box', function() { var playerValue = $(this).html(); $(this).html("test"); }, function () { $(this).html(playerValue); } ); </code></pre> <p>Thanks!</p>
jquery
[5]
2,618,699
2,618,700
How do I provide a download for existing Excel with PHP?
<p>I have a generated xls file on my server that I would like to push to the client for download but can't seem to get it working. Here is what I have so far:</p> <pre><code>$xlsFile = 'test.xls'; header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download");; header("Content-Disposition: attachment;filename=$xlsFile"); header("Content-Transfer-Encoding: binary "); exit(); </code></pre> <p>My excel file is correct and can be opened if I open it from the server but how can I push this file to the client for download?</p>
php
[2]
1,461,840
1,461,841
c# backspace simulator - deletes entire word instead of just a letter?
<p>I am writing a simple C# program in which when I press "ctrl+g" I want my program to automatically delete the character directly left of the cursor in any program (ex: chrome browser, word document, powerpoint document, etc...). I have installed a global hook for "ctrl+g" and it works fine. I am using a keyboard simulator that I found from codeproject: <a href="http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library" rel="nofollow">http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library</a> My issue is that when I simulate a backspace like so:</p> <pre><code>KeyboardSimulator.KeyPress(Keys.Back); </code></pre> <p>the entire word is deleted instead of just the character to the left of the cursor. For example, if I am in a Microsoft Word document with the following line of text: "Happy new year" if my cursor is at the end of "year" and I press ctrl+g, my program deletes "year" and puts the cursor just to the right of "new" instead of just deleting the letter "r" of "year". I have tried other simulators as well with the same result. Does anyone have a solution or know what I am doing incorrectly? Thanks.</p>
c#
[0]
2,216,920
2,216,921
JavaScript: Why do document.write failed with 'no privilige'?
<pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; #navigator a { display: none; } &lt;/style&gt; &lt;script type="text/javascript"&gt; function view() { var a = document.getElementsByTagName("a"); for (var i = 0; i &lt; a.length; i++) alert(a[i].innerHTML); for (var i = 0; i &lt; a.length; i++) document.write(a[i].innerHTML); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="navigator" class="navigator"&gt; &lt;div class="menu"&gt; Programming Language &lt;a href=""&gt;C&lt;/a&gt; &lt;a href=""&gt;C++&lt;/a&gt; &lt;a href=""&gt;Java&lt;/a&gt; &lt;button type="button" onclick="view()"&gt;View&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><code>alert</code> worked fine. <code>document.write</code> succeed with the first element 'C' but failed with the next two element.</p> <p>Why did document.write fail with 'no privilige'?</p> <p>Thanks.</p>
javascript
[3]
4,602,799
4,602,800
static local variable and static local object initialization
<p>In VC++2008 there is a serious difference in initialization of static local variable and static local object. Static local variable is initialized before main() and its definition statement within the function is skipped. Static local object is initialized by 0 value before main() and its definition statement within the function is executed only once . Constructor is started and object is initialized by appropiate value. All that can be seen in Debug mode. Does this solution correspond to the existing C++ Standard?</p>
c++
[6]
2,568,112
2,568,113
String formatting problem Java
<p>im trying to format this string into a fixed column style but cant get it to work, heres my code, whats up?</p> <pre><code>System.out.format("%32s%10n%32s%10n%32s%10n", "Voter: " + e.voteNo + "Candidate: " + vote + "Booth: " + boothId); </code></pre> <p>All variables are integers,</p> <p>I want the output to be like </p> <pre> Voter: 1 Candidate: 0 Booth: 1 </pre> <p>Thanks</p>
java
[1]
5,269,344
5,269,345
C++ basic constructors/vectors problem (1 constructor, 2 destructors)
<p>Question is probably pretty basic, but can't find out what's wrong (and it leads to huge of memleaks in my app):</p> <pre><code>class MyClass { public: MyClass() { cout &lt;&lt; "constructor();\n"; }; MyClass operator= (const MyClass&amp; b){ cout &lt;&lt; "operator=;\n"; return MyClass(); }; ~MyClass() { cout &lt;&lt; "destructor();\n"; }; }; main() { cout &lt;&lt; "1\n"; vector&lt;MyClass&gt; a; cout &lt;&lt; "2\n"; MyClass b; cout &lt;&lt; "3\n"; a.push_back(b); cout &lt;&lt; "4\n"; } </code></pre> <p>The output is:</p> <pre><code>1 2 constructor(); 3 4 destructor(); destructor(); </code></pre> <ol> <li>Why are there 2 destructors? </li> <li>If it's because a copy is created to be inserted into vector - how come "operator=" is never called?</li> </ol>
c++
[6]
2,845,111
2,845,112
What are the differences between a subtype and subclass?
<p>What are the differences between a subtype and subclass, and how can I tell whether a class is a subtype/subclass of another class?</p>
c++
[6]
5,419,325
5,419,326
javascript does return stop a loop
<p>Suppose I have a loop like this:</p> <pre><code>for (var i = 0; i &lt; SomeArrayOfObject.length; i++) { if (SomeArray[i].SomeValue === SomeCondition) { var SomeVar = SomeArray[i].SomeProperty; return SomeVar; } } </code></pre> <p>Quick question: does the <code>return</code> stop the execution of the loop in and of itself?</p>
javascript
[3]
3,673,965
3,673,966
Sending notification to Android Application using PHP
<p>I am making an android application that can be remotely managed by PHP.</p> <p>I mean like, for example, I want to send a notification to the android app. My android app will then fetch it and process it.</p> <p>I have an idea, my PHP program will just save this notification to "pending notifications table" then my android app will fetch it. But my android app will always fetch like for example every 5 seconds, get pending notifications, and even if no pending notifications, it will just fetch and fetch every 5 seconds which I think not a better solution for this.</p> <p>What I want to do is, when I send a notification to the android app using PHP, it will automatically be processed.</p> <p>Any better solution to this?</p> <p>Thank you. </p> <p>PS. What I mean with notifications are not push notifications. It's like a command that I will send to the android app.</p>
android
[4]
4,420,179
4,420,180
Radio button text issue in ASP.NET
<pre><code>&lt;asp:RadioButton ID="RadioButton3" runat="server" Text="Test" /&gt; </code></pre> <p>Getting radio button text in the next line (below the radio button) and facing table alignment issues in default.aspx, but the same code works fine with other web form pages. </p> <p>How to fix this?</p>
asp.net
[9]
181,774
181,775
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]
4,798,834
4,798,835
Display html formatting in listview android
<p>I've got a list view in which i have to dispaly some text from html with proper formatting. Though i pass the html as string to <strong>Html.fromHtml</strong> method but my formatting as <strong>align="justify"</strong> don't work.</p> <p>here is the code snippet:</p> <pre><code>String text = "&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;div align="justify"&gt;as part of its growth plan, the ranchi-based central coalfields ltd (ccl) is gearing up to double the company's production in the next couple of years and also to increase the capacity of coal washeries.&lt;/div&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;"; </code></pre> <p>i pass this this string to </p> <pre><code>Spanned nText = Html.fromHtml(text); </code></pre> <p>and then i display it on the screen</p> <p>When String nText displays on the emulator screen the formatting that should be there, i.e. the text should be displayed as justified, is gone.</p> <p>Please help</p>
android
[4]
1,452,786
1,452,787
Image processing for video game on Android
<p>I have the following question, recently I started with the study of Android and for some reason my research approach to development with GLES (OpenGL ES) thinking it was the only way of making application that is out of control that comes with the sdk standard they are made for it to be controlled.</p> <p>Now I have been looking at the examples that comes with the SDK (Jetboy, LunarLander, etc) and I realize that use the method specifications drawBitMap canvas to display the images on the canvas.</p> <p>I believe striking but still does not give the performance I expected (do not know if it's because I'm working in emulator) but not fluid.</p> <p>know a form / technique / framework / library for this kind of development</p>
android
[4]
5,924,832
5,924,833
Separate variable from string
<p>I've got 2 vars - $j and $r</p> <p>In string "$jx$r" php sees $jx as variable, but "x" is a string.</p>
php
[2]
2,344
2,345
Capitalizing the first character of a string - Java
<p>I've looked all over for how to capitalize the first character of a string, but nothing I've found has helped. For my method to work, I need to set a user entered string to lower case.</p> <pre><code>sourceText = enterText.getText(); char chr = sourceText.charAt(0); </code></pre> <p>so I have a boolean that's true if the first character is uppercase.</p> <pre><code>boolean upperCase = Character.isUpperCase(chr); sourceTextLower = sourceText.toLowerCase(); </code></pre> <p>Cool stuff happens here, and the final product is another string called translatedTextString and an if statement</p> <pre><code>String s2 = ""; if(upperCase == true) { int x = translatedTextString.length(); s2 = translatedTextString.substring(0,1).toUpperCase().concat(translatedTextString.substring(1, x)); } //translatedText is a label translatedText.setText(s2); </code></pre> <p>However, when I run the program, the first character of my result is still lower case. So my questions is: is this even the right way to go about doing this? If so, what am I doing wrong, and if not, how can I do it correctly?</p>
java
[1]
3,433,451
3,433,452
iphone+Webservice whihc gives shorten url in responce
<p>I want the webservice in json OR in xml which gives the shorten url in response. I have to implement the webserivce in iPhone application.. The webserivce Example If i give <strong>HTTP://WWW.GOOGLE..COM</strong> in request</p> <p>Then it give <strong>http://goo.gl/fbsS</strong> in response. Please do provide me any webserivce which do the following.</p> <p>I found this:- <a href="https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS" rel="nofollow">https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS</a></p> <p>But this is actually the reverse of what i want.In htis i have to pass the shorten url and it gives the long url in response</p> <p>Like this:-</p> <p>{ "kind": "urlshortener#url", "id": "http://goo.gl/fbsS", "longUrl": "http://www.google.com/", "status": "OK" }</p> <p>Please help me.</p>
iphone
[8]
1,036,791
1,036,792
do {...} while(false)
<p>I was looking at some code by an individual and noticed he seems to have a pattern in his functions:</p> <pre><code>&lt;return-type&gt; function(&lt;params&gt;) { &lt;initialization&gt; do { &lt;main code for function&gt; } while(false); &lt;tidy-up &amp; return&gt; } </code></pre> <p>It's not <em>bad</em>, more peculiar (the actual code is fairly neat and unsurprising). It's not something I've seen before and I wondered if anyone can think of any logic behind it - background in a different language perhaps?</p>
c++
[6]
2,517,435
2,517,436
BaseType of a Basetype
<p>this is my first question here so I hope I can articulate it well and hopefully it won't be too mind-numbingly easy.</p> <p>I have the following class <em>SubSim</em> which extends <em>Sim</em>, which is extending <em>MainSim</em>. In a completely separate class (and library as well) I need to check if an object being passed through is a type of <em>MainSim</em>. So the following is done to check;</p> <pre> Type t = GetType(sim); //in this case, sim = SubSim if (t != null) { return t.BaseType == typeof(MainSim); } </pre> <p>Obviously <em>t.BaseType</em> is going to return <em>Sim</em> since <em>Type.BaseType</em> gets the type from which the current Type directly inherits. </p> <p>Short of having to do <em>t.BaseType.BaseType</em> to get <em>MainSub</em>, is there any other way to get the proper type using .NET libraries? Or are there overrides that can be redefined to return the main class? </p> <p>Thank you in advance</p>
c#
[0]
3,405,940
3,405,941
What's the best way to have a variable be accessible from anywhere in your program?
<p>I'm making a game right now and pretty much everything has its own class. The main classes I feel that I have a problem with are my 'Level' and 'Object' class. The level class contains images to every image in the level, and the Object class contains the image for each object on the screen(an object is pretty much anything: your player, an enemy, an item, etc).</p> <p>The way I have it right now is that the Object class has an Image and when you create a new object, you load a new image into it. So lets say you have two enemies that use the same image, both instances of the object will separately load the image and I'll have two of the same images in memory. This seems like a really bad idea and later when my game gets more complicated it will slow it down a lot.</p> <p>So what I was thinking about doing is having something like a Resource Manager class that would hold all of the images, and than each object would just ask the resource manager for the image it needs. That way it would only store each image once and save some space.</p> <p>I could probably easily do this with a static variable in the Object class, but since the Level class also needs to use images it would also need access to the Resource Manager. Would it be best to send a pointer to a resource manager to each instance of an object/level(or any other class I later make that would need it) and access it that way? Or would there be a better way to do this?</p>
c++
[6]
1,644,601
1,644,602
JQuery : event.preventDefault()
<p>In which condition we use JQuery : event.preventDefault(); .... where it will be used ?</p>
jquery
[5]
5,386,057
5,386,058
How to understand the type of a request?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3124636/detect-ajax-calling-url">Detect Ajax calling URL</a> </p> </blockquote> <p>is it possible to understand if a request is sent using ajax(xhr) from a server side language like php? I should know if the request is sent from a "normal page" or from an ajax call... is it possible without passing arguments(querysring) to the .php page?</p>
php
[2]
1,921,971
1,921,972
Monitor assignment PHP extension
<p>I'm trying to figure out if it is possible to make an extension that monitors every assignment that is made in PHP. </p> <p>I want to do some taint detection, I've seen the PHP taint project, but it would be nicer to have it as an extension for my project.</p> <p>Additionally, where can I find API documentation and similar for Zend/PHP extensions, I haven't been able to find anything good :/</p>
php
[2]
433,087
433,088
which is best server for developing java web applications?
<p>I'm confused. There are lot of servers(GlassFish, Tomcat, Apache,etc.,). But which one is used to implement easy for developing web application? Please suggest me. Thanks in advance.</p>
java
[1]
3,428,535
3,428,536
Storing records in batches of 12 sql
<p>Is it possible to store data in sets or batches of 12 in sql? I have a query which before inserting a new row should check if the existing records are equal or less than twelve. If they are twelve then it should create a new batch which also stores a maximum of twelve records.</p>
c#
[0]
304,049
304,050
Looping through lists with different number of elements
<blockquote> <p>I have the right result in C=[ ] but I can´t get Tx equal to: [42, 68, 86] [23, 45, 59] [40, 68, 85] [30, 56, 72] This is the loop I can´t do. I think it´s easy but I´m new in this, and I can´t find a solution, every thing I need to do depends on this type of aproach. Give me a light if you can.</p> </blockquote> <pre><code>#T(1) = [T0 * C[1]+QIN[1]] multiply each element of T by each element of C adding each element of QIN #T(2) = [T1 * C[2]+QIN[2]] multiply each element of T1 by each element of C2 adding each element of QIN2 #T(3) = [T2 * C[3]+QIN[3]] multiply each element of T2 by each element of C3 adding each element of QIN3 #T(4) = [T3 * C[4]+QIN[4]] multiply each element of T3 by each element of C3 adding each element of QIN4 QIN=[2.0, 3.0, 5.0, 2.0] TIN=[10.0, 12.0, 13.0, 12.0] V=[2.0, 4.0, 5.0] T0=[10.0, 11.0, 12.0] for i in range(len(QIN)): C = [] for v in V: C.append(v + QIN[i]) print C for q in QIN: Tx = [] for c in C: for t in T0: Tx.append(t * c + q) print Tx </code></pre>
python
[7]
2,253,176
2,253,177
Is ther anyway to create a non-type template parameter for a class but not declare using <>?
<p>My original code looks like this:</p> <pre><code>class a{ ... char buff[10]; } </code></pre> <p>and im attempting to make this change to the code:</p> <pre><code>template &lt;int N = 10&gt; class a{ ... char buff[N]; } </code></pre> <p>Is there any thing I can do to keep my existing code creating instances of class a like this:</p> <pre><code>a test; </code></pre> <p>instead of making the change to:</p> <pre><code>a&lt;&gt; test; </code></pre> <p>to get the default parameter?</p>
c++
[6]
5,652,494
5,652,495
retrive string from array
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/13681277/want-to-retrieve-string-from-my-array">Want To retrieve string from my array</a> </p> </blockquote> <p>My string array contains below values </p> <pre><code>NULL String 1 String 2 String 3 Null String 4 String 5 String 6 Null String 7 String 8 String 9 </code></pre> <p>I want to retrieve </p> <pre><code>String 1 String 2 String 3 String 4 String 5 String 6 String 7 String 8 String 9 </code></pre>
c#
[0]