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
1,597,339
1,597,340
Python : run a py program on another box
<p>I have a Python script that scans my logs and reports all its findings. Is it possible that the script in my box (say Box A) can be executed for another box (say B) without copying it.</p> <p>Do I really need to copy my Python script to Box B and then execute it from box A or there is a method by which staying in Box A I can connect to Box B run my python program for box B there get its output to and close the same.</p>
python
[7]
402,598
402,599
Capture SIGINT in Java
<p>What is the best way to capture a kill signal in java without using JNI. I did discover the sun.misc.Signal and the sun.misc.SignalHandler and the warning of the possibility of being removed in the future releases. </p> <p>Would using JNI to call a c lib be the only option i have? </p>
java
[1]
1,107,950
1,107,951
Is it better to move this anonymous function to a real named function?
<p>I am using the following code:</p> <pre><code> $('#dataTable .select-topic') .click(function () { if ($(this).attr('data-list') == "N") { $(this).attr('data-list', 'Y') var topicSelectHtml = $('#TopicID') .clone() .find("optgroup:first").remove().end() .find("option[value$='**']").remove().end().html(); $(this).html(topicSelectHtml); $(this).attr('data-clicked', 'Y') } }) .change(function () { $(this).attr("title", $("option:selected", this).text()); var type = $(this).attr('id').split('_')[1]; updateField(entity, $(this), type); }) </code></pre> <p>It's applied to a few hundred rows as each row has a select. For efficiency would it be better for me to create named functions and attach these to the click and change. If so then how could I do this for the above code?</p>
jquery
[5]
5,077,229
5,077,230
How can I check SIM lock on Android application level
<p>I'm looking for a way to find out if an android device is SIM locked or not. I know that in /efs/ should be a file where this setting is stored at. The problem is that without root there's no access to /efs/. </p> <p>USSD codes like <em>#</em>#7465625# does no more work for Android 4.1.2 on Samsung devices.</p> <p>So does anybody know how I can figure out if there's a SIM lock enabled?</p> <p>Thanks, tom</p>
android
[4]
3,046,793
3,046,794
Where can I find free PHP forms?
<p>There is a question concerning PHP. Whether there is a product similar on a functional liks <a href="http://phpforms.net/tutorial/html-basics/php-forms.html" rel="nofollow">PHP forms</a> but is more cheaper? Thanks!</p>
php
[2]
2,712,032
2,712,033
Calculate CPU usage for an application
<p>I need to calculate the cpu usage of a perticular process in android device. I have tried to find it out using top command. Problem is that it is completely different from the android assistant which is showing cpu usage in RTCPU percentange. I dont know what is RTCPU. Can anyone explain me ?</p> <p>I also want to know that CPU usage I have found using top command is correct or not...</p>
android
[4]
85,946
85,947
About Ambient Light sensor in iphone
<p>Thanks in advance.</p> <p>I got the information about the iphone sensors from <a href="http://ipod.about.com/od/ipodiphonehardwareterms/qt/iphone-sensors.htm" rel="nofollow">http://ipod.about.com/od/ipodiphonehardwareterms/qt/iphone-sensors.htm</a>. But I didn't get information about how to use ambient sensor in iphone</p>
iphone
[8]
2,660,018
2,660,019
"this" vs normal initialization java
<p>I am a beginner in java and has slowly started to get the feel of this language.</p> <p>I am having a hard time understanding "this" variable.</p> <p>For example, which is better.. and why?</p> <pre><code> public class Foo{ int a; public Foo(int _a){ a = _a; } } </code></pre> <p>vs</p> <pre><code>public class Foo{ int a; public Foo(int _a){ this.a = _a; } } </code></pre> <p>Thanks</p>
java
[1]
766,109
766,110
Android NFC TECH_DISCOVERED with foreground dispatcher
<p>I am programming an NFC application in Android and I have a little problem when writing tags. I have been able to write a tag but in order to do it I detect it using intent-filters in the manifest. However, what I want to do is to deal with the tag directly with the application using the foreground dispatcher. I am able to "catch" NDEF_DISCOVERED tags with the foreground dispatcher but I don't know how to use TECH_DISCOVERED in the same fashion.</p> <p>This code works with NDEF_DISCOVERED:</p> <pre><code> // Setup an intent filter for all MIME based dispatches IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } mFilters = new IntentFilter[] { ndef, }; // Setup a tech list for all NfcF tags mTechLists = new String[][] { new String[] { NfcF.class.getName() } }; </code></pre> <p>But what should I do for TECH_DISCOVERED???? I'm trying this and it doesn't work:</p> <pre><code> IntentFilter ntech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); mFilters = new IntentFilter[] { ntech, }; // Setup a tech list for all NfcF tags mTechLists = new String[][] { new String[] { NfcF.class.getName() } }; } </code></pre>
android
[4]
3,258,138
3,258,139
How can i scroll a Listview within a scrollview?
<p>Iam new to Android, iam developing an application with listview in a scrollview. According to my requirement i need to show some of views with vertical scrolling and below that a listview. I want to scroll the entire view and listview vertically, where as listview must scroll independently. I have googled for the solution but found that we should not use Listview in a scrollview.</p> <p>I have tried An alternative to this, by replacing the Listview with the Dynamic LinearLayouts, that is also not working.</p> <p>I tried doing the disabling the focus of the ScrollView when I touch the ListItem and viceversa, but i didn't get it.</p> <p>I tried the below code to disable the focus of scroll view.</p> <pre><code>mScrollView.setFocusableInTouchMode(true); mScrollView.setFocusable(true); mScrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); mScrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.requestFocusFromTouch(); return false; } }); </code></pre> <p>Please help me out, thanks in advance</p>
android
[4]
1,671,949
1,671,950
Jquery Radio Button Checked, Whole Page quickly flicks
<p>I have a form that has a question which has two radio options (Yes and No). </p> <p>I managed to get the code working fine, but when i click yes out of the radio button the whole screen flashes very quickly. </p> <p>I have never seen this before. can anyone help? </p> <pre><code>$(document).ready(function(){ $(".pension_hide").css("display","none"); $("#q32081_q11_0").click(function(){ if($("#q32081_q11_0").is("input:radio")) { $(".pension_hide").show("fast"); } else { $(".pension_hide").hide("fast"); } }); }); </code></pre> <p>I also have a radio button called q32081_q11_1 which is the no button, i also want this to remove the field when i have checked it.</p> <p>Thanks for your help everyone!</p>
jquery
[5]
6,018,061
6,018,062
How to sort 2D array (row-wise) in Visual Studio C#?
<p>Need your expert guidance as how to sort a 2D array, row-wise ( means considering each row independently and sort all rows independently of a 2D array) in Visual Studio C#.Example</p> <p>First row: 5 4 3 6 Second row: 2 3 1 4</p> <p>Sorted: First row :3 4 5 6 Second row: 1 2 3 4</p> <p>There is a method called Array.Sort (), but it is specific to 1D arrays only. Thanks and Regards Asad</p>
c#
[0]
5,983,289
5,983,290
How to compare variables and find difference in python
<p>I have two variables readARP and readFPING which will have a series of IP's listed in them and I want to compare one to the other. After comparing them I would like to print out the difference if there is any.</p> <pre><code>readARP = scanProcess.read() readFPING = fpingscanPocess.read() &gt;&gt;&gt; print readARP 192.168.1.1 192.168.1.100 192.168.1.1 &gt;&gt;&gt; print readFPING 192.168.1.1 192.168.2.1 192.168.1.12 </code></pre> <p>I want to compare both and then print 192.168.2.1 192.168.1.12 192.168.1.100 since they are unique to the two.</p> <p>P.S. What is "readFPING" referred to as in python I have adapted the term variable</p> <p>After I find out what is different how could I add the different to a variable. Example: 192.168.1.2 isnt in readFPING but I then want to add it (Creating a master ip list)</p>
python
[7]
4,008,823
4,008,824
Use anchors/hashbangs in the URL to trigger functions on load?
<p>Say someone is linked to the url, <code>example.com/#boom</code></p> <p>Can the hashbang in the url, <code>#boom</code> be linked to triggering a function like <code>boom()</code> on the page?</p> <p>Thanks!</p>
javascript
[3]
2,414,457
2,414,458
php: session_start() error
<p>I have a file, which starts <code>&lt;?php session_start();?&gt;</code>, and it returns an error</p> <pre><code>Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp2\htdocs\index.php:1) in C:\xampp2\htdocs\index.php on line 3 </code></pre> <p>and now take a look at the moment, i can't anderstand anyway when i copy the all content of my file into another file, it start working. can somebody explain how can it happen. thanks</p> <h2>update</h2> <p><strong>i havent't any white spaces, at least i can't see them</strong></p>
php
[2]
1,027,338
1,027,339
why null==undefined is true in javascript
<p>If we <code>alert(null==undefined)</code> it outputs to <code>true</code>.</p> <p>What is the logical reason for this.</p> <p>Is this something that is hard coded in javascript or is there an explanation for this.</p>
javascript
[3]
4,255,596
4,255,597
Finding all possible combination on python
<p>I am trying to find all combination of numbers in a list that gives a certain number on python 2.7.Tried combinations of itertool but can't quite figure it out,so here it goes.</p> <pre><code>mylist=[1,2,3,4,5,6,7,8,9,10] number=60 # for 3 elements results=[[3,4,5],[2,3,10],[2,5,6],[1,6,10]...] </code></pre> <p>I tried</p> <pre><code>import itertools num = [1, 2, 3, 4, 5,6,7,8,9,10] combinations = [] for combination in itertools.combinations(num, 3): combinations.append(int("".join(str(i) for i in combination))) print combinations # ... combination=[123,124,125....] </code></pre>
python
[7]
5,375,127
5,375,128
Takes away a % of a number not working
<p>What I want it to do is take 10% from what ever the price is.</p> <p>The code is</p> <pre><code>$SALEPRICE = $PS-&gt;Price; $TAX = .10 * ($PS-&gt;Price); $PROFIT = ($PS-&gt;Price) - ($TAX); $getAmount = $PROFIT; </code></pre> <p>$PS->Price is the price it will take 10% from. When $PS->Price is 100,000 it works fine but anything under it does not work.</p> <p>Any idea why this is not working?</p>
php
[2]
4,139,448
4,139,449
Partially hide Layout programatically?
<p>What should I do to partially hide some layout from code? Should I play with <code>setMargins</code>?</p> <p>Basically, I want to detect size of the screen and then I want that element X becomes visible only 10% of its width? I know how to do it all except <strong>how to make it partially hidden or offscreen</strong>?</p> <p>Look at these images to see what I want to achieve. Image 1 - UI element is in the center. Image 2 - I set in code it's moved to top offscreen thus becoming only partially visible. </p> <p><img src="http://i.stack.imgur.com/3aO6Y.png" alt=""></p> <p><img src="http://i.stack.imgur.com/SkJjW.png" alt=""></p>
android
[4]
900,747
900,748
How do I delay a form from submitting
<p>I have an additional function to execute before I submit the form. This isn't doing the trick.</p> <pre><code>$('form').submit( function(event) { var formId = $(this).attr('id'); mySpecialFunction(formId); event.preventDefault(); setTimeout( function () { $(this).submit(); }, 300); }); </code></pre> <p>This isn't working obviously.</p>
jquery
[5]
5,018,515
5,018,516
How to show two images in a view one after another and viceversa?
<p>How to show two images in a view one after another,I have tow images named image1 and image2,when the user opens a perticular page it wants to show the image1 then after 2 second image1 dissapers and shows image2 then after 2 second image2 disappers and shows the image1 and go on. I hope you will understand my question.How to do this. Thanks in advance.</p>
iphone
[8]
245,550
245,551
How to add elements to a sorted linked list?
<p>while loop (so that while the current element in the list is less than the parameter, go to the next element)....but how do I do this? I can't do &lt; or compareTo, so I'm not sure how to do this.</p>
java
[1]
597,300
597,301
How to insert external stylesheet in JavaScript (dynamically)
<p>...with right path.</p> <p>For example. I have script called foo.js. I'd like to insert stylesheet declaration which I can do with following instruction:</p> <pre><code>$('head').append('&lt;link rel="stylesheet" href="/template/foo.css" type="text/css" /&gt;'); </code></pre> <p><strong>Problem</strong>: I have to put full path to the stylesheet file. So instead of /template/foo.css I have to put: <a href="http://hostname/directory/template/foo.css" rel="nofollow">http://hostname/directory/template/foo.css</a>. I can't set it statically beacause script can be placed in different servers and different locations. So it can be: <a href="http://foo.com/bar/foo.css" rel="nofollow">http://foo.com/bar/foo.css</a> or <a href="http://foo.com/foo.css" rel="nofollow">http://foo.com/foo.css</a>. </p> <p>It would be very useful if I can get path of foo.js file on the server. That would be good enough beacause then I could set stylesheet location based on the javascrpt's file.</p>
javascript
[3]
5,416,049
5,416,050
Using keys in same web.config
<p>My application accesses an active directory for login and querying information about users and I'd like to keep all of my active directory connection information in one place.</p> <p>I'd like to be able to access AD connection information from web.config. I'd assume the correct way to do that would be through appSettings</p> <pre><code>&lt;appSettings&gt; &lt;add key="LDAPPassword" value="LDAPPassword"/&gt; &lt;add key="LDAPPath" value="LDAP://ConnectionString"/&gt; &lt;add key="LDAPUser" value="LDAPUser"/&gt; &lt;/appSettings&gt; </code></pre> <p>How would I go about using these keys further down in the web.config file in order to configure the MembershipProvider?</p> <pre><code>&lt;membership defaultProvider="ADMembershipProvider"&gt; &lt;providers&gt; &lt;clear /&gt; &lt;add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, BlahBlahBlah" connectionStringName=LDAPPath connectionUsername=LDAPUser connectionPassword=LDAPPassword /&gt; &lt;/providers&gt; &lt;/membership&gt; </code></pre> <p>If it is not possible to simple use those added keys is there some sort of support for declaring variables elsewhere that will let me keep from repeating this environment specific information? Or is it possible to query the ADMembershipProvider for it's connectionString, connectionUsername and connectionPassword?</p>
asp.net
[9]
2,394,944
2,394,945
How to customize text color of the CheckBoxPreference title
<p>How to change the color of Title text in CheckBoxPreference?</p>
android
[4]
2,173,217
2,173,218
Can we apply themes in an C#.net Application?
<p>Can we apply themes in an C#.net Application?</p>
c#
[0]
2,167,423
2,167,424
Executing a jquery function to all href attributes
<pre><code>function openFile(file) { var extension = file.substr( (file.lastIndexOf('.') +1) ); switch(extension) { case 'jpg': case 'png': case 'gif': alert('was jpg png gif'); break; case 'zip': case 'rar': alert('was zip rar'); break; case 'pdf': alert('was pdf'); break; default: alert('who knows'); } }; openFile("somestring.png"); </code></pre> <p>I got this piece a code from another question posted here, but im unsure how to implement it for my purpose. I want to check the hrefs of every link and place the appropriate icon for the file type. </p>
jquery
[5]
416,232
416,233
Convert a 4 char string into int32
<p>Is there a fast way to convert 4 chars into a 32bit int? I know i can loop through it like :</p> <pre><code>string key = "ABCD"; int val = 0; for (int i = 0; i &lt; 4; i++) { int b = (int)key[i] * (int)Math.Pow(256, i); val += b; } // val = 1145258561 </code></pre> <p>I would like something lower level, I know the chars are stored as bytes. I don't mind if its unsafe code because I am basically trying to write a 4 char string to an integer pointer location.</p>
c#
[0]
1,387,942
1,387,943
Passing $(this) to functions
<p>In JQuery, how we can pass entire $(this) to a functions? Possible?</p>
jquery
[5]
2,478,668
2,478,669
Communication between RS422 serial device and Javascript
<p>I've written a simple web page that uses Javascript to control a Quicktime plugin for movie playback. There's also some AJAX stuff using jquery to get info on the movies from an MSSQL database. The web page is served to the user from an Apache 2.0 server, this also hosts MSSQL. The end users will view the page in IE6 (unfortunately).</p> <p>My problem is that the end users now want to use an RS422 jog/shuttle deck control to drive the movie timeline, in place of another jog/shuttle unit that relied on emulating keypresses which was easy for me to detect.</p> <p>As I'm not a programmer I'm at a loss what to start looking at for a solution to receive the RS422 data and then send that to the Javascript to control the timeline. Is this something that a custom activeX bit of code could do? I've googled ActiveX with Javascript but it's unclear to me (as a novice) how the two work together, or whether this would be suitable at all.</p> <p>If anyone could give me an overview of what to start researching that'd be much appreciated.</p> <p>Many thanks.</p> <p>Jon</p>
javascript
[3]
5,585,615
5,585,616
Add prefix to mobile number in php before sending it to database
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/11786411/please-help-me-validate-mobile-no-in-php-form">Please help me VALIDATE Mobile no in php form</a> </p> </blockquote> <p>I got mobile number to validate but I am stuck at the prefix part.</p> <pre><code>if(empty($_POST['mobileno'])) // phone number is not empty { $error[] = 'Please enter mobile number'; } else { if(preg_match('/^\d{10}$/',$_POST['mobileno'])) // phone number is valid { $mobile = $_POST['mobileno']; // your other code here } else // phone number is not valid { $error[] = 'Phone number invalid !'; } } $prefix = 0; $pmobile = $prefix . $mobile; </code></pre> <p>This is what I am trying to do for prefix. Is this right as I cant add the value 0 before the number.</p>
php
[2]
3,183,740
3,183,741
Learning Android programming
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1114287/good-book-for-beginning-android-development">Good book for beginning android development</a> </p> </blockquote> <p>I have been working in android for around 5 months and while I have no problem in designing I am having problems with writing the java code. Can anyone recommend resources to help learn more about the implementation side of android programming please. </p> <p>Thanks in advance Tushar</p>
android
[4]
105,138
105,139
Weak Reference issue
<p>My App uses CoreAudio and CoreVideo frameworks (supported in iOS4 or later). Now I want my app to be run in device 3 or later. For that i have made core audio and core video frame work to Weak Reference. but it is still giving same problem. </p> <pre><code>dyld: Symbol not found: _OBJC_CLASS_$_AVCaptureDevice Referenced from: /var/mobile/Applications/67EDB406-FBEF-4FA4-8B6A-752CD9E3DA31/TescoClubCard.app/TescoClubCard Expected in: /System/Library/Frameworks/AVFoundation.framework/AVFoundation </code></pre>
iphone
[8]
1,275,950
1,275,951
Javascript dynamic objects
<p>I don't really know the correct words to describe what I am trying to do, but the functionality is very similar to overriding the __get() function of PHP classes. For example this is what I want to do.</p> <pre><code>var obj = { param1:'a', func1:function(){ return '1';}, catch_all:function(input){ return input; } } //alerts 'a' alert( obj.param1 ); //alerts '1' alert( obj.func1() ); //alerts 'anything' alert( obj.anything ); </code></pre> <p>Basically I want a way to redirect any unused key to a predefined key. I have done some research on this and really didn't know what to search for. Any help is greatly appreciated. Thanks.</p>
javascript
[3]
1,010,623
1,010,624
Bigrams and ranks of words
<p>I am using this code to get the frequency of bigrams:</p> <pre><code>text1='the cat jumped over the dog in the dog house' text=text1.split() counts = defaultdict(int) for pair in nltk.bigrams(text): counts[pair] +=1 for c, pair in ((c, pair) for pair, c in counts.iteritems()): print pair, c </code></pre> <p>The output is :</p> <pre><code>('the', 'cat') 1 ('dog', 'in') 1 ('cat', 'jumped') 1 ('jumped', 'over') 1 ('in', 'the') 1 ('over', 'the') 1 ('dog', 'house') 1 ('the', 'dog') 2 </code></pre> <p>What I need is for the bigrams to be listed, but instead of each word, I need to word's rank to be printed. When I mean "rank" I mean the word with the highest frequency has rank 1, the second has rank 2 ect... Here the ranks are : 1.the 2.dog and the ones with equal frequency are assigned ranks in decreasing order. 3.cat 4.jumped 5.over etc..</p> <p>eg </p> <pre><code>1 3 1 </code></pre> <p>instead of</p> <pre><code>('the', 'cat') 1 </code></pre> <p>I believe that to do this I need a dictionary with words and their rank, but I am stuck and don't know how to proceed. What I have is:</p> <pre><code>fd=FreqDist() ranks=[] rank=0 for word in text: fd.inc(word) for rank, word in enumerate(fd): ranks.append(rank+1) word_rank = {} for word in text: word_rank[word] = ranks print ranks </code></pre>
python
[7]
2,527,150
2,527,151
best way to inject html using javascript
<p>I'm hoping that this isn't too subjective. I feel there is a definitive answer so here goes.</p> <p>I want to create this html on the fly using JS (no libraries):</p> <pre><code>&lt;a href="#" id="playButton"&gt;Play&lt;/a&gt; &lt;a href="javascript: void(0)" id="muteUnmute"&gt;Mute&lt;/a&gt; &lt;div id="progressBarOuter"&gt; &lt;div id="bytesLoaded"&gt;&lt;/div&gt; &lt;div id="progressBar"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="currentTime"&gt;0:00&lt;/div&gt; &lt;div id="totalTime"&gt;0:00&lt;/div&gt; </code></pre> <p>using javascript. I know I can do this using createElement etc but it seems extremely long winded to do this for each element. Can anyone suggest a way to do this with more brevity.</p> <p>I do not have access to a library in this project....so no jquery etc.</p>
javascript
[3]
5,514,803
5,514,804
How can I simplify this code snippet?
<p>I have a method that 'steps' from a start to an end value, which works perfectly well and ignores steps that are either infinite or that already fails the condition. But the only different is <code>&gt;=</code> vs <code>&lt;=</code> if the step is negative. I've tried what feels like everything with no luck. Show me the magic.</p> <pre><code> if (step &lt; 0) { while(start &gt;= endpoint) { // use start here start += step; } } else { while(start &lt;= endpoint) { // use start here start += step; } } </code></pre>
java
[1]
2,525,519
2,525,520
how to prevent growing activity stack in android
<p>I read somewhere that each time you call startActivity() to transition to a new screen, you are creating a new instance of that activity. This immediately raised a red flag to me.</p> <p>In search of a way to prevent this issue, I read about using FLAG_ACTIVITY_REORDER_TO_FRONT. However I'm a little alarmed that this method is not used in any of the tutorials I've seen for opening a new screen in your app. So I think I might be missing something. I mean wouldn't you always want to make sure you're not creating a duplicate Activity? isn't this kind of a big deal and shouldn't tutorials address it? </p> <p>I just want to make sure that I am understanding, and dealing with, this issue correctly, and using the commonly practiced way to transition between screens.</p> <p>I understand in some cases you open a screen, do something, then close it using finish() and go back. But if an app has a complex 4 level hierarchy , and the user needs to be able to jump around between the screens?</p>
android
[4]
3,222,594
3,222,595
My picture can't fill the tab
<p>I develop an app like below,In the mainActivity,when I try to add an image the TAB1,the picuture can't fill full of the tab,it has a border lost.</p> <p><img src="http://i.stack.imgur.com/0KQeG.jpg" alt="activity picutre"></p> <p>The yellow part is the TAB1,I need yellow color fill with the TAB1.any help will be appreciated :),thanks</p> <h2>EDIT:</h2> <p>I update my key code</p> <pre><code>public class MainActivity extends TabActivity implements OnTabChangeListener{ private TabSpec ts1,ts2,ts3;//declare three page private TabHost tableHost; @override public void onCreate(Bundle savedInstanceState){ super.onCreat(savedInstanceState); tableHost=this.getTabHost(); LayoutInflater.from(this).inflate(R.layou.activity_main,tableHost.getTabContentView()); ts1=tableHost.newTabSpec("Tabone"); ts1.setIndicator("TAB1",getResources().getDrawable(R.drawable.read2)); ts1.setContent(R.id.btn); ts2=tableHost.newTabSpec("Tabtwo"); ts2.setIndicator("TAB2"); ts2.setContent(R.id.et); ts3=tableHost.newTabSpec("Tabthree"); ts3.setIndicator("TAB3"); ts3.setContent(R.id.mylayout); tableHost.addTab(ts1); tableHost.addTab(ts2); tableHost.addTab(ts3); tableHost.setOntabChangedListener(this); } } </code></pre>
android
[4]
5,653,276
5,653,277
JavaScript works just once
<p>I have the following script. It works when the users clicks the search button but it only works once. Please guide me how can I make it work for more clicks. Thanks,</p> <pre><code> &lt;form action="" method="get" id="searchform"&gt; &lt;input name="q" type="text" id="search" size="32" maxlength="128" class="txt"&gt; &lt;input type="button" id="hit" value="Search" class="btn"&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; var nexturl =""; var lastid =""; var param; $(document).ready(function () { $("#hit").on("click", function myFunction() { param = $('#search').val(); alert("I am an alert box!"); if (param != "") { $("#status").show(); var u = 'https://graph.facebook.com/search/?callback=&amp;limit=100&amp;q='+param; getResults(u); } $("#more").click(function () { $("#status").show(); $("#more").hide(); pageTracker._trackPageview('/?q=/more'); var u = nexturl; getResults(u); }); }); }); &lt;/script&gt; </code></pre>
javascript
[3]
1,909,661
1,909,662
subclassing a View and overriding onDraw(Canvas)
<p>When I'm instantiating myView in the Activity, why is it necessary to pass the context and why is it required to pass the context to the View's constructor? What is the significance?</p> <pre><code>import android.app.Activity; import android.os.Bundle; import android.view.View; import android.graphics.Canvas; public class POCII extends Activity { myView mv = new myView(this); /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(mv); } } class myView extends View { public myView(Context context) { super(context); } @Override public void onDraw(Canvas canvas) { Paint paint = new Paint(); canvas.drawRect(0,0,100,100, paint); } } </code></pre>
android
[4]
5,098,613
5,098,614
Followup: Check if two integers have the same sign
<p>I experimented with the bitwise-operator suggested <a href="http://stackoverflow.com/questions/10298109/check-if-two-integers-have-the-same-sign">to my question</a> and <a href="http://stackoverflow.com/a/66968/1047823">here</a>.</p> <p>Check the results of my testsuite:</p> <pre><code>function equal(n1,n2){ var bool = (n1^n2 &gt;= 0)?true:false; document.write("&lt;div&gt;"+bool+" ("+(n1^n2)+")&lt;/div&gt;"); } equal(-5,-2); //true equal(-4,-20); //true equal(15,-2); //false equal(25,3); //true equal(-1,1); //false equal(1,1); //true equal(-1,-1); //true // edgecases equal(0,0); equal(-0,0); equal(+0,0); equal(-0,+0); equal(+0,-0); </code></pre> <p>outcome:</p> <pre><code>true (5) true (16) true (-15) true (26) true (-2) false (0) true (0) true (0) true (0) true (0) true (0) true (0) </code></pre> <p>My according <a href="http://jsfiddle.net/qSwFt/" rel="nofollow">fiddle is here</a>.</p> <p>The result confuses me very much. Am I too stupid? What has happened here?</p>
javascript
[3]
5,550,932
5,550,933
Save dialouge box in ASP.NET
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/12351415/showing-save-file-dialog-box-in-asp-net">Showing Save file dialog box in asp.net</a> </p> </blockquote> <p>Currently, In my website, users are able to download file from my website with option to open/save file. In addition to that I want to display save dialouge box which will allow user to save file to specific location on his local machine. How can i do that?</p>
asp.net
[9]
2,407,028
2,407,029
Please correct the following Python CGi program
<p>Please correct the following cgi program</p> <pre><code>#!usr/bin/python print "Content-type : text/html\n\n" print "&lt;html&gt;&lt;body&gt;&lt;span&gt;Hello World&lt;/span&gt;&lt;/body&gt;&lt;/html&gt;" </code></pre> <p>What is wrong with the above code?</p> <p>I am getting 500 Internal Server error and it is working through command prompt.</p> <p>And also please tell me why we need to keep two "\n" in statement </p> <pre><code>print "Content-type : text/html\n\n" </code></pre>
python
[7]
4,734,489
4,734,490
How to iterate & search in a dictionary?
<p>I've constructed a dictionary like this:</p> <p>dir is: </p> <pre><code>{((2, 1), 'South', 1): set([((2, 2), 'South', 1)]), ((1, 3), 'South', 1): set([((1, 4), 'South', 1)]), ((5, 3), 'East', 1): set([((4, 3), 'North', 1)]), ((2, 2), 'South', 1): set([((2, 3), 'East', 1)]), ((4, 2), 'East', 1): set([((3, 2), 'East', 1)]), ((1, 1), 'West', 1): set([((2, 1), 'South', 1)])} </code></pre> <p>I want to iterate thru this dictionary like this:</p> <p>If I have <code>((2, 1), 'South', 1)</code> as a key, then I'd like to extract its value <code>set([((2,2),'South',1)])</code> and take this as a key and search thru and find its value and so on...</p> <p>But I'm unable to construct a function for the same. I keep getting just one value and it goes in an infinite loop. I think I may be fetching the values the values incorrectly. Can someone please tell me how I can do this?</p>
python
[7]
2,076,877
2,076,878
loop in python !
<p>can anyone help me with loop i want loop that code</p> <pre><code>login_form_data = urllib.urlencode(login_form_seq) opener = urllib2.build_opener() site = opener.open(B, login_form_data).read() </code></pre> <p>the code allow me to login to site but site have problem and the problem is: you can't login from first time</p> <p>that mean I have to press submit then when page reload press submit again... so i think loop will do that but How!?</p>
python
[7]
89,878
89,879
how to convert a WebView into an ImageView?
<p>i have a WebView of an html page which shows only one image</p> <p><a href="http://www.google.fr/intl/en_com/images/srpr/logo1w.png" rel="nofollow">http://www.google.fr/intl/en_com/images/srpr/logo1w.png</a></p> <pre><code>webView = (WebView) findViewById(R.id.webView); webView.loadUrl("http://www.google.fr/intl/en_com/images/srpr/logo1w.png"); </code></pre> <p>is there a simple way to turn it into an ImageView ?</p>
android
[4]
3,584,942
3,584,943
Picture box always throws object reference not set to instance of object error
<p>I have a class which holds a picturebox. I have created an array of objects of my class, but when I try to create a new picture box, I am getting an error stating, object reference is not set to an instance of object. </p> <p>Here is how I am creating pictureboxes</p> <pre><code> GreyHound[] dog; public Form1() { InitializeComponent(); dog[1].MyPictureBox = new PictureBox(); dog[1].MyPictureBox = pictureBox1; dog[2].MyPictureBox = new PictureBox(); dog[2].MyPictureBox = pictureBox2; dog[3].MyPictureBox = new PictureBox(); dog[3].MyPictureBox = pictureBox3; dog[4].MyPictureBox = new PictureBox(); dog[4].MyPictureBox = pictureBox4; </code></pre> <p>Edited Code :</p> <p>GreyHound[] dog;</p> <pre><code> public Form1() { InitializeComponent(); dog = new GreyHound[4]; dog[0].MyPictureBox = new PictureBox(); dog[0].MyPictureBox = pictureBox1; dog[1].MyPictureBox = new PictureBox(); dog[1].MyPictureBox = pictureBox2; dog[2].MyPictureBox = new PictureBox(); dog[2].MyPictureBox = pictureBox3; dog[3].MyPictureBox = new PictureBox(); dog[3].MyPictureBox = pictureBox4; } </code></pre>
c#
[0]
1,634,013
1,634,014
using str_replace with file_get_contents
<p>I am using file_get_contents to grab a page, but i need to replace some data in the contents of the page before echoing it. </p> <p>I have this so far (this script runs on domain2.com)</p> <pre><code>&lt;?php $page = file_get_contents('http://domain.com/page.html'); str_replace('href="/','href="http://domain.com','$page'); echo $page; ?&gt; </code></pre> <p>The problem is, that when the page displays, some links on the domain.com page read:</p> <pre><code>&lt;a href=/about.html&gt; </code></pre> <p>Which when i call in my script, are prepending it with the incorrect domain. I tried using str_replace, to look for</p> <pre><code>href="/ </code></pre> <p>and replace it with</p> <pre><code>href="http://www.domain.com/ </code></pre> <p>But its not working. Any clues?</p>
php
[2]
294,973
294,974
Python CSV DictReader ignore columns?
<p>If I'm using CSV.dictReader to read in an CSV, how would I go about having it ignore certain columns in the CSV?</p> <p>For example,</p> <pre><code>"id","name","address","number","created" "123456","someName","someAddress","someNumber","2003-5-0294" </code></pre> <p>And I want to just get the id and name using the reader, discarding and ignoring the rest. I tried using fieldnames but it still reads it in and sets it as "None". I noticed that the csv.DictWriter has an 'ignore' function but it seems the DictReader does not. Was hoping there was a more elegant way to do this versus just reading and then writing only the columns I want to another CSV and then reading that CSV using DictReader to do further processing.</p> <p>Thanks guys!</p>
python
[7]
3,748,804
3,748,805
Silde up / down
<p>I have this markup</p> <pre><code>&lt;div id="content" &gt; &lt;h1&gt;&lt;a href="#"&gt;Sample 1&lt;/a&gt;&lt;/h1&gt; &lt;img src="" alt="sample 1" /&gt; &lt;h1&gt;&lt;a href="#"&gt;Sample 2&lt;/a&gt;&lt;/h1&gt; &lt;img src="" alt="sample 2" /&gt; &lt;h1&gt;&lt;a href="#"&gt;Sample 3&lt;/a&gt;&lt;/h1&gt; &lt;img src="" alt="sample 3" /&gt; &lt;h1&gt;&lt;a href="#"&gt;Sample 4&lt;/a&gt;&lt;/h1&gt; &lt;img src="" alt="sample 4" /&gt; &lt;/div&gt; </code></pre> <p>I want that all images hide when the page loads, then when I click on every "h1", its image slide down and when I click on it again, it slides up. 1- consider that I do not want all images slide down and up when I click on a "h1", just the related image slides up and down.</p> <p>help me please</p>
jquery
[5]
3,721,184
3,721,185
How to display this in format dd.mm.yyyy?
<pre><code>alert(end); //Wed Oct 22 2014 00:00:00 GMT+0200 (CEST) </code></pre> <p>How to display this in format dd.mm.yyyy ?</p>
javascript
[3]
446,102
446,103
Opening jar files in java
<p>I want to know how to load a jar file through another jar file</p> <p>I.e. I hit the start button and it loads up the other jar file.</p> <p>The start button is a button in the first app.</p>
java
[1]
4,602,822
4,602,823
App icon not showing up on emulator
<p>I created a simple splash screen application, and it works just fine only when i click the "Run" button in eclipse indigo, and I am not able to find the icon at all in the emulator. Where is icon?! I ran it as android 4.0.3.</p>
android
[4]
2,150,041
2,150,042
python unpack little endian
<p><P>I'm trying to use Python read a binary file. The file is in LSB mode. I import the struct module and use unpack like this:</p> <pre><code>f=open(sys.argv[1],'rb') contents= unpack('&lt;I',f.read(4))[0] print contents f.close() </code></pre> <p><p>The data in the file is 0XC0000500 in LSB mode, and the actual value is 0X000500C0. So you can see the LSB mode's smallest size is per byte. <p>However, I use a Mac machine, perhaps because of the version of my gcc or machine (I am not for sure. I just read the <a href="http://docs.python.org/library/struct.html" rel="nofollow">http://docs.python.org/library/struct.html</a> about the sizeof and sys.bitorder), the result from the above code is X0500C000, so the size of the LSB mode is 2Bytes. <p>How should I solve this problem? <p>I will keep digging no matter this question is answered or not, and I will update if I ever get something. <p> Thanks in advance. <p>:)</p> <p>ps: The data file is an ELF file for a 32-bit machine. <p>pps: Since I am going to read a huge amount of data, and this is a general problem in the reading, so the manual way is not the best for me. Question is still open for answers. Thank you. <p>ppps: &lt; means "little-endian,<b>standard size (16 bit)</b>" Now I read this...... I am going crazy...</p>
python
[7]
4,594,605
4,594,606
Problem with Refreshing data in ExpandableListView
<p>My problem is when I want to refresh data in ExpandableListView while being in that current activity. I create adapter and when I want to add new data to list I call again constructor of that adapter(it is my private variable) with all new data....and then I call onContentChanged() method to redraw my list. But what happens is that I cant expand my list any more...like it is blocked or something and logcat isn't saying anything... This is the code that i call after setting new data in arraylists and maps:</p> <pre><code> mAdapter = new MyExpandableListAdapter( this, groupData, R.layout.contact_list_parent, new String[] { NAME ,NUM_PHOTOS},//NUM_PHOTOS new int[] { R.id.rowText1, R.id.rowText2, R.id.photoAlbumImg }, childData, R.layout.contact_list_child, new String[] { NAME,NUM_PHOTOS}, //NUM_PHOTOS new int[] { R.id.rowText1, R.id.rowText2, R.id.photoAlbumImg } ); this.onContentChanged(); </code></pre> <p>If anyone knows answer to this question please help me:) Thanks.</p>
android
[4]
2,594,763
2,594,764
how to make default no when contact is clicked to send sms....in android
<p>how to get contact number when its clicked on contact to send sms. and in the method showSelectedNumber(type, number); what to write in this method,i m not getting please provide me a solution to this method or any alternate way to get contact default.</p>
android
[4]
4,680,694
4,680,695
How to show videos from sdcard in thumbnail view?
<p>How can I get a list of all videos from a folder on the sdcard and display the thumbnails in a list? When I click on a thumbnail, it should then open that video for playback.</p> <p>Please help me out. </p>
android
[4]
5,271,200
5,271,201
Sum instead of concatenation
<p>I have my code</p> <pre><code>sum=parseFloat($('input[name=fieldname]').val()) * 60 + parseFloat($('input[name=fieldname]').val()) + (($('input[name=fieldname]').val()) /60).toFixed(2). </code></pre> <p>It get's the values from felds where I enter duration and it should give me the sum in minutes. The problem is that the sum I get concatenates the 3 fields instead of returning the number of minutes.</p> <p>Eg: for 1 hours and 20 minutes I get 6020 instead of (60+20) 80</p> <p>Edit: The code above is the generic form, here is the exact code.</p> <pre><code>var sum = parseFloat($('input[name="&lt;?php esc_attr_e( $field-&gt;field_id ); ?&gt;hrs"]').val())*60 + parseFloat(($('input[name="&lt;?php esc_attr_e( $field-&gt;field_id ); ?&gt;mins"]').val()) + parseFloat($('input[name="&lt;?php esc_attr_e( $field-&gt;field_id ); ?&gt;secs"]').val())/60).toFixed(2) </code></pre>
javascript
[3]
981,648
981,649
How can I get android device Unique ID?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id">Is there a unique Android device ID?</a> </p> </blockquote> <p>I used below code to get android device IMEI and How can I change below code to get android device Unique ID. </p> <pre><code>String getDeviceID1(TelephonyManager phonyManager){ String id = phonyManager.getDeviceId(); if (id == null){ id = "not available"; } int phoneType = phonyManager.getPhoneType(); switch(phoneType){ case TelephonyManager.PHONE_TYPE_NONE: return "" + id; case TelephonyManager.PHONE_TYPE_GSM: return "" + id; case TelephonyManager.PHONE_TYPE_CDMA: return "" + id; /* * for API Level 11 or above * case TelephonyManager.PHONE_TYPE_SIP: * return "SIP"; */ default: return "" + id; } //I used to show IMEI TextView textDeviceID = (TextView)findViewById(R.id.deviceid); //retrieve a reference to an instance of TelephonyManager TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); textDeviceID.setText(getDeviceID1(telephonyManager)); } </code></pre>
android
[4]
3,369,208
3,369,209
java : Need help converting an Object to Array
<p>I have this Userlist Object with some data in it </p> <pre><code>Userlist userlist = new Userlist(); userlist.setUserlistItem(userlistitem); </code></pre> <p>Now i have another Object UserDatalists , the structure of UserDatalists is shown below </p> <pre><code>public class UserDatalists{ private Userlist[] userlist; public Userlist[] getUserlist() { return userlist; } public void setUserlist(Userlist[] userlist) { this.userlist = userlist; } } </code></pre> <p>As you can see that the UserDatalists Object accepts an array of Userlist .</p> <p>Please tell me how can i convert the Userlist to an array , so that i can set it inside the UserDatalists</p> <pre><code>public class Userlist { private static final long serialVersionUID = 1L; public String getId() { return id; } public void setId(String id) { this.id = id; } public UserlistItem[] getUserlistItem() { return UserlistItem; } public void setUserlistItem(UserlistItem[] userlistItem) { UserlistItem = userlistItem; } private String id; private UserlistItem[] UserlistItem; } public class UserDatalists { private Userlist[] userlist; public Userlist[] getUserlist() { return userlist; } public void setUserlist(Userlist[] userlist) { this.userlist = userlist; } } </code></pre>
java
[1]
2,479,675
2,479,676
Java and UDP web server
<p>I thinking of building a mini-server where Java can send data through UDP protocol so that my other Flex application can read. The data consist of short string of up to 64 characters. Should I consider HTTP instead?</p> <p>Where can I find out more tutorial on building HTTP/UDP web server</p>
java
[1]
5,200,373
5,200,374
JavaScript target question
<p>Here is some code I don't understand, but I know it opens the link in THE SAME WINDOW. I like it to open in BLANK NEW WINOWS... what to add/modify?</p> <pre><code>[some code before] _.addEvent(b, 'click', function (e, i) { document.location.href = (('undefined' !== typeof i) ? i: e.target).getAttribute('flickrshow-u')});_.addEvent(b, 'load', function (e, i) { [some code after] </code></pre> <p>I tried to add <code>e.target = "_blank";</code> before document, but no luck! I got this error: setting a property that has only a getter.</p>
javascript
[3]
3,797,193
3,797,194
Setting\Getting Environment Variables through batch file inside java program
<p>I am facing a problem where I need to run a bat file from java program. This Batch file contains certain SET ms-dos command which i need to access further down in my application.</p> <p>I used ProcessBuilder Class to invoke the batch file but processBuilder.environment() is not returning me the variables set by the batch file. </p> <p>DOS SET command sets the variables on that prompt only. </p> <p>I am unable to find the solution for this problem.</p> <p>Is there any ulternate approach for such issue. I cant change the Batch file.</p> <p>Regards Abhay </p>
java
[1]
1,919,297
1,919,298
Format a Number, Exactly Two in Length?
<p>I have an integer that is less then 100 and is printed to an HTML page with JavaScript. How do I format the integer so that it is exactly two digits long? For example:</p> <p>01<br> 02<br> 03<br> ...<br> 09<br> 10<br> 11<br> 12<br> ... </p>
javascript
[3]
4,291,080
4,291,081
jquery, perl, form and serialize command not working IE browser
<p>I have this form section with dynamic clone of select drop down menus.</p> <p>The form are passing the values into the serialize. </p> <pre><code> var data3 = $("#advance_mode_inputs").serialize(); </code></pre> <p>Firefox works but in IE, it isn't working. Any ideas? There were no errors reported by the IE browser.</p> <p>regards, Gordon</p>
jquery
[5]
3,025,643
3,025,644
I get the error: ‘cout’ was not declared in this scope when I try to use cout
<pre><code> #include&lt;iostream&gt;//test.cpp int main() { char t = 'f'; char *t1; char **t2; cout&lt;&lt;t; return 0; } </code></pre> <p>g++ test.cpp</p> <p>I get this error </p> <p>why?</p>
c++
[6]
4,709,982
4,709,983
White square after loading in Mozilla
<p>I'm running some beta tests in this URL: <a href="http://acquasports.esp.br/site/" rel="nofollow">http://acquasports.esp.br/site/</a></p> <p>Whenever I load the main page and the jquery is already loaded (when I click the company logo, per example), the browser Mozilla renders the menu area as a large white square.</p> <p>What could be causing this?</p> <p>There are different scripts running in the main page, maybe there is somekind of conflict: </p> <ul> <li>A toggleFade in the menu</li> <li>A horizontal scroll for news</li> </ul> <p>Thanks for the attention,</p> <p>Leo</p>
jquery
[5]
174,793
174,794
class properties that can be assigned only when creating object?
<p>It's possible in C# to write things such way:</p> <pre><code>Instrument instr = new Instrument { ClassCode = "Hello", Ticker = "World" }; </code></pre> <p>However to do that you have to add <code>set;</code> in the corresponding class:</p> <pre><code>class Instrument { public string ClassCode { get; set; } public string Ticker { get; set; } } </code></pre> <p>This means that later someone can accidentally change value:</p> <pre><code>instr.ClassCode.set = "Destroy" </code></pre> <p>And I don't want to allow that. I.e., from one hand I want a readonly property, from another hand i want to create objects like that:</p> <pre><code>Instrument instr = new Instrument { ClassCode = "Hello", Ticker = "World" }; </code></pre> <p>I'm not sure if this is possible. Probably I should use fields or something else instead of properties. I only want to have the syntax of the last sentence but keep things readonly at the same time.</p> <p><strong>upd:</strong> In short no, readonly properties are not allowed in any way. Regular constructor and "get" should be used in this case.</p>
c#
[0]
5,024,833
5,024,834
Google Javascript tutorial like Mozilla developer Center
<p>I am just a beginner, so forgive me for any mistake.</p> <p>I am searching for JavaScript Documentation from Google such like Mozilla have their own.</p> <p>Please suggest...</p>
javascript
[3]
4,843,101
4,843,102
Transfering data from a sensor to the iphone
<p>I have an external device (some kind of sensor) that can do a measurment. This sensor can be connected to a PC via Bluetooth or USB cable, and it also comes with its own software. I want to develop an app for iphone that will analyze the data that this sensor is measuring (for example creating a graph, calculating some equations etc.). How can i make my iphone to "recognize" this sensor, so the app will get the data that has benn measured from the sensor? is there any manual which explain how to code this? our preffered way of transfering the data is via Bluetooth, so there will be no need of using cables.</p> <p>Thanks a lot, Or.</p>
iphone
[8]
1,511,518
1,511,519
Android Platform Backwards Compatable
<p>I am importing an android app into Eclipse. I am receivng the following error</p> <pre><code>Unable to resolve target 'Google Inc.:Google APIs:8 </code></pre> <p>I have installed Android 4.0.3 (API15). Do I also need to install Android 2.2(API8)?</p> <p>Is Android 4.0.3 (API15) not backwards compatable?</p>
android
[4]
33,958
33,959
How to compare objects in C#
<p>How do you compare objects in C#. Here is a sample of my code</p> <pre><code>namespace MyService { public static class CurrentVCobj { public static string id { get; set; } public static string Month { get; set; } public static string Year { get; set; } } public static class ResponseVCObj { public static string id { get; set; } public static string Month { get; set; } public static string Year { get; set; } } } </code></pre> <p>I would like to assign values to the above objects (CurrentVCobj and ResponseVCObj) then compare(TRUE OR FALSE) them in the method below to see if they are equal</p> <pre><code>public static void compareMethood(IEnumerable&lt;tets&gt; vc ) { var myvar = vc; var mycac = rep.populateDict(); foreach (var item in myvar) { ResponseVCObj.id = item.id; ResponseVCObj.Month = DateRange.Month; ResponseVCObj.Year = DateRange.Year; CurrentVCobj.id = currentV.Select(d =&gt; d.Value.id).ToString() ; CurrentVCobj.Month = currentV.Select(d =&gt; d.Value.Month).ToString(); CurrentVCobj.Year = currentV.Select(d =&gt; d.Value.Year).ToString(); //COMPARE OBJECTS HERE } } </code></pre>
c#
[0]
2,066,477
2,066,478
filter select box options using jquery
<p>I have two selection boxes,one contains different country names and another contains all state names of all countries.</p> <p>Then if i select <code>India</code> from country selection box, the state selection box has need to show all states of <code>India</code> alone and remove all other states from it. </p> <p>I need to do this in JQuery, any one is there to guide me!!!!!</p>
jquery
[5]
5,586,632
5,586,633
how to check for Notice (8) Undefined index
<p>I know why I am getting this error, and this is because there currenly no ratings for this specific dish, so it is null or empty but I am not sure how to handle it.. I tried this but still the same error came up..</p> <pre><code> if(empty($rate_dishes[$j]["DishRating"]["dish_id"])) { echo $this-&gt;Form-&gt;hidden('dish_id', array('value'=&gt; $this-&gt;params['var'])); } else { echo $this-&gt;Form-&gt;hidden('dish_id', array('value'=&gt; $rate_dishes[$j]["DishRating"]["dish_id"])); } </code></pre> <p>Basically I am providing the dish id if its not provided by the posted array.. Whenever there is a rating for that particular dish it takes the 'else' condition.. but if it does not have a rating.. it gets to the first condition and still shows that error..</p> <pre><code>the URL would be /special_dishes/rate_dishes/4/?var=4 </code></pre> <p>PS: new to CakePHP bare with me</p>
php
[2]
184,446
184,447
class and private variables
<pre> class Test1: def __init__( self ): self.__test = 1 def getvalue( self ): return self.__test class Test2( Test1 ): def __init__( self ): Test1.__init__( self ) self.__test = 2 test = Test2() </pre> <p>Why print test.getvalue() return 1 ?</p>
python
[7]
1,643,891
1,643,892
How can I bold text in ASP .NET
<p>How can I bold my output like this</p> <p>Student "<strong>John</strong>" assigned to Officer "<strong>Mick</strong>".</p> <p>i want <strong>John</strong> and <strong>Mick</strong> bold in web</p> <p>This is my code aspx :</p> <blockquote> <p>this.lblAssignee.Text = " Student \"" + StudentAssign + "\" assigned to Officer \"" + objAssign.FullName + "\".";</p> </blockquote>
asp.net
[9]
1,079,908
1,079,909
Changing "/" to "\" [C#]
<p>I have already seen the other way around. But this one I can not catch. I am trying to get a part of a web resourcePath and combine it with a local path. Let me Explain a bit more.</p> <pre><code>public string GetLocalPath(string URI, string webResourcePath, string folderWatchPath) // get the folderwatcher path to work in the local folder { string changedPath = webResourcePath.Replace(URI, ""); string localPathTemp = folderWatchPath + changedPath; string localPath = localPathTemp.Replace(@"/",@"\"); return localPath; } </code></pre> <p>But, When I do this the result is like</p> <pre><code>C:\\Users </code></pre> <p>But what I want to have is</p> <pre><code>C:\Users </code></pre> <p>Not "\\" but my debug shows it like <code>C:\\Users</code> but in the console it shows it as I expect it. I want to know the reason for that thanks..</p>
c#
[0]
4,615,113
4,615,114
How to extract javascript contents
<p>As we extract html contents using </p> <pre><code>alert(document.all[0].innerHTML); </code></pre> <p>how can i extract javascript contents.</p> <p>Anyone who knows the answer, please help me Thanks in advance.</p>
javascript
[3]
5,933,799
5,933,800
split python source code into multiple files?
<p>I have a code that I wish to split apart into multiple files. In matlab one can simply call a <code>.m</code> file, and as long as it is not defined as anything in particular it will just run as if it were part of the called code. Example (edited):<br> <strong>test.m</strong> (matlab)</p> <pre><code>function [] = test() ... some code using variables ... test2 </code></pre> <p><strong>test2.m</strong> (matlab)</p> <pre><code>... some more code using same variables ... </code></pre> <p>Calling <code>test</code> runs the code in test as well as the code in test2.</p> <p>Is there a similar way for python, to put <code>... some more code ...</code>, into an external file, that will simply be read as if it is in the file that it is called from? </p>
python
[7]
4,341,040
4,341,041
Uploading image to twitter using twitter api in android
<p>Is it possible to post image to twitter using twitter api?</p> <p>If possible how to do,please provide some information on this.</p> <p>Thanks</p>
android
[4]
167,268
167,269
Sorting files by creation/modification date in PHP
<p>In PHP, how to retrieve the files contained into a folder sorted by creation date (or any other sorting mechanism)?</p> <p><a href="http://uk3.php.net/manual/en/function.readdir.php" rel="nofollow">According to the doc</a>, the <em>readdir()</em> function:</p> <blockquote> <p>The filenames are returned in the order in which they are stored by the filesystem.</p> </blockquote>
php
[2]
1,764,010
1,764,011
Dynamic radio buttons
<p>I have a page full of radio buttons and it won't display "Success: You have completed all questions" dynamically.</p> <p>html:</p> <pre><code> Question 1:&lt;br /&gt; &lt;label&gt;&lt;input name="income" type="radio" value="1" /&gt;10,000&lt;/label&gt; &lt;br /&gt; &lt;label&gt;&lt;input name="income" type="radio" value="3" /&gt;30,000&lt;/label&gt; &lt;br /&gt; &lt;label&gt;&lt;input name="income" type="radio" value="5" /&gt;50,000&lt;/label&gt; &lt;br /&gt; Question 2:&lt;br /&gt; &lt;label&gt;&lt;input name="debt" type="radio" value="1" /&gt;10,000&lt;/label&gt; &lt;br /&gt; &lt;label&gt;&lt;input name="debt" type="radio" value="5" /&gt;50,000&lt;/label&gt; &lt;br /&gt; &lt;label&gt;&lt;input name="debt" type="radio" value="10" /&gt;10,000&lt;/label&gt; &lt;br /&gt; &lt;div id="display"&gt;0&lt;/div&gt; </code></pre> <p>script:</p> <pre><code>$('#display').each(function(){ if($(':radio[name=income]:checked, :radio[name=debt]:checked').length == 2) $("#display").html('&lt;p&gt;Success: You have completed all questions&lt;/p&gt;'); else $("#display").html('&lt;p&gt;You have NOT yet completed all questions&lt;/p&gt;'); }); </code></pre> <p>Thank if you can help.</p> <p><a href="http://jsfiddle.net/C7NmD/" rel="nofollow">http://jsfiddle.net/C7NmD/</a></p>
jquery
[5]
2,026,773
2,026,774
Creating a guage in Android
<p>I want to create gauge, it should contain a semi circle and the pointer has to move according to my data. Drawing with canvas is the only solution? How to start with canvas? and How to move the pointer dynamically?</p> <p>regards,</p> <p>Krishna</p>
android
[4]
2,105,003
2,105,004
Show Yes/No-Dialog instead of OK/Cancel
<p>I hate the OK/Cancel dialogs, because if my application ask somebody if (s)he really want to do something you should never answer with "Cancel".</p> <p>A little example:</p> <pre><code>final AlertDialog.Builder b = new AlertDialog.Builder(this); b.setIcon(android.R.drawable.ic_dialog_alert); b.setTitle("Hello World"); b.setMessage("Did you do your homework?"); b.setPositiveButton(android.R.string.yes, null); b.setNegativeButton(android.R.string.no, null); b.show(); </code></pre> <p>Is it possible that the constants "yes" and "no" really means "yes" and "no" with localization? Or have I do this explicit in my string resource and can't use global constants. So I replace the two lines with:</p> <pre><code>b.setPositiveButton("Yes", null); b.setNegativeButton("No", null); </code></pre> <p>(or the resources instead of constants here)</p> <p>Sincerely xZise</p>
android
[4]
643,792
643,793
Advanced Javascript form validation function
<p><a href="http://www.javascript-coder.com/html-form/javascript-form-validation.phtml#using" rel="nofollow">This</a> is what I'm using.</p> <p>It's great. I only need to add function that checks if one of "cp", "bp", "hp" input area is entered or not. If not it should give an error that says "Please enter at least 1 phone number." </p> <p><em>(cp = cell phone, bp = business phone, hp = home phone)</em></p>
javascript
[3]
5,896,404
5,896,405
When is it best to use the stack instead of the heap and vice versa?
<p>In C++, when is it best to use the stack? When is it best to use the heap?</p>
c++
[6]
3,205,510
3,205,511
UILongPressGesture in iphone sdk
<pre><code> UILongPressGestureRecognizer *longPressOnUndoGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressOnUndoGesture:)]; [longPressOnUndoGesture setMinimumPressDuration:2.0]; [longPressOnUndoGesture release]; </code></pre> <p>i have the above code to deasctivate the autoscroll timer in my applicationthis is the function for this.</p> <pre><code>-(void) handleLongPressOnUndoGesture:(UILongPressGestureRecognizer*)recognizer { [autoscrollTimer invalidate]; } </code></pre> <p>but when i taptohold for 2 seconds it wont stop the timer.is there any error in my code for gesture. Thanks in advance.</p>
iphone
[8]
3,086,064
3,086,065
I keep on having problems with syntax and calculating the roots of the quadratic equation
<p>Hey I am having problems with calculating the roots of the quadratic equation with the quadratic formula, using python's complex number functionality.</p> <p>When I try</p> <pre><code>&gt;&gt;&gt; if root&lt;0: root=abs(complex(root)) j=complex(0,1) x1=(-b+sqrt(root))/2*a x2=(-b-j+sqrt(root))/2*a else: </code></pre> <p>I get the error message</p> <blockquote> <p>SyntaxError: invalid syntax</p> </blockquote> <p>Then, when I try instead</p> <pre><code>&gt;&gt;&gt; if root&lt;0: root=abs(complex(root)) j=complex(0,1) x1=(-b+j+sqrt(root))/2*a x2=(-b-j+sqrt(root))/2*a break </code></pre> <p>I get the error</p> <blockquote> <p>SyntaxError: 'break' outside loop</p> </blockquote> <p>I am trying to put:</p> <pre><code>else: x1=(-b+j+sqrt(root))/2*a x2=(-b-j+sqrt(root))/2*a </code></pre> <p>under it but it won't work.</p> <p>Any help please?</p>
python
[7]
4,627,263
4,627,264
Data Parsing Question C#
<p>I am getting back data in a string like the following:</p> <pre><code>dog,cat,snake,bird,cow,parrot,lion grass,green,fruit,bag,car,melon,coat apple,orange,grape,butter,jelly,chips,milk </code></pre> <p>I want to put this data in a gridView where each of these rows stands for a row in a gridView, I also wanna take the first entry or each row and populate a dropdown.</p> <p>The problem is how do I in code know where each row starts and ends? Because the data is coming back like this in a string.</p>
c#
[0]
2,984,336
2,984,337
how come ![] is not true?
<p>Was just playing around with nodejs and chrome's console when I tested this:</p> <pre><code>[] == true // false ![] == true // false !![] == true // true </code></pre> <p>How come? Isn't it wrong?</p>
javascript
[3]
1,356,724
1,356,725
asp.Net + encrypted QueryString requested not reading '+' sign
<p>I have an encrypted query string passed from another page, it reads something like "/se73j+sef" but after receiving it, the '+' sign got omitted and became "/se73j sef". Is this normal? Please kindly advice. Thanks.</p>
asp.net
[9]
1,531,115
1,531,116
Split a text box in one form to multiple labels into another form
<p>I need to send information input into a text box in one form to labels in another form. I have it split at the moment, but since there is only one split If the user enters more that one space in the text box (lets say First, Middle, Last) the second form will only show first and middle. I need to split it twice times just in case the user does enter two spaces. </p> <p>This is the code I have at the moment.</p> <pre><code> //Name Split if (strTextBox.Contains (' ')) { var fullname = strTextBox; var names = fullname.Split(' '); // perhaps TODO -- there could be a middle name/initial label3.Text = names[0]; // first label5.Text = names[1]; // middle initial } else //without this conditional if a user only enters a first name the app fails. label3.Text = strTextBox; </code></pre> <p>I have been trying t figure this out but I cannot seem to wrap my head around it. This code compiles fine but I cannot get it to show the last name.</p> <p>Here is my code:</p> <pre><code> //Name Split if (strTextBox.Contains (' ')) { var fullname = strTextBox; var names = fullname.Split(' '); // perhaps TODO -- there could be a middle name/initial label3.Text = names[0]; // first label5.Text = names[1]; // middle initial } else if (strTextBox.Contains (" " + " ")) { var FN = strTextBox; var N = FN.Split(' '); label3.Text = N[0] + " " + N[1]; // first and middle label5.Text = N[2]; // last name } else //incase only a first name is entered label3.Text = strTextBox; } </code></pre> <p>Any Suggestions?</p> <p>I already have passing the information to the next form, I just need to fix this conditional so I can get all three names just incase the user does have first, middle, last.</p>
c#
[0]
1,389,895
1,389,896
Don't set variable if string does not start with six integers in c# 2.0?
<p>I have</p> <pre><code>string customer_id; </code></pre> <p>In a for loop I assign a value coming from a database request</p> <pre><code>customer = (Customer)records[i]; </code></pre> <p>I want to assign customer_id to customer.entityId only if entityId (a string) starts with six integers.</p> <p>So:</p> <pre><code>string internal_id = ""; string customer_id = ""; Customer customer; for (int i = 0, j = (response.pageIndex - 1) * _pageSize; i &lt; records.Length; i++, j++) { customer = (Customer)records[i]; internal_id = customer.internalId; customer_id = customer.entityId; } </code></pre> <p>If entityId is something like xxyyzz then ignore it, if it is 123456 xxyyzz then assign the two variables. How do I best perform this check?</p> <p>Thanks in advance</p>
c#
[0]
1,777,317
1,777,318
What's the easiest way to generate a List<int> of ordered numbers in C#?
<p>This seems like a no-brainer:</p> <pre><code>List&lt;int&gt; steporders = new List&lt;int&gt;(); for (int i = 1; i &lt;= 10; i++) { steporders.Add(i); } </code></pre> <p>But I figure there's some simpler, better or more clever way I haven't thought of. Is there?</p>
c#
[0]
5,226,147
5,226,148
Getting values from a response based on an "expected response" expression
<p>I have an expected response, which <strong>could be in any format</strong>, but for example:</p> <pre><code>myfoo={FOO}&amp;mybar={BAR}&amp;mybaz={BAZ} </code></pre> <p>Then I have the response string:</p> <pre><code>myfoo=hello&amp;mybar=test&amp;mybaz=yup </code></pre> <p>So my question is, in JavaScript, how can I use these two strings to create an object containing the values, like so:</p> <pre><code>{ FOO : 'hello', BAR : 'test', BAZ : 'yup' } </code></pre> <hr> <p>In another example the expected string could be a sentence:</p> <pre><code>Hello, my name is {NAME} and I am {AGE} years old. </code></pre> <p>Then the actual response:</p> <pre><code>Hello, my name is Fred and I am 30 years old. </code></pre> <p>Which should build:</p> <pre><code>{ NAME : 'Fred', AGE : '30' } </code></pre>
javascript
[3]
5,811,720
5,811,721
Question about real_2d_array in alglib using c++
<p>I'm a bit confused about using the setlength() function of real_2d_array in alglib. Below is a code example:</p> <pre><code>int main() { using namespace alglib; int s=3, t=5, i, j; real_2d_array fmatrix; fmatrix.setlength(s,t); for(i=0;i&lt;s;i++) { for(j=0;j&lt;t;j++) fmatrix[i][j]=i+j; } for(i=0;i&lt;s;i++) { for(j=0;j&lt;t;j++) cout &lt;&lt; fmatrix[i][j] &lt;&lt; " "; cout &lt;&lt; endl; } return 0; } </code></pre> <p>Running this, I get (as expected):</p> <p>0 1 2 3 4</p> <p>1 2 3 4 5</p> <p>2 3 4 5 6</p> <p>But if I switch around s and t in setlength (making it fmatrix.setlength(t,s) ), instead of getting a segmentation fault or something, I get</p> <p>0 1 2 3 1</p> <p>1 2 3 4 2</p> <p>2 3 4 5 6</p> <p>Does anyone know what's going on here? is the last column (1,2,6) completely random and unspecified?</p>
c++
[6]
5,544,795
5,544,796
Getting this error when running my web service
<blockquote> <p>Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. </p> <p>Parser Error Message: Could not create type 'DBwebService.WebService1'.</p> <p>Source Error: </p> <p>Line 1: &lt;%@ WebService Language="C#" CodeBehind="WebService1.asmx.cs" Class="DBwebService.WebService1" %></p> <p>Source File: /WebService1.asmx Line: 1 </p> <p>Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 --. Metadata contains a reference that cannot be resolved: 'http://localhost:50387/WebService1.asmx'. The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' Server Error in '/' Application. Parser Error '. The remote server returned an error: (500) Internal Server Error. If the service is defined in the current solution, try building the solution and adding the service reference again.</p> </blockquote>
asp.net
[9]
2,235,322
2,235,323
Step 1 into Android Development
<p>I am yet to touch the whole android platform, jst getting my tools in order. I noticed that there is Android <a href="http://developer.android.com/sdk/android-4.0.html" rel="nofollow">4, 3, 2</a></p> <p>What should I start on? Any IDE that is prefered? </p> <p>I am reading "Learning Android By Marko Gargenta, O'REILLY Publications" as suggested in <a href="http://stackoverflow.com/questions/1114287/good-book-for-beginning-android-development">this thread</a> </p>
android
[4]
5,489,736
5,489,737
jquery templating plugin - using a normal unnamed array?
<p>Does anyone know if it's possible to just use a normal array (e.g. [1,2,3]) with the jQuery templating plugin?</p>
jquery
[5]