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
610,109
610,110
JQuery Trim as Text Enters field
<p>Hi I have some code..</p> <pre><code>$(document).ready(function() { $("#inputPageName").keyup(function () { var value = $(this).val(); $("#inputPageHandle").val(value); }).keyup(); }); </code></pre> <p>Basically I need to create a page handle in a hidden field so when the user type in the PageName field it update the PageHandle field however I want to use jQuery.trim() to remove the spaces that the user my put in the PageName field</p> <p>Any ideas?</p>
jquery
[5]
1,360,830
1,360,831
Defining NSString
<p>How can I define a NSString with name <code>media:thumbnail</code>, It's giving me an error.</p> <pre><code>error:bit-field 'media' has invalid type </code></pre>
iphone
[8]
1,540,748
1,540,749
doesn't know a type (casting)
<p>I want to add a variable in a message header so I used <code>unit8_t</code> to define them but when I want to read this variable I need to cast it in double I did: </p> <pre><code>hello.positionx = unit8_t (m_ipv4-&gt;GetObject&lt;MobilityModel&gt; ()-&gt;GetPosition ().x); hello.positiony = unit8_t (m_ipv4-&gt;GetObject&lt;MobilityModel&gt; ()-&gt;GetPosition ().y); </code></pre> <p>as you can see these lines are similar but when I run my program it shows an error in second line which : <code>unit8_t</code> in not defined in this scope<br> I added the Header : </p> <pre><code> #include"stdint.h" </code></pre> <p>I don't know, what's the meaning of this error. I will be thankful if you help me . </p>
c++
[6]
4,040,040
4,040,041
Is it possible to sort two lists(which reference each other) in the exact same way?
<p>Okay, this may not be the smartest idea but I was a bit curious if this is possible. Say I have two lists:</p> <pre><code>list1 = [3,2,4,1, 1] list2 = [three, two, four, one, one2] </code></pre> <p>If I run <code>list1.sort()</code>, it'll sort it to <code>[1,1,2,3,4]</code> but is there a way to get to keep list2 in sync as well(so I can say item 4 belongs to 'three')? My problem is I have a pretty complex program that is working fine with lists but I sort of need to start referencing some data. I know this is a perfect situation for dictionaries but I'm trying to avoid dictionaries in my processing because I do need to sort the key values(if I must use dictionaries I know how to use them).</p> <p>Basically the nature of this program is, the data comes in a random order(like above), I need to sort it, process it and then send out the results(order doesn't matter but users need to know which result belongs to which key). I thought about putting it in a dictionary first, then sorting list one but I would have no way of differentiating of items in the with the same value if order is not maintained(it may have an impact when communicating the results to users). So ideally, once I get the lists I would rather figure out a way to sort both lists together. Is this possible?</p>
python
[7]
2,212,201
2,212,202
pear DB: very strange behaviour
<p>Consider the following code</p> <pre><code> $dsn = array('phptype' =&gt; 'mysql', 'username' =&gt; Config::DB_STORE_USERNAME, 'password' =&gt; Config::DB_STORE_PASSWORD, 'hostspec' =&gt; Config::DB_STORE_HOSTNAME, 'database' =&gt; Config::DB_STORE_NAME); echo '222222'; $db = DB::connect($dsn); echo '111111'; if (PEAR::isError($db)) { echo '2143234234235'; return null; } </code></pre> <p><code>222222</code> is outputed while <code>111111</code>. Still no error is outputed (in <code>php.ini</code> <code>error_reporting</code> is <code>E_ALL</code>). Have you any idea how is it possible to track the issue?</p> <p><strong>UPD:</strong> if it helps, I installed DB not with <code>pear install DB</code> but simply downloaded and unpacked archive.</p>
php
[2]
5,598,053
5,598,054
Creating date with numbers (new Date(2012, 03, ...) gives wrong month (+1)
<p>When creating a <code>new Date</code> object using numbers for the parts, the value I get back is exactly <strong>one month</strong> ahead of the value I put in for 'month'. </p> <pre><code>new Date(2012, 05, 17, 00, 00, 00) Sun Jun 17 2012 00:00:00 GMT+0800 (HKT) // june?! </code></pre> <p>However, a normal parse of exactly the same string returns the correct time:</p> <pre><code>new Date("2012-05-17 00:00:00") Thu May 17 2012 00:00:00 GMT+0800 (HKT) </code></pre> <p>I get the same result in ie/ff/chrome. Removing hours/min/seconds doesn't have any effect. I can work around it by subtracting one before setting the month, but instead I just switched to writing out my date as a string.</p> <p><strong>Edit:</strong> <em>The string parse doesn't work in IE. I have no idea what I did, but I swear I made that work. Thats prob. why I avoided it in the first place. I've switched to using moment.js for now.</em></p> <p>Ah, now I get it. Just like regular java dates, which I don't code in except rarely, and even then always with a library (joda, etc). What a terrible idea anyway. Here is skeets take on the question: <a href="http://stackoverflow.com/questions/344380/why-is-january-month-0-in-java-calendar">Why is January month 0 in Java Calendar?</a></p> <p>Why is this happening? </p>
javascript
[3]
2,834,176
2,834,177
Java IB API/ TWS get mulitple quotes/price of the company
<p>Am using java ib api / traders workstaion, now am getting current price for company using ticketprice, is there anyway to get multiple quotes</p>
java
[1]
2,574,251
2,574,252
Pass an object as parameter in PHP
<p>In Java, I can pass an object straight in parameter </p> <pre><code>public int foo (Bar bar) { ... call the methods from Bar class } </code></pre> <p>So how can I do same thing with PHP. Thanks This is my code:</p> <pre><code>class Photo { private $id, $name, $description; public function Photo($id, $name, $description) { $this-&gt;id = $id; $this-&gt;name = $name; $this-&gt;description = $description; } } class Photos { private $id = 0; private $photos = array(); private function add(Photo $photo) { array_push($this-&gt;photos, $photo); } public function addPhoto($name, $description) { add(new Photo(++$this-&gt;id, $name, $description)); } } $photos = new Photos(); $photos-&gt;addPhoto('a', 'fsdfasd'); var_dump($photos); // blank </code></pre> <p>If I change the function add</p> <pre><code>function add($name, $description) { array_push($this-&gt;photos, new Photo(++$this-&gt;id, $name, $description)); } </code></pre> <p>It works pefectly. So What is wrong ?</p>
php
[2]
2,673,261
2,673,262
Best practice for passing object
<p>I have a little simple question.</p> <p>Let's say I have a data object with about 10 properties, and I want to pass data from my object to a function. Most of the time I only need one of these values in the receiving function, and could just as well pass only that value (let's say an int). So what is the pros and cons with always sending the whole object vs only sending one of the contained values?</p> <p>Is there a best practice?</p>
c#
[0]
516,981
516,982
OLE AUTOMATION WITH PHP or PHP-CLI?
<p>I read here <a href="http://www.daniweb.com/code/snippet217293.html#" rel="nofollow">http://www.daniweb.com/code/snippet217293.html#</a> it is possible.</p> <p>What should be activated in PHP.Ini or elsewhere to make this work ? Are there any examples with Excel ?</p>
php
[2]
5,988,556
5,988,557
jQuery animate .prepend
<p>Rather than simply dumping the HTML into the page I want it to be animated, how can I change the jQuery below to either animate or slide down as the HTML is inserted?</p> <pre><code>$('.button').click(function() { j('.tweets ul').prepend(j('.refreshMe ul').html()); }); </code></pre>
jquery
[5]
4,908,166
4,908,167
JavaScript: Return owner method from inside onclick function
<p>I am currently writing a custom dialog box script in JavaScript (to show dialog boxes with a choice of buttons, titles, etc.) thus mimicking C#'s MessageBox.Show() method. However, I'm having problems with correctly returning values from the function.</p> <p>For example, the Show() method I have created is static, and called as follows from a button click:</p> <pre><code>&lt;input type="button" onclick="return MessageBox.Show(dialogueMessage, 'Really Delete?', 'confirm', false)") /&gt; </code></pre> <p>Once the MethodBox.Show() function has been called, the dialog is displayed. I would like the option so that when a user clicks on the "Yes" button, the MessageBox.Show() function returns true, otherwise it returns false. The code I have for creating the (dynamic) buttons is as follows:</p> <pre><code>var yesButton = document.createElement('input'); yesButton.setAttribute('type', 'button'); yesButton.setAttribute('value', 'Yes'); yesButton.setAttribute('name', 'button-yes'); yesButton.onclick = function() { MessageBox.Hide(); return true; }; var noButton = document.createElement('input'); noButton.setAttribute('type', 'button'); noButton.setAttribute('value', 'No'); noButton.setAttribute('name', 'button-no'); noButton.onclick = function() { MessageBox.Hide(); return false; }; </code></pre> <p>However, as you can appreciate, the 'return false' / 'return true' statements refer to the button itself, and not the function (MessageBox.Show()). What I would like to know, is if there's a method I can use return the function when (and only when) the user clicks one of the buttons, so that the button clicked to call the function can be correctly used.</p> <p>It's difficult for me to explain what I'm trying to achieve, but the above should make sense.</p> <p>Thanks, Ben.</p>
javascript
[3]
5,914,721
5,914,722
Possible to get user input without inserting a new line?
<p>I know I can stop print from writing a newline by adding a comma</p> <pre><code>print "Hello, world!", </code></pre> <p>But how do I stop <code>raw_input</code> from writing a newline?</p> <pre><code>print "Hello, ", name = raw_input() print ", how do you do?" </code></pre> <p>Result:</p> <blockquote> <p>Hello, Tomas<br /> , how do you do?</p> </blockquote> <p>Result I want:</p> <blockquote> <p>Hello, Tomas, how do you do?</p> </blockquote>
python
[7]
3,269,977
3,269,978
How to check url is valid or not for thousands of nodes together in very short time?
<p>I have a need of checking a particular url <code>"http://16.100.106.4/xmldata?item=all"</code> if it is working or not? Now thing is that, I use the below code if url does not work then connection timeout waits for about 20 seconds before giving exception. Now, I have to check the URL for around 20000 IPs and i can not afford to wait for that long time. Threading can be an option but with that also I am not sure till how much thread should I go. I want the whole operation to be done in matter of seconds.</p> <pre><code>public static boolean exists(String URLName){ boolean available = false; try{ final URLConnection connection = (URLConnection) new URL(URLName).openConnection(); connection.connect(); System.out.println("Service " + URLName + " available, yeah!"); available = true; } catch(final MalformedURLException e){ throw new IllegalStateException("Bad URL: " + available, e); } catch(final Exception e){ // System.out.print("Service " + available + " unavailable, oh no!", e); available = false; } return available; } </code></pre>
java
[1]
2,776,509
2,776,510
How to use comparison and ' if not' in python?
<p>In one piece of my program I doubt if i use the comparison correctly. i want to make sure that ( u0 &lt;= u &lt; u0+step ) before do something. </p> <pre><code>if not (u0 &lt;= u) and (u &lt; u0+step): u0 = u0+ step # change the condition until it is satisfied else: do something. # condition is satisfied </code></pre> <p>Thanks for suggestions :)</p>
python
[7]
3,005,895
3,005,896
iOS app for installing to remote device using UDID Build Error
<p>Hi I am not new to titanium but i am new in creating the ipa using the titanium.The problem is that when i provide the provisioning file to the titnaium it start to build but it gives the following error</p> <pre><code> ERROR] [DEBUG] While reading /Users/aadilf/Desktop/QLD Best Bets/build/iphone/build/Debug-iphoneos/QLD Best Bets.app/images/icon.png pngcrush caught libpng error: [ERROR] [ERROR] While reading /Users/aadilf/Desktop/QLD Best Bets/build/iphone/build/Debug-iphoneos/QLD Best Bets.app/images/icon.png pngcrush caught libpng error: [ERROR] [ERROR] Error: Traceback (most recent call last): File "/Library/Application Support/Titanium/mobilesdk/osx/2.1.3.GA/iphone/builder.py", line 1477, in main execute_xcode("iphoneos%s" % iphone_version,args,False) File "/Library/Application Support/Titanium/mobilesdk/osx/2.1.3.GA/iphone/builder.py", line 1231, in execute_xcode output = run.run(args,False,False,o) File "/Library/Application Support/Titanium/mobilesdk/osx/2.1.3.GA/iphone/run.py", line 41, in run sys.exit(rc) SystemExit: 65 </code></pre>
iphone
[8]
1,090,004
1,090,005
error with using include_once in php
<p>I have a file header where i have created variables for all the paths i need, like this:</p> <pre><code>$GLOBAL_stylePath = "http://localhost/pspace/css/"; </code></pre> <p>(if i shouldn't use http in the above, then how would it be? C://htdocs/xampp/pspace/css/ ???)</p> <pre><code>include_once "/classes/authorizationUtils.php"; $authorizationUtils = new AuthorizationUtils(); </code></pre> <p>anyways, the includes are messing up everything and giving me errors such as:</p> <pre><code>Warning: include_once() [function.include-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\pspace\includes\header.php on line 12 </code></pre> <p>how can i enable this configuration in my php.in. i have a variable allow_url_include=off, when i "on" it, no changes happen. and also this:</p> <pre><code>Warning: include_once() [function.include]: Failed opening 'http://localhost/pspace/classes/authorizationUtils.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\pspace\includes\header.php on line 12 </code></pre>
php
[2]
3,328,205
3,328,206
How to integrate Linkedin with my android application?
<p>i want to integrate linkedin with my android app. In this i want to do login with linkedin and to do post on my linked account.</p> <p>So can you help me how i can do it? Please reply ASAP.</p> <p>and also give steps to follow?</p>
android
[4]
4,017,057
4,017,058
How to select a particular value from a <select> element?
<p>I have come across <code>&lt;select&gt;</code> (drop down list) in HTML in the learning process. I learnt how to code a <code>&lt;select&gt;</code> drop down list.</p> <p>How can I perform a particular action (in my case I am performing a mathematical operation) when a value in the <code>&lt;select&gt;</code> is chosen?</p>
javascript
[3]
1,702,015
1,702,016
Can I play sound from this class into another class and control it from the other class
<p><a href="http://pastie.org/1887099" rel="nofollow">http://pastie.org/1887099</a></p> <p>I want to be able to control this sound from another class via a JButton from a different class.</p>
java
[1]
5,414,468
5,414,469
Playing flv android
<p>Can we play flv stream videos in Android without using WebView, it's too slow? I mean play .flv video directly from url. Any ideas? VideoView now work with the .flv link.</p>
android
[4]
5,058,229
5,058,230
how do I close all the activities in Android in one simple click
<p>I know that the mechanism of android about stacks work as a stack each one of them goes above each other, what i want is how to make it clear and exit the app with one single click. I google it and i found some long code instead of this should have been very easily and simple to do it.</p> <p>Thanx</p>
android
[4]
5,607,752
5,607,753
Python - passing a string as input to a command
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/967443/python-module-to-shellquote-unshellquote">Python module to shellquote/unshellquote?</a> </p> </blockquote> <p>I am trying to pass a string's value into a command as input, in Python for executing a bash command. I currently have somthing like this:</p> <pre><code>cmd = 'echo ' + &lt;StringValue&gt; + ' | command' output = commands.getOutput(cmd) </code></pre> <p>but it does not work because my string value also contains both " and ', so it parses them wrong. Can anyone please tell me how I can pass this?</p>
python
[7]
2,061,807
2,061,808
jQuery validation plugin: apply one rule on all required fields
<p>I am using jquery validation plugin for validation. I am using one javascript function for many forms so it is difficult to define rules for all fields for many forms.</p> <p>What is the code if I want to apply a rule "required=true" for all textfields those have a class "required".</p> <p>I am trying this but it is applying this rule only on first field. Remember I want to show images instead of error text message when a field in not validated.</p> <pre><code>$(obj).find("input.required").rules("add", { required: true, minlength: 2, messages: { required : "&lt;img id='exclamation' src='images/exclamation.gif' title='This field is required.' /&gt;", minlength: "&lt;img id='exclamation' src='images/exclamation.gif' title='At least 2 characters.' /&gt;" } }); </code></pre>
jquery
[5]
2,876,679
2,876,680
can I use a compatible action bar AND a fragment in the same activity?
<p>OK, I've been extending my activities to </p> <pre><code>extends ActionBarActivity </code></pre> <p>My main menu page </p> <pre><code>extends FragmentActivity </code></pre> <p>when I change it to extend ActionBarActivity so I can see my action bar title on the main menu, it throws up and gives me the "Error Inflating Class Fragment" error.</p> <p>Is there any way around this?</p>
android
[4]
5,345,345
5,345,346
Javascript Replace HTML Characters
<p>I am a total noob on Javascript. What I want is to have a search form, and the input to the form should change the url, then it will open a new tab with the new url.</p> <p>For example, when I enter 'production', the url will become <a href="http://production-test.com/test/" rel="nofollow">http://production-test.com/test/</a>, then a new tab will open with the new url.</p> <p>I know that this should be in Javascript, but I don't know how it will be able to return back the new url. </p> <p>I have this html so far which does not work at all.</p> <pre><code> &lt;script language="javascript"&gt; function change_url(result) { #var result = document.getElementById().value; var new_url = "http://" + result + "-test.com/test/'; # open new window with the new url } &lt;form id="search-box" name="search_box" method="get" action="http://variable-test.com/test/" target="_blank""&gt; &lt;input id="search-text" type="text" autocomplete="off" class="form-text-box no-focus" name="c" value="" aria-haspopup="true"&gt; &lt;input type="radio" id="rel" name="sort" value="1" onchange="saveType('rel');" /&gt;&lt;span data-message="TypeOp1"&gt;Relevance&lt;/span&gt;&lt;br /&gt; &lt;input id="search-button" type="submit" /&gt; </code></pre>
javascript
[3]
403,871
403,872
why am I getting format exception in this code? It has one argument only
<pre><code>public override string ToString() { string val; if (blower) val = "Yes"; else val = "No"; return string.Format( "With Blower \t:\t {0} \n" + val); } </code></pre> <p>I am getting an exception in these lines:-</p> <pre><code> return string.Format( "With Blower \t:\t {0} \n" + val); </code></pre> <p>The exception is:</p> <blockquote> <p>Index (zero based) must be greater than or equal to zero and less than the size of the argument list.</p> </blockquote> <p>What am I doing wrong?</p>
c#
[0]
1,103,727
1,103,728
Can you capture end user's Java version when they run an applet?
<p>An applet developed outside our company just started failing for some users this week. Apparently it was because of the latest version of java (1.6u24) that auto updated. Is there a way to capture what version of java the user opened the applet with? </p>
java
[1]
187,107
187,108
Why does the Java compiler say my file was not found in the class path when I can clearly see it in the class path?
<p>I am using <code>java -classpath $CLASSPATH ...</code>, where <code>$CLASSPATH</code> has been set to <code>/file1path/file1:/file2path/file2</code> and so on. Despite this, Java complains that <code>file1</code> is not found. I tried to set <code>-Dfile1=file:///fullpath/file1</code>, but it still says it cannot find the file. Is there any reason why this might happen other than that I am not seeing a simpler problem like a typo or something (which I have checked for many times)?</p> <p>More specifically, <code>this.getClass().getClassLoader().getResourceAsStream(configurationFileName)</code> is returning <code>null</code>.</p> <p>The file that is not being found is a configuration file (.properties), not a JAR file.</p>
java
[1]
582,922
582,923
password strength checker in android
<p>How can we implement <strong><em>password strength checker</em></strong> in android.<br> Please Help</p>
android
[4]
759,285
759,286
Is it possible (or advisable) to use Activity as switched component of ActionBar's navigation tab or drop-down navigation
<p>I have 2 Activities. One of it is displaying line chart, another is displaying pie chart. I would like to embed both in a single launched Activity. User is allowed to perform single click, to switch between line chart and pie chart.</p> <p>I realize ActionBar's navigation tab, or drop-down navigation is the best candidate to help me achieve this purpose. </p> <p>From Android API demo, and guideline found from <a href="http://developer.android.com/guide/topics/ui/actionbar.html" rel="nofollow">http://developer.android.com/guide/topics/ui/actionbar.html</a>, I realize all switched components are implemented as <code>Fragment</code>, not <code>Activity</code></p> <ol> <li>Does it mean that I need to port my previous 2 Activities into 2 Fragments, in order to embed them into ActionBar's tab navigation view/ drop-down navigation view?</li> <li>Is there any other ways I can do without porting? But, is it advisable as I do not find an official example by using Activity.</li> <li>In API demo, I realize most Fragment is implemented in the following pattern.</li> </ol> <hr> <pre><code>public class FragmentStack extends Activity { ... public static class CountingFragment extends Fragment { // CountingFragment never access any members in FragmentStack } } </code></pre> <p>Is there any reason to do so? Why don't they have <code>CountingFragment</code> is a separated file? </p>
android
[4]
3,524,439
3,524,440
Assign scroll animation to focus in jquery
<p>I have the following code which focuses on an input field which has a validation error. I would like to add some sort of animation with the scroll to the focused position (so if you click submit it "scrolls up to where the first input field is which failed validation).</p> <p>Any ideas?</p> <pre><code> if(validation_failed == true) { $(selected_form).find(":input.validator_element_error:visible:enabled").first().focus(); return false; } </code></pre>
jquery
[5]
2,979,566
2,979,567
how to set get_magic_quotes_gpc to Off
<p>How can I set get_magic_quotes_gpc to Off in php.ini ? I have tried to overwrite value to Off in php.ini. it is showing Off in file but when i echo, it returns 1 means On.</p> <p>any suggesion that can help me..</p> <p>I am using XAMPP server ...</p>
php
[2]
5,631,011
5,631,012
Java - Object properties does not differ
<pre><code>ClassName ref = new ClassName(); ref.setCredentials(Credentials); ref.setVal(value); ref.setUser(user); </code></pre> <p>Now when I create a new object of the same class reference, I still get the previous values I have set. Why is this so?</p> <pre><code>ClassName ref2 = new ClassName(); ref2.setVal(value); ref2.setUser(user); ref2.setSomethingNew(somethingNew); </code></pre> <p>My <code>ref</code> and <code>ref2</code> instances have all the values [<code>Credentials, Value, User and SomethingNew</code>]. I want to differentiate these two instances. Is it because it's holding the same object?</p> <p><strong>Update My Lapse:</strong></p> <p>It's actually <code>ref2</code> and not <code>ref</code>. I get the values in <code>ref2</code> which i am not setting, and <code>ref</code> too holds a value which I am setting in the instance of <code>ref2</code>. Both are in same context.</p>
java
[1]
3,826,175
3,826,176
Add html element 'h1' in html element 'a' with php
<p>I have the following html string in php</p> <pre><code>$html='&lt;div style="display:block; float:left; width:40px;"&gt;&amp;nbsp;&lt;/div&gt;&lt;a href="http://cosa.gr/index.php?cPath=15" class="headerNavigation"&gt;text&lt;/a&gt;'; </code></pre> <p>and I need to add an 'h1' html element in the a element were the string text is in an programmatical way. The bellow code shows the result I need.</p> <pre><code>$html='&lt;div style="display:block; float:left; width:40px;"&gt;&amp;nbsp;&lt;/div&gt;&lt;a href="http://cosa.gr/index.php?cPath=15" class="headerNavigation"&gt;&lt;h1&gt;text&lt;/h1&gt;&lt;/a&gt;'; </code></pre> <p>Is there a way to do this?</p>
php
[2]
953,039
953,040
Why the size of a pointer is 4bytes in C++
<p>On the 32-bit machine, why the size of a pointer is 32-bit? Why not 16-bit or 64-bit? What's the cons and pros?</p>
c++
[6]
560,935
560,936
java Object inside a try {}
<p>Hy ... I have the following code :</p> <pre><code> try { Nrtrde record = new Nrtrde(); } catch (Exception e) { System.out.println(" ERROR\n"); e.printStackTrace(); } finally { Nrtrde record = new Nrtrde(); System.out.println(" OK\n"); } record.setSpecificationVersionNumber(specificationVersionNo); </code></pre> <p>and when compiling i get the following error :</p> <pre><code>NRTRDE\ENCODER.java:28: error: cannot find symbol record.setSpecificationVersionNumber(specificationVersionNo); ^ symbol: variable record location: class ENCODER 1 error </code></pre> <p>It seems I cannot create an object insinde a <code>try {}</code> and use it outside <code>try {}</code> ..</p> <p>Why ?</p> <p>Thank you</p>
java
[1]
4,092,209
4,092,210
android externel application
<p>Hi form the following site <a href="http://grepcode.com/snapshot/repository.grepcode.com/java/ext/com.google.android/android-apps/2.1_r2/" rel="nofollow">http://grepcode.com/snapshot/repository.grepcode.com/java/ext/com.google.android/android-apps/2.1_r2/</a><br> i can download the source code of all android app as jar ,i need the videorecording app from the above jar ,is it possible ie by importing jar in to my app and call like default intent calling eg Intent i=new ... Startactivity().</p>
android
[4]
848,678
848,679
Characters changed by the webserver
<p>I have this code in an .js file, if it is downloaded via ftp</p> <pre><code>texto=texto.replace(/á/g,"Waacute;"); texto=texto.replace(/é/g,"Weacute;"); texto=texto.replace(/í/g,"Wiacute;"); texto=texto.replace(/ó/g,"Woacute;"); texto=texto.replace(/ú/g,"Wuacute;"); </code></pre> <p>but when the web browser downloads it with the webpage, that is what it gets.</p> <pre><code>texto=texto.replace(/á/g,"Waacute;"); texto=texto.replace(/é/g,"Weacute;"); texto=texto.replace(/í/g,"Wiacute;"); texto=texto.replace(/ó/g,"Woacute;"); texto=texto.replace(/ú/g,"Wuacute;"); </code></pre> <p>I don't know what's wrong with the code. I hope some body can guide me. Thanks in advance.</p> <p>ernesto</p>
javascript
[3]
2,452,967
2,452,968
Activity name in AndroidManifest.xml
<p>Is it required to start activity name with dot ('.') in manifest file.? for example activity ContactManager starts with '.'</p> <pre><code>&lt;activity android:name=".ContactManager" android:label="@string/app_name"&gt; </code></pre> <p>where as the activity ContactAdder is without dot</p> <pre><code>&lt;activity android:name="ContactAdder" android:label="@string/addContactTitle"&gt; </code></pre> <p>in the manifest file of ContactManager sample <a href="http://developer.android.com/resources/samples/ContactManager/AndroidManifest.html">http://developer.android.com/resources/samples/ContactManager/AndroidManifest.html</a> </p> <p>UPDATE: If activity name starts with . it is appended to package name to become fully qualified name, but what happens if it doesn't start with '.'</p>
android
[4]
1,140,361
1,140,362
Accessing a property of a Javascript object with bracket notation
<p>I want to access the property values of...</p> <pre><code>var $o = {a:2, b:{c:6}}; </code></pre> <p>...via $o[<em>index</em>] notation.</p> <p>I'm using the newest Firebug console (I don't know whether it's using ECMAScript 5 Strict Mode), but when I use $o[0], $o[0].a or $o['0'], I get undefined and TypeError.</p>
javascript
[3]
1,826,312
1,826,313
Reading a javascript script, why so many $ (dollar signs)?
<p>I am trying to decipher a .js script and I am finding it filled with $ throughout? Is there any reason to use this? I'm pretty new to JavaScript.</p>
javascript
[3]
2,216,360
2,216,361
How to ensure if atleast one checkbox is selected for multiselect jqury plugin
<p>I am using the jquery multiselect <a href="http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/" rel="nofollow">plugin</a>. Right now I am checking if the user has selected any checkbox or not with the below code.</p> <pre><code> function fntemp() { var values = $("select").val(); alert(values); if(!values){ alert("Please select atleast one value from the dropdown."); } } </code></pre> <p>But this does not work when we click "Check All" link. Any suggestions?</p>
jquery
[5]
5,584,686
5,584,687
PHP split alternative?
<p>PHP is telling me that split is deprecated, what's the alternative method I should use?</p>
php
[2]
2,925,224
2,925,225
Setup a asp.net web development platform for free
<p>I need to set up a web developer plat form or c# working enviorment with MSSQL database. I saw some links, but its not updated with new Microsoft pages. So I couldn't find that . In fact I need to create database driven website.</p> <p>Please help me</p>
c#
[0]
341,725
341,726
java negator operator
<p>Hi i'm trying to use a negator operator in java to try and change a negative amount inputted by a user to the same number but just as a positive. Any tips on how to do this would be greatly appreciated. Thanks</p>
java
[1]
1,265,835
1,265,836
javascript shorten string without cutting words
<p>I'm not very good with string manipulation in javascript and i was wondering how you would go about shortening a string without cutting any word off. I know how to use substring but not indexof or anything really well.</p> <p>say i had the string text = "this is a long string i cant display" i want to trim it down to 10 characters but if it doesnt end with a space finish the word i don't want the string variable to look like this "this is a long string i cant dis" i want it to finish the word until a space occurs.</p>
javascript
[3]
3,362,358
3,362,359
Android Google Map
<p>Is this possible in Android, when i will say a name of place google map pointer will zoom to that place. i.e. I want to search Map by voice if possible then how to do this? Though i have done so many apps in Google map, but din't try this before! Can any body help?</p>
android
[4]
2,735,774
2,735,775
javascript don't display the image placeholder if the image is not found
<p>Is there a way to not display the image placeholder if the image was not found? I've got images loaded by automatic feed, and for some items images are there, but for some there are not. So, if the image is not there, I would like to display placeholder.</p> <p>Thank you,</p> <p>H</p>
javascript
[3]
4,499,419
4,499,420
Self hosted jquery OR Google hosted jquery?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2859612/should-i-use-a-hosted-version-of-jquery-which-one">Should I use a hosted version of JQuery? Which one?</a> </p> </blockquote> <p>I have been thinking of this for a while now because I am wondering if which is better to use. Jquery that is self hosted or the one in google codes.</p>
jquery
[5]
1,976,788
1,976,789
jQuery rotating through list items in a gallery, how to do this with muliple images on a page
<p>Hi I have tried the above here <a href="http://www.jsfiddle.net/b3Lf5/1/" rel="nofollow">http://www.jsfiddle.net/b3Lf5/1/</a> the trouble is I can not get it to work on my homepage. Also I would like to have this work but for multiple images rotating at different times (would look weird if they rotated at the same time), is this possible. Any help would be really appriciated, thank you in advance.</p>
jquery
[5]
1,627,119
1,627,120
How to Know if the incoming call is rejected or get missed
<p>I want to detect if call was Missed or it was rejected using Call State.</p> <pre><code>public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: //when Idle i.e no call if(flag==2){ Toast.makeText(context,"Missed Call", Toast.LENGTH_LONG).show(); flag=0; }else{ Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show(); } break; case TelephonyManager.CALL_STATE_OFFHOOK: // flag=0; // when Off hook i.e in call // Make intent and start your service here Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show(); flag=1; break; case TelephonyManager.CALL_STATE_RINGING: //when Ringing Toast.makeText(context, "Phone state Ringing", Toast.LENGTH_LONG).show(); flag=2; break; default: break; } } </code></pre> <p>and how can i popup Dialog box for Call_STATE_RINGING?</p>
android
[4]
4,625,138
4,625,139
Transactions for C# objects?
<p>Just curious, is there any support for transactions on plain C# objects? Like</p> <pre><code>using (var transaction = new ObjectTransaction(obj)) { try { obj.Prop1 = value; obj.Prop2 = value; obj.Recalculate(); // may fire exception transaction.Commit(); // now obj is saved } except { transaction.Rollback(); // now obj properties are restored } } </code></pre> <p>Just to make answers more useful ;-) is there anything similar in other languages?</p> <p>Update on STM: here's what it claims:</p> <pre><code>atomic { x++; y--; throw; } </code></pre> <p>will leave x/y unchanged, including chained methods calls. Looks like what I ask for. At least it's very interesting. I think that's close enough. Also, there're similar things in other languages, for example Haskell STM. Notice I don't say that it should be used for production ;-)</p>
c#
[0]
5,444,636
5,444,637
How to kill an Android activity when leaving it so that it cannot be accessed from the back button?
<p>In an given Android activity, I would like to start a new activity for the user at some point. Once they leave the first activity and arrive at the second, the first activity is stale and I want to remove it completely so it can not be accessed again from the back button.</p> <p>How is the best way to accomplish this? How do I kill or destroy this activity immediately after the user has launched the new activity?</p>
android
[4]
2,201,703
2,201,704
how compare two static function are equal or not in javascript
<p>how to compare two static functions in javascript equal or not equal?</p>
javascript
[3]
2,092,697
2,092,698
Python class function default variables are class objects?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument">&ldquo;Least Astonishment&rdquo; in Python: The Mutable Default Argument</a> </p> </blockquote> <p>I was writing some code this afternoon, and stumbled across a bug in my code. I noticed that the default values for one of my newly created objects was carrying over from another object! For example:</p> <pre><code>class One(object): def __init__(self, my_list=[]): self.my_list = my_list one1 = One() print(one1.my_list) [] # empty list, what you'd expect. one1.my_list.append('hi') print(one1.my_list) ['hi'] # list with the new value in it, what you'd expect. one2 = One() print(one2.my_list) ['hi'] # Hey! It saved the variable from the other One! </code></pre> <p>So I know it can be solved by doing this:</p> <pre><code>class One(object): def __init__(self, my_list=None): self.my_list = my_list if my_list is not None else [] </code></pre> <p>What I would like to know is... Why? Why are Python classes structured so that the default values are saved across instances of the class?</p> <p>Thanks in advance!</p>
python
[7]
972,787
972,788
Drop Down Select with ASP Get function
<p>I am using a GET function with asp query string. I am passing the select option as a variable in the query string, but it is not setting the default value. </p> <p>Here is the code:</p> <pre><code>&lt;% Dim email,name,location,comments email = CStr(Request("email")) name = CStr(Request("name")) location = CStr(Request("location")) comments = CStr(Request("comments")) %&gt; </code></pre> <p>Here is the select:</p> <pre><code>&lt;option value="&lt;%=location%&gt;" selected&gt;&lt;/option&gt; </code></pre> <p>Thanks</p>
asp.net
[9]
5,437,974
5,437,975
Jquery Carousel - Need A Script Hack to Customize
<p>I hope someone can help me out here. I am coding a site for a client using the carouFredsel. I am using this because it allows for variable widths with in the slideshow as seen here: <a href="http://2938.sandbox.i3dthemes.net/index-old.html" rel="nofollow">http://2938.sandbox.i3dthemes.net/index-old.html</a>. My problems are as follows: to use the built in auto center script the scrolling changes the white space in between images during the transition to fit the width of the wrapper.</p> <p>I need a hack to keep the white space during transition the same, like this: <a href="http://2938.sandbox.i3dthemes.net/index.html" rel="nofollow">http://2938.sandbox.i3dthemes.net/index.html</a>.</p> <p>Also, I can't figure out how to put this snippet into my code and make it work</p> <pre><code> scroll: { onAfter: function() { if ( $(this).triggerHandler( "currentPosition" ) == 0 ) { $(this).trigger( "pause" ); } } } </code></pre>
jquery
[5]
3,530,549
3,530,550
parse error in eval() - eval()'d code
<p>Where is the problem in my eval code??? because Apache said:</p> <blockquote> <p>Parse error: syntax error, unexpected T_STRING in E:\xampp\htdocs\1php\mas_res\inc\mysql_class.php(120) : eval()'d code on line 1</p> </blockquote> <p>my code:</p> <pre><code> $type1 = "row"; $query1 = mysql_query("SELECT * FROM table"); $textToEval = "mysql_fetch_{$type1}($query1);"; $query = eval($textToEval); </code></pre> <p>And what is the correct mode??</p> <p>Thanks ..</p>
php
[2]
2,925,439
2,925,440
Numbers in separate divs have default number if null
<p>I have a number i'm taking out of database, basically votes.</p> <p>So numbers are going to be separate.</p> <pre><code>For example [ ] = A div styled box. And $foo = 100 it will display like this: [ 1 ] [ 0 ] [ 0 ]. &lt;?php for($i=0; $i&lt;strlen($counter); $i++) { echo "&lt;div class='votebg'&gt;$counter[$i]&lt;/div&gt;"; } ?&gt; </code></pre> <p>But I made this work automatically, just by taking the INT from the database.</p> <p>Now my int is empty, so I put up a checker to check if its empty, if it is, it will make it 0.</p> <pre><code>if (empty($rcvotes)) { $rcvotes = 0; } </code></pre> <p>Now my page only displays a zero</p> <pre><code>[ 0 ] </code></pre> <p>How do I make it so it automatically fills the missing number with a zero if not exists?</p> <p>For example, we have 7 votes.</p> <p>The number will display like this:</p> <pre><code>[ 0 ] [ 0 ] [ 7 ] </code></pre> <p>We have 88 votes, the number will display like this:</p> <pre><code>[ 0 ] [ 8 ] [ 8 ] </code></pre> <p>What is exactly the problem?</p> <p>Thanks!</p> <pre><code>mysql_query('SELECT FROM * `vote_count`'); $rcvotes = $row['vote_number']; if (empty($rcvotes)) { $rcvotes = 0; } $counter = strval($rcvotes); </code></pre>
php
[2]
2,263,857
2,263,858
Is document.location.protocol ever invalid?
<p>I want to construct URLs with the same scheme (presumably, "http:" or "https:") as the page that loaded the currently-running JavaScript. Modern browsers support simply omitting the scheme (for example, <code>src="//example.com/test.js"</code>), but this isn't fully cross-browser compatible. (I've read that IE 6 is the only browser that doesn't support it, but I still need compatibility with that version.)</p> <p>The cross-browser way to do this seems to be to check <code>document.location.protocol</code>. For example, Google Analytics uses:</p> <pre><code>('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + ... </code></pre> <p>In Google's case, they wanted to use different domains depending on whether the request uses SSL, so that pattern makes sense. But I've seen others use the same pattern when only the scheme is changing:</p> <pre><code>('https:' == document.location.protocol ? 'https:' : 'http:') + "//example.com" </code></pre> <p>(One example is in the "Final Wufoo Snippet" at <a href="http://css-tricks.com/thinking-async/" rel="nofollow">http://css-tricks.com/thinking-async/</a>.)</p> <p>I'd prefer to use this simpler expression instead:</p> <pre><code>document.location.protocol + "//example.com" </code></pre> <p>Should I really be concerned about the possibility of <code>document.location.protocol</code> taking on some value other than "https:" or "http:" when my code is used on sites I don't control?</p>
javascript
[3]
5,538,381
5,538,382
jQuery: How to select form elements for the current clicked button?
<p>I have a jsfiddle here - <a href="http://jsfiddle.net/9kKXX/3/" rel="nofollow">http://jsfiddle.net/9kKXX/3/</a> </p> <p><strong>Requirement</strong></p> <p>Every form has bunch of dynamic data like video id, title, views, that I want to send to backend depending on which button "New" clicked </p> <p>How can I do that? </p> <p>The fiddle is to correctly alert the title for the video, for example</p>
jquery
[5]
923,005
923,006
How to place the vertical line inbetween on cell
<p>How to place the vertical line inbetween on cell</p>
iphone
[8]
3,500,972
3,500,973
How to make a contact form send a confirmation email to the user?
<p>This is what i have so far..</p> <pre><code> $full_name = $_REQUEST['full_name'] ; $company = $_REQUEST['company'] ; $abn = $_REQUEST['abn'] ; $customer_number = $_REQUEST['customer_number'] ; $about = $_REQUEST['about'] ; $areacode = $_REQUEST['areacode'] ; $telephone = $_REQUEST['telephone'] ; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $body =" Full Name: ".$full_name."\n Company: ".$company."\n ABN: ".$abn."\n Customer Number: ".$customer_number."\n About: ".$about."\n Area Code: ".$areacode."\n Telephone: ".$telephone."\n Email: ".$email."\n Message: ".$message; $to = "$email"; mail( "[email protected]", "Contact Us Form", $body, "From: $email" ); </code></pre>
php
[2]
4,283,137
4,283,138
Global variable is NULL in class method
<p>My first line in my script I have:</p> <pre><code>$db = new db_class(); </code></pre> <p>This is just an example to start the db object. Then I have:</p> <pre><code>class main { function init() { $this-&gt;session_start(); } protected function session_start() { $sh = new session_handler(); session_set_save_handler( array (&amp; $sh, 'open'), array (&amp; $sh, 'close'), array (&amp; $sh, 'read'), array (&amp; $sh, 'write'), array (&amp; $sh, 'destroy'), array (&amp; $sh, 'gc') ); } } </code></pre> <p>All of the problems are in the in <code>session_handler</code> class. This code:</p> <pre><code>public function write($id, $data) { global $db; var_dump($db); //returns NULL } </code></pre> <p>says that <code>$db</code> is <code>NULL</code> instead of an instance of <code>db_class</code>.</p> <p>Note, <code>db_class</code> objects work except when calling the <code>write()</code> method:</p> <pre><code>class main { function init() { global $db; var_dump($db); //returns the db object correctly $this-&gt;session_start(); } protected function session_start() { $sh = new session_handler(); session_set_save_handler( array (&amp; $sh, 'open'), array (&amp; $sh, 'close'), array (&amp; $sh, 'read'), array (&amp; $sh, 'write'), array (&amp; $sh, 'destroy'), array (&amp; $sh, 'gc') ); } } </code></pre>
php
[2]
1,822,870
1,822,871
Is there a difference between "addition" and "bitwise addition"?
<p>As a little project (nothing mission critical), I decided to try and write an implementation of GOST 28147-89 in C#. However, while reading through <a href="http://tools.ietf.org/html/rfc5830#section-3.2">RFC 5830</a> (an informational defining GOST 28147-89), I noticed this.</p> <blockquote> <p>(+) is a bitwise addition of the words of the same length modulo 2.</p> <p>[+] is an addition of 32-bit vectors modulo 2^32.</p> </blockquote> <p>What is the difference between these two, mainly the first specifying <em>bitwise</em> addition, and the second simply stating addition?</p>
c#
[0]
1,468,336
1,468,337
Redirect to handling page
<p>On the masterpage I have menu items links that look like like:</p> <pre><code>&lt;ul&gt;&lt;li&gt;&lt;a href=type=article&amp;articleId=82&gt;Article 82&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; </code></pre> <p>When the link is clicked, I want to navigate to the right aspx page based on the QueryString 'type' (in this case DisplayArticle.aspx) and pass the parameter to it (in this case articleId=82).</p> <p>How to do it? </p> <p>Should I create a special Handler page like HandleRequest.aspx, so the menu item would look like:</p> <pre><code>&lt;ul&gt;&lt;li&gt;&lt;a href=HandleRequest.aspx?type=article&amp;articleId=82&gt;Article 82&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; </code></pre> <p>And then after parsing the QueryString, rediret to a needed page?<br> Or maybe there is a better approach?</p>
asp.net
[9]
3,777,337
3,777,338
Close Android popup window with back press
<p>I have created a android application where I have created a popup screen. But when I am pressing the back button, popup is not getting closed. </p> <p>I have tried with onBackPressed(). It is not working.</p> <p>Can someone tell me what to do.</p> <p>Regards,</p> <p>Shankar</p>
android
[4]
2,197,385
2,197,386
checking if form data has been changed
<p>I have been trying the following C# code to check if form data has been changed before closing and saving but it seems that it always reports the form as being changed even when no changes were made.</p> <pre><code>//Declare a private variable private bool requiresSaving =false; //Declare an event private void SomethingChanged(object sender, EventArgs e) { requiresSaving = true; } //Hook up this event to the various changed events, eg this.txtNameDepart.TextChanged += new System.EventHandler(this.SomethingChanged); //Check this variable when you are closing the form private void DepartamentEdit_FormClosing(object sender, FormClosingEventArgs e) { if (requiresSaving) { .... </code></pre> <p>You also need to set requiresSaving false in the saveDepart method.</p>
c#
[0]
2,676,357
2,676,358
Android AccountManager API
<p>I'm struggling to understand the Android AccountManager API. As far as I got thinks working I can use the blockingGetAuthToken method and specify whether Android should provide a notification for user to allow or deny the request. Another possibility is to use getAuthToken and check if KEY_INTENT is returned. If that's the case I could start a new Activity where the user can confirm my request.</p> <p>My problem is that I would like to call one of these two methods from within a Service. Is there any chance to get a callback once the user has made a decision?</p> <p>Thanks for your help</p>
android
[4]
217,424
217,425
Download excel files generated from sql Queries
<p>I have a code snippet like this one here below:</p> <pre><code>&lt;pre&gt; &lt;?php set_time_limit (0); $files = array('export_ird', 'export_earm',); foreach($files as $f){ include_once $f.".php"; echo "finished file $f\n"; flush(); } ?&gt; &lt;/pre&gt; </code></pre> <p>Now those two files names in the array are files which contain queries to a postgres database. Each of those queries and is different and when those files are run separately, the query is made and the data got is converted into an excel file and is downloaded. Now using th code snippet above, i intend to loop through the files such that each query is made and converted to excel file which is downloaded on the fly. But instead, its only the first file in the code snippet thats executed and the other file doesnt get excuted. What could be causing this and how can i solve the problem i have at hand which is: i would like to be able to have one php file say export_all.php which calls specified php files such that instead of calling all of them separately, they are called by this one file .</p>
php
[2]
3,789,194
3,789,195
Where is the source code of IEnumerator?
<p>I just download the .Net framework source code from <a href="http://referencesource.microsoft.com/netframework.aspx" rel="nofollow">http://referencesource.microsoft.com/netframework.aspx</a> It’s Net_4.msi. But after I installed it, I cannot find IEnumerator code file. I just wonder why Net_4.msi does not include all of .Net class.</p> <p>Thanks.</p> <hr> <p>Update: Thanks for replies and sorry for the confusions. </p> <p>I am not asking for the definition of IEnumerator. I think that “Net_4.msi” should include all of .Net classes/ interfaces’ source code files. Such as in the folder </p> <p>Net_4\Source\ndp\clr\src\BCL\System\Collections, </p> <p>you may find IList.cs, ICollection.cs, IDictionary.cs and IEnumerable.cs. These 4 files are IList, ICollection, IDictionary and IEnumerable source code files respectively. Pls see picture: <a href="http://i55.tinypic.com/35clth4.jpg" rel="nofollow">enter link description here</a></p> <p>But I cannot find the file: IEnumerator.cs. I just curious to know where IEnumerator.cs is. Why does IEnumerator.cs not include in the “Net_4.msi”?</p> <p>Thanks.</p>
c#
[0]
2,655,229
2,655,230
How can I read a String into an inputStream in Java?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/782178/how-do-i-convert-a-string-to-an-inputstream-in-java">How do I convert a String to an InputStream in Java?</a> </p> </blockquote> <p>How can I read a String into an InputStream in Java ? </p> <p>I want to be able to convert <code>String say = "say"</code> into an InputStream/InputSource. How do I do that?</p>
java
[1]
3,847,757
3,847,758
How does Stackoverflow hide the URL of the new share on facebook etc
<p>When you create a post , over in the Left hand side under the vote up and vote down, is a new share on twitter facebook and linkedin.</p> <p>How do they do that, is it just using javascript ?</p> <p>Or something far more clever than say:</p> <p>This : <a href="http://www.openjs.com/articles/ajax/target_url_hiding.php" rel="nofollow">http://www.openjs.com/articles/ajax/target_url_hiding.php</a></p>
javascript
[3]
4,722,482
4,722,483
Change ListView Text Color in Simple ListView - Android
<p>I am using Simple Listview to display Email addresses from Contact List. Its working fine. Now I want to change the color of text displaying email address on each row as I am displaying background for Listview.</p> <p>Please give me your suggestions or any code. How can I change color?</p> <p>This is the code:</p> <pre><code>&lt;ListView android:id="@+id/listSendEmailFinal" android:layout_below="@+id/btnAddRecepients" android:layout_width="fill_parent" android:layout_height="250dip" android:layout_marginLeft="5dip" android:layout_marginRight="5dip" android:background="@drawable/listview_border" android:cacheColorHint="#00000000" &gt; &lt;/ListView&gt; </code></pre> <p>Where listview_border.xml is:</p> <p> </p> <pre><code>&lt;stroke android:width="1dp" android:color="#83F52C" /&gt; &lt;padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" /&gt; &lt;corners android:radius="10dp" /&gt; &lt;solid android:color="#E6E6FA" /&gt; </code></pre> <p></p> <p>And this the listview coding:</p> <pre><code>mainListView.setAdapter(new ArrayAdapter&lt;String&gt;(AddReceiverDialog.this,android.R.layout.simple_list_item_multiple_choice, lv_arr)); mainListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); </code></pre>
android
[4]
5,758,658
5,758,659
constructor inheriting self python
<p>I made a class which looks something like.</p> <pre><code>class NewInt: def __init__(self, x,y): self.holders = {"x":x,"y":y} </code></pre> <p>Now, I have a number say a dictionary. So everything is exactly same</p> <p>except its not NewInt but a dict.Somethng like</p> <pre><code> A {"x": 3,"y":4} </code></pre> <p>So it is exactly of type NewInt except its a dictionary.</p> <p>Is there a way i can do something like </p> <pre><code>this_int = NewInt(A) </code></pre> <p>I forgot but there was a special name to such constructor where assignment is done ?? Thanks</p>
python
[7]
3,342,070
3,342,071
Assigning default argument values
<p>Using this script:</p> <pre><code>color = 'blue' def say_color(color): print 'The color is: ' + color say_color() </code></pre> <p>Here, I am trying to allow <code>say_color</code> to be processed without passing an argument, and the result being the default color (blue). However, if a color is specified, it will not use blue and use the string given instead.</p> <p>How is this done?</p>
python
[7]
408,290
408,291
How to pick contacts only from google contacts (not facebook etc) with phone numbers?
<p>I need to fix a bug in an old app of mine. Part of the bug is how I select contacts. Here is what I need:</p> <ol> <li>The contact must be from the 'normal' google contacts list, i.e. I don't want to get any contacts from facebook or similar.</li> <li>The contact must have at least one phone number.</li> <li>The contact must be from the old <code>android.provider.Contacts</code> provider.</li> <li>If I can use an Intent to fetch the contact URI without having to create the selection list etc myself, then that is a bonus.</li> </ol> <p>Sounds simple, but I am really struggling. This is what I am trying:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent(Intent.ACTION_PICK, Contacts.People.CONTENT_URI); startActivityForResult(intent, PICK_CONTACT_REQUEST); } </code></pre> <p>That works OK. I still see contacts without phone numbers, but I can live with that. Worse though is that I still see facebook contacts in the list! This seems to be in contradiction to the following quote found at the <a href="http://developer.android.com/reference/android/provider/Contacts.html">Froyo API for the deprecated Contacts content provider</a>:</p> <blockquote> <p>The APIs have been superseded by ContactsContract. The newer APIs allow access multiple accounts and support aggregation of similar contacts. These APIs continue to work but will only return data for the first Google account created, which matches the original behavior. </p> </blockquote> <p>That sounds like exactly what I wanted, but alas, not what I got. </p> <p>Finally, here are my concrete questions that I hope someone can answer:</p> <ol> <li>Why am I seeing Facebook contacts when using the android.provider.Contacts content provider?</li> <li>If this doesn't work, how else can I get the user to select a google contact with a phone number?</li> </ol> <p>Many thanks. Gustav</p>
android
[4]
4,108,193
4,108,194
How to lowercase a string except for first character with C#
<p>How do convert a string to lowercase except for the first character? Can this be completed with LINQ?</p> <p>Thanks</p>
c#
[0]
5,560,938
5,560,939
Prepend a byte to a byte array
<p>I need to prepend the string "00" or byte 0x00 to the beginning of a byte array? I tried to do it with a for loop but when I convert it to hex it doesn't show up in the front.</p>
java
[1]
709,763
709,764
Change date format for jquery validation Engine future now
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/511439/custom-date-format-with-jquery-validation-plugin">Custom date format with jQuery validation plugin</a> </p> </blockquote> <p>How can I change the date format for the jQuery validation engine future now? </p> <p>The Date now is ISO <code>YYYY-MM-DD</code>. I need it to be <code>DD-MM-YYYY</code></p>
jquery
[5]
1,896,587
1,896,588
calling jquery from ajax page
<p>I'm having trouble using jQuery with child page</p> <p>parent.html loads child.html like so: ie user clicks </p> <pre><code>&lt;a href="#" id="n-email"&gt; </code></pre> <p>JQuery</p> <pre><code>$('a#n-email').click(function() { $.ajax({ type: "GET", url: "/scripts/contact.js", dataType: "script" }); $('#content').load("child.htm"); }); </code></pre> <p>contact.js</p> <pre><code>$(function() { alert ("contact js hit"); } </code></pre> <p>This occasionally works. But i can't work out the logic why it works. I've also tried adding adding a ref to the Jquery on the handler also. I feel like i'm missing a trick here. </p> <p>Thanks to jake + lucus. I've got the following working. Needs a refactor, but works</p> <p>$('#n-email').click(function() { var e = this; reset(e);</p> <pre><code> var mypage = $('#contentemail').load("email.php"); $.ajax({ type: "GET", url: "/scripts/contact.js", dataType: "script", success: function(mypage) { $(document).append(mypage); } }); $('#contentemail').show(); }); </code></pre>
jquery
[5]
3,673,104
3,673,105
How do I get an int variable in javascript to input in a java method
<p>In the code below, I am trying to use the <code>var i</code> in the java method <code>option.value = &lt;% ppList.get(i).getId(); %&gt;</code> but it is not working out for me very well. </p> <p>here is the full js function:</p> <pre><code>function receiveAnswer(response) { var aSeats = document.getElementById("aSeats"); while (aSeats.childNodes.length &gt; 0) { // clear it out aSeats.removeChild(aSeats.childNodes[0]); } &lt;% List&lt;Physical_Package&gt; ppList = (List&lt;Physical_Package&gt;) session.getAttribute("currentPack"); %&gt; for (var i = 0; i &lt; response.aSeats.length; i++) { // add the items back in var option = aSeats.appendChild(document.createElement("option")); option.setAttribute("type", "hidden"); option.setAttribute("name", "id"); option.setAttribute("value", "") option.appendChild(document.createTextNode(response.aSeats[i])); option.value = &lt;% ppList.get(i).getId(); %&gt; } } </code></pre>
javascript
[3]
3,349,924
3,349,925
detect locked file
<p>Given a reference to a <code>File</code> instance, is it possible to (programatically) detect whether the corresponding file is locked, and if so, which process is holding the lock?</p> <p>I'm using Java 5, running on Windows.</p> <p>Thanks, Don</p>
java
[1]
893,561
893,562
Comparing two class types
<p>I am trying to compare two class types, but i keep getting an error.</p> <pre><code> if (mediaTitleCollection[i].GetType() == Catalog.FilmMedia) </code></pre> <p>I get following error: 'Catalog.FilmMedia' is a 'type' which is not valid in this context.</p> <p>I dont exactly see the problem hence the primary thing im comparing with is a type aswell?</p>
c#
[0]
216,304
216,305
set consisting of an emtpy set
<p>To get an empty set in python I use <code>{}</code> and it works.</p> <p>I need to use the empty set as an element in a set.</p> <p>But <code>{{}}</code> yields an error and <code>{set()}</code> too.</p> <p>Is there a way?</p>
python
[7]
4,311,534
4,311,535
pull everything from db and then compute stats?
<p>I am working on an auto trade website. On the page where Ad list gets displayed, I plan to display the number of Ad for different categories: for example, for location: I will display something like "Vancouver (50), Richmond (12), Surrey (20)". For vehicle make, the following will be shown "Honda (20), Ford(12), VW (24)".</p> <p>I am not sure if I should pull ALL the ad from the db into a List first, bind one page of the result to gridview control, and then compute stats for each category using Linq. if course I will limit the number of rows pulled from the db using some kind of condition - maybe set the MAX # of rows to be returned as 500. </p> <p>My major concern is - is this going to be a memory hog?</p>
asp.net
[9]
1,447,969
1,447,970
What Would You Consider Best Practice Workflow Tools For Web Application (PHP) Development?
<p>I'm really hoping somebody with more experience can edit the question as per my examples of answers:</p> <blockquote> <p>• using version control</p> <p>• test driven development</p> <p>• debugging code (xdebug for php)</p> <p>• use of UML diagrams</p> <p>• use of OOP for maintainable, reusable code</p> <p>• use of frameworks (like Zend Framework for php) for rapplication application development</p> </blockquote> <p>Anything else or an elaboration of what I mentioned above?</p> <p>Basically, I'm in the middle of forming a team of developers (I'm a developer myself) and I'd like some advice on how professional programers/designers etc should work together and what standards/paradigms they should use.</p> <p>Also, if anybody has any books or links on the subject I'd welcome that!</p>
php
[2]
3,218,130
3,218,131
Java - Take a string from user and use KeyPress from the Robot object to type it out
<p>How would I go about doing this?</p> <p>I got a loop for it but don't know how to type it out..</p> <pre><code> //Start typing the given strings for( int i=0; i&lt;vString_size; i++ ) //Run through all the strings { string_size = vString.get(i).length(); for( int j=0; j&lt;string_size; j++ ) //Run through each letter { letter = vString.get(i).charAt(j); //Press key //Release key } //Press [ENTER] r.keyPress( KeyEvent.VK_ENTER ); } </code></pre>
java
[1]
1,005,570
1,005,571
sort an array of a class in C#
<p>In my program, I have a class like this:</p> <pre><code>Class Customer{ double Start; double Finish; double Wait; } </code></pre> <p>and I created an array of this class:</p> <pre><code>Customer[] customer = new Customer[300]; </code></pre> <p>How I can sort this array according to Start values Descending or Ascending?</p> <p>Thanks... </p>
c#
[0]
4,303,034
4,303,035
Move Focus to Server Side Validator
<p>I have a page with multiple CustomValidators and I want the focus to be brought to the offending validator when there is an error. I know this is possible with client side validation, but is it possible with server side? </p> <p>Additionally, the CustomValidators are located in different parts of the page so I can't simply scroll the page to one general location when there is any validation failure.</p> <p>I have tried: SetFocusOnError CustomValidator.Focus() immediately after validation, after the button click, and in Page.PreRender()</p> <p>Thanks in advance</p>
asp.net
[9]
4,074,344
4,074,345
How can i use Log.d to get what has passed to a variable in my activity, and where can i see the result?
<p>Its a noob question, but i'd searched quite a while but i didn't understand</p> <p>i really want to find what is the value that is passed to a variable..and where can i see the result?</p>
android
[4]
4,252,608
4,252,609
jquery removeattr not found execption
<p>I am using jquery-1.7.2.min.js</p> <p>TypeError: </p> <blockquote> <p>$("#TextBox1").removeattr is not a function [Break On This Error] $("#TextBox1").removeattr("disabled"); </p> </blockquote>
jquery
[5]
3,276,249
3,276,250
Passing value in java BEGINNER stuff
<p>i am having a little bit of trouble in my code i wish to take the value operation = flip in the last if statement and pass it to the top where operation = "" so that it is either + - or * is this even possible sorry for such a basic question but i am really stuck</p> <pre><code>JButton operand = (JButton) calculate.getSource(); String flip = operand.getLabel(); String operation = ""; String operation1(operation); System.out.println(operation); String value1 = (box1.getText()); String value2 = (box2.getText()); box1.setText(box1.getText() + operand.getLabel()); if (flip == "C") {box2.setText(""); box1.setText(""); } if (flip == "!") {int intValueNeg = Integer.parseInt(value1); int negateIntValue = intValueNeg * (-1); String negativeInt = Integer.toString(negateIntValue); box1.setText(negativeInt);} if (flip == "+" || flip == "-" || flip == "*" ) { box2.setText(value1); box1.setText(""); operation = flip; } </code></pre>
java
[1]
3,974,759
3,974,760
comparing lists at a previous index
<p>I have got 2 lists for which I would like to compare to one index before :</p> <pre><code>for (min,max) in zip(csv_parse(2010)['min'],csv_parse(2010)['max']): </code></pre> <p>basically I would like something like this :</p> <p><strong>if min > min(back one increment) and max &lt; max (back on increment)</strong></p> <p>then, do something .</p> <p>Thanks !</p>
python
[7]
389,043
389,044
android Howto "really" get the mime type of sd card files
<p>hi<br> Dont say this is a duplicate question because i have read them all for two days. And non of them really supply a useful answer.</p> <p>I have a number of different files in a folder on the sdcard. Want to open right app depending on apk, txt, mp3, avi, jpg or show a chooser dialog. Therefor i need the mime type on the fly.</p> <p>I have tried : manageQuery return null cursor to often.<br> MimeTypeMap cannot resolve the .3gp file and think its a .txt<br> URLConnection.guessContentTypeFromName Dont work at all </p> <p>Was thinking i have to use the MediaFile.java and build my own..file.equals(".mp3")</p> <p>addFileType("MP3", FILE_TYPE_MP3, "audio/mpeg");<br> addFileType("M4A", FILE_TYPE_M4A, "audio/mp4");<br> addFileType("WAV", FILE_TYPE_WAV, "audio/x-wav");<br> addFileType("AMR", FILE_TYPE_AMR, "audio/amr");</p> <p>Is that the way to do it?</p>
android
[4]
3,373,092
3,373,093
Read ringtone string assigned to Contact on iOS
<p>using iOS sdk 4.3</p> <p>In order to determine the phone numbers a contact has on iOS one can use the code below</p> <pre><code> ABMutableMultiValueRef multi = ABRecordCopyValue(person, kABPersonPhoneProperty); CFIndex i = ABMultiValueGetIndexForIdentifier (multi,identifier); phoneNumberLabel = (CFStringRef)ABMultiValueCopyLabelAtIndex(multi, i); phoneNumber = (NSMutableString* )ABMultiValueCopyValueAtIndex(multi, i); </code></pre> <p>However what property type ie kABPersonxxxProperty will give me the string value of the Ringtone for a contact. This is all i need, just to read the string.</p> <p>Thanks</p>
iphone
[8]
5,365,054
5,365,055
Extract commas from variable
<p>Hey there, I have this variable:</p> <pre><code>&lt;?php $blog_description = get_bloginfo('description'); ?&gt; $blog_description ='I am a text, I have commas, and periods. And I want the text without them'; </code></pre> <p>How can I extract the commas and periods from $blog_description? I want to use it as meta description in my website header.</p>
php
[2]
1,371,843
1,371,844
How to get random elements from an array
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4550505/javascript-getting-random-value-from-an-array">JavaScript: Getting random value from an array</a> </p> </blockquote> <pre><code>var numbers = new Array('1','2','4','5','6','7','8','9','10'); </code></pre> <p>I have a JavaScript Array and now want to randomly choose four different numbers from it and then express it on the page (through <code>document.write</code>). Obviously each time the page is reloaded by the user it would show four different random numbers.</p>
javascript
[3]
2,298,382
2,298,383
Javascript position two elements on top of each other
<p>I have two divs one above the other. The second on is absolutely positioned below it (an absolute div inside a relative div).</p> <p>I want to move the second div on top of the other div, so it appears in the middle.</p> <p>The procedure for this is to set the style.top of DIV2 to be the same as DIV1, this should in theory position it on top of it. However so far attempts have failed.</p> <p>The absolute positioning is working correctly, because putting in values moves it correctly, but I think I am using the wrong way to get the height/top values of DIV1.</p> <p>Ideas?</p> <p>I tried this:</p> <p>divLoading.style.top = divContent.style.top;</p> <p>but it stays where it was.</p> <p>Edit: The problem isn't how absolute/relative works but which javascript values are the correct ones to use. Using DIV2.style.top = DIV2.style.top - DIV1.clientHeight moves it to the top... but clientHeight is not correct, because if DIV1 changes size, it moves DIV2 way too far upwards.</p> <p>Edit: offsetTop seems to be zero.</p>
javascript
[3]