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,773,550
2,773,551
how loop through return ajax data using jquery?
<p>My test.php file contains the following information that is sends list of information.</p> <pre><code> while($row = mysqli_fetch_array($testResults)) { echo "&lt;li&gt;" . $row['test'] . "&lt;/li&gt;"; } </code></pre> <p>Output:</p> <pre><code> &lt;li&gt; test A &lt;/li&gt; &lt;li&gt; test B &lt;/li&gt; &lt;li&gt; test C &lt;/li&gt; &lt;li&gt; test D &lt;/li&gt; &lt;li&gt; test E &lt;/li&gt; &lt;li&gt; test F &lt;/li&gt; &lt;li&gt; test G &lt;/li&gt; &lt;li&gt; test H &lt;/li&gt; </code></pre> <p>I need the ajax code to loop through each list coming the php echo command</p> <pre><code> $.post("test.php", function(data) { $.each(data, function(key, value) { alert(value); }); }); </code></pre> <p>The above code is display elements tag symbols and name and text node but I only want it to display only the textnode (test A).</p>
jquery
[5]
1,491,971
1,491,972
How to extract end of URL in Javascript?
<p>I have URLs in the form:</p> <blockquote> <p>serverName/app/image/thumbnail/2012/4/23/1335228884300/bb65efd50ade4b3591dcf7f4c693042b</p> </blockquote> <p>Where <code>serverName</code> is the domain name of the server.</p> <p>I would like to write a JS function that accepts one of these URLs and returns the very last (right-most) forward-slash-delimited string. So if the URL above was passed into the function, it would return "<code>bb65efd50ade4b3591dcf7f4c693042b</code>";.</p> <pre><code>function getImageDirectoryByFullURL(url) { // ... Not sure how to define regexp to delimit on forward slashes, // or how to start searching from end of string. } </code></pre>
javascript
[3]
3,076,876
3,076,877
Clearinterval name isn't defined after JS while loop
<p>I'm using this code:</p> <pre><code>var s_wrap = document.getElementById('slider'); var s_list = document.getElementById('slider-list'); var li_items = s_list.getElementsByTagName("li"); var next = document.getElementById('next'); var pos, item_w, refreshIntervalId; next.onclick = function() { item_w = window.getComputedStyle(li_items[0],null).getPropertyValue("width").split('px')[0]; move('left', li_items[0], 10, item_w); }; var move = function(direction, el, increment, amount) { while(pos &lt;= amount){ keep_moving = setInterval(function(){ pos = el.style[direction].split('px')[0]; if(pos == '') pos = 0; pos = parseInt(pos) + increment; el.style[direction] = pos + 'px'; }, 100); } clearInterval(keep_moving); }; </code></pre> <p>So basic gist of the code is, click a div, move a div left by 10 pixels at a time until it reaches 600px.</p> <p>Now am I going about this the wrong way?</p> <p>At the moment I get a </p> <pre><code>Uncaught ReferenceError: keep_moving is not defined </code></pre>
javascript
[3]
5,568,316
5,568,317
Welcoming Guest using SQL tables
<p>I have this code currently inside of my page.</p> <pre><code>&lt;?php if ($admin-&gt;get_permissions()==3) echo 'Welcome Administrator'; elseif ($admin-&gt;get_permissions()==1) echo 'Welcome User'; else echo 'Welcome Guest'; ?&gt; </code></pre> <p>Now if you're logged in as an admin or a standard user it works fine, but if you're visiting the site as a guest then it gives the error</p> <pre><code>Call to a member function get_permissions() on a non-object in </code></pre> <p>The error begins at the start of this script. How could I make sure that the get_permissions function works for people logged in and displays custom data for them and also displays information for a guest logged in? I've been racking my brain around this to no avail. If anybody can help it'd be much appreciated.</p>
php
[2]
4,458,766
4,458,767
PHP PDO + copy out Array
<p>I have a PDO Query that returns what appears to be an array $pds. I can loop through this array as follows:</p> <pre><code>foreach ($pds as $row) { } </code></pre> <p>I need to loop through the same array a second time but when I do this there doesn't appear to be any data in the array. Also I've tried to copy the array as follows:</p> <pre><code> $pds2 = $pds; </code></pre> <p>Is there a trick I'm missing to use this array twice?</p> <p>thx</p> <p>Code:</p> <pre><code> // Remove Duplicate Locations where words are in a different order $cityArray = $pds; foreach ($cityArray as $data) { $words = explode(' ', $data['city'] . ' ' . $data['region1'] . ' ' . $data['region2'] . ' ' . $data['region3']); sort($words); $cityWordsArray[$data['id']] = implode(' ', $words); } $cityWordsArray = array_unique($cityWordsArray); foreach ($pds as $row) { echo 'hi'; foreach($cityWordsArray as $key=&gt;$value) { if($row['id'] == $key) { </code></pre>
php
[2]
3,387,271
3,387,272
Combine an Image File with an Audio File
<p>I have a requirement in my PHP site to join an image(jpg or png) with an audio(wav) and the output should be a video (like mpeg ,mp4 or wav itself).</p> <p>Is there any tool available for this?</p>
php
[2]
2,104,163
2,104,164
Convert String to Double and put it into a Stack
<p>I have this expression, for example: <code>400 2.11 +</code> I try to push real numbers into a stack, when i do that, it shows me an error in this part of code</p> <pre><code>ch = input.charAt(j); if (ch &gt;= '0' &amp;&amp; ch &lt;= '9' || ch == '.') temp = temp + ch; else if (ch == ' ') { x = Double.parseDouble(temp); theStack.push(x); temp = ""; } else { ... public void push(double j) { stackArray[++top] = j; } </code></pre> <p>This is the message</p> <pre><code>Exception in thread "main" java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1011) at java.lang.Double.parseDouble(Double.java:540) at ParsePost.doParse(ParsePost.java:26) at InfixApp.main(InfixApp.java:21) </code></pre>
java
[1]
288,109
288,110
java unicode encoded file reading problem in jdk 1.3
<p>I am using jdk1.3 for blackberry platform. Now I am facing a problem when I trying to read an Unicode encoded xml file.</p> <p>My code :</p> <pre><code>java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(path),"UTF16")); br.readLine(); </code></pre> <p>Error:</p> <pre><code>sun.io.MalformedInputException: Missing byte-order mark at sun.io.ByteToCharUnicode.convert(ByteToCharUnicode.java:123) at java.io.InputStreamReader.convertInto(InputStreamReader.java:137) at java.io.InputStreamReader.fill(InputStreamReader.java:186) at java.io.InputStreamReader.read(InputStreamReader.java:249) at java.io.BufferedReader.fill(BufferedReader.java:139) at java.io.BufferedReader.readLine(BufferedReader.java:299) at java.io.BufferedReader.readLine(BufferedReader.java:362) </code></pre> <p>Thanks</p>
java
[1]
6,207
6,208
Disable warning/error beep when changing focus
<p>Whenever I change the focus from one textbox to another it plays an irritating warning/error beep.</p> <p>Example:</p> <pre><code>public void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) textBox2.Focus(); } </code></pre> <p>whenever I press <strong>Enter</strong> it changes the focus to textBox2 and gives the warning beep.</p> <p>Any help to disable this would be appreciated. Thank you.</p>
c#
[0]
1,773,592
1,773,593
C++: What is the default length of an int?
<p>I've been searching for a while but couldn't find a definite answer to this apparently simple question: what is the default length of an int? </p> <p>I know that by default, an int is signed. But is it short or long? </p> <p>According to the "Fundamental data types"table found in the following page, an int is a long int by default (4 bytes). <a href="http://www.cplusplus.com/doc/tutorial/variables/" rel="nofollow">http://www.cplusplus.com/doc/tutorial/variables/</a></p> <p>Is it always true, or does this depend on the OS (32bit/64bit), the compiler or other things? </p>
c++
[6]
2,745,383
2,745,384
How to replace jQuery with a different version
<p>ASP.NET 3.5</p> <p>Project uses jQuery v1.2.6 which is included in a master page and I'd like to replace it with different version only on selected pages which use this master.</p> <p>How can it be done?</p>
jquery
[5]
2,644,199
2,644,200
How to disable call function on click
<pre><code>$('form').ketchup(); </code></pre> <p>Form contains input with <code>type="submit"</code> and id, say, "bindOff". Is it possible not to call function when clicking on this input?</p>
jquery
[5]
1,586,142
1,586,143
Fancy box does not work in second time
<pre><code>$(document).ready(function () { $("#GridBusOne a[id*='l1']").fancybox( { 'type' : 'iframe', 'hideOnOverlayClick':false, 'hideOnContentClick': false, 'closeClick' : false, }); }); &lt;%--&lt;a href="Mine.aspx" class="s11" id="s1"&gt;Click&lt;/a&gt;--%&gt; </code></pre> <p>If i click the button inside(click) button in grid, it shows the fancy in first time, then when you click in second time it shows the page in new tab instead of showing in fancy box. let me know if you still need more information.</p> <p>Pl</p>
jquery
[5]
2,076,534
2,076,535
Appending to a Python list without making list of lists
<p>I start out with an empty list and prompt the user for a phrase. I want to add each character as a single element of the array, but the way I'm doing this creates a list of lists. </p> <pre><code>myList = [] for i in range(3): myPhrase = input("Enter some words: ") myList.append(list(myPhrase)) print(myList) </code></pre> <p>I get:</p> <pre><code>Enter some words: hi bob [['h', 'i', ' ', 'b', 'o', 'b']] Enter some words: ok [['h', 'i', ' ', 'b', 'o', 'b'], ['o', 'k']] Enter some words: bye [['h', 'i', ' ', 'b', 'o', 'b'], ['o', 'k'], ['b', 'y', 'e']] </code></pre> <p>but the result I want is:</p> <pre><code>['h', 'i', ' ', 'b' ... 'o', 'k', 'b', 'y', 'e'] </code></pre>
python
[7]
2,619,695
2,619,696
Can I optimize checking for multiple null values in C#
<p>I have the following code: </p> <pre><code>if (Session["CurrentUrl"] != null &amp; Session["CurrentHost"] != null) </code></pre> <p>I use this in many places. I am wondering if anyone can think of a way to optimize the C# code just to make things slight more clear.</p>
c#
[0]
6,018,886
6,018,887
How to change the background color on hover using jQuery
<pre><code>&lt;div&gt; &lt;div id="nav"&gt; &lt;ul&gt; &lt;li&gt;&lt;a class="active" href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#nav li a").hover( function () { $(this).parent('ul').parent('li').find('a.active').css('background-color', 'Red'); } ); }); &lt;/script&gt; &lt;/div&gt; </code></pre> <p>I am simply trying to change the background-colour of the menu item with a class name 'active' when the user hovers over any other item.</p>
jquery
[5]
3,639,894
3,639,895
Java Script: Using Same Instance in two diffrent .js
<p>How can I use same instance of one particula .js across all .js functions</p> <p>For eg: var test = new Test();</p> <p>this test i need to use when ever I want to access Test() function(i.e same instance)</p>
javascript
[3]
1,333,715
1,333,716
How can I change an option menu's sub-item selection color programmatically?
<p>I know how to change the selection color of android option menu but how can I change the selection color of an option menu's sub-item?</p>
android
[4]
4,972,957
4,972,958
Why java.sql.Time.toString() adds hours?
<p>Follow the simple a example</p> <pre><code>java.sql.Time t = new Time(1000); System.out.println("Time t =" + t); </code></pre> <p>This gives the following output:</p> <pre><code>Time t = 01:00:01 </code></pre> <p>While I would expect:</p> <pre><code>Time t = 00:00:01 </code></pre> <p>Could someone tell me how to get rid of the hours portion?</p>
java
[1]
899,238
899,239
What do I need for a Windows C# quickstart?
<p>What bits and pieces do I need to be able to compile and run a simple Windows console application written in C#? Does the version of Windows matter?</p>
c#
[0]
2,474,053
2,474,054
Function within a function in python
<p>I recently came across this idea of defining a function within a function in Python. I have this code and it gives error: </p> <hr> <pre><code>def f1(a): def f2(x): return a+x return 2*a </code></pre> <hr> <p>Error: On calling <code>f2(5)</code></p> <pre><code>Traceback (most recent call last): File "&lt;pyshell#19&gt;", line 1, in &lt;module&gt; f2(5) NameError: name 'f2' is not defined </code></pre> <hr> <p>I have some difficulty understanding the way global variables are used across functions or even in recursive calls. I would really appreciate if someone would point out my mistake and may be help me along the way. Thanks in advance !!</p>
python
[7]
5,223,675
5,223,676
Javascript <script> tag error
<p>I faced a strange issue today at my work place. In a JSP, i had multiple script tags like below, one of which has a empty space in src of the script tag. This JSP is loaded successfully firefox, after i input the values and click submit, the JSP is submitted twice, once with post request and other with get request. The issue is why the form is submitted twice? If anybody had faced this issue. Please respond.</p> <p>We some how resolved this issue by placing a dummy js file in the script tag, but want to understand the real problem behind it.</p> <pre><code>&lt;script src="file.js" type="text/javascript"/&gt; &lt;script src="file1.js" type="text/javascript"/&gt; &lt;script src="file2.js" type="text/javascript"/&gt; &lt;script src="file3.js" type="text/javascript"/&gt; &lt;script src=" " type="text/javascript"/&gt; &lt;script src="file4.js" type="text/javascript"/&gt; </code></pre>
javascript
[3]
4,186,225
4,186,226
setContentView not working
<p>i have file name TabGroupActivity.java which contains the below function as </p> <pre><code> public void startChildActivity(String Id, Intent intent) { try{ Window window = getLocalActivityManager().startActivity(Id,intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); if (window != null) { System.out.println("Start Account page....."); Global.mIdList.add(Id); setContentView(window.getDecorView()); } } catch(Exception ex){ System.out.println("Start Account page....."+ex.getMessage()); } } </code></pre> <p>This is called from various files, when this is called as below it works. </p> <pre><code> file name e.java Global.eInsObject = this; Global.eIns = new Intent(this,myAccount.class); startChildActivity("myAccount",Global.eIns); </code></pre> <p>This works perfectly fine but when i call the below was it doesnt give any error but also doesnt show new view or anything,. </p> <p>file name :- Home.java</p> <pre><code>System.out.println("Global.eInsObject is" +Global.eInsObject); System.out.println("Global.eIns is" +Global.eIns); TabGroupActivity parentActivityE = (TabGroupActivity) Global.eInsObject; //System.out.println("parentActivityE is "+parentActivityE); parentActivityE.startChildActivity("myAccount", Global.eIns); </code></pre>
android
[4]
1,920,002
1,920,003
Use ASP.NET when creating Windows 8 App
<p>Hi i just wonder if I could use ASP.NET to create a Windows 8 App or is ASP.NET only for homepages?</p>
asp.net
[9]
2,034,164
2,034,165
Script that recognizes first sentence, put it inside a heading and the rest inside a paragraph
<p>Hey there, I have this code, i take a wordpress post content, put it inside a variable and than match the first sentence, put it inside a h2 heading and the rest inside a paragraph.</p> <p>1.The problem is this... my script recognizes only . or ! or ? at the end of the first sentance. <strong>Can i make it recognize "..." suspension points?</strong></p> <p>2.If in my wordpress post i have a text like this:</p> <p>The first sentance! followed by some text</p> <p><strong>than i hit enter</strong></p> <p>continue with more text</p> <p>My script shows only "The first sentance! followed by some text" and nothing after the enter that i hit. Why? and ideeas? </p> <p>Here is the code:</p> <pre><code>ob_start(); the_content(); $old_content = ob_get_clean(); // I put wordpress inside a variable $content = strip_tags($old_content); // I use strip tags preg_match('/(.*?[?.!])(.*)/', $content, $match); $first_sentence = $match[1]; $the_rest = $match[2]; if ( $first_sentence != '' &amp;&amp; $the_rest != '' ): echo '&lt;h2&gt;'.$first_sentence.'&lt;/h2&gt;'; echo '&lt;p&gt;'.$the_rest.'&lt;/p&gt;'; else: echo '&lt;h2&gt;About me:&lt;/h2&gt;'; endif; </code></pre>
php
[2]
2,750,480
2,750,481
How to check if current thread is not main thread
<p>I need to check if the thread running a certain piece of code is running on the main (UI) thread or not. How can I achieve this?</p>
android
[4]
6,022,667
6,022,668
php method for key retrieval
<p>Is there any equivalent <strong>php method</strong> to 'urllib.urlopen()' for retrieving the public key from any public key server</p>
php
[2]
5,431,258
5,431,259
Service or Bound Service?
<p>Simple question.</p> <p>I'm creating an application that connects to an XMPP server on Android. I want to keep the connection on till the user logs out.</p> <p>Should I use a regular Service or a Bound Service to keep the connection on?</p> <p>Any tips, advice and helpful information are welcomed.</p> <p>Thank you in advance.</p>
android
[4]
1,129,966
1,129,967
How can write pseudo-code on java to solve this?
<p>Suppose Alice has picked three distinct integers and placed them into a stack S in random order. Write a short, straightline piece of pseudo-code (with no loops or recursion) that uses only one comparison and only one variable x, yet guarantees with probability 2/3 that at the end of this code the variable x will store the largest of Alice's three integers. Argue why your method is correct.</p> <p>Data Structure on Java</p>
java
[1]
2,269,014
2,269,015
How to print a board in python?
<p>I was trying to program the game called triple triad on Python, but I have a problem with the output of the board, it has to be like this every square, where each number represents a cardinal point,there are 9 squares, three for every line.</p> <pre><code>| 1 | 1 | 9 | |2@3|1*6|7*2| | 4 | 1 | 2 | </code></pre> <p>I thought doing a list for every line and start the board with numbers for every cardinal point, for example, "0" if it is north or something like that, so when I have to replace with the numbers of the card, I know exactly where to put every cardinal point, Any suggestions?</p> <p>Thanks in advance</p>
python
[7]
2,802,693
2,802,694
order by timestamp without a database?
<p>I have to store some info (timestamp of post, title and link) from various feeds (facebook,twitter,rss and some custom xml) without using a database. So I'm writing what I need to xml files and then pulling everything in using simplexml. This works fine. However, I need output the info from the various feeds in to a un-ordered list that's ordered by the timestamp. I don't know how to do this. I can get the info from each feed aggregated in to one array but how do I order by the timestamp before I output it in to html?</p>
php
[2]
3,321,161
3,321,162
Documentation about a jQuery function return
<p>I've been looking at the API documentation for jQuery functions and one thing I cannot find is for any arbitrary function, what exactly does the function return. For example:</p> <pre><code>$(this).appendTo($someElement); </code></pre> <p>What does the appendTo function return. I looked at the documentation and it just says it returns a jQuery object, but it doesn't say what object in particular.</p> <p>I wanna know because I want to be able to chain my statements without worrying about on what elements exactly I'm chaining on. Thanks</p>
jquery
[5]
1,060,361
1,060,362
Auto-Implemented Properties c#
<ol> <li><p>could someone explain me what's the idea behind using Auto-Implemented Properties c#?</p> <pre><code>public class Customer { public int ID { get; set; } public string Name { get; set; } } </code></pre> <p>I get the motivation to use properties for private field, so we can determine how one can access a private field. But here - it's just like defining the field to be public from the first place. no?</p></li> <li><p>Is there a difference between defining a field to be "public const" or define it to have a get-only property ?</p></li> </ol>
c#
[0]
2,506,549
2,506,550
Jquery fold effect not working for asp.net controls?
<p>In asp.net, i am trying to do fold effect on div using asp.net button control but it is not working. instead of asp.net button when i put html controls the effect working fine. can any body help me why it is not working.</p> <pre><code>&lt;script type="text/javascript" language="javascript"&gt; $(document).ready(function() { $("#hide").click(function(){ $(".target").hide( "fold", {horizFirst: true }, 2000 ); }); $("#show").click(function(){ $(".target").show( "fold", {horizFirst: true}, 2000 ); }); }); &lt;/script&gt; the code for buttons goes here &lt;asp:Button ID ="show" runat ="server" Text ="Show" /&gt; &lt;asp:Button ID ="hide" runat ="server" Text ="hide" /&gt; </code></pre> <p>html controls </p> <pre><code>&lt;input type ="button" id ="show" value ="Show" runat ="server" title ="Show" /&gt; &lt;input type ="button" id ="hide" runat ="server" title ="Hide" value ="Hide" /&gt; </code></pre>
jquery
[5]
285,282
285,283
how to get string from sms
<p>i need some help. how to get text from sms, I will receive sms like this in my device "GPS location: <a href="http://maps.google.com/maps?q=-6.97425,107.63164" rel="nofollow">http://maps.google.com/maps?q=-6.97425,107.63164</a>" and if it start with "GPS location:" then i want to retrieve the link to my application, but I have no idea how to do this.</p> <pre><code>for (SmsMessage message : msgs) { String msg = message.getMessageBody(); if (msg.startsWith("GPS location")){ //how to get the link??? } </code></pre> <p>pardon my english, and thanks for the help guys. </p>
android
[4]
4,277,522
4,277,523
Facing problem to access resource file in maven project
<p>I am unableto access <code>myXml.xml</code> file through <code>MyStaticClass.java</code> class from following project structure.<br> If I put this xml file somewhere under java folder I can access it by:</p> <pre><code>MyStaticClass.class.getResourceAsStream("[...]/myXml.xml"); </code></pre> <p>But can't access from resources folder, neither by absolute path (/myXml.xml) nor by relative path starting from app folder. Is something special with maven project or I am doing some mistake?<br> Please help me resolve this issue.</p> <pre><code>my-app `-- src -- main |-- java | `-- com | `-- mycompany | `-- app | `-- App.java | `-- MyStaticClass.java `-- resources `-- myXml.xml </code></pre>
java
[1]
4,421,169
4,421,170
android hello world program taking too much time to run
<p>I had followed android developer forum for installation and done all the steps. But finally when i try to run the application , it is just handing on "ANDROID" black screen with below message on console</p> <pre><code>[2011-10-09 23:59:27 - HelloAndroid] Android Launch! [2011-10-09 23:59:27 - HelloAndroid] adb is running normally. [2011-10-09 23:59:27 - HelloAndroid] Performing my.mobile.test.HelloAndroidActivity activity launch [2011-10-09 23:59:27 - HelloAndroid] Automatic Target Mode: launching new emulator with compatible AVD 'my_avd' [2011-10-09 23:59:27 - HelloAndroid] Launching a new emulator with Virtual Device 'my_avd' [2011-10-09 23:59:33 - HelloAndroid] New emulator found: emulator-5554 [2011-10-09 23:59:33 - HelloAndroid] Waiting for HOME ('android.process.acore') to be launched... </code></pre> <p>It already took 15-20 min and still hanging there. Am i missing anything. Please suggets </p> <p><img src="http://i.stack.imgur.com/tqBck.jpg" alt="enter image description here"></p>
android
[4]
5,856,547
5,856,548
System.NullReferenceException: Object reference not set to an instance of an object
<blockquote> <p><strong>Possible Duplicates:</strong> <a href="http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net">What is a NullReferenceException in .NET?</a> <a href="http://stackoverflow.com/questions/6213271/system-nullreferenceexception-object-reference-not-set-to-an-instance-of-an-obje">System.NullReferenceException: Object reference not set to an instance of an object</a></p> </blockquote> <p>I am using the following code.</p> <pre><code>public partial class SectionControls_SingleBanners : SectionControlBaseClass { private SingleBanners _section; protected void Page_PreRender(object sender, EventArgs e) { updateViews(); if (RssCapable(this._section.GetType()) &amp;&amp; _section.BannersEntries.Rows.Count &gt; 0) { </code></pre> <p>So here on this code I am getting the error</p> <pre><code>this._section.GetType(); </code></pre> <p>How can this problem be fixed?</p>
c#
[0]
1,644,481
1,644,482
better way to do Debug only assert code
<p>I am writing my first Android application and I am liberally using asserts() from junit.framework.Assert</p> <p>I would like to find a way to ensure that the asserts are only compiled into the debug build, not in the release build.</p> <p>I know how to query the android:debuggable attribute from the manifest so I could create a variable and accomplish this in the following fashon:</p> <p>static final boolean mDebug = ...</p> <p>if (mDebug) Assert.assertNotNull(view);</p> <p>Is there a better way to do this? i.e. I would prefer not to use an if() with each assert.</p> <p>thanks</p>
android
[4]
470,015
470,016
Online customization tshirt site
<p>I want to integrate an online customization options for tshirt where you can design your own tshirt with uploading images or using predefined templates/symbols/text etc..</p> <p><a href="http://ilogo.in/personalize.php?p=3105#land" rel="nofollow">like this</a></p> <p>Please help me with a prebuilt template/plugin/html/php source code. </p> <p>Thanks!</p>
php
[2]
2,586,747
2,586,748
particular tabbar item hide when app loads in Tab bar controller?
<p>HI, i have added the following in Appdelegate.m file to hide particular tab bar item("Hai") in tab bar controller(created by IB).but it did not work </p> <pre><code> - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if ([viewController.tabBarItem.title isEqualToString:@"Hai"]) { self.tabBarController.tabBar.hidden = YES; } } </code></pre>
iphone
[8]
3,198,695
3,198,696
Error converting a numeric month into textural representation
<p>I am using the following code in php to convert the month in numeric to textural representation. </p> <pre><code>date('M',strtotime(8)); </code></pre> <p>But for every digit I am getting 'Dec' as my month.</p> <p>How should i make it work. </p> <p>Thank you Zeeshan</p>
php
[2]
5,559,711
5,559,712
Using $_GET on other pages
<p>I have a search file - dir/search.php</p> <p>In search.php:</p> <pre><code>&lt;script type="text/javascript" src="timeout.js"&gt;&lt;/script&gt; </code></pre> <p>In timeout.js:</p> <pre><code>&lt;script src="functions.php"&gt;&lt;/script&gt; </code></pre> <p>In functions.php in one line I have:</p> <pre><code>document.write('&lt;?php if (!isset($_GET["r"])) { echo "error"; } elseif ($_GET["r"] == "top") { ?&gt;&lt;title&gt;Top Results&lt;/title&gt;&lt;?php } ?&gt;'); </code></pre> <p>I was wondering why when I looked at search.php?r=top, it would display "error"?</p>
php
[2]
3,668,389
3,668,390
Adding a button to the default incoming call screen in Android
<p>I'm in the process of developing an Android app for which I need to add a button on the incoming call screen. Is it possible to add a new button to the existing incoming call screen or should I create a custom screen specific to my app?</p> <p>Edit: I want to add a button in addition to the Answer and Decline buttons in the screen that appears when there is an incoming call. </p>
android
[4]
3,090,075
3,090,076
How to set the label of a layout programmatically?
<p>Is it possible to set a label of a class/screen/layout programmatically? I am retrieving a short string e.g. "Today is Sunday" from a webpage and I would like to set that string as the title/label of the screen.</p> <p>What I meant for label/title: The grey box at the top of the screen which can be set manually in the manifest file. </p> <p><img src="http://i.stack.imgur.com/RHHiC.jpg" alt="label"></p>
android
[4]
4,545,713
4,545,714
What's the best way to retrieve the position of an element relative to one of its ancestors?
<p>I have a td inside a table. </p> <p>What's the best way to get its position relative to the table?</p> <p>Should I be using offset, position or something else?</p>
jquery
[5]
3,817,368
3,817,369
Common "Debug" function within class library
<p>I am using several class libraries within a project, and one of them is a typical "project.common.dll" library containing some common helper functions. One of these functions is a debug function that creates debug output. Now I would like to enable/disable debug output by using a user-level property (application settings). How can I reference variables defined in main application's program.cs within this class library ? </p> <p>Update : Thanks all. I will probably create a static method in my base application that performs the check (to debug or not) and then calls the Debug function in the common library.</p>
c#
[0]
3,984,038
3,984,039
warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data -- C++
<p>I made a simple program that allows the user to pick a number of dice then guess the outcome... I posted this code before but with the wrong question so it was deleted... now I cannot have any errors or even warnings on this code but for some reason this warning keeps popping and I have no clue how to fix it... <strong>"warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data"</strong></p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;cstdlib&gt; #include &lt;time.h&gt; using namespace std; int choice, dice, random; int main(){ string decision; srand ( time(NULL) ); while(decision != "no" || decision != "No") { std::cout &lt;&lt; "how many dice would you like to use? "; std::cin &gt;&gt; dice; std::cout &lt;&lt; "guess what number was thrown: "; std::cin &gt;&gt; choice; for(int i=0; i&lt;dice;i++){ random = rand() % 6 + 1; } if( choice == random){ std::cout &lt;&lt; "Congratulations, you got it right! \n"; std::cout &lt;&lt; "Want to try again?(Yes/No) "; std::cin &gt;&gt; decision; } else{ std::cout &lt;&lt; "Sorry, the number was " &lt;&lt; random &lt;&lt; "... better luck next time \n" ; std::cout &lt;&lt; "Want to try again?(Yes/No) "; std::cin &gt;&gt; decision; } } std::cout &lt;&lt; "Press ENTER to continue..."; std::cin.ignore( std::numeric_limits&lt;std::streamsize&gt;::max(), '\n' ); return 0; } </code></pre> <p>This is what I am trying to figure out, why am I getting this warning: warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data</p>
c++
[6]
4,819,660
4,819,661
Why doesn't this jQuery add an image to my div?
<p>I am trying to use the <a href="http://api.jquery.com/add/" rel="nofollow">add function</a> to add an HTML fragment to a div but I can't get it to work. My code:</p> <pre><code>$('#curveContainer').add('&lt;img src="http://upload.wikimedia.org/wikipedia/commons/f/f0/Blue-dot-5px.png" alt="test" /&gt;'); </code></pre> <p>Fiddle here - <a href="http://jsfiddle.net/7a86g/4/" rel="nofollow">http://jsfiddle.net/7a86g/4/</a></p>
jquery
[5]
4,028,001
4,028,002
Can PHP include work for only a specified portion of a file?
<p>I have a PHP include that inserts an html form into another html form. When the form gets included I now have two form headers. Is there a php tag I could use that would allow me to...</p> <pre><code>&lt;form id="orderform"&gt; &lt;!-- &lt;?php for the include FROM here?&gt; --&gt; PROD:&lt;input class="ProductName" type="text" size="75"&gt;| Discount:&lt;input class="Discount" type="text" size="3"&gt;| QTY:&lt;input class="qty" type="text" size="6"&gt;| Line/Total:&lt;input class="LineTotal" type="text" size="9" disabled&gt; &lt;!-- &lt;?php for the include TO here?&gt; --&gt; &lt;/form&gt; </code></pre> <p>So the include would go into that file with the form in it and get the specified HTML?</p> <p>Is this possible?</p> <h2>EDIT</h2> <pre><code>&lt;?php $dom = new DOMDocument(); $html = 'phptest3.php'; $dom-&gt;loadHTMLFile($html); $div = $dom-&gt;getElementById("divtagid"); echo $div-&gt;nodeValue; ?&gt; </code></pre> <p>This only returns the text. How do I get the HTML form elements in the divtagid?</p>
php
[2]
4,527,085
4,527,086
How to wait current thread execution and execute another thread completedly
<pre><code>public class Thread1 extends Thread { public void run() { testFun1(); } public void testFun1(){ for(int i=1;i&lt;10;i++){ try { Thread.sleep(1000); System.out.println("From testFun1() = "+i); } catch (Exception e) { } } } } class Thread2 extends Thread { public void run(){ testFun2(); } public synchronized void testFun2() { try { for(int i=20;i&lt;=25;i++){ Thread.sleep(1000); System.out.println("From testFun2() = "+i); } } } </code></pre> <hr> <p>MainClass.java</p> <pre><code>public class MainClass{ public static void main(String[] args) { try{ Thread1 thread1 = new Thread1(); Thread2 thread1 = new Thread2(); thread1.start(); Thread.sleep(3000); thread1.join(); thread2.start(); }catch(Exception e){ } } } </code></pre> <hr> <p>Required output:</p> <pre><code>From testFun1() 1 From testFun1() 2 From testFun1() 3 From testFun2() 20 From testFun2() 21 From testFun2() 22 From testFun2() 23 From testFun2() 24 From testFun2() 25 From testFun1() 4 From testFun1() 5 From testFun1() 6 From testFun1() 7 From testFun1() 8 From testFun1() 9 From testFun1() 10 </code></pre> <p>But didn't get the above out put.</p>
java
[1]
5,871,650
5,871,651
Native methods in Java
<p>I have spent some time learning what are Java Native methods and that they are implemented in platform dependent code(mostly C).</p> <p>But where can I find those native implementations of Java? eg : sleep(long millis) method of Thread class is native. But where is its implementation code???</p>
java
[1]
2,877,453
2,877,454
File loop in PHP
<p>I wrote some code to create a text file just once each time I execute the php file. Its idea is to check all existing files with a specific name then create a text file with the previous name +1</p> <p>For example, if there is a file called <code>filetext0.txt</code>, my code will create a file called <code>filetext1.txt</code> and so on... Please help me to find the error in my code:</p> <pre><code>&lt;?php for ($i=0; $i=1000; $i=$i+1) { $handle = fopen("filetext".$i.".txt","r"); if ($handle) { fclose($handle); $s=$i+1 $handlex = fopen("filetext".$s.".txt","w+"); fclose($handlex); break } } ?&gt; </code></pre>
php
[2]
1,381,764
1,381,765
Removing Double space from a textbox using REGEX
<p>Input: </p> <pre><code>"I want to remove double space from textbox." </code></pre> <p>Output: </p> <pre><code>"I want to remove double space from textbox." </code></pre> <hr> <pre><code>function valid(f) { return f.replace(/^\s+|\s+$/g,'').replace(/\s+/g,' '); } </code></pre> <p>I have called this event <code>onblur="valid(this);"</code></p>
javascript
[3]
705,348
705,349
Store multi-line input into a String (Python)
<p>Input:</p> <pre class="lang-none prettyprint-override"><code>359716482 867345912 413928675 398574126 546281739 172639548 984163257 621857394 735492861 </code></pre> <p>my code :</p> <pre><code>print("Enter the array:\n") userInput = input().splitlines() print(userInput) </code></pre> <p>my problem here is that, <code>userInput</code> only takes in the first line value but it doesn't seem to take in values after the first line? </p>
python
[7]
5,715,307
5,715,308
jquery loads after images
<p>Is it possible that any js document "$(document).ready()" loads before images load?</p>
jquery
[5]
2,165,359
2,165,360
external-internal storage
<p>In android, whats the difference between external storage that is nonremovable (internal) and the internal storage? I am not sure where to save my data. I just need to save a game stats that a person can pull anytime they want</p> <p>Thank you</p>
android
[4]
3,627,363
3,627,364
Split string by delimiter ignoring delimiter inside quotes
<p>string from the file i'm importing: <code>1,2,3,"a","b","c","1,2,3,4,5",6,7</code></p> <p>desired output would be an array split by the comma but ignoring any comma that falls between double quotes.</p> <pre><code>[0] = 1; [1] = 2; [2] = 3; [4] = "a"; [5] = "b"; [6] = "c"; [7] = "1,2,3,4,5"; [8] = 6; [9] = 7; </code></pre> <p>Needs to work with PHP 5.2 and below. I know the fget_csv function allows for this in PHP 5.3 but its not an option unfortunately. </p> <p>Searched fairly extensively and so far no solutions for this that I can find. Any ideas?</p>
php
[2]
4,539,175
4,539,176
Error 101 (net::ERR_CONNECTION_RESET): Unknown error
<pre><code>&lt;?php // Connect to database // require("phpsqlajax_dbinfo.php"); $con=mysql_connect("localhost","root",""); if (!$con) { die ('cannot connect:'.mysql_error()); } mysql_select_db("tracking", $con); function parseToXML($htmlStr) { $xmlStr=str_replace('&lt;','&amp;lt;',$htmlStr); $xmlStr=str_replace('&gt;','&amp;gt;',$xmlStr); $xmlStr=str_replace('"','&amp;quot;',$xmlStr); $xmlStr=str_replace("'",'&amp;#39;',$xmlStr); $xmlStr=str_replace("&amp;",'&amp;amp;',$xmlStr); return $xmlStr; } // Select all the rows in the markers table $query = "SELECT lat, lng, DATE_FORMAT(datetime, '%W %M %D, %Y %T') AS datetime FROM markers1 WHERE 1"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); // Start XML file, echo parent node echo "&lt;markers&gt;\n"; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '&lt;marker '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'datetime="' . $row['datetime'] . '" '; echo "/&gt;\n"; } // End XML file echo '&lt;/markers&gt;'; // Free up the resources mysql_free_result ($result); // Close the database connection mysql_close(); ?&gt; </code></pre> <p>i`m using window 7 ultimate with WAMPSERVER.</p> <p>the page show me nothings , pls help me..i really out of idea on trying this for past 2 days.</p>
php
[2]
5,107,930
5,107,931
How to prevent access to object properties that do not yet exist
<p>Often I have this situation: <code> var obj = { field: 2 }; </code></p> <p>and in the code: <code> do_something( obj.fiel ); // note: field spelt wrong </code></p> <p>ie The property is incorrectly typed. I want to detect these bugs as early as possible.</p> <p>I wanted to seal the object, ie <code>obj = Object.seal(obj);</code></p> <p>But that only seems to prevent errors like <code>obj.fiel = 2;</code> and does not throw errors when the field is simply read.</p> <p>Is there any way to lock the object down so any read access to missing properties is detected and thrown?</p> <p>thanks, Paul</p> <p>EDIT: Further info about the situation</p> <ol> <li>Plain javascript, no compilers.</li> <li>Libraries used by inexperienced programmers for math calc purposes. I want to limit their errors. I can spot a misspelt variable but they can't.</li> <li>Want to detect as many errors as possible, as early as possible. ie at compile time (best), at runtime with thrown error as soon as wrong spelling encountered (ok), or when analysing results and finding incorrect calculation outputs (very very bad).</li> <li>Unit tests are not really an option as the purpose of the math is to discover new knowledge, thus the answers to the math is often not known in advance. And again, inexperienced programmers so hard to teach them unit testing.</li> </ol>
javascript
[3]
3,562,118
3,562,119
Wrong output from mktime() in PHP
<p>I am trying to set up a php where that it sets the date up for the 1st September for each year. I am using CRON to state that everytime the date is 7th September, then the php will actually update the database for rows whose dates ae a week before that 7th September, (ist September).</p> <p>Now the code below I tested for the 28th October and when I echo <code>$selectedDate</code> it outputs <code>2012-10-28</code> which is fine. But when I change the date to 1st September, it outputs <code>`2011-12-01</code> which is obviously incorrect. it should output `2013-09-01 as the next September date will be in 2013. Then after the Ist September date has passed in 2013, then the year should change to 2014 and etc.</p> <p>How can I get the correct date to be outputted?</p> <p>Below is code:</p> <pre><code>$createDate = mktime(0,0,0,09,01,date("Y")); $selectedDate = date('Y-m-d', ($createDate)); </code></pre>
php
[2]
2,935,569
2,935,570
Weird JAVA Boolean Evaluation Issue
<p>Hi I have the following code:</p> <pre><code> boolean result = someexpression(); if(!result) { System.out.println("False..."); } if (result); { System.out.println("True"); } </code></pre> <p>It prints both (False and true) I also tried using things like</p> <pre><code> if(result==true) </code></pre> <p>but that doesnt seem to do the trick. No matter what the value of the variable it just enters the condition.?? I am using eclipse and this only happens at a specific portion.</p>
java
[1]
287,026
287,027
Delegate method for UIImagePIcker notr getting called
<p>Please help me out because i have set the delegate self as well i set their protocol refrence in .h class.same code run for different class but not for this class.</p>
iphone
[8]
3,311,970
3,311,971
Converting an array with 50,000+ entries into a mysql database
<p>Ok, so I am helping someone with their site. Their original coder thought it would be a great idea to put their entire database in an array.</p> <p>I am looping through each piece of data in the array and inserting it into a new mysql table I created, the rows are getting inserted just fine but the problem is that php wont let my script execute for more than 60 seconds.</p> <p>How can I override this setting?</p>
php
[2]
2,820,932
2,820,933
Errors when modifying a dictionary in python
<p>Suppose I want to create a dictionary that maps digits to numbers less than 100 ending in those digits as follows:</p> <pre><code>d = {} for i in range(100): r = i % 10 if r in d: d[r] = d[r].append(i) else: d[r] = [i] print d </code></pre> <p>First of all, when i is 20, d[r] is apparently a NoneType when I try to append to it, throwing an error. Why would this be? Secondly, I feel like my approach is inefficient, as the work in checking if r in d isn't propagated. Something like this would be better, I feel:</p> <pre><code>case(d[r]) of SOME(L) =&gt; d[r] = L.append(i) | NONE =&gt; d[r] = [i] </code></pre> <p>Is there a way to have that logic in python?</p>
python
[7]
2,769,109
2,769,110
How to check if a program is installed on system
<p>how can I check with Java if a program is installed on system, for example to check for Mozilla Firefox?</p>
java
[1]
1,649,262
1,649,263
How to unbind a live event?
<p>I am trying to unbind the click event for my code.</p> <p>I have</p> <pre><code>$('#test').unbind('click'); //this won't work $('#test').live('click', function(e){ alert('alert') $(this).unbind(e) //this won't work }) </code></pre> <p>I am using jquery 1.63 and I need <code>.live</code> for my element.</p> <p>Any idea? Thanks a lot!</p>
jquery
[5]
5,501,424
5,501,425
How to save empty form field as null?
<p>I have a html form that sends POST data to php file. In php I'm making a query to mysql database. In database I have int column that accept null.</p> <p>The problem is when web form field is empty, I want to save null to database. I tried to make check before building the query</p> <pre><code>if (empty($licence)) $sql_query.="null,r1="; else $sql_query.="'".$_POST["licence"]."',r1="; </code></pre> <p>It's working. But if user write 0 in the form field, in database will be saved null, which is wrong. If user entered 0, I want to save 0, but if the field is empty I want to save null. How to fix this?? The problem is that if field is empty, 0 will be send as post data...</p>
php
[2]
3,442,781
3,442,782
appendTo() not working in chromium 14 linux
<p>I'm trying to append data into <code>&lt;h5&gt;</code> tag in below manner..</p> <pre><code>$('&lt;h5&gt;').text(data[key].age).appendTo('#myContainer' + i); </code></pre> <p>but in chromium 14 for linux, this type of chaining doesn't work so i'll have to use..</p> <pre><code>var x = $('&lt;h5&gt;').text(key); x.appendTo('#imageContainer' + i); </code></pre> <p>What would be the best alternative for this ?? and is there a way so that i can emulate different version of chrome(windows) </p>
jquery
[5]
5,096,413
5,096,414
Detect touch on EditText, but not interrupt it?
<p>I need to know when the user touches/taps/clicks the edittext in my activity.</p> <p>How can I do this without interrupting the events, so the keypad still displays properly?</p> <p>(And I need to know about it before the OS displays the keypad...if possible)</p>
android
[4]
2,696,428
2,696,429
Binary tree through jQuery
<p><a href="http://frank-mich.com/jQuery/" rel="nofollow">http://frank-mich.com/jQuery/</a> .this is the link where i can draw binary tree. but when I copied the source, everything is working well but the tree is not getting displayed inside the box. Please anybody who can solve this problem and give me code after removing all unnecesary code stuffs because I'm completely new to jQuery.</p>
jquery
[5]
4,604,065
4,604,066
Any better alternatives for getting the digits of a number? (C++)
<p>I know that you can get the digits of a number using modulus and division. The following is how I've done it in the past: (Psuedocode so as to make students reading this do <em>some</em> work for their homework assignment):</p> <pre><code>int pointer getDigits(int number) initialize int pointer to array of some size initialize int i to zero while number is greater than zero store result of number mod 10 in array at index i divide number by 10 and store result in number increment i return int pointer </code></pre> <p>Anyway, I was wondering if there is a better, more efficient way to accomplish this task? If not, is there <em>any</em> alternative methods for this task, avoiding the use of strings? C-style or otherwise?</p> <p>Thanks. I ask because I'm going to be wanting to do this in a personal project of mine, and I would like to do it as efficiently as possible. </p> <p>Any help and/or insight is greatly appreciated. </p>
c++
[6]
4,830,462
4,830,463
thumbs.db messing up my upload routine
<p>I'm getting the following error while uploading a zip archive.</p> <pre><code>Warning: ZipArchive::extractTo(C:\xampplite\htdocs\testsite/wp-content/themes/mytheme//styles\mytheme/Thumbs.db) [ziparchive.extractto]: failed to open stream: Permission denied in C:\xampplite\htdocs\testsite\wp-content\themes\mythem\uploader.php on line 17 </code></pre> <p>The thing I can't quite figure is that I don't see a thumbs.db file in either the zip archive or the destination folder that was created (the upload still processes, I just get these errors).</p> <p>The function is below, line 17 is commented...</p> <pre><code>function openZip($file_to_open) { global $target; $zip = new ZipArchive(); $x = $zip-&gt;open($file_to_open); if($x === true) { $zip-&gt;extractTo($target); //this is line 17 $zip-&gt;close(); unlink($file_to_open); } else { die("There was a problem. Please try again!"); } } </code></pre>
php
[2]
4,089,579
4,089,580
Application crashes on setting two onclick listener
<p>I have placed the following code in the main activity in the onCreate method </p> <pre><code>public class MyTest extends Activity implements OnClickListener{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //... some other code here to init the layout Button btn1 = (Button)findViewById(R.id.button1); Button btn2 = (Button)findViewById(R.id.button2); btn1.setOnClickListener(this); btn2.setOnClickListener(this); } </code></pre> <p>And have placed the following code outside the class MyTest</p> <pre><code>@Override public void onClick(View v) { switch(v.getId()){ case R.id.button1: break; case R.id.button2: break; } } </code></pre> <p>When running the application it crashes. Please can someone help me</p>
android
[4]
4,450,915
4,450,916
javascript function name vs function literal usage
<p>When testing for a partial evaluation function: </p> <pre><code>function partialEval(fn) { var sliceMethod = Array.prototype.slice; if(arguments.length &gt; 1) { var aps = sliceMethod.call(arguments, 1); } return function () { return fn.apply(this,aps.concat( sliceMethod.call(arguments) )); }; } var x= function add(a,b,c,d){ console.debug(a + " - " + b + " - " + c + " - " + d); return a+b+c+d; } var pa = partialEval(add, 1,2); // Query here var zz = pa(3,4); console.debug(zz); </code></pre> <p>What is the difference between calling partialEval(add,1,2) and partialEval (x,1,2)? I understand that x is a function literal here and using x gives the correct results. But when I use add as a function name sent to the partialEval method the output is coming as 3. Can someone explain the execution differences between the two?</p> <p>thanks.</p>
javascript
[3]
2,322,120
2,322,121
Python: Mapping with Index of Previous Occurrence
<p>I'm often met with an analog of the following problem, and have had trouble writing clean code to solve it. Usually, I have something involving a temporary variable and a for loop, but is there a more elegant way?</p> <p>Suppose I have a list of booleans or values which evaluate to booleans:</p> <pre><code>[True, False, True, False, False, True] </code></pre> <p>How would I map this to a list of values, with the index of the previous True, inclusive?</p> <pre><code>[0, 0, 2, 2, 2, 5] </code></pre> <p>[EDIT] Have tried something along the lines of:</p> <pre><code>def example(lst): rst, tmp = [], None for i in range(len(lst)): if lst[i]: tmp = i rst.append(tmp) return rst </code></pre> <p>Assuming the first element of the list is always True.</p>
python
[7]
3,169,621
3,169,622
Getting folder name
<p>I iterate over a bunch of folders and files in the folders, doing this:</p> <pre><code>def get_files_in_directory(directory=rootDirectory): for root, dirs, files in os.walk(directory, topdown='true'): print("root %s dirs %s files %s" %(root, dirs, files)); for file in files: ext = os.path.splitext(file)[-1].lower(); if (ext == '.mod'): print(file); </code></pre> <p>When I print the file, I would like to also print the relative name of the dir that contains it. </p> <p>So if I have</p> <pre><code>C:\\myfolderA\\myFolderB\\myFile.MOD </code></pre> <p>I just get</p> <pre><code>myFolderB </code></pre> <p>I don't want</p> <pre><code>C:\\myFolderA\\myFolderB </code></pre> <p>which of course I can get from the dir variable</p>
python
[7]
5,727,086
5,727,087
How to remove AspxAutoDetectCookieSupport
<p>Many of my url's on my site www.mysite.com/Display.aspx?ID=128</p> <p>gets displayed to users as</p> <p>www.mysite.com/Display.aspx?ID=128&amp;AspxAutoDetectCookieSupport=1</p> <p>How can I remove AspxAutoDetectCookieSupport.</p> <p>I understand it has to do something with cookie in web.config, but where? And what would be the implications if I remove that. How to remove?</p>
asp.net
[9]
341,893
341,894
Blowfish Crypt confusion
<p>Not sure why but i think i have totally not understood how this works....</p> <p>I found an example script which had this:</p> <pre><code>echo crypt('abc123', '$2a$04$saltsaltsaltsaltsaltxx'); </code></pre> <p>And it claims to give the output:</p> <pre><code>$2a$04$saltsaltsaltsaltsaltxuK2.MS4sJd6ZjnuS0fp2eenjndo.g4hS </code></pre> <p>But when i did it the same code i get:</p> <pre><code> $2pGiQ0v1IyNY </code></pre> <p>As an output... doesn't really explain anything to me so far or why i get a different output to the example i saW? </p> <p>I'm trying to get the sale + the hashed password and store them in the user table for each user but I'm not following how to:</p> <p>a) generate a random salt per user</p> <p>b) get the salt and the hash password from it to store it ?</p> <p>c) how you then check it on for example a login page</p>
php
[2]
2,375,110
2,375,111
Getter function that won't crash when object not found
<p>I have a class that contains a member variable which is a list of custom objects. I am trying to write a getter function which looks through this list trying to find one with the provided name. I would like to return said object by constant reference if found, or just output "Object with name "name" not found." otherwise, without crashing my program. Any ideas? I'm thinking I could make another function that simply returns a boolean if a matching object exists, and calling that first. If it returns true, then get the given item. However, this is inefficient, and I would like to do better.</p>
c++
[6]
5,514,570
5,514,571
How to make application completely ignore screen orientation change in Android?
<p>Is there a way to make an application completely ignore a screen orientation change?</p>
android
[4]
4,617,985
4,617,986
Strange arithmetic error with vectors
<p>I am using DirectX to draw on screen. </p> <p>I want to make the image about whilst keeping the dimensions, so I am assigning some arithmetic to the vertexes:</p> <pre><code>float boxPosFactorX = (869-3)+(100/100 * (1063 - 869)); float boxPosFactorY = (940-3)+(100/100 * (1038 - 940)); vertexes[0].Position = new Vector4((50 * boxScale) + boxPosFactorX, (50 * boxScale) + boxPosFactorY, 0, 1.0f); // other vertexes with same structure just different constants (e.g. 50 above is the constant values of that vertex. </code></pre> <p>Now here is the really weird part, the code above works as expected, but as soon as change the ratio "100/100" to anything below "99/100" or less, it behaves as if the code were:</p> <pre><code>float boxPosFactorX = (869-3) float boxPosFactorY = (940-3) </code></pre>
c#
[0]
3,949,599
3,949,600
ASP.NET Cache unique
<p>Is HttpRuntime Cache unique for each user in ASP.NET as well as the Sessions?</p>
asp.net
[9]
2,453,131
2,453,132
How to replace \" in a string with \\"?
<p>I would like to replace \" in a string with \\" using c#. I wanna escape this character. I cant find and replace \ with \\.</p>
c#
[0]
3,997,392
3,997,393
Dirty memory use in iOS
<p>My app uses about 50 MB of memory at startup when I look at dirty memory using the VM Tracker instrument. It's a pretty simple app, and from what I recall at WWDC this year, this seems like way too much memory use for an app with only one simple UIWebview at startup. </p> <p>I think I recall someone from Apple telling me to keep my memory use below 20MB as a guideline. </p> <p>Before I go off and try to track this down - what's a good target to keep performance smooth and mem warnings reasonable? </p>
iphone
[8]
3,028,988
3,028,989
How to set the background color of new activity after clicking tabs
<p>I am switching activities on tab clicks and successful at this. But, in one of my Activity class I am doing the following: <code>public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main);}</code></p> <p>main.xml has the following:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#BDBDBD" &gt; </code></pre> <p></p> <p>I want to change the background of this layout only and I want tabs to their as it is. But with the currentandroid:layout_height="fill_parent"in main.xml my background is overwriting the tabs which means I am unable to see tabs. and If I makeandroid:layout_height="wrap_content"` I cannot see any change taking and tabs are still their.</p>
android
[4]
3,374,194
3,374,195
'pow' Was Not Declared In This Scope
<pre><code>#include &lt;iostream&gt; #include &lt;string.h&gt; using namespace std; int main() { int e=0; int b=0; cout&lt;&lt;"Enter Exponent"; cin&gt;&gt;e; cout&lt;&lt;"Enter Base"; cin&gt;&gt;b; pow(e, b); cout&lt;&lt;"Power:"&lt;&lt;e; return 0; } void pow(int e, int b) { int t=1; while(b==t) { e=e*b; t++; } } </code></pre> <blockquote> <p>ulaga.cpp|29|error: 'pow' was not declared in this scope</p> </blockquote> <p>Can any one explain why this error occurred?</p>
c++
[6]
2,956,982
2,956,983
Simple JavaScript not working
<p>Can somebody tell me what I am doing wrong?</p> <pre><code>window.onload = initForm; function initForm() { var allTags = document.getElementsByTagName("*"); for(i=0; i&lt;allTags.length; i++) { if (allTags[i].className.indexOf("textbox") &gt; -1) { allTags[i].onFocus = fieldSelect; allTags[i].onBlur = fieldDeSelect; } } } function fieldSelect() { this.style.backgroundImage = "url('inputBackSelected.png')"; } function fieldDeSelect() { this.style.backgroundImage = "url('inputBack.png')"; } </code></pre> <p>I am a beginner at JavaScript so I am not used to debugging code yet.</p> <p>Thanks</p> <p>Luke</p>
javascript
[3]
3,984,163
3,984,164
PHP DOMDocument stripping HTML tags
<p>I'm working on a small templating engine, and I'm using DOMDocument to parse the pages. My test page so far looks like this:</p> <pre><code>&lt;block name="content"&gt; &lt;?php echo 'this is some rendered PHP! &lt;br /&gt;' ?&gt; &lt;p&gt;Main column of &lt;span&gt;content&lt;/span&gt;&lt;/p&gt; &lt;/block&gt; </code></pre> <p>And part of my class looks like this:</p> <pre><code>private function parse($tag, $attr = 'name') { $strict = 0; /*** the array to return ***/ $out = array(); if($this-&gt;totalBlocks() &gt; 0) { /*** a new dom object ***/ $dom = new domDocument; /*** discard white space ***/ $dom-&gt;preserveWhiteSpace = false; /*** load the html into the object ***/ if($strict==1) { $dom-&gt;loadXML($this-&gt;file_contents); } else { $dom-&gt;loadHTML($this-&gt;file_contents); } /*** the tag by its tag name ***/ $content = $dom-&gt;getElementsByTagname($tag); $i = 0; foreach ($content as $item) { /*** add node value to the out array ***/ $out[$i]['name'] = $item-&gt;getAttribute($attr); $out[$i]['value'] = $item-&gt;nodeValue; $i++; } } return $out; } </code></pre> <p>I have it working the way I want in that it grabs each &lt;block&gt; on the page and injects it's contents into my template, however, it is stripping the HTML tags within the &lt;block&gt;, thus returning the following without the &lt;p&gt; or &lt;span&gt; tags:</p> <pre><code>this is some rendered PHP! Main column of content </code></pre> <p>What am I doing wrong here? :) Thanks</p>
php
[2]
3,176,152
3,176,153
Distance Routing Vector Implementation
<p>I am trying to implement Distance Vector Routing algorithm, using <a href="http://www.cs.bu.edu/fac/byers/courses/791/F99/scribe_notes/cs791-notes-990923.html" rel="nofollow">http://www.cs.bu.edu/fac/byers/courses/791/F99/scribe_notes/cs791-notes-990923.html</a><br> (in C++). </p> <p>Here is what I have done so </p> <p>far:</p> <pre><code>i) Read no. of nodes. ii) Implement the points 1 to 4 in the article as: for(i = 0; i &lt; nodes; i++) //nodes is the no. of nodes { for(j = 0; j &lt; nodes; j++) { if(distanceVector[i][j] != 0) //distanceVector holds the cost value between every pair of links, 0 if no link exists { for(k = 0; k &lt; nodes; k++) { if((distanceVector[i][j] + distanceVector[j][k]) &lt; distanceVector[i][k]) { distanceVector[i][k] = distanceVector[i][j] + distanceVector[j][k]; via[i][j] = i; // intermediate node, in case no link exists via[j][i] = j; } } } } } </code></pre> <p>I get the same array / matrix as it is. I have also tried juggling <strong>i, j, and k</strong>, but of no use.</p> <p>Am I right in my implementation...???</p>
c++
[6]
3,574,303
3,574,304
Getting more than excepted with siblings().length
<p>I have the following html</p> <pre><code>&lt;div id="myDiv"&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>When I execute this jquery code</p> <pre><code>var count = $('#myDiv table tbody tr').siblings().length; </code></pre> <p>I am expecting to get 8 as the value of count, instead I am getting 45. There is more html on the page than the area I have shown, and each of the above elements hold various amounts of data. What am I missing?</p>
jquery
[5]
564,548
564,549
is it possible to share desktop screen on web site through .net c#?
<p>is it possible to share desktop screen on web site through .net c#?<br> My requirement is that, I want to create a website in C# which allow users to share their screens</p>
c#
[0]
4,823,776
4,823,777
Server tag in OnClientClick
<p>The following gives me an error of "The server tag is not well formed"</p> <pre><code>&lt;asp:LinkButton ID="DeleteButton" runat="server" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete &lt;%# Eval("Username") %&gt;?');"&gt; Delete &lt;/asp:LinkButton&gt; </code></pre> <p>(This is used in a data bound ListView that displays a list of users. When you click the delete button a JavaScript confirm dialog is used to ask you if you're sure)</p> <p>So, how can I embed a server tag in a string that contains JavaScript?</p>
asp.net
[9]
5,762,828
5,762,829
why is that my context.getResources().getStringArray() still got error
<p>Good day, i am figuring out what's wrong with my code. I hope you guys can help me. This is my code:</p> <pre><code>String[] commandWords = context.getResources().getStringArray(R.array.on_command); </code></pre> <p>This is my strings.xml file:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string name="OnAppliance1"&gt;first appliance&lt;/string&gt; &lt;string name="OnAppliance2"&gt;second appliance&lt;/string&gt; &lt;string name="OnAppliance3"&gt;third appliance&lt;/string&gt; &lt;string name="OnAppliance4"&gt;fourth appliance&lt;/string&gt; &lt;string name="OnAppliance5"&gt;fifth appliance&lt;/string&gt; &lt;string-array name="on_command"&gt; &lt;item&gt;@string/OnAppliance1&lt;/item&gt; &lt;item&gt;@string/OnAppliance2&lt;/item&gt; &lt;item&gt;@string/OnAppliance3&lt;/item&gt; &lt;item&gt;@string/OnAppliance4&lt;/item&gt; &lt;item&gt;@string/OnAppliance5&lt;/item&gt; &lt;/string-array&gt; &lt;/resources&gt; </code></pre>
android
[4]
5,425,813
5,425,814
Should I somehow protect my $_FILE user input?
<p>I want to make my site hack-proof so this is why I do:</p> <pre><code>Text: mysql_real_escape_string($myVar); Number: (int)$myVar; </code></pre> <p>Should I use something similar to file array that is given by <code>$myVar = $_FILE['myFile'];</code> ?</p>
php
[2]
4,126,175
4,126,176
android phone won't have 2 dev apps on it at once
<p>i'm developing a couple of apps at the moment one is an image-processing app, the other a google maps app. when i'm developing them i can only have one app at a time on the phone. is there any reason for this? my phone is a Samsung galaxy portal api2.1.</p> <p>i'd like to have a few apps on my phone that are in the development process for interview purposes. Is this possible?</p>
android
[4]
4,192,465
4,192,466
texlive.js possible?
<p>I just found about <a href="https://github.com/kripken/emscripten/wiki" rel="nofollow">emscripten</a>, <a href="http://manuels.github.com/texlive.js/website/" rel="nofollow">texlive.js</a> is it really a converted version of texlive in JavaScript or a server as <a href="http://www.scribtex.com/" rel="nofollow">Scribtex</a> and many others? Is this really possible?</p>
javascript
[3]
478,310
478,311
Define a js function inside another js function
<p>I've recently found this code snippet:</p> <pre><code>function start() { function sleep(milliSeconds) { var startTime = new Date().getTime(); while (new Date().getTime() &lt; startTime + milliSeconds); } sleep(10000); return "Hello Start"; } </code></pre> <p>What advantages do we have defining functions this way instead of using a 'traditional' approach?</p> <p>Thanks in advance.</p>
javascript
[3]
4,967,770
4,967,771
String helper method
<p>I need a little help on how i could put in a helper method. This is the helper method I wrote.</p> <pre><code>public static String helper(String help) { help = help.toLowerCase(); help = help.replaceAll("\\s+", ""); } </code></pre> <p>and this is how i used it in main method.</p> <pre><code>String help = RecursivePalindrome.helper(x); </code></pre> <p>If I keep it like this then on the helper method they ask me for a return value but if i put the <code>return help;</code> then the method doesn't execute correctly. If I change the helper method to void then i cant put String help on my main method. </p> <p>This is what happens when i run the program:</p> <pre><code>Enter a word to test whether it is a palindrome or not(press quit to end.): RaceCar 'RaceCar' is not a palindrome. </code></pre> <p>See i put the helperclass to ignore the upper cases but it wont. RaceCar would be a palindrome but the uppercase makes the program say its not.</p>
java
[1]
5,377,620
5,377,621
js code to tell if a function is available for an object
<p>The following line of javascript gets a Uncaught TypeError: <strong>Object #Text has no method 'getAttribute'</strong> in chrome and safari but not in IE.</p> <pre><code>this.Element.getAttribute("whatever") </code></pre> <p>I get that this.Element is the main problem, but would like a temporary fix for debugging other parts of the code. <strong>How can test to see if a function is available on an item without getting a javascript error?</strong></p>
javascript
[3]