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
3,489,035
3,489,036
Is a JavaScript object automaticaly created for every HTML id?
<p>I'm giving a JavaScript course, and one of my students came up with a weird syntax that works but I don't understand why. I understand what it does, but would like to know if it is part of the JavaScript standard to react this way, or if it's a Firefox "glitch". The question was simply to have a paragraph turn green or red depending if the mouse is over another paragraph. His answer was:</p> <pre><code> &lt;p id ="p1"&gt;a text&lt;/p&gt; &lt;p onmouseover = "p1.style.color = 'red';" onmouseout = "p1.style.color = 'green';"&gt;another text&lt;/p&gt; </code></pre> <p>What I find strange is the "p1.style" part. What is p1? I understand that it is the <code>&lt;p id="p1"&gt;</code>. But does JavaScript automatically create an object for every ID?</p>
javascript
[3]
1,937,156
1,937,157
how to read a line in C++ in a certain pattern and store it in a string?
<p>I want to read each line of txt file which resembles something like this </p> <p>1190/2132 123/23123 45 </p> <p>I want to read the whole line and then store them in three separate strings for future use to build a tree . I am using fgets right now , but getting errors regarding putting it into a string . How should i do it ?</p>
c++
[6]
4,424,807
4,424,808
Is there a lib to convert timestamp into time offset
<p>I am looking for a javascript library that takes unix timestamp string as an input and converts it to something like '5 minutes ago', '3 days ago', etc...</p> <p>The purpose is to display time difference of the forum post but I don't want to apply this logic in the php script on the server, I want to send the data just how it's stored in database and let the client do this extra work.</p> <p>Does anybody know if class of function exists in any js library for this?</p>
javascript
[3]
744,817
744,818
android Not allowed to load local resource:file:///android_asset
<p>i come across a strange issue that when load html page from server, in the page contains a script that links to android sdcard js file. and it fails.</p> <p>code like below :</p> <p>java part code :</p> <pre><code>String url ="http://192.168.84.86:8080/test/maw/js_load_test.html"; this.loadUrl(url); </code></pre> <p>complements: I use phonegap develop android web application.</p> <p>js_load_test.html file part code :</p> <pre><code>&lt;script src="file:///sdcard/test.js"&gt;&lt;/script&gt; and i also try : &lt;script src="file:///android_asset/www/js/test.js"&gt;&lt;/script&gt; test.js file exists, and js file path is correct. but in logcat shows: when load first script: 03-18 13:01:12.467: E/Web Console(26189): Not allowed to load local resource: file:///sdcard/test.js at :0 and second script: 03-18 13:01:53.467: E/Web Console(26189): Not allowed to load local resource: file:///android_asset/www/js/test.js at :0 </code></pre> <p>thanks so much.</p>
android
[4]
1,251,815
1,251,816
Trying to list Android Bookmarks showing History as well
<p>I'm trying to list the system default bookmarks but when I run the app, it list not only the bookmarks but also show History URLs and Most Visited URLs.</p> <p>How can I avoid this and show only the bookmarks?</p> <p>here is the method: (imported everything necessary + permissions valid) </p> <pre><code>public class CLASSNAME extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String[] projection = new String[] {Browser.BookmarkColumns._ID, Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL}; String[] displayFields = new String[] {Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL}; int[] displayViews = new int[] { android.R.id.text1, android.R.id.text2 }; Cursor cur = managedQuery(android.provider.Browser.BOOKMARKS_URI, projection, null, null, null); setListAdapter(new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cur, displayFields, displayViews)); } } </code></pre>
android
[4]
1,426,374
1,426,375
send sms to a particular number through Android App programmtically
<p>Actually my concept is with android application code message have to send a particular number..please any body help me..My code is</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); buttonSend = (Button) findViewById(R.id.buttonSend); textPhoneNo = (EditText) findViewById(R.id.editTextPhoneNo); textSMS = (EditText) findViewById(R.id.editTextSMS); buttonSend.setOnClickListener(new OnClickListener() { public void onClick(View v) { String phoneNo = textPhoneNo.getText().toString(); String sms = textSMS.getText().toString(); try { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, sms, null, null); String smsNumber = textPhoneNo.getText().toString(); String smsText = textSMS.getText().toString(); smsManager.sendTextMessage(smsNumber, null, smsText, null, null); Toast.makeText(getApplicationContext(), "SMS Sent!", Toast.LENGTH_LONG).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS faild, please try again later!", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } }); } </code></pre>
android
[4]
5,520,591
5,520,592
How to pass data between pages
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4100450/php-pass-non-form-variables-between-pages">PHP: Pass non-form variables between pages?</a> </p> </blockquote> <p>I have problem with passing data dynamically populated. The code below dynamically display the restaurant hours of operation. Now I want to pass this hours into new page.<br /></p> <pre><code>while ($start &lt;= $end) { $startIn = strtotime('+0 minutes',$start); $hourIn = ( date('h:ia', $startIn)); //dispaly restaurant availability echo "&lt;td id='td'&gt;"."&lt;a href='$resName.php' style='text-decoration: none;'&gt;" . $hourIn ."&lt;/a&gt;". "&lt;/td&gt;"; $start = strtotime('+30 minutes',$startIn); } </code></pre>
php
[2]
226,579
226,580
why aren't the cookies saved ?
<p>why aren't the cookies saved when i run the following script:</p> <pre><code>window.onload=init; function init() { var userName=""; if(document.cookie != "") { username=document.cookie.split("=")[1]; } document.getElementById("name_field").value = username; document.getElementById("name_field").onblur = setCookie; } function setCookie() { var exprDate = new Date(); exprDate.setMonth(exprDate.getMonth() + 6); var userName = document.getElementById("name_field").value; document.cookie = "username=" + username + ";path=/;expires=" + exprDate.toGMTString(); } </code></pre> <p>When i refresh the page the <code>text-field</code> gets empty? why is so ? <strong>HTML</strong></p> <pre><code>&lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script type="text/javascript" src="writing_cookie.js"&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;label&gt;Enter your name&amp;nbsp;&amp;nbsp;&lt;input type="text" id="name_field" /&gt;&lt;/label&gt; &lt;br/&gt; &lt;input type="submit" value="submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
1,196,774
1,196,775
Android: How I get amplitude from mediaplayer?
<p>I need to get amplitude from mediaplayer.</p> <p>I try to use AudioManager, mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC ); but is not my need.</p> <p>Thanks.</p>
android
[4]
2,091,502
2,091,503
creating a multiplication table in python with user input
<p>I am extremely new to python so my question might seem a bit too trivial but believe me, its like rocket science right now for me. So, here it is. I have to create a program that reads single line of user input containing an integer, and print out the multiples of that number up to 12 times that number. For example:</p> <p>Enter a number: 3</p> <pre><code>3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 3 x 8 = 24 3 x 9 = 27 3 x 10 = 30 3 x 11 = 33 3 x 12 = 36 </code></pre> <p>I think I have to use for and range functions but don't know how to do that. Please help me :(</p>
python
[7]
4,152,678
4,152,679
How Can i Call an application which is on Desktop?
<p>I have a Server basically Apache Tomcat Server</p> <p>My Desktop is connected to the server</p> <p>I want my request which comes from browser to be redirected to the Desktop Via server</p> <p>Can any one tell me how can i do it?</p> <p>I got my solution... I amUsing RMI or even Socket Programming is an option to achieve what i want Thanks</p>
java
[1]
620,692
620,693
Using VLSM, design an IP subnetting solution given the single class B IP addres
<p>Given: 130.0.0.0</p> <p>and subnets:</p> <p>A - 31000 hosts<br> B - 16000 hosts<br> C - 8000 hosts<br> D - 4000 hosts<br> E - 1500 hosts<br> F - 120 hosts<br> G - 60 hosts<br> H - 10 hosts </p> <p>I know and understand how to calculate for A - E... but I can't with F - H because it belongs to class C already.<br> Can anybody help me understand? </p> <p>Does F - H belong to the 1024 hosts already and only have different subnet masks?</p>
asp.net
[9]
3,324,010
3,324,011
How to get the index of particular view OR ViewGroup which is added to the ViewGroup(layout)
<p></p> <pre><code>&lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="24dip" android:text="Add Notes" /&gt; &lt;TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="24dip" android:layout_marginRight="24dip" android:id="@+id/tlNotes" android:stretchColumns="0"&gt; &lt;/TableLayout&gt; &lt;Button android:id="@+id/bAddNoteLine" android:layout_marginLeft="24dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ADD"&gt; &lt;/Button&gt; &lt;LinearLayout android:id="@+id/llIndex" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="21dip" android:gravity="center"&gt; &lt;Button android:id="@+id/bSaveSubjectiveNote" android:layout_width="192dip" android:layout_height="wrap_content" android:text="Save" /&gt; &lt;Button android:id="@+id/bDiscardSubjectiveNote" android:layout_width="192dip" android:layout_height="wrap_content" android:layout_marginLeft="48dip" android:background="@drawable/button" android:text="Discard" /&gt; &lt;/LinearLayout&gt; </code></pre> <p></p> <p>how to retrieve the index of linearLayout which has "llIndex" as id. Thanks</p>
android
[4]
3,197,294
3,197,295
Want to develope multiple apk to upload on google play for single application of indic font
<p>I am developing indic font application for android but some devices not able to render indic fonts for that I am going to use images of indic text ,that will created on server side and my application going to fetch it at runtime this thing is doable for me.</p> <p>I want to make two apk for upload on google play.</p> <p>1)I can upload multiple apk for single application </p> <p>using this <a href="http://developer.android.com/guide/google/play/publishing/multiple-apks.html#SingleAPK" rel="nofollow">Link shows how to upload multiple apk</a></p> <p>Is it a best solution to create multiple apk for this.</p> <p>reasons to make multiple apk are for these are 1) Device which can render indic font use text rendering apk for fast downloading because images of text slow down my app.</p> <p>help me what is the best solution for this problem </p>
android
[4]
4,631,396
4,631,397
iPhone:How to insert placeholder in UITextView?
<p>Is there any way to insert placeholder in UITextView like UITextField i iPhone?if yes,then please send me any link or any idea to develop this functionality.</p> <p>Thanks in advance.</p>
iphone
[8]
2,546,919
2,546,920
android eclipse plugin can't find valid paths
<p>I just installed the latest galileo eclipse release. I added the latest adt plugin and configured it to use my android sdk (r4). Unfortunately, the eclipse plugin is wiggin out. for some reason, it can't find(execute?) the android tools. I get this error on the eclipse project:</p> <blockquote> <p>Error executing aapt. Please check aapt is present at ~/android-sdk-linux_86/platforms/android-1.6/tools/aapt</p> </blockquote> <p>but here is the output of ls:</p> <pre><code>ls -al ~/android-sdk-linux_86/platforms/android-1.6/tools/aapt -rwxrwxrwx 1 solid solid 3416259 2009-12-18 21:02 /home/solid/android-sdk-linux_86/platforms/android-1.6/tools/aapt </code></pre> <p>When I try running the program directly, I see the following:</p> <pre><code>~/android-sdk-linux_86/platforms/android-1.6/tools/aapt bash: /home/solid/android-sdk-linux_86/platforms/android-1.6/tools/aapt: No such file or directory </code></pre> <p>I just unzipped the sdk and installed the platforms and <code>ls</code>'d it so I know it is there.</p> <p>I have tried recreating the project from the command line (which works) but when I import it into eclipse I get the same error.</p> <p>BTW this is linux amd 64 </p>
android
[4]
1,977,449
1,977,450
Static initializer on a inner class?
<p>How to allow static initializer on a inner class like this:</p> <pre><code>public class MyClass { public class InnerClass { static { // do something } public bar(){ // do something } } // method stuff public void foo() { // do something } } </code></pre>
java
[1]
3,431,412
3,431,413
Why can only newest button work ? I find that other button's onclick function is null
<pre><code>function B(sName) { this.name = sName; } B.prototype = { instanceCreatButtonCount: 0, funA: function () { // alert instance's name alert(this.name); }, funB: function () { // create a button which clikced can alert this instance's name through funA; var that = this; B.prototype.instanceCreatButtonCount++; var id = "_id" + that.instanceCreatButtonCount; var str = "&lt;button id='" + id + "' &gt;clike me&lt;/button&gt;"; var a = document.getElementById("btns"); a.innerHTML += str; var btn = document.getElementById(id); btn.onclick = function () { that.funA(); }; } }; var b1 = new B("Jim"); var divB1 = document.getElementById("b1"); divB1.onclick = function () { b1.funB(); } var b2 = new B("Dad"); var divB2 = document.getElementById("b2"); divB2.onclick = function () { b2.funB(); } </code></pre> <ul> <li><p>After I click divB1, I create a button through b1.funB().</p></li> <li><p>After I click divB2, I create a button througb b2.funB().</p></li> </ul> <p>Why can only newest button alert name ? I find that other button's onclick function is null.</p>
javascript
[3]
4,898,296
4,898,297
c2Dm Registration
<p>when install the application on the phone it did not get the registration id of c2dm of first time .when run on the second time it will be get the registration id of the phone.whats problem.Please help me.</p>
android
[4]
1,529,466
1,529,467
How can i make an API wrapper for a HTTP service that uses json?
<p>I want to make a HTTP wrapper for twitch.tv in python. How would I do this? I know how to use HTTP GET and that's about it. I would like it to work like this:</p> <pre><code>import twichtvwrapper twich = twichtvwrapper(useragent, username, password). channel = twich.channel(channelname) </code></pre> <p>then all the json properties would go in here like:</p> <pre><code> print(channel.game) #this would say the last played game print(channel.displayname) #this would print the display name of the channel print(cahnnel.link.chat) #this will return the chat link </code></pre> <p>etc.</p> <p>How would I go about making this wrapper?</p>
python
[7]
2,837,783
2,837,784
How to cast vector<unsigned char> to char*
<p>I have a buffer like this:</p> <pre><code>vector&lt;unsigned char&gt; buf </code></pre> <p>How can I cast it to char*?</p> <p>If I do:</p> <pre><code>(char *)buf </code></pre> <p>I get this error:</p> <pre><code>/home/richard/Desktop/richard/client/src/main.cc:102: error: invalid cast from type ‘std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;’ to type ‘char*’ </code></pre> <p>For those wondering why I am trying to do this. I need to pass the buffer to this function:</p> <pre><code>n_sent = sendto(sk,(char *)buf,(int)size,0,(struct sockaddr*) &amp;server,sizeof(server)); </code></pre> <p>And it only accepts char*.</p>
c++
[6]
2,584,903
2,584,904
How does Python sort a list of tuples?
<p>Empirically, it seems that Python's default list sorter, when passed a list of tuples, will sort by the first element in each tuple. Is that correct? If not, what's the right way to sort a list of tuples by their first elements?</p>
python
[7]
2,716,705
2,716,706
Can not set UISwitch outside of controller class
<p>The iphone program is set up in the Utility Application model where you have a root view and two subviews (mainViewController &amp; flipsideViewController) which are outlets. </p> <p>If I try to set the UISwitch at rootViewController's viewDidLoad (with [flipsideViewController.switchInstance setOn:YES]), it doesn't work. </p> <p>Within flipsideViewController, that method works but not outside of it. Any idea why? I can pass other methods...</p> <p>Even if I pass a method to the flipsideViewController that then does the setOn method, it still doesn't work...</p> <p>Any ideas?</p>
iphone
[8]
2,906,987
2,906,988
onDownload complete notification - inapp purchase in Android
<p>In my Android application I am downloading a video through an application purchase from <a href="http://en.wikipedia.org/wiki/Urban_Airship" rel="nofollow">Urban Airship</a>.</p> <p>When I click a particular button in my application the downloading gets started. In such a case, after the download completes fully I want to get a notification or alert so that the button becomes invisible. How can I know that the video has been downloaded completely?</p> <p>Is there any piece of code I could write to be notified when a download finishes in Android?</p>
android
[4]
4,873,907
4,873,908
prepend $ to a string to make it a variable
<p>How do I prepend the $ sign to a string to make it a variable?</p> <pre><code>Eg: $consumer = array() $industrial = array()//These 2 are in a separate include file. $var = $_GET['val'] // value here is 'consumer' function ('$'.$var,$bar) //I'm trying to make consumer -&gt; $consumer </code></pre>
php
[2]
232,083
232,084
IntSetArray implementation in c++
<p>i have trying to imlement IntSetArray in c++ it compiles fine but result is wrong first 300 is ok and other numbers are below zero something very strange numbers .e.g -8231313 something like this) what is wrong? it is code</p> <pre><code>#include &lt;iostream&gt; using namespace std; int quantity=10; class Set { private : int n,*x; public: Set(int maxval){ x=new int[quantity+1]; n=0; x[0]=maxval; } int size(){ return n;} void insert(int t){ for (int i=0;x[i]&lt;t;i++) { if (x[i]==t) return ; for (int j=n;j&gt;=i;j--) x[j+1]=x[j]; x[i]=t; } n++; } void display() { for (int i=0;i&lt;n;i++){ cout&lt;&lt;x[i]&lt;&lt;" "&lt;&lt;"\n"; } } }; int main(){ Set s(300); s.insert(123); s.insert(45); s.insert(89); s.insert(50); s.insert(13); s.insert(19); s.display(); return 0; } </code></pre>
c++
[6]
2,470,281
2,470,282
How to change "ddd" datetime format to a number view
<p>I want to make that code to show me a current datetime on my pc clock when i click a button... i did it with that code listed down. But here is my question how can i make the "ddd" (day of a week) to be shown in number, not in words, I mean: 00-sunday 01-monday and etc. ...</p> <p>This is my code for the button:</p> <pre><code>private void SetClock_Click(object sender, EventArgs e) { SetClock.Click += new EventHandler(SetClock_Click); { DateTime time = DateTime.Now; string format = "yy-MM-dd-ddd-hh-mm-ss"; txtSend.Text = time.ToString(format); } } </code></pre> <p>What i have to add to make it. Thanks</p>
c#
[0]
4,923,320
4,923,321
Searching the Nested file
<p>How to serach for file inside nested folders?</p>
asp.net
[9]
3,531,524
3,531,525
Python: loop through a file for specific lines
<p>I have the following lines in a file where I want to take the third column; In the file I don't have the numbers column:</p> <ol> <li>Red; Blue; Green; White; Orange;</li> <li>Green; White; Orange;</li> <li>Blue; Green; White;</li> <li>Red; Blue; Green; White;</li> <li>Blue; Green; White; Orange;</li> <li>Orange</li> <li>Green; White; Orange;</li> <li>White; Orange</li> <li>Green;</li> </ol> <p>I used this code line to do that:</p> <pre><code>lines = i.split(";")[2] </code></pre> <p>The problem is that some of the lines have only one column or two, so it gives me 'index out of range' error. Please tell me how to go about this problem?</p> <p>thanks a lot Adia</p>
python
[7]
56,164
56,165
Feature panel hover changer effect
<p>Haven't seen this before so hopefully someone has a easy solve, I have a 3 feature panel divs side by side, what I want happen is the 1st panel has a "hover" class added so I can change the background etc and then on a timed interval the hover class jumps to the next panel then the next panel then back to the start on a loop.</p> <p>Also on a side note can you keep the code in mind to be able to add more then 3 feature divs so you could have for example 6 or more or less etc.</p>
jquery
[5]
5,777,328
5,777,329
Can pages loaded into an iframe from another domain be scrolled via JavaScript?
<p>If yes, could you please show me an example of how to do it?</p>
javascript
[3]
4,190,093
4,190,094
android, Samsung 10.1, drawable image resizes
<p>I'm developing an app for Samsung 10.1. Pictures are stored in drawable-hdpi folder.</p> <p>when I use ImageView to show the picture, the image is somehow resized. for example, 1280x60 size image is shown as a 853x43 image.</p> <p>Any idea why the image is resized and how to prevent resizing?</p>
android
[4]
1,103,317
1,103,318
C# + PostScript
<p>Is there a way to implement PostScript like page display for text files in C#??</p> <p>ie a Print Preview for a bunch of text in a web page. The requirement is to show a Print Preview like in Google Docs for a text displayed inside a label.</p>
c#
[0]
617,599
617,600
Content Provider multiple app flexibility
<p>I've been training myself up in Android development. I have an idea for a series of apps that all relate to the same basic data store which stores similar/related hobby data. I suppose in my mind access to this data should be similar to how many apps make use contacts. So I started reading up on content providers but from what I can see they don't actually provide the flexibility I require.</p> <p>What I want is to create say 4 or 5 hobby related apps that record similar and related data however a customer might decide they only need a specific one to start with. Later they might decide that one or more of the other apps might also be useful. </p> <p>The data the apps store is very similar, the core data is the same. So the obvious choice is a content provider. However I can't see the providers offer the flexibility I require. Firstly how does the 2nd app purchased figure out that a content provider is already available and if so not install its own (this seems to be hardwired in the manifest and there is no programatic control). Secondly how would an app realise there is no content provider and install one (related to point one). Thirdly a new app installed might have a more up to date provider or an older provider!</p> <p>So I don't think the providers offer what I need. I also notice that the databases are sandboxed and providers seem to be the only method for apps to share persisted data, or is there something I'm missing. It actually makes me wonder how for none default installed content providers how useful providers are!</p> <p>I suppose an alternative method would be for a customer to purchase and app and then later ad on extra functionality but I'm not sure if this is possible and if so where the information is.</p> <p>Any help would be appreciated.</p> <p>Steve</p>
android
[4]
2,604,437
2,604,438
Why is my string to string comparison failing?
<p>Ok so I have an Android app where I want to check to see if an app name that is installed matches a string passed to the function containing this code. The code and example is below:</p> <pre><code>private Boolean checkInstalledApp(String appName){ PackageManager pm = this.getPackageManager(); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List&lt;ResolveInfo&gt; list = pm.queryIntentActivities(mainIntent, 0); Boolean isInstalled = false; for(ResolveInfo info: list) { if (info.activityInfo.applicationInfo.loadLabel( pm ).toString()==appName){ isInstalled = true; break; } } return isInstalled; } </code></pre> <p>Assuming you called checkInstalledApp('SetCPU'); and the app name on the phone is called the same thing it should return true. However, it never does. I logged the results and it should match up but it does not. Can anyone please enlighten me as to why this doesn't work?</p>
android
[4]
25,204
25,205
How to detect co-ordinates of mouse pointer over a div
<p>Suppose there is a DIV with the following properties:</p> <pre><code>top:100; left:100; height:200; width:200; </code></pre> <p>Now, when i position the mouse pointer in the browser at co-ords(105,210), it means that the mouse pointer is on the div at (5, 110). So this is the thing that i want to calculate using <code>jQuery</code>. Can anyone help me with some code suggestions?</p>
jquery
[5]
3,145,978
3,145,979
How to get default system style on C# progressbar
<p>In Windows Vista &amp; 7 progressbars are green and have a glassy finish. But the one served up by Visual Studio 2010 has the system default of blue highlight (which appears flat and looks a bit Windows 98).</p> <p>How do I get that glassy green look (or whatever the user's theme default is)?</p> <p>(Using C# v4.0 if that makes a difference)</p> <p><img src="http://i.stack.imgur.com/XfJ6P.jpg" alt="Dull flat blue progress bar"></p> <p><strong>EDIT:</strong> Ok - just noticed how square the buttons look on this and other dialogs' controls - I think somehow the entire app is being styled pre win XP? Can someone tell me how to set the style correctly for the whole app (i.e. to match the current OS)?</p>
c#
[0]
1,443,751
1,443,752
want to know about webapplication urls
<p>Im running a web application in visual studio 2008... while running, my first web page url is <em>http://localhost/ABC/default.aspx</em> while i run this in another system, it is <em>http://localhost:2435/ABC/default.aspx</em> Really eager to know what is this all about... because the images in root folder are displaying in my system but not in another system... Give me some idea about this.. Thank u in advance..</p>
asp.net
[9]
2,899,155
2,899,156
ajax autosuggest
<p>i can use auto-suggest with the text box <code>txtCode</code> like this...</p> <pre><code>as_jsonReportingTo = new bsn.AutoSuggest('&lt;%= txtCode.ClientID %&gt;', optionsRe); </code></pre> <p>Now I will create text boxes dynamically, i want to bind autosuggest with the new created text boxes. What should I do?</p>
asp.net
[9]
2,240,054
2,240,055
How is the call getApplicationContext which returns a context type used in applications?
<p>I'm new to java and android development. After spending few days working with java I started with android development. I've this question with regards to the Context class.</p> <p>Context is a abstract class. Which cannot be instantiated and cannot be used to call methods unless it refers to a concrete subclass. Can someone tell how the call getApplicationContext which returns a context type is used in applications (a small snippet of how will be a huge help). </p> <p>And also help me understand this statement Context context = getApplicationContext() getApplicationContext is an abstract method so when we use this call, which object implements this? Is it the ContextWrapper object of the current process (app) that gives this method.</p> <p>Thanks in advance.</p>
android
[4]
5,662,294
5,662,295
Is it a good practice to calculate and override hashCode once for ever
<p>I work with the OpenSource OODB <a href="http://community.versant.com/Downloads.aspx" rel="nofollow">db4o</a> and my serialized classes inherit from a common abstract.class which have two fields :</p> <pre><code>. . . private final Long timeCreate = (System.currentTimeMillis() &lt;&lt; 20) + (System.nanoTime() &amp; 0xfffff); private final int hashCode = timeCreate.hashCode(); . . . @Override public final int hashCode() { return hashCode; } . . . </code></pre> <p>Is it a good practice to so?</p> <p>The benchmarks I've tried give faster responses, but is a pitfall nested some where?</p>
java
[1]
5,176,371
5,176,372
How can I loop through a string, replacing sections that match a pattern?
<p>I have the following HTML markup</p> <pre><code>&lt;p&gt;xxxx&lt;/p&gt; &lt;pre&gt;xxx&lt;/pre&gt; &lt;p&gt;xxxx&lt;/p&gt; &lt;pre&gt;yyy&lt;/pre&gt; </code></pre> <p>I need to be able to change this to:</p> <pre><code>&lt;p&gt;xxxx&lt;/p&gt; &lt;pre&gt;ABC xxx ABC&lt;/pre&gt; &lt;p&gt;xxxx&lt;/p&gt; &lt;pre&gt;ABC yyy ABC &lt;/pre&gt; </code></pre> <p>I had a suggestion to use:</p> <pre><code> var loDoc = XDocument.Parse(lcHTML); foreach (XElement loElement in loDoc.Descendants("pre")) </code></pre> <p>This does extract all the pre elements but it doesn't give me a way to tie things together and reinsert code into the original string. </p> <p>Is there another way I could do this that would allow me to make the code change I need. I was thinking of using split and splitting on the <code>&lt;pre&gt;..&lt;/pre&gt;</code> but then that would not really give me what I need as I need to replace the code inside the <code>&lt;pre&gt;...&lt;/pre&gt;</code></p>
c#
[0]
2,987,445
2,987,446
PHP:Can't retrieve line by line text from a text file with php
<p>I have a text file in my server which changes dynamically and i wanted to print specific line of the text file in my php page also i wanted to trim the current line. For example,Assume data.txt</p> <pre><code>score=36 name=Football Cup Player=albert </code></pre> <p>and i wanted to print like this in my page<br> 36<br> Football Cup<br> albert </p> <p>So how can i print specific words or sentence from a text file which is dynamically changes.</p>
php
[2]
4,104,187
4,104,188
Can someone PLEASE find an error with this regular expression code? I used it to validate an email
<p>Is there a problem with this regular expression? I've got jquery enabled and all that, so nothing is a problem, except this regex doesn't work, for some reason. Thanks!</p> <pre><code>var thereg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; return thereg.test($("email").value); </code></pre>
javascript
[3]
4,288,329
4,288,330
Creating Objects with jQuery: String Concat or Methods?
<p>When dynamically creating DOM objects in jquery is it better to use pure string concatenation or should I use the jquery methods? Which is the more "jQuery way"?</p> <pre><code>var tr = $('&lt;tr/&gt;').addClass('foobar'); // or $('&lt;tr class="foobar"/&gt;'); tr.append('&lt;td&gt;' + someobj.property + '&lt;/td&gt;'); // or ... tr.append($('&lt;td/&gt;').text(someobj.property)); </code></pre>
jquery
[5]
1,780,888
1,780,889
Function not recognized from jQuery
<p>I've got a .js file that has this function in it:</p> <pre><code>function showDialog(divID) { alert("got here"); var dialogDiv = $(divID); dialogDiv.dialog ( { bgiframe: true, modal: true, autoOpen: false, show: 'blind' } ) dialogDiv.dialog("open"); } </code></pre> <p>And in my page this:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function() { $("input.invokeDialog").click.showDialog("#testDialog"); }); &lt;/script&gt; </code></pre> <p>I'm trying to figure out why it doesn't recognize my showDialog function. Is it not possible to reference it with the dot as I am doing? Do I need a jQuery specific function or syntax for it to know that it's a jQuery function or is there no such thing?</p>
jquery
[5]
606,350
606,351
Graceful exiting of a program in Python?
<p>Hey all, I have a script that runs as a </p> <pre><code>while True: doStuff() </code></pre> <p>What is the best way to communicate with this script if I need to stop it but I don't want to kill it if it is in the middle of an operation?</p> <p>Thanks!</p>
python
[7]
151,246
151,247
How to make thread safe to servlet
<p>This questoion is realeated to the J2ee </p>
java
[1]
3,123,894
3,123,895
A Java bounds-checking optimization example
<p>I have read that some of the JVMs out there can optimize code execution by removing bounds checking. What I am trying to figure out is what coding technique will work better.</p> <p>In method <strong>example1</strong> below would the JVM ever figure it out and eliminate the bounds checking of the <strong>source[index]</strong> reference?</p> <p>Is <strong>example2</strong> the better code practice? It would seem so, but in some algorithms inside a loop the index being out of bounds is a normal condition. So you don't want to be generating tons of Exception objects inside that loop.</p> <pre><code>public void example1(int [] source, int index) { if (index &gt;= 0 &amp;&amp; index &lt; source.length) System.out.println("Value is " + source[index]); else System.out.println("Out of range: " + index); } public void example2(int [] source, int index) { try { System.out.println("Value is " + source[index]); } catch (IndexOutOfBoundsException exp) { System.out.println("Out of range: " + index); } } </code></pre> <p>These code fragments are only representational. I am aware that in these examples the bounds-checking will hardly matter to performance. However I am working on an embedded protocol application where the redundant bounds checking will add up.</p>
java
[1]
503,501
503,502
Java regex to extract version
<p>I am trying to write a java regex to strip off java version from string I get from java -version command.</p> <p>If the string is <code>"java version 1.7.0_17"</code> I need to extract 1.7 and 17 separately. Suppose if the string is <code>"java version 1.06_18"</code> I need to extract 1.06 and 18. Where first string should be only till the first decimal point. I tried with the below regex, </p> <pre><code>Pattern p = Pattern.compile(".*\"(.+)_(.+)\""); </code></pre> <p>But it extracts only 1.7.0 and 17, but I not sure how to stop still one decimal point. Any help will be really appreciable.</p>
java
[1]
4,060,295
4,060,296
FadeIn element with .before Jquery
<p>How do I fade in an element after using jquery's .before?</p> <p>jQuery </p> <pre><code>$('.button').on("click", function(event){ var html = ''; html = '&lt;div class="row new"&gt;Test&lt;/div&gt;'; $('.content .row:first').before(html); }); </code></pre> <p>HTML</p> <pre><code>&lt;a class="button"&gt;Insert me and fade me&lt;/a&gt; &lt;div class="content"&gt; &lt;div class="row"&gt;&lt;/div&gt; &lt;div class="row"&gt;&lt;/div&gt; &lt;div class="row"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
5,054,948
5,054,949
How can I cast double[] to System.Windows.Media.DoubleCollection?
<p>Is there any way to to it without copying values?</p>
c#
[0]
494,478
494,479
Use accelerometer or not?
<p>I am developing my first app for Android, and I wanted to know whether it is feasible to use the accelerometer.<br> I have heard that not all Android phones come built with an accelerometer. Is this true?<br> If it is true, then is there a way for a customer to know (via Android market) that an accelerometer is required to run the app?</p> <p>Should I include the use of accelerometer or not?</p>
android
[4]
340,028
340,029
Increasing security on imageUpload, issues with img src="image.php"
<p>Cant seem to get the php script to execute and fetch the image script, the image placeholder.jpg is sored outside of the public_html webroot, here is what i do</p> <p>Show image .php file</p> <pre><code>&lt;img src="image.php?image=&lt;?php echo urlencode('placeholder.jpg') ?&gt;"/&gt; </code></pre> <p>image.php</p> <pre><code>&lt;?php $file = basename(urldecode($_GET['image'])); $fileDir = '/noaccess/avatars/'; if (file_exists($fileDir . $file)) { $contents = file_get_contents($fileDir . $file); header('Content-type: image/jpg'); echo $contents; } ?&gt; </code></pre>
php
[2]
2,023,014
2,023,015
" Couldn't get connection factory client" Android Problem
<p>Is there anybody solved this problem or stil is a bug? I checked <a href="http://groups.google.com/group/android-developers/browse_thread/thread/94e3d0454612d143" rel="nofollow">google site</a> but no good news..</p>
android
[4]
4,581,984
4,581,985
Stanford CS106a: some java applet errors that do not allow to run the programs
<p>Wasnt able to solve the problems in this screen.</p> <p><a href="http://s8.postimage.org/n5osf76ed/qestions.jpg" rel="nofollow">http://s8.postimage.org/n5osf76ed/qestions.jpg</a></p> <p>All the code worked a month ago. What have I changed: I have a different version of eclipse (now: Eclipse IDE for Java Developers 1.5.1.20120920-0737, don't know what the previous one was).</p> <p>Messed with environment variable. Since this does not effect the ot</p> <p>Please help.</p>
java
[1]
1,174,284
1,174,285
Displaying <a> in Text-box value
<p>I am trying to display in a textbox value but it not displaying properly.</p> <p>I am fetching following code from database</p> <pre><code>&lt;a href="http://www.test.com" target="_blank"&gt;Click Me&lt;/a&gt; </code></pre> <p>When i am displaying value in textbox it displays like</p> <pre><code>&lt;input type="text" target="_blank" www.test.com"="" http:="" value="&amp;lt;a href=" id="action_url" name="action_url"&gt; </code></pre>
php
[2]
5,813,356
5,813,357
Can we detect what function to call on fly from parameters given at runtime?
<p>Say we have <code>N</code> function overrites, we receive argunments array, parsed it into some types (say first time we get <code>int</code>, <code>string</code>, <code>string</code>; second time we get <code>int</code>, <code>int</code>, <code>int</code>); Now we want to call for first set of arguments our <code>call(int, string, string)</code> while second time <code>call(int, int, int)</code>. Can we detect which function to call on fly having arguments types array?</p>
c++
[6]
3,494,850
3,494,851
How to programmatically trigger the click on a link Using jquery?
<p>How to programmatically trigger the click on a link using jquery?</p>
jquery
[5]
4,238,193
4,238,194
Initialise a std::vector with data from an array of unions
<p>How might I initialise a std::vector from an array of structs, where the struct contains a union of different types. In other words, the array is used to store a number of values of a specific type, which can be int, char* etc.</p> <p>This is my solution so far but I'm looking for a better approach:</p> <p>The convert function returns a <code>vector&lt;int&gt;</code> if it stores <code>int</code>s or a <code>vector&lt;std::string&gt;</code> if it stores <code>char*</code>.</p> <p>The Value type below is a struct containing a union called value. The Container class below points to a buffer of such Values.</p> <pre><code>// union member getter class Getter { public: void operator()(int8_t&amp; i, const Value&amp; value) { i = value.value.i; } void operator()(std::string&amp; s, const Value&amp; value) { s = std::string(value.value.s); } ... }; template&lt;class T&gt; std::vector&lt;T&gt; convert(Container* container) { std::vector&lt;T&gt; c; c.reserve(container-&gt;nrOfValues); Getter g; for(int i=0;i&lt;container-&gt;nrOfValues;i++) { T value; g(value, container-&gt;values[i]); c.push_back(value); } return c; } </code></pre>
c++
[6]
1,081,834
1,081,835
Internet availability checking in android
<p>In my application there are 20 activities and about 30 webservice calls.I need to check that internet availability before calling the webservice.I think calling Networking availability function on every time before calling each webservice is not an efficient way.whats the efficient way to check Internet?</p>
android
[4]
891,650
891,651
Best library/api for 2D android game development?
<p>I am looking into creating a 2D game for android.</p> <p>Searching the web I see all kinds of libraries and game engines for this. But, I don't see any one that stands out, or is most used.</p> <p>What have you used, and what was good/bad about them?</p> <p>Thanks for your help!</p>
android
[4]
2,677,594
2,677,595
How to Cache css/js in one file and call that file from cache folder?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/10587376/cache-css-and-js-in-cache-folder-and-call-css-from-that-folder-is-it-possible">Cache css and js in cache folder and call css from that folder is it possible?</a> </p> </blockquote> <p>How to Cache css/js in one file and call that file from cache folder? like css"http://http ref/css.r235436346.css"</p>
php
[2]
2,884,187
2,884,188
A text box appears when I load the page even though I have set its "style:display" to none
<pre><code>&lt;input type="text" name="otherPONumber" id="otherPONumber" maxlength="25" style="display: none;"&gt; &lt;script type="text/javascript"&gt; function toggleField(val) { var obj = document.getElementById('otherPONumber'); if(obj != undefined &amp;&amp; txt != undefined) { (val == 'Other')? obj.style.display = 'block' : obj.style.display = 'none'; } } &lt;/script&gt; </code></pre> <p>Inspite of this, the text box appears when the page loads.</p>
javascript
[3]
2,394,972
2,394,973
List of lists value in dictionary?
<p>Input file 'test.txt':</p> <pre><code>a 2012 fff b 2011 ttt a 2011 fff b 2012 sss a 2011 vvv </code></pre> <p>I have determined the following code to populate dictionary and sort values:</p> <pre><code>from collections import defaultdict res = defaultdict(list) with open('test.txt','r') as file: for line in file: field0, field1, field2 = line.split() res[field0] += [field1, field2] for i in res.keys(): print i, sorted(res[i], key=lambda x: x[0]) </code></pre> <p>However, this yields "a [2011, 2011, 2012, fff, fff, vvv]" and I want output to be in the exact same format as the input (but sorted):</p> <pre><code>a 2011 fff a 2011 vvv a 2012 fff </code></pre> <p>I can't just use sort on the original input since I will be referencing multiple times and need to store in memory. Should value for each line be stored in a list (ie. dictionary value is list of lists)?</p>
python
[7]
2,489,503
2,489,504
How to retrieve an object from a Python Dictionary
<p>I'm trying to retrieve an object that I've placed into a dictionary, but every time I try to retrieve it I receive an error:</p> <pre><code> class CSVEntry: lat = [] lon = [] count = 0 # Create dictionary for tracking inputs dict = defaultdict(list) # Lookup the zipcode (returns an integer value) zipcode = ConvertLatLonToZip(row[latCol], row[lonCol]) # If the zipcode is already in the dictionary, update it with the new count if zipcode in dict: oldEntry = dict[zipcode] oldEntry.lat.append(row[latCol]) oldEntry.lon.append(row[lonCol]) oldEntry.count = dict[zipcode].count + 1 # Otherwise, make a new entry else: entry = CSVEntry() entry.lat.append(row[latCol]) entry.lon.append(row[lonCol]) entry.count = 1 # Hash on the zipcode dict[zipcode].append(entry) </code></pre> <p>It has no problem inserting entries into the dictionary, but as soon as it finds a duplicate, it fails with this error:</p> <pre><code>Traceback (most recent call last): File "ParseCSV.py", line 125, in &lt;module&gt; oldEntry.lat.append(row[latCol]) AttributeError: 'list' object has no attribute 'lat' </code></pre> <p>I apologize if this is a duplicate or a ridiculously simple question. I'm a beginner to Python and I searched for a long while before deciding to post.</p> <p>EDIT: Added the definition of dict</p>
python
[7]
2,903,818
2,903,819
How to display a 2D table in java
<p>I try do disply a 2 D table but for some reason I can't, I don't see what i wrote wrong.</p> <p>This is my code (I am working in vim):</p> <pre><code> int [][] tab = new int [5][5]; for (int i= 0; i&lt;tab.length ; i++){ for (int j =0; j&lt;tab[i].length; j++){ tab[j][i]=i; System.out.println("" + tab[j][i]); } System.out.println(""); } } </code></pre> <p>The result of this code is:</p> <p>0</p> <p>0</p> <p>0</p> <p>0</p> <p>1</p> <p>1</p> <p>1</p> <p>1</p> <p>2</p> <p>2</p> <p>2</p> <p>2</p> <p>3</p> <p>3</p> <p>3</p> <p>3</p> <p>4</p> <p>4</p> <p>4</p> <p>4</p> <p>And i want:</p> <p>0 0 0 0</p> <p>1 1 1 1</p> <p>2 2 2 2</p> <p>3 3 3 3</p> <p>4 4 4 4</p> <p>Can someone help me with this?</p> <p>Thank you</p>
java
[1]
1,401,127
1,401,128
How to get opposite boolean value of variable in Javascript
<pre><code>var a = true; </code></pre> <p>How to get opposite value of <code>a</code> (false) and vice versa?</p>
javascript
[3]
4,630,931
4,630,932
How to save the contents of Data URI to image
<p>In Google Chrome the <strong>'chrome.tabs.captureVisibleTab(integer windowId, function callback)</strong>' method will return a data URL of the JPEG encoding of the visible area of the captured tab.</p> <p>We want to save that content as image to hard disk without opening/passing the contents into new html page.</p> <p>Does anybody know how it can be done by javascript. Please provide help.</p> <p>Thanks.</p>
javascript
[3]
201,647
201,648
Create a 3D array from a list
<p>I have the following list:</p> <blockquote> <p>1945/01/05 BA 87 34 1 59 50<br> 1945/01/05 CA 18 17 45 49 82<br> 1945/01/13 BA 6 66 1 16 48<br> 1945/01/13 CA 40 60 32 50 80</p> </blockquote> <p>and so on.... </p> <p>I want to arrange them as an array like the following:</p> <pre><code>$array['BA'][0][0] = 87; $array['BA'][0][1] = 34; $array['BA'][0][2] = 1; $array['BA'][0][3] = 59; $array['BA'][0][4] = 50; $array['CA'][0][0] = 18; $array['CA'][0][1] = 17; $array['CA'][0][2] = 45; $array['CA'][0][3] = 49; $array['CA'][0][4] = 82; $array['BA'][1][0] = 6; $array['BA'][1][1] = 66; $array['BA'][1][2] = 1; $array['BA'][1][3] = 16; $array['BA'][1][4] = 48; $array['CA'][1][0] = 48; $array['CA'][1][1] = 60; $array['CA'][1][2] = 32; $array['CA'][1][3] = 50; $array['CA'][1][4] = 80; </code></pre> <p>I know that I can use preg_split('/\s+/', $list); to create an array, but how can I create a 3D Array from this list?</p> <p>Thank you for your help</p>
php
[2]
2,027,703
2,027,704
what is a commandline argument?
<p>I am a newcomer to python (also very sorry if this is a newb question but) i have no idea what a command line argument is. when <code>sys.argv</code> is called, what exactly are the arguments? Any help with understanding this would be a great service.</p>
python
[7]
2,573,168
2,573,169
select last elements from parents
<p>I'm quite new to JQuery so this is probably an easy one...</p> <p>Consider this HTML structure - I know it is not valid HTML but that's not the point:</p> <pre><code>&lt;table id="mytable"&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" checked="checked" /&gt;&lt;/td&gt; &lt;td&gt;1.2&lt;/td&gt; &lt;td&gt;1.3&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" checked="checked" /&gt;&lt;/td&gt; &lt;td&gt;2.2&lt;/td&gt; &lt;td&gt;2.3&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" /&gt;&lt;/td&gt; &lt;td&gt;3.2&lt;/td&gt; &lt;td&gt;3.3&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Basically I need to select the last table cell from each table row where the checkbox is marked, in this case the table cells containing "1.3" and "2.3" (not "3.3"). Finding the checked checkboxes is easy but somehow I always end up with only the last table cell ("2.3") from the last table row. Does someone know a solution to this?</p>
jquery
[5]
4,287,208
4,287,209
how to handle while loop and calculate multiple values
<p>hi im running a query to get total number of minutes used in a conversation in an hour on cell query is</p> <pre><code>$sql="SELECT COUNT(*) calls, AVG(cd.leg2duration) avg_dur FROM call_detail cd WHERE cd.cid_did = '".$this-&gt;cid."' AND cd.phonetype = '8' AND cd.leg1start_date BETWEEN '{$this-&gt;startdate}' AND '{$this-&gt;enddate}'"; </code></pre> <p>which is giving me result like </p> <pre><code>hours minute 0 2 1 5 </code></pre> <p>i want to display it like this 0-6 hours in a same column and calculate minutes used in 0-6 hours im not getting any idea how to implement it in my while loop please help </p>
php
[2]
4,848,646
4,848,647
Getting .focus() to work in jQuery 1.4.2?
<p>I am trying to validate an input field when it loses focus and re-focus the field if the validation fails. But I cannot seem to get the field to re-focus. I have written a test case at <a href="http://jsbin.com/ahepo/edit" rel="nofollow">http://jsbin.com/ahepo/edit</a> . It is failing in Firefox 3.6.2 and IE 8, but working in Chrome 4.1.</p>
jquery
[5]
2,193,337
2,193,338
JavaScript: Rotate Polys
<p>My code doesn't work right:</p> <pre><code>function rotate(Points, Angle) { for (var i=0; i&lt;Points.length;i++) { Points[i] = [Math.cos(Angle) * Points[i][0] - Math.sin(Angle) * Points[i][1], Math.sin(Angle) * Points[i][0] + Math.cos(Angle) * Points[i][1]]; } return Points; } rotate([[0, 0], [50, 0], [25, 25]], 5); </code></pre> <p>I used the following: <a href="http://www.vb-helper.com/howto_rotate_polygon_points.html" rel="nofollow">http://www.vb-helper.com/howto_rotate_polygon_points.html</a></p>
javascript
[3]
5,793,196
5,793,197
PHP validation form data
<p>I've 10 fields,when user submits forms,i need to validate the data in form.</p> <p>Two things,</p> <ol> <li><p>To check whether fields is empty.</p></li> <li><p>Validating data,if present.</p></li> </ol> <p>x would allow only spaces,underscore,aplha numeric characters y will check whether it is an image or not.</p> <p>I'm using below code,it does not work.It is not validating and printing error.</p> <p><strong>Update</strong></p> <pre><code>$validate = array( '/^[a-z\d ]{4,20}$/i' =&gt; array("$x" =&gt; "Please enter valid name."), '/^[a-z\d ]{4,20}$/i' =&gt; array("$y" =&gt; "Please enter a real category.") ); $error = ''; foreach ($validate as $key =&gt; $field) { if (preg_match($key,$field[0])) { $error.= $field[0]; } } if($error) { echo $error; exit; } </code></pre> <p>Thanks in advance!</p> <p>Let me know,if you some thing is not clear in this post.</p>
php
[2]
4,122,587
4,122,588
Software metric tool for Python
<p>I want a tool which can compute source code metrics such as lines of code, number of packages, classes, functions, cyclomatic complexity number, depth of inheritance tree etc. for my Python Code. I have tried pylint, but it didn't offer much metrics. pynocle seemed interesting but I dont know how to use it.</p> <p>Can anyone give me some suggestions ?</p> <p>Thanks in advance</p>
python
[7]
826,840
826,841
Python version recommendation
<p>I have developed some internal tools at work using Python. I have been using version 2.5 (or 2.6/2.7) for that and my personal projects as they would work fine with Django and GAE. My question is - should I be switching to version 3 or shall I wait and continue to work with 2.5/2.6/2.7. How stable is 3.0 as compared to 2.x? And what is the switching curve? Thanks.</p>
python
[7]
4,901,434
4,901,435
How to replace string in iPhone
<p>How do I search-and-replace the following string:</p> <blockquote> <pre><code> &amp; ââÄô &amp;’&amp;lsquo;*amp;nbsp; </code></pre> </blockquote> <p>Right now I'm trying</p> <pre><code>NSString *str = [string stringByReplacingOccuranceOfString:@"&amp;" withString:@"&amp;"]; </code></pre> <p>Can anyone help getting this?</p>
iphone
[8]
3,303,716
3,303,717
TraceView Android
<p>Before putting this question i have seen following links </p> <p><a href="http://stackoverflow.com/questions/4850974/how-to-use-traceview-in-eclipse-for-android-development">how to use traceview in eclipse for android development?</a></p> <p><a href="http://stackoverflow.com/questions/6491855/android-cant-use-traceview">Android - Can&#39;t use traceview</a></p> <p><a href="http://developer.android.com/guide/developing/tools/traceview.html" rel="nofollow">http://developer.android.com/guide/developing/tools/traceview.html</a></p> <p><a href="http://developer.android.com/guide/developing/debugging/debugging-tracing.html" rel="nofollow">http://developer.android.com/guide/developing/debugging/debugging-tracing.html</a></p> <p>Now i am able to generate trace and do method profiling.</p> <p>But it is still not clear to me how to read the trace and make my code efficient.My application is working so slow.Please guide me </p> <p>Please see the images also of timeline panel and profile panel <img src="http://i.stack.imgur.com/VDVmy.jpg" alt="enter image description here"></p> <p><img src="http://i.stack.imgur.com/8vltw.jpg" alt="enter image description here"></p>
android
[4]
448,687
448,688
PHP submit form button question
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/218907/how-to-handle-multiple-submissions-server-side">How to handle multiple submissions server-side</a> </p> </blockquote> <p>How can I stop the submit form button from being pressed multiple times resulting in sending the data multiple times using PHP.</p>
php
[2]
6,015,893
6,015,894
How to get 12.6 with a=10.3 and b=2.3?
<p><a href="http://jsfiddle.net/DYKJB/2/" rel="nofollow">Tried</a> :</p> <pre><code>var a=10.3; var b=2.3; alert(a+b); </code></pre> <p>but I get <code>12.600000000000001</code>. I know JavaScript is loosely typed, but I hope I can do a sum :)</p>
javascript
[3]
789,050
789,051
Forms with a variable number of fields
<p>I'm attempting to create a sort of marketplace. Each item on the market has a type (i.e. the item being sold), a value, a quantity, a seller name, and an id, and all of this information is stored in a MySQL database.</p> <p>When the user views the market, all entries in the market are returned. In addition, an input text field appears at the end of each entry. The user can enter any number between leaving it blank (0) and the max quantity available.</p> <p>My problem is that since each input field is the result of a while loop of unknown iterations, I can't simply hard code a name into each field. I've tried using a counter variable to keep track and make names, but it doesn't seem to be working. For example: <code>name='.$i++.'</code></p> <p>On a related note, in order for the program to work, each field needs to send two values - the id (which I can use to look up the rest of the entry's values) and the quantity that the user wishes to purchase. I've been doing this with a hidden field before the input quantity field. I'm not sure if this is a good way of going about this, but I should note that there's no need as far as I can tell for the id to be kept secret.</p> <p>Just so everything's clear, here's a basic UI mockup: <a href="http://img850.imageshack.us/img850/2654/marketui.jpg" rel="nofollow">http://img850.imageshack.us/img850/2654/marketui.jpg</a></p> <p>Note that the column starting with consists of user inputted values (i.e. the 100s are the values of user-inputted text fields). The hitch is that while there are 2 rows in this example, the actual number is not deterministic, and so I can't hard code names for each input field.</p>
php
[2]
4,841,020
4,841,021
Variable passed to each() is not an array or object
<p>I really don't understand why I'm getting this error or how to fix it! Variable passed to each() is not an array or object on line-</p> <pre><code>while(list($key,$value) = each($_FILES['images']['name'])) </code></pre> <p>Full code-</p> <pre><code>$max_no_img=4; // Maximum number of images value to be set here $imgs_names = array('CV', 'Research Plan', 'Degree Transcript', 'GRE Scores'); echo "&lt;form method=post action='' enctype='multipart/form-data'&gt;"; echo "&lt;table border='0' width='400' cellspacing='0' cellpadding='0' align=left&gt;"; for($i=1; $i&lt;=$max_no_img; $i++){ echo "&lt;tr&gt;&lt;td&gt;".$imgs_names[$i-1]."&lt;/br&lt;/td&gt;&lt;td&gt; &lt;input type=file name='images[]' class='bginput'&gt;&lt;/td&gt;&lt;/tr&gt;"; } echo "&lt;tr&gt;&lt;td colspan=2 align=center&gt;&lt;input type=submit value='Submit'&gt;&lt;/td&gt;&lt;/tr&gt;"; echo "&lt;/form&gt; &lt;/table&gt;"; while(list($key,$value) = each($_FILES['images']['name'])) { echo $key; echo "&lt;br&gt;"; echo $value; echo "&lt;br&gt;"; if(!empty($value)){ // this will check if any blank field is entered $filename =rand(1,100000).$value; // filename stores the value $filename=str_replace(" ","_",$filename); $add = "upload/$filename"; // upload directory path is set copy($_FILES['images']['tmp_name'][$key], $add); echo $add; </code></pre> <p>Any ideas?</p>
php
[2]
1,822,241
1,822,242
How to modify private static variable through setter method
<p>I have the following variable in a class named Example:</p> <pre><code>private static int number; </code></pre> <p>If I wanted to assign the variable a number using an outside class, which would I do?</p> <p>1) Make the setter method in Example static so I can access it like this: </p> <pre><code>Example.setNumber(3); </code></pre> <p>2) or Make the setter method non-static so I create an object of Example to set the number</p> <pre><code>Example e = new Example() e.setNumber(3); </code></pre> <p>What are the differences between the two and which one is the better way?</p>
java
[1]
1,161,038
1,161,039
Shell exec file runs in background process ???
<p>Using ShellExec process, I have run a file with one argument. arguments we will get from a single txt file. That txt file has more than 75000 lines. So that file will run 75000 times. At that time, will the server handle that process??? </p>
php
[2]
623,324
623,325
jQuery .get doesn't work in IE7
<p>I have the following code which gets the top three pieces of news from a page (news.html). It works fine in all other browsers (IE8, FF, Chrome), except in IE7 where it loads the whole page rather than just the top 3 news. Have been googling all around, no help. So hopefully one of you could tell me where the problem is or how to fix this. Thanks.</p> <pre><code>jQuery(document).ready(function () { $.get('/news.html', function(data) { var news = $(data).find('tr td:lt(9)'); $('#newsTop3').html(news); // ... // ... }); }); </code></pre> <p>UPDATE:</p> <p>Here I have shown what I want to achieve. From BBC's news page I want to grab the first three ones, as can be seen from the link below. <a href="http://jsfiddle.net/qrGFb/9/" rel="nofollow">http://jsfiddle.net/qrGFb/9/</a></p> <p>It works fines in other browsers, the only problem is IE7 that loads all the news page, not just the top 3.</p>
jquery
[5]
5,869,140
5,869,141
Progress dialog in async task is not shown anymore after screen rotation
<p>I am using an async task for uploading pictures to a remote server. To show the progress to the user I am using a progress dialog. This progress dialog is created at the preExecute method of the async task class.</p> <p>When the user rotates the screen, the progress dialog disappears but the async task is still running. The activity holds a static reference to the async task so I do know that the task is still running. How can I now show up the progress dialog again? I tried the following:</p> <p>The create method of the activity:</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if(task != null) { Status status = task.getStatus(); if(status == Status.RUNNING) { task.updateViewContext(this); } } </code></pre> <p>the constructor of my async task class:</p> <pre><code>public UploadTask(UploadPicturesActivity activity) { this.context = activity; dialog = new ProgressDialog(activity); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); } </code></pre> <p>the preexcetue method of my asnyc task class:</p> <pre><code>protected void onPreExecute() { this.dialog.show(); } </code></pre> <p>and trying to show the dialog again (does not work):</p> <pre><code>public void updateViewContext(UploadPicturesActivity activity) { this.context = activity; dialog.show(); } </code></pre> <p>Regards</p> <p>Michael</p>
android
[4]
2,383,705
2,383,706
JavaScript constructor and prototype object
<p>I am curious as to what's going on here. As you can see, I have defined a constructor function called <code>range</code> to build new <code>range</code> objects. I've extended the <code>range</code> constructor through it's prototype, adding a simple <code>includes</code> method. I've created my new object and used the variable of <code>p</code>. When I attempt to use this method with my <code>range</code> objects, all is well and it works as expected. The problem is when I try to look at at <code>p.prototype</code> it tells me that it's type is undefined and <code>p.prototype</code> has no methods... Huh??</p> <p>What's going on here?? How is <code>p</code> an object and <code>p.prototype</code> is not?</p> <pre><code> function range(from, to) { this.from = from; this.to = to; } range.prototype = { includes: function(x) { return this.from &lt;= x &amp;&amp; x &lt;= this.to; }, } var p = new range(1, 4); console.log(typeof p) //outputs object console.log(typeof p.prototype) //outputs undefined console.log(Object.getOwnPropertyNames(range.prototype)); //outputs includes console.log(Object.getOwnPropertyNames(p.prototype)); //throws error, p.prototype is not an object </code></pre>
javascript
[3]
2,313,457
2,313,458
close the command interpreter
<p>my requirement is the follwing. I run the batch file using java code. The batch file does the following</p> <ol> <li>one xml file using java and it takes some time.</li> <li>After xml file is run the applet is displayed.</li> <li>If the applet is closed manually then the command prompt will close.</li> <li>I need to close the command prompt using the java</li> </ol> <p>my problem is that if i exceute taskill/im cmd.exe all others are also closed which i dont want</p>
java
[1]
1,063,017
1,063,018
How do I simulate a scrollbar click with jQuery?
<p>How do I simulate a scrollbar click with jQuery? So, if a user clicks on a div that says "scroll down," it'll be the exact same behavior as if he/she clicked on the down arrow of the browser's scrollbar. Using the current browser's behavior would be optimal, vs. doing something like <code>$.browser.scrolldown(200,'fast')</code>. </p> <p>Something like <code>$.browser.triggerDownArrowOnScrollBar()</code> would be sweet!</p>
jquery
[5]
3,558,652
3,558,653
Open source C# examples of good code/spagetti code
<p>I'm looking for some code projects/examples that would be considered really good C# code and some that would be considered really bad/spaghetti deluxe code.</p> <p>All links and ideas on where to find these kinds of examples are welcome.</p> <p>/P</p> <p>Edit: Code snippets are always nice. But What I'm really looking for is source codes for complete projects to see the structure of the program and how they have implemented patterns etc etc...</p> <p>There is a tip with some repositories that are without or with little code smells .... which is really nice. Now if we could just find some nightmare projects...</p>
c#
[0]
5,951,915
5,951,916
jQuery animate when mouseover and mouseout
<p>I have the following code which moves a <code>DIV block</code> 20px down on mouseover:</p> <pre><code>$('.outerDiv').mouseover(function() { $(this).animate({marginTop: "+=20px",},500); }); $('.outerDiv').mouseout(function() { $(this).animate({marginTop: "-=20px",},500); }); </code></pre> <p>The div contains another <code>div</code> inside. The problem is that when the mouse is over the inner <code>div</code>, the mouse out event occurs and the <code>div</code> block shift up <code>20px</code>. I am wondering if there is a way to only fire the mouseout event if the mouse is only outside the outer <code>div</code>.</p> <p>Here is the HTML structure:</p> <pre><code>&lt;div class='outerDiv'&gt; &lt;div class='innerDiv'&gt; bla bla bla &lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
4,067,515
4,067,516
Why is possible to call nonstatic member-function without an object instance?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2533476/what-will-happen-when-i-call-a-member-function-on-a-null-object-pointer">What will happen when I call a member function on a NULL object pointer?</a> </p> </blockquote> <p>Well I think this code and program output explain it self:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; class Test { public: void Not_Static(string args) { cout &lt;&lt; args &lt;&lt; endl; } }; int main() { Test* Not_An_instance = nullptr; Not_An_instance-&gt;Not_Static("Non-static function called with no object?"); cin.ignore(); return 0; } </code></pre> <p><strong>program output:</strong></p> <blockquote> <p>Non-static function called with no object?</p> </blockquote> <p>why is that possible?</p>
c++
[6]
519,157
519,158
Why this message: does not contain a definition for 'Controls' and no extension method 'Controls' accepting a first argument
<p><strong>Hi,</strong></p> <p>What I'm doing is a method to display images from a specific folder but when I debug I'm getting this error on the last line of code and I have no idea why.**</p> <pre><code>Error 3 'MBKiosk.classTools' does not contain a definition for 'Controls' and no extension method 'Controls' accepting a first argument of type 'MBKiosk.classTools' could be found (are you missing a using directive or an assembly reference?) </code></pre> <p><strong>Thanks for any help.</strong></p> <p><strong>Here is the code:</strong></p> <pre><code>using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Data.SqlClient; using System.Data; using System.IO; using System.Windows.Forms; using System.Drawing; using System.ComponentModel; using System.Collections.ObjectModel; using MBKiosk; namespace MBKiosk { class classTools { public void ShowImages(string path) { FlowLayoutPanel imagePanel = new FlowLayoutPanel(); imagPanel.FlowDirection = FlowDirection.LeftToRight; imagePanel.Size = new Size(1240, 630); imagePanel.Location = new Point(12, 344); imagePanel.WrapContents = true; imagePanel.AutoScroll = false; DirectoryInfo dInfo = new DirectoryInfo(path); foreach (FileInfo file in dInfo.GetFiles()) { System.Diagnostics.Debug.Print(file.Extension); if ((file.Extension == ".jpg") || (file.Extension == ".gif") || (file.Extension == ".png")) { PictureBox image = new PictureBox(); image.Image = Image.FromFile(file.FullName); image.SizeMode = PictureBoxSizeMode.Normal; image.Size = new Size(180, 108); imagePanel.Controls.Add(image); imagePanel.Refresh(); } } this.Controls.Add(imagePanel); } } } </code></pre>
c#
[0]
1,498,770
1,498,771
Android: Customize Calling Screen
<p>Anybody knows how to Customize Calling Screen for incoming and outgoing calls?</p> <p>Any sample code would be of great help.</p>
android
[4]
4,631,978
4,631,979
python: class attributes and instance attributes
<p>I'm new to python and learned that class attributes are like static data members in C++. However, I got confused after trying the following code:</p> <pre><code>&gt;&gt;&gt; class Foo: ... a=1 ... &gt;&gt;&gt; f1=Foo(); &gt;&gt;&gt; f2=Foo() &gt;&gt;&gt; f1.a 1 &gt;&gt;&gt; f1.a=5 &gt;&gt;&gt; f1.a 5 &gt;&gt;&gt; f2.a 1 </code></pre> <p>Shouldn't f2.a also equal 5?</p> <p>If a is defined as a list instead of an integer, the behavior is expected:</p> <pre><code>&gt;&gt;&gt; class Foo: ... a=[] ... &gt;&gt;&gt; f1=Foo(); &gt;&gt;&gt; f2=Foo() &gt;&gt;&gt; f1.a [] &gt;&gt;&gt; f1.a.append(5) &gt;&gt;&gt; f1.a [5] &gt;&gt;&gt; f2.a [5] </code></pre> <p>I looked at <a href="http://stackoverflow.com/questions/207000/python-difference-between-class-and-instance-attributes">Python: Difference between class and instance attributes</a>, but it doesn't answer my question.</p> <p>Can anyone explain why the difference? Thanks</p>
python
[7]
5,282,211
5,282,212
Hide Navigation Links From Non-Members
<p>I have an include file that stores the navigation links for my website. I just built a members-only section and I would like to make it so that some of the links in the navigation bar are visible only if someone is logged in. What are some good ways of going about doing this?</p>
php
[2]
3,415,496
3,415,497
python working with files as they are written
<p>So I'm trying to create a little script to deal with some logs. I'm just learning python, but know about loops and such in other languages. It seems that I don't understand quite how the loops work in python. </p> <p>I have a raw log from which I'm trying to isolate just the external IP addresses. An example line:</p> <blockquote> <p>05/09/2011 17:00:18 192.168.111.26 192.168.111.255 Broadcast packet dropped udp/netbios-ns 0 0 X0 0 0 N/A</p> </blockquote> <p>And heres the code I have so far:</p> <pre><code>import os,glob,fileinput,re def parseips(): f = open("126logs.txt",'rb') r = open("rawips.txt",'r+',os.O_NONBLOCK) for line in f: rf = open("rawips.txt",'r+',os.O_NONBLOCK) ip = line.split()[3] res=re.search('192.168.',ip) if not res: rf.flush() for line2 in rf: if ip not in line2: r.write(ip+'\n') print 'else write' else: print "no" f.close() r.close() rf.close() parseips() </code></pre> <p>I have it parsing out the external ip's just fine. But, thinking like a ninja, I thought how cool would it be to handle dupes? The idea or thought process was that I can check the file that the ips are being written to against the current line for a match, and if there is a match, don't write. But this produces many more times the dupes than before :) I could probably use something else, but I'm liking python and it makes me look busy. </p> <p>Thanks for any insider info.</p>
python
[7]
618,988
618,989
Why is getProperty returning null via PHP ReflectionClass
<p>I am making a new <code>ReflectionClass</code>, then setting the protected property <code>_products</code> to accessible. It is always returning <code>null</code> Am I doing something wrong here? I am on 5.4.11</p> <pre><code>$project = new ReflectionClass( $instance_of_object ); $property = $project-&gt;getProperty( '_products' ); $property-&gt;setAccessible( true ); $products = $property-&gt;getValue( $project ); </code></pre> <p>I am trying to make sure a property is set correctly in my unit tests...</p>
php
[2]