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,323,542
2,323,543
Extract the values from NSMutableDictionary
<pre><code>( { dateVal = "nov 26, 2010"; price = "1 - 195 kr"; }, { dateVal = "nov 26, 2010"; price = "425 - 485 kr"; }, { dateVal = "nov 26, 2010"; price = "415 - 640 kr"; }) </code></pre> <p>How can i extract this NSMutableDictionay?</p> <p>Help me!</p>
iphone
[8]
562,163
562,164
Same keyword for two purposes in java?
<p>As we use "default" keyword as a access specifier, and it can be used in switch statements as well with complete different purpose, So i was curious that is there any other keywords in java which can be used in more then one purposes</p>
java
[1]
4,605,714
4,605,715
How to load an XML document with a web page
<pre><code>XmlDocument doc; doc = new XmlDocument(); string url = "http://apps.lehighcounty.org/Assessment_DNN/Puba.cfm?doc=SearchAddr_Result.cfm&amp;Addressnum=&amp;Addressline=" + "AVE"; doc.Load(url); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("wp", "http://api.whitepages.com/schema/"); </code></pre> <p>I get the following error message from the code above. Why?</p> <blockquote> <p>'stylesheet' is an unexpected token. The expected token is '"' or '''. Line 28, position 11.</p> </blockquote>
c#
[0]
2,627,769
2,627,770
Beginner exception handling issue
<p>this post is probably a bit different from the usual questions about exceptions in c++. I hope i'm not wasting people's time with my seemingly obvious questions but i'm struggling to understand what i'm about to ask when reaching out to the obvious sources of knowledge before one would directly ask for help in understanding a concept.</p> <p>My question is this, in c++, how does someone go about handling user input errors, by this specifically i mean when a user is being prompted for an integer and they enter a float or a string/char or vice versa. You know like someone entering their name when being prompted for their age or something.</p> <p>I'm basically talking about c++'s equivilent to what would be in python something like:</p> <pre><code>try: [code to prompting user for an integer.] exception ValueError: [code to run if exception is thrown.] </code></pre> <p>Now i know i'm probably going to get alot of face-palming because this seems like such a basic concept of programming but i'm having trouble understanding how to go about this in c++.</p> <p>If one of you awesome guys has the spare time to explain this to me in a way a beginner would be able to understand it would be <strong>hugely</strong> appreciated guys. As this is something i'm getting frustrated with, it should be very simply i would have thought, perhaps my researching skills need work.</p> <p>Thankyou in advance people and once again i'm very sorry for any time i've wasted with my noob-ass question. But i just want to learn, and would mean alot if someone could help me out here.</p> <p>Thanks.</p>
c++
[6]
5,996,667
5,996,668
clearing doubts about value and reference types
<p>value type variables contain the actual data directly and reference type variables contain the reference to the actual data.</p> <p>I think of this as: </p> <p>l.h.s is value type and r.h.s is reference type</p> <p><img src="http://i.stack.imgur.com/uxyKv.jpg" alt="enter image description here"></p> <p>on the left hand side, if I copy <code>i</code> into <code>j</code>, a new memory location is filled with same original data (45).</p> <p>on the right hand side, if I copy <code>k</code> to <code>l</code>, a new memory location is filled with the reference to the object; and this reference points to the actual object in memory.</p> <p>now, I am confused about this reference type copying. here's a slight different thing:</p> <p><img src="http://i.stack.imgur.com/CQ8JG.jpg" alt="enter image description here"></p> <p>Here, the copy on the r.h.s makes <code>l</code> points to same location as <code>k</code>.</p> <p>My question is <strong>1. "Which one is truer?"</strong> or is there more to it than I imagined?</p> <p>Also, value types may be allocated on heap, depending upon the how jitter sees it fit, then <strong>2. Can we force a reference type to be allocated on stack?</strong></p> <p>Sorry for sloppy image editing.</p>
c#
[0]
16,671
16,672
I'm unable to display a form dynamically
<p>When I try to use the <code>&lt;form&gt; &lt;/form&gt;</code> tag dynamically, it is not working.</p> <p>Sample code:</p> <pre><code>&lt;?php $i=1; while($i&lt;4) { &lt;form name="form'.$i.'" action="" method="post"&gt; &lt;input type="submit" name="a'.$i.'" /&gt; &lt;/form&gt; $i++; } ?&gt; </code></pre> <p>The code runs, but the form tag doesn't work for the first button. It works from the second button. But I need this for the first button also.</p> <p>How can I resolve this?</p>
php
[2]
4,522,021
4,522,022
How do I keep my screen unlocked during USB debugging?
<p>Android OS2.2 used to have an option under Settings/Applications/Development to disable screen lock during USB debugging. After upgrading my Samsung Galaxy S to OS2.3.3 this option disappeared and it's VERY frustrating to keep unlocking my phone while debugging.</p> <p>Has this option moved or is there another way to do it? (I hate when useful options are removed for no reason!)</p> <p>Thanks in advance...</p>
android
[4]
5,796,007
5,796,008
jQuery in parent
<p>I'm having an issue pushing my code through into the parent window. It's currently in an iFrame and I've been ratteling my brain over this for some time. I have very little experience with parent functions. Any help would be great, Thanks!</p> <pre><code> $(document).ready(function(){ $("a[rel*=2gain]").facebox({ loadingImage : 'rc/loading.gif', closeImage : 'rc/closelabel.png' }); }); </code></pre>
jquery
[5]
1,264,346
1,264,347
Jquery get .val
<p>What I need is the "this" value of</p> <pre><code>( $(this).attr("value")); </code></pre> <p>to show up in the "this" of</p> <pre><code>$("#activities_" +btn_id).val($(this).val()); </code></pre> <p>Here is the code.</p> <pre><code>$('.thoughts_list').click(function(){ ( $(this).attr('id')); ( $(this).attr("value")); }); $('#close_thoughts').click(function(){ $("#activities_" +btn_id).val($(this).val()); }); </code></pre> <p>Currently, the value that is returned is "Cancel", which is the value of the "#close_thoughts", instead I need the value of the clicked ".thoughts list"</p> <p>ANSWERED, apperantly this is what i was looking for.</p> <pre><code>$('.thoughts_list').click(function(){ ( $(this).attr('id')); ( $(this).attr("value")); }); $('#close_thoughts').click(function(){ $("#activities_" +btn_id).val($('input[name=thoughts_list]:checked').val()); }); </code></pre>
jquery
[5]
3,747,825
3,747,826
libtask on the iPhone
<p>Has anyone gotten 'libtask', <a href="http://code.google.com/p/libtask/" rel="nofollow">http://code.google.com/p/libtask/</a>, running on the iPhone device? It seems to run we enough on the iPhone simulator but does not like running on the device at all.</p> <p>Any help would be greatly appreciated.</p>
iphone
[8]
2,252,589
2,252,590
Fast read and write large data pack on hdd
<p>I have this issue. I have a list of file names.Each consists of date, hour and other int like parameters. Ex. 20130505_1240_8445_3336.ext. I broke it down to objects File(Int date, int hour, etc) And stored in List.</p> <p>Problem is list contains 6 million Objects. My "slow" machine is making that list for 4 hours because of regexp i have to use there. I'd like to skip making that list every time i lunch program therefore i want to save it somehow. I tried to save it with binaryFormater as serialized object List. It was big, over 200Mb. I could easily save it but when i wanted to read it it was loooong wait. I would like to skip SQL part if i can. </p> <p>Is there any smooth possibility to manage that big set of data? Preferably easily searchable and fast as can be. Speed is factor i care the most. Security have no matter to me. </p> <p>Thanks in advance ;)</p>
c#
[0]
214,851
214,852
Animated game for web and iPhone - how?
<p>I would like to create arcade game (cartoon style). I need framework/technology to create one code and use it on website and iPhone in same way. Is it possible?</p>
iphone
[8]
573,591
573,592
Expose web server running on Android on Verizon 3G to the internet?
<p>It is possible to serve web pages from a android phone over 3G network to the internet?</p>
android
[4]
4,353,018
4,353,019
i had an exception in image renderer done in threading in java
<pre><code>Exception in thread AWT-EventQueue-0 org.pushingpixels.substance.api.UiThreadingViolationException: Component creation must` be done on Event Dispatch Thread at org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.testComponentC </code></pre>
java
[1]
4,620,443
4,620,444
Why this PHP function "forgets" parameters?
<p>I've fount this implementation of a function to convert an array to a URL. It seems correct and, in fact, it works pretty well in many cases, except when I pass an array value with a 0 value. This is the function:</p> <pre><code>function strtourl($arr, $entity = true, $prefix = '') { $params = array(); foreach ($arr as $k =&gt; $v) if ($v) { $params[] = is_array($v) ? strtourl($v, $entity, $prefix ? $prefix.'['.$k.']' : $k) : sprintf($prefix ? $prefix.'[%s]' : '%s', urlencode($k)).'='.urlencode($v); } return implode($entity ? '&amp;amp;' : '&amp;', $params); } </code></pre> <p>This is an example I'm using:</p> <pre><code>$array = array( 'type' =&gt; 0, 'content' =&gt; array( 'msg_id' =&gt; 'XSS120', 'source' =&gt; 0, 'dest' =&gt; 4, 'type' =&gt; 0, 'msg' =&gt; 'message' ) ); </code></pre> <p>It returns this string:</p> <pre><code>content[msg_id]=XSS120&amp;content[dest]=4&amp;content[msg]=message </code></pre> <p>instead of this:</p> <pre><code>type=0&amp;content[msg_id]=XSS120&amp;content[source]=0&amp;content[dest]=4&amp;content[type]=0&amp;content[msg]=message </code></pre> <p>What's happening and how to fix it?</p>
php
[2]
5,248,286
5,248,287
How to programmatically sense the iPhone mute switch?
<p>I can't seem to find in the SDK how to programatically sense the mute button/switch on the iPhone. When my app plays background music, it responds properly to the volume button without me having any code to follow that but, when I use the mute switch, it just keeps playing away.</p> <p>How do I test the position of mute?</p> <p>(NOTE: My program has its own mute switch, but I'd like the physical switch to override that.)</p> <p>Thanks!</p>
iphone
[8]
5,650,113
5,650,114
android list view - row color
<p>I am trying to develop a simple android app. It has two text boxes for entering search criteria. A submit button to submit the page. In the next page (new intent) I show search results.</p> <p>Now I want to search results in a listview. The xml code of the view looks like below.</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="wrap_content" android:layout_height="wrap_content" android:padding="5dp"&gt; &lt;ImageView android:id="@+id/image" android:layout_width="50px" android:layout_height="50px" android:layout_marginLeft="5px" android:layout_marginRight="20px" android:layout_marginTop="5px"&gt; &lt;/ImageView&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@+id/label" android:textSize="15px" &gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/addr" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@+id/label" android:textSize="15px" &gt; &lt;/TextView&gt; </code></pre> <p> </p> <p>In the XXXArrayAdapter class, getView method, I set background color as below.</p> <pre><code> private int[] colors = new int[] { 0x30FF0000, 0x300000FF }; int colorPos = position % colors.length; rowView.setBackgroundColor(colors[colorPos]); </code></pre> <p>However, I do not see backgorund color filling the entire row. Please see below screenshot. Ignore red boxes, I am intentionally hiding the search results.</p>
android
[4]
2,820,271
2,820,272
How to take snapshot of playing video and store that image view in android
<p>I'm trying to implement a project in android that take a snapshot of <strong>playing video</strong> and store that in image view... i've tried many links but not get what i want... please help me.</p>
android
[4]
5,404,719
5,404,720
translate animation
<p>I want an image to move horizontally. i.e image should move from left end bottom corner to right end bottom corner once. No need to come back again to left end bottom corner. </p> <p>The piece of code which I tried was</p> <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator"&gt; &lt;translate android:fromXDelta="0%p" android:toXDelta="200%p" android:duration = "2000"/&gt; &lt;/set&gt; </code></pre> <p>this moves the image from left till right. But its again coming to the left side. Can anyone tell me how to solve this?</p>
android
[4]
5,858,681
5,858,682
Launching android application from Email
<p>Is there any way to launch android application from Email, without using http/https ?</p>
android
[4]
5,502,103
5,502,104
hide a DIV when the user clicks on a button or outside of it - Almost there
<p>I have an "Options" button on my webpage. When the user click on that button, a little submenu appear.</p> <p>When I click outside that menu, it closes. So far so good. </p> <p><strong>My problem is that when I click again on the option button(when the menu is visible), the menu stays open. It should close.</strong> </p> <p>Here's the code that manage the "click outside" functionality</p> <pre><code>$j(document).mouseup(function(e) { var container = $j('.playlist-menu'); if (container.has(e.target).length === 0) { container.hide(); } }); </code></pre> <p>And the event on the button</p> <pre><code>$j('#options').click(function() { $j('.playlist-menu').toggle(); }); </code></pre> <p>The HTML structure:</p> <pre><code>&lt;button id="options" class="float-left" title="Options" type="button"&gt; &lt;div class="playlist-menu display-none"&gt; &lt;ul&gt; ... &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I don't understand why its not closing when I click a second time on the option button, the e.target of that button is not 'playlist-menu' so why is the menu not closing??</p> <p>Thanks</p>
jquery
[5]
3,690,898
3,690,899
Best method for (HEX) string comparison
<p>suggest a best and efficient method for this</p> <pre><code>a = "data read from serial port in HEX" TX1 = "\x10\x04" RX1 = "\x10\x04" TX2 = "\xF2\x00\x04\x43\x30\x40\x32\xED\x45" RX2 = "\x06\xF2\x00\x13\x50\x30\x40\x30\x30\x31\x31\x31\x30\x31\x31\x30\x30\x30\x30\x30\x30\x30\x30\xAE\xFD" if tx1 in a: send.ser(rx1) read_buufer() if tx2 in a: send.ser(rx2) read_buf() </code></pre> <p>so what is the best way to do this comparison....jus wanna verify the hex data received from serial buffer (a) and verify with list of available request string tx1,tx2,tx3.....txn and send response to from rx1,rx2,rx2......rxn...</p>
python
[7]
5,813,020
5,813,021
Are we actually instantiating an Abstract class here?
<pre><code>// Concrete implementation built atop skeletal implementation static List&lt;Integer&gt; intArrayAsList(final int[] a) { if (a == null) throw new NullPointerException(); return new AbstractList&lt;Integer&gt;() { public Integer get(int i) { return a[i]; // Autoboxing } @Override public Integer set(int i, Integer val) { int oldVal = a[i]; a[i] = val; // Auto-unboxing return oldVal; // Autoboxing } public int size() { return a.length; } }; } </code></pre> <p>So far I knew we can not instantiate an abstract class at all . But what aren't we doing the same thing here with <code>return new AbstractList&lt;Integer&gt;()</code> ? I am confused .</p>
java
[1]
3,786,868
3,786,869
Why wouldn't a global object's property accept a new assignment?
<p>I'm trying to assign a new value to the 'notes' property of the 'attendee' object in this global session object... whenever I try the assignment though, the value doesn't keep.</p> <p>From the console in webkit:</p> <pre><code>&gt; session['attendee']['notes'] null &gt; session['attendee']['notes'] = "test" "test" &gt; session['attendee']['notes'] null &gt; window.session['attendee']['notes'] = "test" "test" &gt; session['attendee']['notes'] null &gt; window.session['attendee']['notes'] null </code></pre> <p>Session is set like so in a global scope:</p> <pre><code>window.session = {}; </code></pre> <p>And then later on I'm assigning an object pulled from the browser's sql database like this;</p> <pre><code>window.session['attendee'] = {'name':'mike' ..etc..} </code></pre> <p><strong>Update:</strong></p> <p>Here's some more console info:</p> <pre><code>&gt; window.session['attendee'] Object address_1: null address_2: null app_id: 1 badge_id: null budget: null city: null company: null decision_maker: null email: null first_name: "Anonymous" followup: null id: null is_influencer: null is_purchaser: null is_user: null last_name: "" notes: null phone: null rating: null scanned: 1 state: null synced: null zip: null __proto__: Object &gt; window.session['attendee'].notes null &gt; window.session['attendee'].notes = "TEST" "TEST" &gt; window.session['attendee'].notes null </code></pre> <p>So there's an object in session.attendee and "notes" is a property in that object, but assigning a value to it doesn't stick.</p>
javascript
[3]
2,134,463
2,134,464
QUERY sql database
<p>PLEASE HELP FOR A QUERY</p> <p>My <code>Student_Master Table</code>:-</p> <pre><code>ID Name 1 AAA 2 BBB 3 CCC 4 DDD My Student Details Table ID MastID Address 1 1 Address 1 2 2 Address 2 </code></pre> <p>Now I have a gridview which is bound to Student master table, now I want a custom column in my gridview called so that "The students who have address there status should be "Address Present" and for the student whose address is not present in table for them there status would be "Address NOT Present" Eg. </p> <pre><code>ID Name Status 1 AAA Address Present 2 BBB Address Present 3 CCC Address NOT Present 4 DDD Address NOT Present </code></pre>
asp.net
[9]
1,028,577
1,028,578
check to see if a domain is available or not using PHP?
<p>If I have a domain like <code>www.example.com</code> and I want to check if it is available using DNS records (not whois)...</p> <p>Is it possible to do this using PHP?</p>
php
[2]
1,000,524
1,000,525
Basic Slot Machine
<p>I'm trying to create simple slot machine with three slots. Each slot will generate a random number between 0 and 9 inclusive. The user will start with 1,000 coins and can wager any number of coins per slot pull. The payouts are: if 2 slots equal each other the user wins 10x the wager, if 3 slots equal each other the user wins 100x the wager, and if 0 slots equal the user loses the wagers. I want the output to generally look like this:</p> <p>Slot Machine<br> You have 1000 coins.<br> Press 0 to exit, any other number to play that many coins per spin<br> 1000<br> Spin: 4 6 6<br> You won 10000 coins! You now have 11000 coins.<br> Press 0 to exit, any other number to play that many coins per spin<br> 11000<br> Spin: 4 4 1<br> You won 110000 coins! You now have 121000 coins.<br> Press 0 to exit, any other number to play that many coins per spin<br> 121000<br> Spin: 5 1 9<br> You lost 121000 coins! You now have 0 coins.<br> Press 0 to exit, any other number to play that many coins per spin<br> 10<br> You ran out of coins. Thanks for playing. </p> <p>I'm not very familiar with programming and a few of the seniors I look after would enjoy this for a little fun with them learning how to use a computer. Thanks.</p>
java
[1]
5,878,049
5,878,050
Is it bad practice to have nested render loops?
<p>I'm porting a game from Ruby to C++. There is a main render loop that updates and draw the content. Now let's say that during the game, you want to select an item another screen. The way it's done in the original code is to do <code>Item item = getItemFromMenu();</code> <code>getItemFromMenu</code> is a function that will open the menu and do have its own update/render loop, which mean that during the whole time the player has this other screen open, you are in a nested render loop. I feel like this is a bad method but I'm not sure why. On the other hand it's very handy because I can open the menu with just 1 function call and so the code is localized. Any idea if this is a bad design or not? I hesitated to post it on gamedev, but since this is mostly a design issue I posted it here</p> <p>edit : some pseudo-code to give you an idea:</p> <p>The usual loop in the main part of the code:</p> <pre><code>while(open) { UpdateGame(); DrawGame(); } </code></pre> <p>now inside UpdateGame() i would do something like:</p> <pre><code>if(keyPressed == "I") { Item&amp; item = getItemFromInventory(); } </code></pre> <p>And <code>getItemFromInventory()</code>:</p> <pre><code> while(true) { UpdateInventory(); if(item_selected) return item; DrawInventory(); } </code></pre>
c++
[6]
193,820
193,821
How to supply not all default arguments in python?
<p>Lets say i have this code:</p> <pre><code>def dosomething(thing1, thing2=hello, thing3=world): print thing1 print thing2 print thing3 </code></pre> <p>I would like to be able to specify what thing3 is, but wihout having to say what thing2 is. (The code below is how i thought it might work...)</p> <pre><code>dosomething("This says 'hello fail!'", , 'fail!') </code></pre> <p>and it would say</p> <pre><code>This says 'hello fail!' hello fail! </code></pre> <p>So is there a way to do it like that, or would i have to specify thing2 every time i wanted to say what thing3 was?</p> <p>I am using python2, if that matters.</p>
python
[7]
2,369,188
2,369,189
Step by step tutorial in javascript
<p>I am trying to write my helloworld code using javascript and html. So, I thought of picking up a project and iterating from there.</p> <p>Lets say, I have a path to xml file. 1) Display the contents of the xml file as it is (i.e treat it as a text file irrespective of the markup)</p> <p>Thats it.. actually.. there is no step 2 :) But, I have very limited background in html as well. can someone help me what will be the helloworld.html (or helloworld.js) be so that I can run it on the browser??</p> <p>I would really really appreciate it </p> <p>Many thanks</p>
javascript
[3]
1,896,609
1,896,610
authenticating user and display page
<p>I have created my page and am trying to authenticate the user before granting the user access to the page. My problem is that i am using the method like so:</p> <pre><code>if($_SESSION['username']){ echo 'PAGE CONTENT HERE'; }else{ SEND BACK TO LOGIN PAGE } </code></pre> <p>Which works fine for some of my pages, but on my main page a populate select boxes with php from my db and when i use the metod above all of my options are displaying outside of the select (works fine if i dont echo the page out)</p> <p>am i missing a trick here?</p>
php
[2]
4,071,458
4,071,459
PHPMailer v. mail() for a simple Contact Form
<p>I am new to PHP, but have a decent grasp of things (have not learned classes yet).</p> <p><strong>The question:</strong></p> <p>Which to choose? PHPMailer or mail() for my new contact form.</p> <p>The form is simple:</p> <pre><code>Your name: Your email: Subject: Body: </code></pre> <p>I have around 2,000 visitors per day and receive about 10 submissions per day, so I don't need anything too fancy. =)</p> <p><strong>Miscellaneous questions in my head:</strong></p> <ul> <li>Is PHPMailer going to better protect my Contact Form from CC: injection (major concern)? I already know the <code>anti-spambot display:none CSS</code> trick.</li> <li>Will PHPMailer save me the step of having to write an <code>email_validator()</code> function?</li> <li>Will PHPMailer save me any other time of having to write any custom functions?</li> </ul> <p>Thanks! With any luck, I'll be answering questions soon. Lol</p>
php
[2]
3,177,328
3,177,329
Why don't switch statements work with arrays?
<p>The following alerts nothing. I assume everyone can see what I'm trying to accomplish. Does anyone know what's going wrong?</p> <pre><code>var myarray = ['foo', 'bar']; switch (myarray) { case ['foo', 'bar']: alert('foobar'); break; case ['foo', 'foo']: alert('foofoo'); break; } </code></pre>
javascript
[3]
3,483,579
3,483,580
Format support for classification in lingpipe
<p>I have excel sheet where one column has product review and second column has respective product name .. My question is, Can I train model in lingpipe with such type of input?</p> <p>If yes, How I can use this in java application?</p>
java
[1]
609,686
609,687
in gridview how to add the textbox when user click on link button?
<p>I have gridview which contain four column ID,Name,Address and Ph_No. In gridview, one column for link button ID=Edit. When user click on the link "Edit" then textbox will be display in gridview control.</p>
asp.net
[9]
3,399,415
3,399,416
Having Problems with Arguments
<p>I have tried to write this little script that will batch rename file extensions. I am passing three arguments, the directory where the files are located, the current extension, and the new extension.</p> <p>The error I am getting is</p> <pre><code>python batch_file_rename_2.py c:\craig .txt .html Traceback (most recent call last): File "batch_file_rename_2.py", line 13, in &lt;module&gt; os.rename(filename, newfile) WindowsError: [Error 2] The system cannot find the file specified </code></pre> <p>The code is</p> <pre><code>import os import sys work_dir=sys.argv[1] old_ext=sys.argv[2] new_ext=sys.argv[3] files = os.listdir(work_dir) for filename in files: file_ext = os.path.splitext(filename)[1] if old_ext == file_ext: newfile = filename.replace(old_ext, new_ext) os.rename(filename, newfile) </code></pre>
python
[7]
3,614,342
3,614,343
connecting my application to wamp server
<p>I am new to android. I want to display my localhost (wampserver) Page on a click of a button.</p> <p>I have tried using <code>httppost</code> method but it is not displaying anything just a blank mess. If I give a wrong addres then it is throwing error message.</p> <p>All help is appriciated</p>
android
[4]
4,491,340
4,491,341
Can I use templates dynamically?
<p>I have a class:</p> <pre><code>class abc &lt;T&gt; { private T foo; public string a { set { foo = T.parse(value); } get{ return foo.toString(); } } } </code></pre> <p>However the T.parse command is giving me an error. Anyone of a way to do what I am trying to do?</p> <p>I am using this as a base class for some other derived classes.</p> <p>Edit:</p> <p>What I ended us doing:</p> <pre><code>Delegate parse = Delegate.CreateDelegate(typeof(Func&lt;String, T&gt;), typeof(T).GetMethod("Parse", new[] { typeof(string) })); </code></pre> <p>I do that once in the constructor</p> <p>and then I do the following in my property:</p> <pre><code> lock (lockVariable) { m_result = (T)parse.DynamicInvoke(value); dirty = true; } </code></pre>
c#
[0]
4,983,644
4,983,645
Fetching the Orientation of the downloaded image
<p>I have been trying to fetch the image orientation when downloaded from the server.</p> <p>I have tried it to camera image and it works fine for me, Can anyone give me any idea how to fetch the orientation of the downloaded image .</p> <p>And here is the code for fetching the orientation of the image when taken from the camera.</p> <pre><code>rotation = (int) exifOrientationToDegrees(exif .getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)); orientation = exif.getAttributeInt( ExifInterface.TAG_ORIENTATION, 1 ); Log.i("photoimage", "got orientation-----&gt;" + orientation); </code></pre> <p>Thanks in advance</p>
android
[4]
242,020
242,021
Website Development Problem CakePHP, WordPress or Start From Scratch?
<p>I'm in the process of starting a new web site that is something like stackoverflow but a little bit more different along with making the members profiles highly more customizable I was thinking of building it from scratch using PHP, but was thinking of using CakePHP, but then I thought WordPress sounded better but I remember working with wordpress and it was a little bit slow at times when you tried to browse the web site. </p> <p>So what I guess I'm trying to ask is that should I design the site from scratch? And I heard techcrunch.com and 9rules.com are completely done in WordPress, is this true?</p>
php
[2]
5,422,321
5,422,322
How to play video from remote URL in android?
<p>I am New to android my intention is to play video using Http.</p> <p>But i am getting "Http Request Failed 404" Exception when iam trying to run my application in emulator. can any one know this error?</p> <p>plz help me Thanks in advance.</p>
android
[4]
5,042,314
5,042,315
Jquery function onclick add class and remove class
<p>I am doing jquery function to enable and disable input type text</p> <p>the first function is working fine and change the class of the a href but the secound function that related to the new class is not working</p> <p>here is the full code</p> <p><a href="http://jsfiddle.net/RcLgz/1/" rel="nofollow">http://jsfiddle.net/RcLgz/1/</a></p>
jquery
[5]
5,268,134
5,268,135
Should I use prepared statements for static values?
<p>Say on each pageload I want to grab the score of one particular use, <code>SELECT score FROM users WHERE id = 6</code>. None of those variables will ever change, and I'm not including POST/GET data into it.</p> <p>Should I still use prepared statements? Or can I just use the <code>query</code> function?</p>
php
[2]
4,347,285
4,347,286
Is this a copy? but why it works like a reference?
<p>The below code, <code>Value r = foo(i)</code>, is <code>r</code> a reference or a copy?</p> <pre><code>Value foo(int i) { return Value::New(i); } Value bar(Arg x) { // should I use Value&amp; r = foo(x.getIndex()); Value r = foo(x.getIndex()); x.close(); return r; } </code></pre> <hr> <p>I tested</p> <pre><code>#include &lt;stdio.h&gt; using namespace std; class Value { public: Value() { printf("construct\n"); } }; Value foo(){ Value a; return a; } Value bar() { Value b = foo(); return b; } int main(){ Value c = bar(); } </code></pre> <p>only construct 1 times.</p>
c++
[6]
1,987,137
1,987,138
Div wont extend to bottom of its contents when divs inside it are floated
<p>I have 2 divs as columns, both are floated left and set to clear none. Their container div has a background image at the top, so the background is at the top of both columns.</p> <p>I want to be able to also have a background image at the bottom of the columns. I've created another div which sits inside the container div (but outside the columns) and set a background image to its bottom.</p> <p>The problem is that this div doesn't extend to the bottom of the columns it contains. How can I make it do this? I've tried playing around with floats and clearing but without any luck.</p>
jquery
[5]
5,299,760
5,299,761
Session variable in C# desktop application?
<p>I am developing a C# a stand alone single user desktop application that requires the user to login to the application. I want to ensure that when there is no activity for 5 minutes or so the application will prompt the user to login again. I have several solution in mind to do this but there do not seem efficient. Previously while doing web programming i was able to do this kind of feature using session variable are there are similiar kind of features in C# that can be used for desktop application.</p>
c#
[0]
3,722,976
3,722,977
concatenate characters and convert to int
<p>i am using c# and i need some help in this... i have 2 strings</p> <pre><code>s1="1234" s2="5678" </code></pre> <p>i want to create 2 integers so that they become equal to the 1st 2 characters and convert to int. ie</p> <pre><code>int i1=12 12 is the 1st 2 characters from s1 int i2=56 56 is the 1st 2 characters from s2 </code></pre>
c#
[0]
4,274,588
4,274,589
I am getting the error in 48th line as "Uncaught TypeError: Object [object Object] has no method 'getElement'' "
<p>I am getting the error in line as</p> <blockquote> <p>Uncaught TypeError: Object [object Object] has no method 'getElement'</p> </blockquote> <p>so please refer my code in javascript file</p> <pre><code>addnavbtn: function(){ if (!(Browser.ie &amp;&amp; Browser.version &lt; 9)) { var jlevel0 = this.menu.getElement('ul.level0'); if(jlevel0){ var jmega = this.menu; var jbutton = new Element ('div', {id:'js-megamenu-button', 'class': 'js-megamenu-button', html: 'Navigation', styles: { display: 'none'}}).inject (jmega, 'before'); jbutton.addEvent('click', function(e){ e.stop(); if(jmega.getStyle('display') == 'block'){ jmega.removeClass('active').setStyle('display', 'none'); jbutton.removeClass('active'); } else { jmega.addClass('active').setStyle('display', 'block'); jbutton.addClass('active'); } }); </code></pre>
javascript
[3]
2,490,200
2,490,201
jQuery - how to decode an AJAX output and place it in a drop-down select menu?
<p>I have a regular text box that people type input to. On keyup, I want to do a like query in the db and see if there are any matches. If there are some matches, I want to display them as choices for the person to choose before they finish typing.</p> <p>This would work just like in stackOverflow, the functionality for choosing tags works.</p> <p>How can I do this? Right now I am returning the choice data encoded in json from my ajax to the jQuery code, but I don't know how to loop through it and make it.</p>
jquery
[5]
2,206,693
2,206,694
Resizing font size in textarea to fit height
<p>I'm trying to do something different than most 'resize' textarea plugins do. I am not trying to resize the actual textarea, but rather the font size in the textarea so that all of the text fits.</p> <p>I basically want an 'auto' font size for a textarea. The problem lies in the fact that there are two different ways that the font needs to get 'smaller':</p> <ol> <li>User presses 'enter' and creates a line break</li> <li>User enters more text than the width of the textarea, causing it to break down</li> </ol> <p>I've seen a few instances of plugins which I've modified that creates a cloned textarea or div with the same styles that you can try to measure the new 'height' and calculate a font size based on this, but it seems to always fail in Safari and Chrome, so I'm guessing the logic is a bit flawed.</p> <p>Has anybody done this before or know of a plugin where it has been done?</p>
jquery
[5]
527,287
527,288
What is the difference between window and this.window, in javascript?
<p>I'm looking at a complex bit of JavaScript, which is doing all sorts of runtime/dynamic manipulation of objects and scripts. In the process, I'm learning all sorts of minutiae about Javascript and its idiosyncrasies.</p> <p>This one has me stumped, though. Is there ever a situation where</p> <pre><code>window !== this.window; //true </code></pre> <p>In other words, when would you ever write this.window instead of straight out window?</p>
javascript
[3]
5,127,531
5,127,532
jQuery fadeToggle not working properly due to bug with delay?
<p>I have a div that is being used an a email newsletter signup form. Upon clicking a link, this div is shown and the user sees a textbox and button and an option checkbox. Upon submission of the email address, the following code is fired:</p> <pre><code>$.post("/asynchronous/addEmail.aspx", {email: $(".emailPopupTextBox").val(), optin: thisOptIn }, function (data) { $(".emailText").hide(); $(".thankYouText").show(); $('.emailPopupBox').delay(800).fadeToggle(); }); </code></pre> <p>On return, the contents of the div are hidden (checkbox, button, and textbox) and a welcome message is shown to the user. At first, this was happening too fast and the email popup was just disappearing too fast. So, I added the <code>.delay</code> and now the emailpopup div shows the welcome message, runs the delay and the togglefade runs but instead of just disappearing as it should, it quickly disappears and flashes real quick and stays visible with the thank you message. If I click the link I initially clicked to fadeToggle the div to appear, it simply makes the div flash real quick but will not hide.</p> <p>EDIT: It seems after the .post that the .fadeToggle no longer functions properly. I am tracking this problem down.</p>
jquery
[5]
4,588,594
4,588,595
what is diffrence between Response.write and Response.output.write
<p>what is difference between Response.write and Response.output.write please give me example</p>
asp.net
[9]
1,329,526
1,329,527
How to display images in ListView instead of gallery layout
<p>Please see the below code:</p> <pre><code>//here i call the gallery view Gallery g = (Gallery) findViewById(R.id.gallery); g.setAdapter(new ImageAdapter(this, json)); //image adapter class public class ImageAdapter extends BaseAdapter { Bitmap bmp; private ImageView[] mImages; String[] itemimage; public ImageAdapter(Context context, JSONArray imageArrayJson) { this.mImages = new ImageView[imageArrayJson.length()]; String qrimage; try { private Image View[] mImages; for (int i = 0; i &lt; imageArrayJson.length(); i++) { JSONObject image = imageArrayJson.getJSONObject(i); qrimage = image.getString("itemimage"); byte[] qrimageBytes = Base64.decode(qrimage.getBytes()); bmp = BitmapFactory.decodeByteArray(qrimageBytes, 0, qrimageBytes.length); mImages[i] = new ImageView(context); mImages[i].setImageBitmap(bmp); </code></pre> <p>My xml view:</p> <pre><code>&lt;Gallery xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; </code></pre> <p>I can view the images from server database in a gallery view. However, I want to display all images in a ListView.</p> <p>Please help me.I am working with prakash</p>
android
[4]
2,616,899
2,616,900
variable php variables :D
<p>I have the ability to add custom fields in a project I am making. I have a page that has all the text inputs on it. Each custom field is named consecutively (field1, field2, field3) according to the order they were created. Since the user will have the ability to add as many as they want, how can I select each one so as to post their values to the database? </p> <p>Hope this makes sense...</p>
php
[2]
820,108
820,109
regarding parsing data from url and showing in list in android
<p>I am making an application of book bottle in android .I have having problem while i am showing array list in listview.Can anyone tell me</p>
android
[4]
3,280,622
3,280,623
Empty variable passed in URL
<p>I am passing a variable in a URL from create_topic.php, but the variable is empty. The page passing the variable uses that variable in a mysql query OK, so I know that its not empty then, but when I click a link in that page to go to another page, the variable is not being passed.</p> <p>in create_topic.php I have:</p> <pre><code>$author_pk = $_GET['author_pk']; </code></pre> <p>Then in the query on that page:</p> <pre><code>$query = "INSERT INTO topic (topic_pk,title,topic,majors,sub_discipline_fk,author_fk,created,place) VALUES ('','$title','$topic','$majors_string','$sub_discipline','$author_pk',NOW(),'$place')"; $result = mysql_query($query, $connection) or die(mysql_error()); </code></pre> <p>$author_pk contains the passed value OK.</p> <p>But in a link in create_topic.php I have:</p> <pre><code>&lt;a href="create_author.php?author_pk="&lt;?php echo $author_pk; ?&gt;&gt;Create&lt;/a&gt; </code></pre> <p>$author_pk is then empty in the URL...</p>
php
[2]
5,594,384
5,594,385
Why does flush in asp.net appear not to be workig?
<p>I call flush but the page just hangs for 5second (purposely) then renders completely. Why isnt it showing me the first part then the last?</p> <p>Firefox 7 and chrome both do this</p> <p>code file</p> <pre><code>using System; namespace ABC { public class Test { static public void Apple() { System.Web.HttpContext.Current.Response.Flush(); System.Threading.Thread.Sleep(5000); } } } </code></pre> <p>page</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; hi &lt;form id="form1" runat="server"&gt; &lt;div&gt; starting &lt;% ABC.Test.Apple(); %&gt; &lt;% WebApplication1._Default.RecurseMe(Response, @"/var/www/wordpress", 0); %&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
asp.net
[9]
3,211,095
3,211,096
Embed videos through Youtube
<p>I have the task to embed videos through the youtube channel in our website. So I want some help me how can I do that? I don't have any information to do that.</p>
asp.net
[9]
2,640,714
2,640,715
Static classes in PHP
<p>Instead of declaring each function as "static" in a class, is there any way that I can make a class itself "static"?</p>
php
[2]
3,997,621
3,997,622
Android: Send arbitrary objects within Activities?
<p>I have read some question here but I didn't find a solution. I have read about <code>Parcelable</code>, <code>Intents</code>, and sharing specific data within <code>Activities</code> from the android dev docs (both dev guide and reference).</p> <p>Here's the scenario:</p> <p>I have one <code>ListActivity</code> that fills in an object parsing an xml file, it shows a list of values, and when clicked I want to return the object that represents the item clicked to the activity that has called it, for then, call another activity with this object.</p> <p>I read on how to implement <code>Parcelable</code> but seems not being the way. Implementing <code>Parcelable</code> receives a <code>Parcel</code> for the constructor and then reads the values from it (or at least that was what I understood). This makes no sense for me and I can't see how to implement basing on that issue. I build the object parsing the xml file, not having a <code>Parcel</code>.</p> <p>I appreciate some clarifications on this, regards.</p>
android
[4]
3,688,362
3,688,363
Insert javascript variable into a form on another page?
<p>I am wondering if there's a good way to take a variable built in Javascript and then insert it into a form that's on another page.</p> <p>My application is a survey: I've got it so that at the end of the survey, all the results are displayed so they can look over their answers. Now I want to have the user click a link and have the answers of the survey show up automatically in the body of the form where they'll then add their email and contact info and click "send."</p> <p>Any ideas?</p> <p>Knowing that this ISN'T possible is fine too...if not, what alternate methods might I accomplish the end result?</p>
javascript
[3]
1,533,167
1,533,168
is there a way to view the source of a module from within the python console?
<p>if I'm in the python console and I want to see how a particular module works, is there an easy way to dump the source?</p>
python
[7]
1,102,033
1,102,034
Button click event handler before page load
<p>I will describe my problem in simple way so it's not exactly what I'm trying to do but the idea is the same.Here is the problem:<br> I create dynamic buttons from code behind.I get some id from query string,create button with that id ,dynamic add event handler to click event,and add button to placeholder.I store the list of id-s in session and in page load method recreate these buttons and add to placeholder.One of the id-s is CurrentId and it's also stored in session.Buttons click handler do something like this</p> <pre><code>Button b=(Button)sender; Session["CurrentId"]=Convert.ToInt32(b.ID); </code></pre> <p>In page load when I create buttons I want to set button text property different from others if <code>id==Convert.ToInt32(Session["CurrentId"])</code> when list of id-s are gotten from session.But problem is that click event handler is called after page load,and when I create buttons in page load ,CurrentId in session hasn't been channged by click event handler.Can you suggest any solution to this situation?</p>
asp.net
[9]
5,381,052
5,381,053
How to display a php 3 level array in table form
<p>Currently I have a PHP 3 level array. How do I display it in a table form? Using print_r I could display out the full array but I need to beautify it to show in a table form. Is it possible?</p> <p>Sample of the array to be inserted is as shown in another posting: <a href="http://stackoverflow.com/questions/3684463/php-foreach-with-nested-array">PHP foreach with Nested Array?</a></p>
php
[2]
3,472,630
3,472,631
How to reload python module from itself?
<p>I have a python module with a lot of variables. These variables are used and changed by many other modules. And I want to reload this module from itself when it happens (for refresh).</p> <p>How to do that?</p> <pre><code># ================================== # foo.py spam = 100 def set_spam(value): spam = value foo = reload(foo) # reload module from itself # ================================== # bar.py import foo print foo.spam # I expect 100 # assume that value changes here from some another modules (for example, from eggs.py, apple.py and fruit.py) foo.set_spam(200) print foo.spam # I expect 200 </code></pre>
python
[7]
1,091,957
1,091,958
How to find all comments in the source code?
<p>There are two style of comments , C-style and C++ style, how to recognize them?</p> <pre><code>/* comments */ // comments </code></pre> <p>I am feel free to use any methods and 3rd-libraries.</p>
java
[1]
706,551
706,552
Get specific item property on onListItemClick() using custom ArrayAdapter<>
<p>I have a <code>ListActivity</code> that displays a list of search results I grab from a webservice off the internet. I parse the XML I receive into an <code>ArrayList&lt;MyObjects&gt;</code> which I then bind to a <code>ListView</code> using my own adapter (as in <code>MyObjectAdapter</code> extends <code>ArrayAdapter&lt;MyObject&gt;</code>).</p> <p>So then I want the user to be able to click on one of the items in the list. Each item has an identifier which will then be put into an intent and sent to a new activity (which then triggers a new webservice request based on this, downloads the rest of the data). But I don't know how to get this one property of the <code>MyObject</code> that was selected.</p> <p>Here's the <code>onListItemClick()</code> method as it stands:</p> <pre><code>@Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String myObjectId; // I want to get this out of the selected MyObject class here Intent i = new Intent(this, ViewObject.class); i.putExtra("identifier_key", myObjectId); startActivityForResult(i, ACTIVITY_VIEW); } </code></pre>
android
[4]
2,438,865
2,438,866
Change function input submit to id
<p>I'm looking at some code here that targets the dom by the type="submit" and I'm trying to change it to be the id="go" of a input or button in the dom. How can I rewrite this to still work.</p> <pre><code> t.addEventListener("submit", function (A) { A.preventDefault(); var C = w(); var B = new C; B.append(q.value || q.placeholder); saveAs(B.getBlob("text/plain;charset=" + s.characterSet), (h.value || h.placeholder) + ".html") }, false); </code></pre>
javascript
[3]
573,656
573,657
How often do you find javascript disabled on browsers?
<p>I have started using ajax/jQuery in our websites / application. There are many plugins that support degrading the javascript to browsers that dont have javascript enabled and techniques to support this. What are peoples thoughts on javascript support, we build applications rather than just websites and are looking to just support javascript enabled browsers as a pre-requisite assuming that most people or companies have javascript enabled. Do you find most people have javascript? do you monitor the percentage of javascript/non-javascript browsers (I guess this can be done with website stats) and what are the numbers regarding this?</p>
javascript
[3]
5,296,860
5,296,861
how to re-bind click() event after using "datatables" search
<p>I have a table that I'm displaying using datatables. One of the columns in the table is a checkbox. Checking (or unchecking) the checkbox causes an Ajax event. Like so:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $(".data-table").dataTable({}); $(".my-checkbox").click(function() { $.ajax(....) }) }) &lt;/script&gt; &lt;table class="data-table"&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" class="my-checkbox"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;!-- repeat many times --&gt; &lt;/table&gt; </code></pre> <p>This works great on the initial page load, but as soon as I use the "search" box, the change() method is unbound from anything found by search.</p> <p>Is there an API hook that I can use to re-bind my click() handler to the checkboxes once the search is complete? Or is there a better way?</p>
jquery
[5]
923,514
923,515
php call python without exec permission
<p>My assigment requires me to run a python file through webpage. I tried calling this php page through ajax</p> <pre><code>if ( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) { exec("rm index.*"); print exec("wget -O index.html http: markets.usatoday.com/custom/usatoday-com/html-mktscreener.asp"); print exec("python hw7-9.py index.html"); print "Done!"; } else { print "Nice try!"; //someone is trying to manually run } </code></pre> <p>However I just realized that I don't have exec function permissions (after trying echo exec('whoami'). I chmod the file to 777.</p> <p>I need to someone run the python script through some sort of ajax call. I am running on an afs system with SunOS. </p>
php
[2]
148,825
148,826
Type of a wildcard object without using "instanceof"
<p>In the code below, I don't want to use <code>instanceof</code> to know the type of repository. Is it the only way to get the type? Is it possible to know de type with the wildcard <code>RepositoryVet&lt;?&gt;</code>? This would save me doing lots of test.</p> <pre><code>public ArrayList&lt;String&gt; rechercherTabTailles(String sexe,String SI,RepositoryVet&lt;?&gt; repository) { ArrayList&lt;String&gt; tabTailles; repository.Open(); repository.rechercherspin(sexe); if (SI.compareTo("US") == 0) { if (repository instanceof ChaussureRepository) tabTailles= ((ChaussureRepository) repository).taillesUS; if (repository instanceof ChemiseRepository) tabTailles= ((ChemiseRepository) repository).taillesUS; } } </code></pre> <p>To complete my question : RepositoryVet is already an abstractClass defined like this :</p> <p>public abstract class RepositoryVet implements IRepositoryVet {</p> <pre><code>public ArrayList&lt;String&gt; taillesEU; public ArrayList&lt;String&gt; taillesUS; public ArrayList&lt;String&gt; taillesUK; public ArrayList&lt;String&gt; taillesIT; public ArrayList&lt;String&gt; taillesJP; public ArrayList&lt;String&gt; taillescm; public ArrayList&lt;String&gt; taillesinch; </code></pre> <p>etc.... }</p> <p>And "ChaussureRepository" is a class that extends RepositoryVet like this :</p> <p>public class ChaussureRepository extends RepositoryVet {</p> <pre><code>public ArrayList&lt;String&gt; taillesEU; public ArrayList&lt;String&gt; taillesUS; public ArrayList&lt;String&gt; taillesUK; public ArrayList&lt;String&gt; taillesIT; public ArrayList&lt;String&gt; taillesJP; public ArrayList&lt;String&gt; taillescm; public ArrayList&lt;String&gt; taillesinch; </code></pre> <p>etc....</p>
java
[1]
5,397,575
5,397,576
removing dot symbol from a string
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2390789/how-to-replace-all-points-in-a-string-in-javascript">How to replace all points in a string in JavaScript</a> </p> </blockquote> <p>I am trying to remove '.'(dot) symbol from my string. and The code that Ive used is </p> <pre><code>checkedNew = checked.replace('.', ""); </code></pre> <p>Bt when I try to alert the value of checkedNew, for example if the checkedNew has original value U.S. Marshal, the output that I get is US. Marshal, it will not remove the second dot in that string. How do remove all dot symbols?</p>
javascript
[3]
5,942,943
5,942,944
regex Illegal repetition
<p>I have a string array of operators that I am iterating through. When I find one that exists in <code>strLine</code>, I replace the first instance of it with a blank string. When I get to the <code>{</code>, I get the <code>java.util.regex.PatternSyntaxException: Illegal repetition</code>.</p> <p>Now, I know that the <code>{</code> is a special java operator so that is the reason it is failing. What would be the best way to escape this character with the setup I have now?</p> <pre><code>String[] operators = {".", ",", "{", "}", "!", "++", "--", "*", "/", "%", "+", "-", "&lt;"} String strLine = "for (int count = input.length(); count &gt; 0; count--) {"; strLine = strLine.trim(); for (int i = 0; i &lt; operators.length; i++) { if(strLine.contains(operators[i])) { strLine = strLine.replaceFirst(operators[i]+"\\s*", ""); System.out.println("Removal of: " + operators[i]); System.out.println("Sentence after removal: " + strLine); } } </code></pre>
java
[1]
4,818,769
4,818,770
TypeError when assigning a random value from a list to a variable?
<p>I have a list and I want to assign a random element from that list to a new variable five times in order to generate a hand of cards. I've searched, and I can't seem to understand why my random.choice is causing errors.</p> <pre><code>import random cards = { '2' '3' '4' '5' '6' '7' '8' '9' 'J' 'Q' 'K' 'A' } for newCard in range(5): newDraw = random.choice(cards) playerdeck.append(newDraw) if newDraw in playerdeck: playermatches = playermatches + 1 newDraw = oldDraw </code></pre> <p>When I try to run it I get this error:</p> <pre><code>Traceback (most recent call last): File "C:\Users\Nathaniel\Desktop\Fcard.py", line 6, in &lt;module&gt; newDraw = random.choice(cards) File "C:\Python32\lib\random.py", line 253, in choice return seq[i] TypeError: 'set' object does not support indexing </code></pre>
python
[7]
4,037,201
4,037,202
page method vs web service
<p>Since a page method can only be called from the browser page that's talking to the aspx page that created the client, is it a correct assumption that a page method is more secure than a web service that's live on the internet for anyone to connect to?</p> <p>Thanks.</p>
asp.net
[9]
3,141,747
3,141,748
if any email is set in textview then open the default email client if clicked
<p>In my app if any number is set then on clicking it starts a call on that number, and if any website link is given then also it shows that underline and on clicking that it opens the browser.</p> <p>Similarly, I want to open the email client if any email address is set in the textview and show it underline.</p>
android
[4]
545,107
545,108
How to copy and output text from another textbox with Javascript?
<pre><code>&lt;input type="hidden" id="prevTicketNo" value="6"/&gt; &lt;script&gt; var ticketNo = document.getElementById(prevTicketNo).value +1; document.getElementById('currentTicketNo').value = ticketNo; &lt;/script&gt; &lt;input id="currentTicketNo" value=""/&gt; </code></pre> <p>What I am trying to do: The prevTicketNo is a value captured from somewhere else. I need that to load as a hidden field so I used type="hidden". Once the value in this textbox is loaded, I need to +1 so that the number increases for my current ticket.</p> <p>Is the right approach?</p>
javascript
[3]
3,119,111
3,119,112
Splash screen opens only first time application starts
<p>There is an application with 2 activities: Splash screen and main screen. After installing application it shows splash, then finishes Splash activity and starts main activity. Then i test 3 scenarios:</p> <ol> <li><p>App is launched, second activity showed on screen. I kill app process by DDMS, launch app again — everything is right — i see splash again, then second activity</p></li> <li><p>App is launched, second activity showed on screen. I press back key, then kill process, launch application again — everything all right too, it launch splash first</p></li> <li><p>App is launched, second activity showed on screen. I press home key, then kill process, launch application again — and there is surprise — <strong>application starts on second activity, escaping splash</strong>.</p></li> </ol> <p>What`s wrong?</p> <p>There is some others question like this one, but i still got no answer.</p> <p>Can anybody explain this behavior?</p>
android
[4]
683,190
683,191
Issues with Adding 1 month to a Unix time stamp
<p>For some reason, I cannot get strtotime('+1 month) to work. Here is my code;</p> <pre><code>$Date = $_REQUEST['date']; //This is a unix time stamp $Start = $_REQUEST['start']; //This is a unix time stamp $End = $_REQUEST['end']; //This is a unix time stamp </code></pre> <p>to add a month onto my dates;</p> <pre><code>$monStart =strtotime('+1 month', $Start); $monEnd =strtotime('+1 month', $End); $monDate =strtotime('+1 month', $Date); </code></pre> <p>then to show my changed dates;</p> <pre><code>$vEnd = date('m/d/Y', $monEnd); $vStart = date('m/d/Y', $monStart); $vDate = date('m/d/Y', $monDate); </code></pre> <p>The problem that I have is that the supplied dates; </p> <pre><code>$Date = 1/31/2013 $Start = 1/01/2013 $End = 1/31/2013 </code></pre> <p>Return;</p> <pre><code>$vDate = 3/03/2013 $vStart = 2/01/2013 //Only correct one $vEnd = 3/03/2013 </code></pre> <p>Please can someone help me?</p>
php
[2]
4,992,158
4,992,159
Using Math Functions in an IF statement
<p>Hi I've just started to learn JavaScript. I'm doing the exercises on <a href="http://www.codecademy.com/" rel="nofollow">http://www.codecademy.com/</a>. You can read it below:</p> <p>FizzBuzz is a children's game where you count from 1 to 20. Easy, right?</p> <p>Here's the catch: instead of saying numbers divisible by 3, say "Fizz". And instead of saying numbers divisible by 5, say "Buzz". For numbers divisible by both 3 and 5, say "FizzBuzz".</p> <p>"1, 2, Fizz, 4, Buzz"...and so forth</p> <p>Let's start by using console.log to print out all of the numbers from 1 and 20.</p> <p>But don't type out the numbers in order—find a more awesome way!</p> <p>I can get the numbers to print using a for loop but now I don't know how to replace the numbers with strings. </p> <p>I thought about doing an IF statement like "if i divided by 3 is zero, then print Fizz" but I'm not sure how to do it. See what I've done so far below:</p> <pre><code>var i; for (i = 0; i &lt;=20; i++) { console.log(i); } if (i / 3 = 0) { console.log("Fizz") } </code></pre> <p>Any help would be great. </p>
javascript
[3]
1,312,159
1,312,160
Turn off a Android Service when the user is not on the their home screen!
<p>I need to turn a App / Widget Service off when a user isn't on their homescreen and on / update when they are. Is that possible?</p>
android
[4]
1,220,893
1,220,894
Extend Dialog goes wrong in android
<p>I extend a Dialog</p> <p>java code</p> <pre><code>public class Dialog_query extends Dialog implements OnClickListener { } </code></pre> <p>Through the XML defines a interface <img src="http://i.stack.imgur.com/HFuZm.jpg" alt="enter image description here"></p> <p>Now want to select date by clicking on 日期1 The code is as follow Recorded as:code button</p> <p>java button</p> <pre><code>Button btn=(Button)findViewById(R.id.BtnDate); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new DatePickerDialog(Dialog_query.this, d2, dateAndTime.get(Calendar.YEAR), dateAndTime.get(Calendar.MONTH), dateAndTime.get(Calendar.DAY_OF_MONTH) ).show(); } }); </code></pre> <p>Now the question is,point out"The constructor DatePickerDialog(Dialog_query, DatePickerDialog.OnDateSetListener, int, int, int) is undefined"</p> <p>Later found in here to add"Toast.makeText(LoginSuccess.this, "About agile software 1.0", Toast.LENGTH_LONG).show();"</p> <p>also point out"The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (Dialog_query, String, int)"</p> <p>But the "code button" is right in Activity.</p> <p>Why in the extend cases will prompt such a mistake?</p>
android
[4]
4,362,748
4,362,749
Small initialization problem
<p>I need a little help in the below initialization. What's wrong I'm doing below.</p> <pre><code>DateTimeOffset? dateTimeFrom, dateTimeTo = null; </code></pre> <p>I'm getting an error "Use of Unassigned local variable dateTimeFrom".</p> <p>Also is there any other way to convert nullable DateTime to nullable DateTimeOffset.</p> <p>What currently I'm doing is:</p> <pre><code>DateTimeOffset? dateTimeFrom, dateTimeTo = null; if (ViewModel.FromDate.HasValue) dateTimeFrom = new DateTimeOffset(ViewModel.FromDate.Value); if (ViewModel.ToDate.HasValue) dateTimeTo = new DateTimeOffset(ViewModel.ToDate.Value); </code></pre> <p>But I think there is a better and elegant way to do the above steps also.</p>
c#
[0]
3,178,378
3,178,379
Change (or) Alter scope of a function, within the function in javascript
<p>As the question says,</p> <p>I want to know that if there a way to change scope of a function like this,</p> <pre><code>function foo(){ var t = this; log(t);//{bar:'baz'} /*** Do something over here to change the scope ***/ var newThis = this; log(newThis); //{something:'somethingelse'} } </code></pre> <p>I am just curious to know, if there is a way.</p> <p>Thanks</p>
javascript
[3]
1,817,175
1,817,176
jQuery Image Gallery with jCarousel with changing preview
<p>I found this script: <a href="http://www.queness.com/post/3036/create-a-custom-jquery-image-gallery-with-jcarousel" rel="nofollow">http://www.queness.com/post/3036/create-a-custom-jquery-image-gallery-with-jcarousel</a></p> <p>which has everything I need except one thing. On right side selection is changing but preview on left side is same all the time.</p> <p>Does anyone knows how to change this?</p>
jquery
[5]
2,546,833
2,546,834
the procedure entry point ?_Xmem@tr1@std@@YAXXZ could not be located in the dynamic link library MSVCP90D.dll
<p>I have installed VS2008 FeaturePack so as to work with regular expressions in C++. However when I execute the program i get the following error.</p> <p>the procedure entry point ?_Xmem@tr1@std@@YAXXZ could not be located in the dynamic link library MSVCP90D.dll.</p> <p>How could have gone wrong?</p> <p>Thanks and Regards, SS</p>
c++
[6]
4,096,708
4,096,709
Can open URL HTML
<p>Can I check if I can open a URL like <strong>OBLevel://id=18291234</strong> in JavaScript before I link to it?</p> <p>Thank you!</p>
javascript
[3]
1,363,557
1,363,558
How to click and "unclick" an element
<p>Okay, I'm a real beginner when it comes to jQuery, and although I've tried searching for this already, I can't seem to find an answer (I'm probably not phrasing it correctly).</p> <p>When one of the li's are clicked, I want to add an element. However, if the li has already been clicked (and the class already added), if the user clicks again, I want the class removed. So far, this is what I have:</p> <pre><code>(function($){ $(".list li").click(function() { $(this).addClass("hilite"); $(this).attr("BeenClicked", "true"); }); })(jQuery); &lt;ul class="list"&gt; &lt;li&gt; Something &lt;li&gt; Something else &lt;/ul&gt; </code></pre> <p>I need to create code that essentially checks the attribute to see if "BeenClicked" is set to true.</p>
jquery
[5]
2,728,484
2,728,485
Neet a simple example about Multi client - server in C#
<p>I'm using C# to develop my application for exercises!</p> <p>I want to use 1 server and 2 clients that connect to the server!</p> <p>For ex</p> <p><pre>client 1: connect and send a string to the server - server recive that string and say reply</pre> <pre>client 2: work as client 1</pre></p> <p>i want its using RPC </p> <p>// sr about my English, i'm a vietnamese</p>
c#
[0]
1,954,393
1,954,394
displaying message in PyQt4
<p>I am developing an application using PyQt4 .</p> <p>Currently I am in need of a message box ie if I am on a current screen and user presses a function the callback function should display message whether by a message box or any other way you can suggest ......However when the user cancels it the flow should go to the current screen.</p> <p>Please help ....</p> <p>Thanks a lot.. </p>
python
[7]
2,313,205
2,313,206
how to handle conflict resolution interceptor in the sync service for timestamp based synchronisation
<p>see this code and tell me any suggetions for timestamp based synchronization when data changed for particular record in a particular table in both client and server databases.After i Synchrosize there conflict will arise.at that time i need timestamp based synchronisation.</p> <p>Is it possible?</p> <p>if possible suggest me..</p> <p>Thanks in advance...</p> <pre><code>#region SyncService: Configuration and setup public class DefaultScopeSyncService : Microsoft.Synchronization.Services.SyncService&lt;DefaultScopeOfflineEntities&gt; { public static void InitializeService(Microsoft.Synchronization.Services.ISyncServiceConfiguration config) { config.ServerConnectionString = ConfigurationManager.ConnectionStrings["ListDbConnectionString"].ToString(); config.SetEnableScope("DefaultScope"); config.AddFilterParameterConfiguration("userid", "User", "@ID", typeof(System.Guid)); config.AddFilterParameterConfiguration("userid", "List", "@UserID", typeof(System.Guid)); config.UseVerboseErrors = true; config.EnableDiagnosticPage = true; } [SyncConflictInterceptor("DefaultScope",EntityType=typeof(LookupType))] public SyncConflictResolution ConflictHandler(SyncConflictContext context, out IOfflineEntity mergedEntity) { context.ResponseHeaders.Add("ConflictInterceptorFired", "true"); mergedEntity = null; return SyncConflictResolution.Merge; } } #endregion </code></pre>
c#
[0]
4,526,115
4,526,116
change size of MPMoviePlayerController view
<p>How to change size of MPMoviePlayerController views. Now it is covering full screen in landscape mode. Can we resize to half size or other size? I want display only half screen and other video related info display in remaining screen? Is it possible? </p>
iphone
[8]
5,745,754
5,745,755
Display image in image control from folder
<p>I try to display image in image control from folder. i'm getting image like icon.</p> <p>code:</p> <pre><code> imgPhoto.ImageUrl = Server.MapPath("~\Document\Employee Photos\" &amp; Session("EmpBadge") &amp; ".jpg") </code></pre> <p>thanks</p>
asp.net
[9]
5,344,454
5,344,455
Android Keyevent injection requires system permissions
<p>hi i am using key event injection using window manager but when i tested this application it gives me error </p> <pre><code> 04-12 18:19:35.794: WARN/WindowManager(58): Permission denied: injecting key event from pid 6290 uid 10039 to window Window{45034880 com.android.launcher/com.android.launcher2.Launcher paused=false} owned by uid 10020 04-12 18:19:35.794: WARN/System.err(6290): java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission 04-12 18:19:35.854: DEBUG/PhoneData(6290): 04-12 18:19:36.048: WARN/System.err(6290): at android.os.Parcel.readException(Parcel.java:1247) 04-12 18:19:36.048: WARN/System.err(6290): at android.os.Parcel.readException(Parcel.java:1235) </code></pre> <p>I also give the inject event permission is there any way to give a application system permissions.</p>
android
[4]
860,810
860,811
How to redirect to a new window without reloading the parent page in ASP.NET?
<p>I have found this class here:</p> <p><a href="http://weblogs.asp.net/infinitiesloop/archive/2007/09/25/response-redirect-into-a-new-window-with-extension-methods.aspx" rel="nofollow">http://weblogs.asp.net/infinitiesloop/archive/2007/09/25/response-redirect-into-a-new-window-with-extension-methods.aspx</a></p> <pre><code>public static class ResponseHelper { public static void Redirect(string url, string target, string windowFeatures) { HttpContext context = HttpContext.Current; if ((String.IsNullOrEmpty(target) || target.Equals("_self", StringComparison.OrdinalIgnoreCase)) &amp;&amp; String.IsNullOrEmpty(windowFeatures)) { context.Response.Redirect(url); } else { Page page = (Page)context.Handler; if (page == null) { throw new InvalidOperationException( "Cannot redirect to new window outside Page context."); } url = page.ResolveClientUrl(url); string script; if (!String.IsNullOrEmpty(windowFeatures)) { script = @"window.open(""{0}"", ""{1}"", ""{2}"");"; } else { script = @"window.open(""{0}"", ""{1}"");"; } script = String.Format(script, url, target, windowFeatures); ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true); } } } </code></pre> <p>it works except that it reloads the parent page which is annoying in my case.</p> <p>How to avoid that ?</p> <p>Thanks.</p>
asp.net
[9]
5,475,666
5,475,667
Android downloading
<p>I downloaded the Android SDK installer file and when i installed it, it launches the SDK manager which then installs many things. i have the following doubts</p> <ol> <li>Are the things which the Android SDK manager asks us for installing essential because i have a very slow Internet connection and the file size under SDK manager is too high.</li> <li>Secondly if files under SDK manager can be downloaded on a different computer with high speed Internet connection and then can be copied to my computer ? Is this possible?</li> </ol>
android
[4]
2,674,965
2,674,966
Error permitted_uri_chars in CodeIgniter
<p>i have make an page controller and i can generate the pages with tinymce</p> <p>the problem is when the page name is arabic like this</p> <p>Example:http://domain/solarBlog/blog/category/السلمي</p> <p>showing error</p> <blockquote> <p><strong>The URI you submitted has disallowed characters</strong></p> </blockquote> <p>is there any way to make the uri allowing the arabic characters ?</p> <p>also im using the default</p> <pre><code>$config[‘permitted_uri_chars’] = ‘a-z 0-9~%.:_\-’; </code></pre> <blockquote> <p><strong>Please note that I used version 2.1.0</strong></p> </blockquote>
php
[2]
5,452,523
5,452,524
Very simple jQuery countdown
<p>I want to do two things using a countdown in jQuery. I have looked at the delay method but it won't be applied to an element like shown in the docs.</p> <p>What I want to do is wait 2 hours and then 30 seconds before the timeout do function A and then after that do function B.</p> <p>During function A I will be showing a modal where I want to show a message saying you have 30 seconds to respond. And show the 30 counting down before executing function B.</p> <p>What would be the best and simplest way of doing all of this?</p> <p>Thanks</p>
jquery
[5]