Dataset Viewer
Auto-converted to Parquet
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
4,165,966
4,165,967
How to get the page's full content as string in javascript?
<p>I'm writing a bookmarklet, i.e. a bookmark that contains javascript instead of a URL, and I have some trouble. In fact, I cannot remember how I can get the content of the page as a string, so I can apply a regular expression to find what I want. Can you please help me on this?</p> <p>Before anyone suggests it, I cannot use getElementBy(Id/Name/Tag), because the data I'm looking for is HTML-commented and inside markups, so I don't think that would work.</p> <p>Thanks.</p>
javascript
[3]
834,702
834,703
How to extract from a list of objects a list of specific attribute?
<p>I have a list of objects. Object has 3 string attributes. I want to make a list containing only a specific attribute from class.</p> <p>Is there any built-in functions to do that?</p>
python
[7]
2,668,893
2,668,894
Good patterns for loose coupling in Java?
<p>I'm new to java, and while reading documentation so far i can't find any good ways for programming with loose coupling between objects. For majority of languages i know (C++, C#, python, javascript) i can manage objects as having 'signals' (notification about something happens/something needed) and 'slots' (method that can be connected to signal and process notification/do some work). In all mentioned languages i can write something like this:</p> <pre><code>Object1 = new Object1Class(); Object2 = new Object2Class(); Connect( Object1.ItemAdded, Object2.OnItemAdded ); </code></pre> <p>Now if <code>object1</code> calls/emits <code>ItemAdded</code>, the <code>OnItemAdded</code> method of <code>Object2</code> will be called. Such loose coupling technique is often referred as 'delegates', 'signal-slot' or 'inversion of control'. Compared to interface pattern, technique mentioned don't need to group signals into some interfaces. Any object's methods can be connected to any delegate as long as signatures match ( C++Qt even extends this by allowing only partial signature match ). So i don't need to write additional interface code for each methods / groups of methods, provide default implementation for interface methods not used etc.</p> <p>And i can't see anything like this in Java :(. Maybe i'm looking a wrong way?</p>
java
[1]
389,312
389,313
Getting only a part of a file
<p>I have some very simple sample code like this:</p> <pre><code>$.ajax({ url: 'demo2.htm', success: function(loadeddata){ $("#loaded_data").html(loadeddata); alert('success'); }, error: function(){ alert('failure'); } }); </code></pre> <p>Loaded data currently returns everything. What I need to is to get only a specific div and make it the html of #loaded_data.</p> <p>How do I do that?</p> <p>Thanks!</p> <p>Edit:</p> <p>While trying to use .load()...</p> <p>Here's what I wrote into the comment. </p> <p>Thanks, your updated example is great. However I'm not sure what's wrong with mine.</p> <p>This: works</p> <pre><code>$("#loaded_data").load("demo2.htm #mydiv", function(text, status, request) { if(status == 'success') { alert('success'); } else { alert('error'); } }); </code></pre> <p>This: </p> <pre><code>$("#loaded_data").load("demo5.htm #mydiv", function(text, status, request) { if(status == 'success') { alert('success'); } else { alert('error'); } }); </code></pre> <p>Does not. It just hangs. There is no demo5.htm But no error is returned.</p> <p>Thanks a lot again for all of your help.</p>
jquery
[5]
5,778,536
5,778,537
Android SDK - get R.id (int) of a string value
<p>Lets say I have an xml file called test1.xml in String xmlFile = "test1.xml" format. How can I get the R.id.test1 value of it?</p>
android
[4]
4,599,965
4,599,966
Name for a public const and private writable atrribute?
<p>Programming in C++, I often want to give the user of a class read-only access to an attribute, and the class itself read-write access. I hate <code>XxxGet()</code> methods, so I often use a <code>public const &amp;</code> to a private attribute, like this:</p> <pre><code>class counter { private: int _count; public: const int &amp; count; counter : _count( 0 ), count( _count ){} void inc( void ){ _counter++; } }; </code></pre> <p>Is there a common name for this trick?</p>
c++
[6]
4,903,936
4,903,937
c# thread method
<p>If I have a public void Method(int m){...} how can I create a thread to this method?</p> <blockquote> <p>Thread t = new Thread((Method));</p> <p>t.Start(m);</p> </blockquote> <p>is not working. Thx</p>
c#
[0]
2,494,061
2,494,062
what is my appID on developer.paypal
<p>I want to create a paypal functionality on android. I have created a test sandbox account at developer.paypal.com</p> <pre><code>i want to use this fuction in my coding:- PayPal pp = **PayPal.initWithAppID(this, "what should i write here",PayPal.ENV_SANDBOX);** please tell me what should i write in second argument.? i have error in project that Error: **Authentication failed, button not enabled.** </code></pre> <p>Thank you in advance.</p>
android
[4]
3,801,576
3,801,577
How to convert vector to array C++
<p>I want to convert vector of double to array of double. Can any one help me to do this</p>
c++
[6]
1,709,557
1,709,558
iframe error when runat="server"
<p>I have a iframe in one of my web pages with <code>runat="server"</code> and a javascript function assigned to the onload event.<br/> When the page renders it gives an error as <br/> <code>"CS1012: Too many characters in character literal"</code><br/> When I remove the runat="server" attribute it works perfectly but I need the iframe to runat="server".<br/> How can I fix this?</p> <pre><code>&lt;iframe id='contentFrame' name='contentFrame' runat="server" width="500" onload="resizeFrame(document.getElementById('contentFrame'))"&gt; &lt;/iframe&gt; </code></pre>
asp.net
[9]
5,989,892
5,989,893
How to point elements childrens with JavaScript
<p>I have little problem with element childrens.</p> <p>Heres some code to explain my question:</p> <pre><code>function check(element){ // I want to get custom attribute from element children. // Children elements are always radio buttons var temp = element. ?? .attr('temp'); return temp; } // element variable is the whole div here &lt;div id = "test"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="radio" temp="somethinghere"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>Hope someone has ideas or even better.. solution.</p>
javascript
[3]
3,183,820
3,183,821
Why cant I step into this loop in Visual Studio
<p>For some reason, Visual studio will not step into this code and I cant see the contents of the variable k and p</p> <pre><code> for(int k=0; k&lt;6; k++) { for(int p=0; p&lt;6; p++) { if(k=0) { levelToDraw[k][p] = LevelOne[k][p]; } else { levelToDraw[k][p] = LevelOne[k-1][p]; } } } </code></pre>
c++
[6]
690,761
690,762
Help to Install Eclipse for A Netbeans Users
<p>I had been using Netbeans all the while to develop Swing application. So far, I am a <strong>Happy Netbeans User</strong></p> <p>Currently, I had a project (GWT, J2EE and Swing), which I need to use Eclipse (Please do not ask Why)</p> <p>Here is the step I had been taken.</p> <ol> <li>Download <em>Eclipse IDE for Java EE Developers (190 MB)</em> from <a href="http://www.eclipse.org/downloads/" rel="nofollow">http://www.eclipse.org/downloads/</a> I thought this should be the correct choice, as I see most features are found in that edition <a href="http://www.eclipse.org/downloads/packages/compare-packages" rel="nofollow">http://www.eclipse.org/downloads/packages/compare-packages</a></li> <li>After struggling a while to get use to the user interface of Eclipse, I still cannot find a <strong>Visual GUI Editor</strong>!</li> <li>After doing some Googling, I realize I need to install something called <strong>Plugins</strong></li> </ol> <p>However, tones of plugins which had similar features has confused me, as I found</p> <p><a href="http://www.cloudgarden.com/jigloo/index.html" rel="nofollow">http://www.cloudgarden.com/jigloo/index.html</a></p> <p><a href="http://www.eclipse.org/vep/WebContent/main.php" rel="nofollow">http://www.eclipse.org/vep/WebContent/main.php</a></p> <p><a href="http://code.google.com/p/visualswing4eclipse/" rel="nofollow">http://code.google.com/p/visualswing4eclipse/</a></p> <p>This makes me even more confuse? Which plugin I should use to develop a Swing based application? Most of them seems not up-to-dated. Or, is there any complete bundle I can download, where 1 click, will install all the necessary Swing development tools for me?</p> <p><strong>I just miss my Netbeans :( I really appreciate their team, who make the installation work so easy. One click button install, all the necessary tools just come to me</strong></p>
java
[1]
257,180
257,181
Python: Check if all dictionaries in list are empty
<p>I have a list of dictionaries. I need to check if all the dictionaries in that list are empty. I am looking for a simple statement that will do it in one line.</p> <p>Is there a single line way to do the following (not including the print)?</p> <pre><code>l = [{},{},{}] # this list is generated elsewhere... all_empty = True for i in l: if i: all_empty = False print all_empty </code></pre> <p>Somewhat new to python... I don't know if there is a shorthand built-in way to check this. Thanks in advance. </p>
python
[7]
391,926
391,927
Jquery - One simple function to handle 16 different buttons being clicked?
<p>I am creating an interactive colour sampler for a web site, which has 16 different swatches which can be clicked to show the fullsize preview.</p> <p>Using jQuery I have a function <code>show_preview(swatch_id)</code> which does all the good visual stuff. However to call that function, I am currently stuck with repeating 16 similar handlers:</p> <pre><code>&lt;div id="#swatch_clicker_1&gt; &lt;div id="#swatch_clicker_2&gt; $("#swatch_clicker_1").click(function() { show_preview('1'); } $("#swatch_clicker_2").click(function() { show_preview('2'); } ... </code></pre> <p>I've been reading round the subject, including here on Stack Overflow and modified a little code from another answer. So If I were to do something like this, would it still run efficiently (if at-all!)?</p> <pre><code>&lt;div class="swatch_clicker" id="#swatch_clicker_1&gt; &lt;div class="swatch_clicker" id="#swatch_clicker_2&gt; $(".swatch_clicker").click(function(event) { var clicker_id=event.target.id; show_preview(clicker_id); } </code></pre> <p>Thanks,</p> <p>Phil</p>
jquery
[5]
5,699,977
5,699,978
How to check whether a string is a concatenation of other strings with a character inserted between each string in python
<p>I'm trying to check whether a user-inputted string is contained in a list of other strings AND any permutation of those strings, separated by a "*".</p> <p>In other words, here's the code I have so far:</p> <pre><code>user_string=raw_input("Please supply a string") viable_entries=['this', 'that', 'something else'] if user_string in viable_entries: print "here I'd move on with my script" </code></pre> <p>I'd also want to print "here I'd move on with my script" if user_string = "something else*this" or "this*that", etc.</p> <p>Is there an easy, pythonic way to do this?</p>
python
[7]
539,151
539,152
Comparison of custom objects and operator overloading in C++
<p>Read <a href="http://stackoverflow.com/questions/1380463/sorting-a-vector-of-custom-objects">this</a> question about how to compare custom objects in C++. I did not understand the operator overloading used here. What is the operator being overloaded here? Is it ()? What is the use of overloading that?</p> <pre><code>struct MyStruct { int key; std::string stringValue; MyStruct(int k, const std::string&amp; s) : key(k), stringValue(s) {} }; struct less_than_key { inline bool operator() (const MyStruct&amp; struct1, const MyStruct&amp; struct2) { return (struct1.key &lt; struct2.key); } }; </code></pre>
c++
[6]
2,927,274
2,927,275
Button differentiation in android
<p>I am new to android.I am developing an application in that i have two buttons in 1 screen.I have to perform to different actions based on the particular button clicked.I have to differentiate according to which button is clicked. </p> <pre><code>public void showSelectedNumber(int type, String number) { ---&gt;Here i have to set two conditions: 1.This for call try { // Intent callIntent = new Intent(Intent.ACTION_CALL); //Call options ////// Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); ////// while (cursor.moveToNext()) { ////// String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); ////// } // callIntent.setData(Uri.parse("tel:"+number)); // startActivity(callIntent); This is for SMS: startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("sms:" //sms options + number))); } catch (ActivityNotFoundException e) { Log.e("helloandroid dialing example", "Call failed", e); } Toast.makeText(this, type + ": " + number, Toast.LENGTH_LONG).show(); } } </code></pre>
android
[4]
606,928
606,929
C++ Casting a byte binary value into a string
<p>How do I convert 6 bytes representing a MAC address into a string that displays the address as colon-separated hex values?</p> <p>Thanks</p>
c++
[6]
2,878,859
2,878,860
checking existance of the list element via c# functions
<p>I have a list like:</p> <pre><code> List&lt;int&gt; baslikIndexes = new List&lt;int&gt; { }; </code></pre> <p>and I added the elements manually. I want to know whether for example if element "23" is in it or not. I am trying to use "Exists" method but I haven't figured out how to use it. I tried this and it gives error: </p> <pre><code> baslikIndexes.Exists(Predicate&lt;int&gt;(23)); // I try to check whether 23 is in the list or not </code></pre> <p>Thanks for help..</p>
c#
[0]
906,046
906,047
Using gcc compiler flag in Xcode
<p>Shark has identified a area of code to be improved - Unaligned loop start and recommends adding -falign-loops=16 (gcc compiler flag). I've added this to Other C flags in iphone Xcode both to the dependant project and top level project. However it still does not seem to affect the performance and Shark is still reporting the same problem so it appears it didn't work.</p> <p>Am i doing this correctly?</p>
iphone
[8]
2,047,795
2,047,796
In Android, how to switch the page
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3803484/moving-from-one-activity-to-next-in-android">Moving from One activity to next in Android</a> </p> </blockquote> <p>i have two classes, how do I switch from one page to another page?</p>
android
[4]
3,360,260
3,360,261
Android Button in Custom Preference gets enabled automatically
<p>I have a custom preference in my application which consists of a textview and a button and it is put in a preference screen. I load the layout in the onCreateView of the preference </p> <pre><code>LayoutInflater inflater = (LayoutInflater)getContext(). getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.custom_preference, parent, false); </code></pre> <p>In my xml, I have put android:enabled="false" for the button because I want to disable it and enable it conditionally later. When my preferencescreen comes up, this button is disabled, but gets enabled automatically in a second(I still haven't added any code to enable this yet). Also I find that the onCreateView of my custom preference keeps getting called again and again. Can someone please help me as to what is happening here?</p>
android
[4]
4,803,386
4,803,387
How to add a field name as variable in Django?
<p>Is it possible to pass in the field name instead of the hardcoded 'last_name'?</p> <pre><code>for item in queryset: to_json.append(item.last_name) </code></pre>
python
[7]
2,127,125
2,127,126
android re-launching application as home button
<p>After many hours of searching and reading articles I am not able to call my stopped application the same way as the home button is re-launching it. So I pressed home button and my application is stopped. And my service(from other package) can only start new instance of my application (main launching activity).</p> <pre><code>Context context = this.getBaseContext(); PackageManager pm = context.getPackageManager(); Intent appStartIntent = pm.getLaunchIntentForPackage("main.application"); appStartIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(appStartIntent); </code></pre> <p>If it is possible I would like to call onResume of my application from my service - I didn't achieve it.</p> <p>I try also this in my activity :D ...</p> <pre><code>@Override protected void onStop() { super.onStop(); super.onResume(): } </code></pre> <p>The best unworking solution - override home button</p> <pre><code>public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK </code></pre> <p>Thank you very much for effort in advance.</p>
android
[4]
3,359,512
3,359,513
C++ pointer array initialization help
<p>I had trouble with initializing arrays of pointers. What I found out compiling with gcc c++ (4.6.0) is:</p> <pre><code>MyClass** a = new MyClass*[100]; </code></pre> <p>Does not always initalize the array of pointers. (most of the time it did give me an array of null pointers which confused me)</p> <pre><code>MyClass** a = new MyClass*[100](); </code></pre> <p>DOES initialize all the pointers in the array to 0 (null pointer).</p> <p>The code I'm writing is meant to be be portable across Windows/Linux/Mac/BSD platforms. Is this a special feature of the gcc c++ compiler? or is it standard C++? Where in the standard does it says so?</p>
c++
[6]
2,461,848
2,461,849
file walking in python
<p>So, I've got a working solution, but it's ugly and seems un-idiomatic. The problem is this:</p> <p>For a directory tree, where every directory is set up to have:</p> <ul> <li>1 <code>.xc</code> file</li> <li>at least 1 <code>.x</code> file</li> <li>any number of directories which follow the same format</li> </ul> <p>and nothing else. I'd like to, given the root path and walk the tree applying <code>xc()</code> to the contents of <code>.xc</code> fies, <code>x</code> to the contents to <code>.x</code> files, and then doing the same thing to child folders' contents.</p> <p>Actual code with explanation would be appreciated.</p> <p>Thanks!</p>
python
[7]
3,609,814
3,609,815
Is the integer parameter passed to setContentView(int) a pointer?
<p>I've looked in the generated R file, and the values in there definitely look like memory addresses, but is that the case?</p>
android
[4]
3,144,763
3,144,764
Back and Forward Navigation does not retain data In Firefox/chrome Browsers, but works fine in Safari
<p>The scenario is, I have 2 tabs in application, 1. Patient List Tab 2. Patient Search Tab</p> <p>After login to application by default first tab that is Patient list tab that will be selected,When I select 2 tab, Patient Search tab and search for a patient, I see a list of patient with a vertical scroller. If I select a patient the application takes me to next page. When I navigate back I come back to same Patient search tab, retaining the same data and scroller position in Safari Browser. </p> <p>If I do the same action on Firefox or chrome, if I navigate back I come back to default tab that is first Patient List Tab.</p> <p>I use below function to navigate</p> <pre><code>function detailsBack() { var backBtn = document.getElementById("backBtn"); if (backBtn.innerHTML == i18n.PTLST) { javascript:history.go(-1); } } </code></pre> <p>Not sure about the issue. Kindly have a look and share your thoughts</p> <p>Thanks Deepak </p>
javascript
[3]
1,980,643
1,980,644
Java restrict random double
<p>I have a simple question and I'm a little rusty on random number generation. I want to generate large odd integers (I'm using doubles since my numbers could be outside the int range) and I can't quite figure out how to get rid of the decimals in the random number generation and have the number be odd. </p> <p>Right now I just have: </p> <pre><code>N = nMin + (nMax - nMin) * rand.nextDouble(); </code></pre> <p>Which as I said gives me any random number (with decimals) between nMin and nMax. Any help would be much appreciated! </p>
java
[1]
1,121,498
1,121,499
What would stop a jQuery function from firing after replacing HTML on the page with similar elements?
<p>If I have the following HTML:</p> <pre><code>&lt;tr id="record_1" &gt; &lt;td id="name_1"&gt;&lt;a href="#" class="logNameAndValue"&gt;Charles Dickens&lt;/a&gt;&lt;/td&gt;&lt;td id="value_1"&gt;A Christmas Carol&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>And another jQuery function is called to replace it with this:</p> <pre><code>&lt;tr id="record_1" &gt; &lt;td id="name_1"&gt;&lt;a href="#" class="logNameAndValue"&gt;Kurt Vonnegut&lt;/a&gt;&lt;/td&gt;&lt;td id="value_1"&gt;Slaughterhouse Five&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>After the replacement, the onClick function no longer works:</p> <pre><code>$('a.logNameAndValue').click( function(event){ console.log("clicked!"); }); </code></pre> <p>I tried moving all jQuery functions from being defined inside the <code>&lt;body&gt;</code> tag to the <code>&lt;head&gt;</code> tag but it made no difference.</p> <p>I've monitored activity in the Firebug Console and Net panels and <strong>Firebug doesn't indicate a click has taken place.</strong></p> <p>But the <code>.click</code> works fine when the page is first loaded.</p> <p>Any suggestions?</p>
jquery
[5]
2,538,704
2,538,705
Settings for SMTP while sending mail in background
<p>iphone× 117661</p> <p>In this statement Smtpout.servername.net,</p> <p>what would be the exact entries?I am pretty much confused.I am using gmail.Please clarify.....</p> <p>//the guts of the message.</p> <pre><code>SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init]; testMsg.fromEmail = @"[email protected]"; testMsg.toEmail = @"[email protected]"; testMsg.relayHost = @"smtpout.yourserver.net"; testMsg.requiresAuth = YES; testMsg.login = @"[email protected]"; testMsg.pass = @"yourPassWord"; testMsg.subject = @"This is the email subject line"; testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS! </code></pre> <p>This code I have used ,Here in <code>testMsg.relayHost = @"smtpout.yourserver.net"</code>;</p> <p>what entries would be used for smtpOut and "Your server"</p>
iphone
[8]
1,588,778
1,588,779
time data did not match error in strptime
<p>I'm converting a string into time object in python 2.4.</p> <pre><code>d1 = time.strptime(d2, '%Y-%m-%d %H:%M:%S.%%') </code></pre> <p>Here d2 is <code>'2012-11-07 13:41:13.138807'</code></p> <p>I'm getting the following error.</p> <pre><code>ValueError: time data did not match format: data=2012-11-07 13:41:13.138807 fmt=%Y-%m-%d %H:%M:%S.%% </code></pre> <p>Any solution?</p>
python
[7]
3,415,555
3,415,556
Alternative to jQuery Mobile changePage functionality
<p>I've been working on a desktop version of a jQuery mobile application I developed. To re-use some of the code base, I thought i would use JQM for the desktop version of the application as well.</p> <p>Turns out that it causes all kinds of problems with the design whenever I load up JQM (mainly because I do all kinds of stuff with native UI elements). Now, I'm actually only interested in the <code>$.mobile.changePage</code> functionality, so it's overkill to actually use this framework just for that. </p> <p>My question is, does anybody know of some jQuery plugin that holds the same functionality as the <code>changePage</code> function in JQM? (including checking for back buttons, etc.)</p>
jquery
[5]
3,847,103
3,847,104
How would i figure out the price difference efficiently with PHP?
<p>I have this <a href="http://posnation.com/shop_pos/step2/Bakery" rel="nofollow">page</a> and if you scroll to the second "Customize" in the middle of the page and you click you will see my print_r() for the products and the thing i am trying to do is figure out the difference in price between the selected and the other two products....all three products are in the array and if you look just below that you will see the radio buttons that i need....here is my php which looks awful...any suggestions </p> <pre><code>$current_price = $product[$selected_product]['product_price']; $standard_price = $product["standard"]['product_price'] - $current_price; $business_price = $product["business"]['product_price'] - $current_price; $premium_price = $product["premium"]['product_price'] - $current_price; if($standard_price == 0){ $standard_price = "included"; } if($standard_price &gt; 0){ $standard_price = "subtract " . $standard_price; }else{ $standard_price = "add " . $standard_price; } if($business_price == 0){ $business_price = "included"; } if($business_price &gt; 0){ $business_price = "subtract " . $business_price; }else{ $business_price = "add " . $business_price; } if($premium_price == 0){ $premium_price = "included"; } if($premium_price &gt; 0){ $premium_price = "subtract " . $premium_price; }else{ $premium_price = "add " . $premium_price; } </code></pre>
php
[2]
5,537,333
5,537,334
Use DDMS to push the sqlite database file faild
<p>i did not find my package name folder in the data/data. </p> <p>There just are many folder named com</p> <p>And then i try to push my sqlite database to data/data/com, But faild. Why? Pls help me .</p> <p>Can give me a smaple? How to use already exist sqlite database.</p> <p>I have learned from a blog : <a href="http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/" rel="nofollow">http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/</a></p> <p>But it's not use. I run the createDataBase method in the oncreat.</p> <p>It's give the error message: No such table </p> <p>Someone told me i need push the sqlite database to emulator first</p>
android
[4]
583,468
583,469
Open an url in android browser, avoid multiple tabs
<p>My project is mostly a web application. Now I have an android app with a home screen widget and would like to open a web page in the built-in browser on some user actions. That is easy. In MyAppWidgetProvider.onUpdate I create a new intent:</p> <pre><code>Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://my.example.com/")); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.text, pendingIntent); </code></pre> <p>Unfortunately, a new browser window/tab is opened every time the user clicks the widget. My page contains some fancy AJAX/javascript running in the background and regularly sending http requests. So I end up having 8 tabs containing the same page and continuously sending 8-fold amount of http requests.</p> <p>Is there any way, e.g. different action or additional parameters to avoid opening new tabs?</p> <p>As a workaround I am now thinking about creating a new activity containing a WebView, but would like to avoid this complexity.</p>
android
[4]
2,068,025
2,068,026
BufferedStream Seek Returns Different Results
<p>Very strange behavior</p> <p>If I create a bufferedstream on top of a file and then seek to an offset I get a block of bytes back </p> <p>If I move the debugger back to the seek and re-seek I get an extra two characters</p> <p>I ve triple checked this </p> <p>Can there possibly be a bug with this class ?</p> <p>If I reseek back to position I expect to get the same - The file has not changed - I open it in read only mode and I seek based on Origin</p> <p>Reproduction: </p> <pre><code>bufferedStream.Seek(100,0, 100) bufferedStream.Reade(buffer, 0, 100) </code></pre> <p>is different to what you get from here</p> <pre><code>bufferedStream.Seek(100,0, 100) bufferedStream.Reade(buffer, 0, 100) </code></pre>
c#
[0]
3,516,294
3,516,295
Difference between graphical layout and emulator
<p>My graphical layout view and the running emulator view is different. I made a landscape layout which shows different in running emulator than the graphical layout's view.What can I do to match them (at least 95%). I wonder if it shows different again in real device.. </p>
android
[4]
1,508,047
1,508,048
Efficient data structure for Zobrist keys
<p>Zobrist keys are 64bit hashed values used in board games to univocally represent different positions found during a tree search. They are usually stored in arrays having a size of 1000K entries or more (each entry is about 10 bytes long). The table is usually accessed by <code>hashKey % size</code> as index. What kind of STL container would you use to represent this sort of table? Consider that since the size of the table is limited collisions might happen. With a "plain" array I would have to handle this case, so I thought of an unordered_map, but since the implementation is not specified, I am not sure how efficient it will be while the map is being populated. </p>
c++
[6]
2,354,293
2,354,294
Interface for controlling Mac via android
<p>I'm interested in writing a mobile application for android and a remote desktop client for near-range control of a Mac personal computer. All the current implementations I can find make use of UDP over WiFi, and that requires the computer to be on the same WiFi network as the phone. Does anyone know of another interface I could potentially look into to making this work? i.e. Bluetooth...</p>
android
[4]
1,522,191
1,522,192
How do you get a USB Drive's Name in C#?
<p>I need to get the name of my USB Drive.</p> <p>Say I rename my USB Drive to "ZeroErrors".</p> <p>and it is Drive letter "G:\" I want to use the drive letter to get the name of the USB Drive.</p>
c#
[0]
3,462,687
3,462,688
JQuery-Set value for empty dropdown from a variable
<p>I have a dropdown box, It has no values in them. I have to set it preselected with a value available in a variable. This is what I have done but it does not set this value.</p> <pre><code>if(condition) { var selectedVal = "myValue"; $("#myDropDownId").val(selectedVal); } </code></pre> <p>as per info from google, the above one works when there are options already available in the dropdown.</p> <p>I tried with the below as well</p> <pre><code>if(condition) { var selectedVal = "myValue"; $("#myDropDownId option:selected").val(selectedVal); } </code></pre> <p>What is the correct syntax for this please? </p>
jquery
[5]
5,171,886
5,171,887
What does rooting of android means?
<p>I am new android development and learning on emulator. What rooting of device means ?? it something like jail break for Iphone. How can i root emulator and why i need root a device ?</p>
android
[4]
3,789,257
3,789,258
extending the jquery .each loop
<p>I have a jQuery function that finds all the images nested in a container DIV with the ID of #popupForm, looks at the SRC attribute and compares it to a hidden input that has it's value created by a server side variable. Once rendered if there's a match it'll do a replace on the SRC of the image, hense:</p> <pre><code>var thisTheme = $("#hiddenTheme").val(); var defaultTheme = "/midway/firstTheme/" $('#popupForm img').each(function () { var thisSRC = $(this).attr('src'); if (thisSRC.indexOf(defaultTheme) !== -1) { var new_src = $(this).attr('src').replace(defaultTheme, thisTheme); $(this).attr('src', new_src); } }); </code></pre> <p>Now this works great but I wish to extend the loop part of this code (the .each part) so not only does it look at images in the container DIV but all inputs (yes some of the inputs have a SRC attribute - please don't ask why)</p> <p>I was thinking of adding an array like such </p> <pre><code>var arrValues = ["#popupForm img", "#popupForm input"]; </code></pre> <p>and then chaning the selector partof the each to contain the array, something like this</p> <pre><code>$(arrValues).each(function () { </code></pre> <p>Does anyone know the best way for me to amend the code for this, what I've tried thus far hasn't worked!</p> <p>Thanks</p>
jquery
[5]
5,680,442
5,680,443
jQuery: using live() with each()
<p>I have this function here:</p> <pre><code>$("a.fancybox_vid").each(function(){ $(this).fancybox({ titleShow : false, width: 640, height: 395, autoDimensions: false, overlayOpacity: 0.6, href: "misc/mc.php?v="+$(this).attr('id') }); }); </code></pre> <p>Now a link with c lass .fancybox_vid gets appended, and then this will not work. Only if it is there from the beginning. How can I have live() in this each().</p>
jquery
[5]
57,362
57,363
Variable not found. Referencing objects from another class
<p>Background:</p> <p>I'm creating a basic download centre on a concurrent server.</p> <p>I create file objects in the <code>Server class</code> under a main method</p> <pre><code>File[] files = { new File("1. Program", "myProgram.jar"), new File("2. Image", "myPicture.jpg"), new File("3. Book", "myBook.txt")}; </code></pre> <p>This references to the <code>File class</code> where I create constructors and getters.</p> <pre><code>class File { private String option; private String fileName; public File(String option, String fileName) { this.option = option; this.fileName= fileName; } public String getOption() { return option; } public String getFileName() { return fileName; } public void getFileOptions(File[] files) { for (File f : files) { System.out.printf("The option is %s\n", f.getOption()); } } } </code></pre> <p>I am attempting to call the <code>getFileOptions</code> method from my <code>ServerState class</code>. </p> <pre><code>theOutput= File.getFileOptions(files); </code></pre> <p>The output is a string that is returned to a client.</p> <p>My IDE says that <code>(files)</code> cannot be found. Any ideas where I'm going wrong? Cam I not return results to a class where the object wasn't initially created? </p>
java
[1]
404,668
404,669
File download complete callback
<p>I would like to able to track, purely on the client side, the progress of a file download, especially file download completion.</p> <p>Is there a JavaScript API that allows me to define a callback upon file download completion?</p>
javascript
[3]
564,713
564,714
Tree panel error in extjs4
<p>In ExtJS4, a tree panel was created with Ext.tree.Panel. When it is clicked multiple times (around 8 to 16) to expand or collapse the tree nodes, It gives error 'event' is null or not an object at line 10708 of ext-all-debug.js. On each click it creats another node below the clicked one. This problem is seen only in IE 8 where as same code are working fine in FirFox. Can anyone fix this issue please?</p>
javascript
[3]
288,755
288,756
How to catch device back button event in android?
<p>I have open pdf file through my application.when click on device back button it is automatically come back to my application .It is working fine.Here i want catch back button event in device.I override the back button.but it is not working.please help me.</p>
android
[4]
1,348,332
1,348,333
Finding DropDownList index by text
<p>I have a populated DropDownList. How do I find the index whose Text value is "x"?</p>
asp.net
[9]
2,068,371
2,068,372
How can I make parameterized method?
<p>I have similar class for making Product factory:</p> <pre><code>package com.nda.generics; import java.util.ArrayList; import java.util.Collection; import java.util.List; import com.nda.generics.Sizeable.Size; public class ProductFactory{ private Collection&lt;? extends Sizeable&gt; sources; public ProductFactory(Collection&lt;? extends Sizeable&gt; sources) { this.sources=sources; } public void setSources(Collection&lt;? extends Sizeable&gt; sources) { this.sources=sources; } public Collection&lt;Product&gt; makeProductList() { Collection&lt;Product&gt; products=new ArrayList&lt;Product&gt;(); for (Sizeable item:sources) { switch(item.getSize()) { case BIG: products.add(new Sausage()); break; case MIDDLE: products.add(new Feets()); break; case LITTLE: products.add(new Conservative()); break; } } return products; } public class Conservative extends Product { private Conservative(){} } public class Feets extends Product { private Feets(){} } public class Sausage extends Product { private Sausage(){} } } </code></pre> <p>This factory makes list of products using size of animals. But I also need to parameterize method/class that I will set type of product, for exampe new Feets (using parameters of constructor). How can I do it? Thank you. </p>
java
[1]
836,316
836,317
Displaying Webalizer Stats using ASP.NET
<p>I have a website (www.teahua.com) that is written using ASP.NET (2.0) and C# running on a Debian server using mono. The hosting provider provides statistic on the website using webalizer.</p> <p>The statistics is accessed uing www.teahua.com/stats (and it runs the index.html page).</p> <p>I am relatively new to the ASP.NET arena. My question is how can I display / include the stats page, and all other links from that page, using ASP.NET.</p> <p>Thank you for your help</p>
asp.net
[9]
787,094
787,095
Not able to enumerate all properties of an object in javascript
<p>I am a newbee with javascript and have the following code:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;object classid="clsid:f6D90f11-9c73-11d3-b32e-00C04f990bb4" id="abc"&gt; &lt;/object&gt; &lt;script&gt; var b=document.getElementById("abc"); for (a in b){ document.write(a+"&lt;br&gt;"); } alert(b.object); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now, my question is why doesnt this code enumerates all the properties for the object b. And to be more specific, this code does not enumerates the "object" property. But the code alert(b.object) tells me that this is an object.</p> <p>Am I doing everything right? can someone clarify my doubts.</p> <p>Thanks</p>
javascript
[3]
3,574,029
3,574,030
How to determine the longest dimension of an multi-dimension array in C#
<p>I was wandering if I have a multi-dimension array (M*N matrix), how to determine the value of M and N in C#?</p> <p>Thanks.</p>
c#
[0]
1,442,560
1,442,561
why copying object in java is not working?
<p>I have to copy an object by value not by reference, I tried different methods, none is working. please take a look at this code :</p> <p>public static class25 copy(class25 otherSpec) { class25 class2 = new class25( otherSpec.Getfct());</p> <pre><code>for (pa pack : otherSpec.Getfct()) class2.addsp(pack); for (dn ddata : otherSpec.getdld()) class2.addsp(data); return class2; </code></pre> <p>} and there is it's use:</p> <p>class25 class22 = class25.copy(class2);</p>
java
[1]
4,758,029
4,758,030
applicationWillTerminate problem
<p>I want to show the UIAlertView when user Click the Iphone Home button( means Close the application)</p> <p>I have done these Code</p> <pre><code>- (void)applicationWillTerminate:(UIApplication *)application { NSString *errorString =@"Testing"; UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Alert" message:errorString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [errorAlert show]; [errorAlert release]; } </code></pre> <p>But UIAlertView is not Showing. please help</p> <p>Thanks in Advance</p>
iphone
[8]
3,707,375
3,707,376
Where should I store a TextView data source
<p>I have an AutoCompleteTextView which works with a list of cities. The list is long, and so I'm thinking where/how/if to store and/or cache it.</p> <p>My initial thought was to get the list from my web service, but it's a long list with 1500+ rows.</p> <p>Should I get it from the web service with each request? Get it once and cache it? Store it in strings.xml to begin with and make sure to keep the list up to date? (It doesn't change much anyway).</p> <p>I'm new to Android and mobile programming in general. Any ideas are welcome.</p>
android
[4]
4,275,638
4,275,639
How to start another android application from code
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3872063/android-launch-an-application-from-another-application">Android Launch an application from another application</a> </p> </blockquote> <p>I want to start Another of my Android Application ( .apk ) using Android code. is it possible ? I have one background kind of Android Application ( Service ). It is separate Android Application. I want to start this Application from my Another Android Application. </p>
android
[4]
3,060,002
3,060,003
Email from ContactsContract?
<p>I'm trying to get the email adress from det ContactsContract like I have done with the ID, NAME and NUMBER. But why can't I get the email this way? How can I get it?</p> <pre><code>int indexColumnId = cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone._ID); int indexColumnName = cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME); int indexColumnNumber = cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER); int indexColumnAdress = cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.??????? </code></pre>
android
[4]
4,924,592
4,924,593
How to check multiple condition for string data type using IF statement using && operator
<p>Anyone please help me, my problem is this i want to check in c#, more textbox values conditions using 'if' statement like this,</p> <pre><code> if(txtbox1.Text == "" &amp;&amp; txtbox2.Text == "" &amp;&amp; ...&amp;&amp;txtboxN.Text =="") { MessageBox.Show("Please enter the details"); return; } </code></pre> <p>but when i use more condition it is not taking the 'second' and others conditions.. what is the solution for this?</p>
c#
[0]
5,620,262
5,620,263
Does using jQuery .data() on an element and then removing the element via direct DOM manipulation leak memory
<p>I've working on a site that was written using Prototype but we're phasing it to jQuery. A lot of page updates are done via Prototype's Ajax.Updater. However, sometimes the elements that Prototype removes and replaces have had a jQuery widget run on them, so $.cache has references to the additional elements created by the widget. Since jQuery isn't doing the DOM removal, it doesn't have a chance to clear the data from $.cache for those elements when they are removed, and I end up with a memory leak. Is there a way to tell jQuery to check it's $.cache and discard any data for elements that are no longer in the DOM?</p>
jquery
[5]
2,851,720
2,851,721
Find index of collection over array
<p>Im having this following loop</p> <pre><code> for (Annotation currAnnotation : annotation.getAnnotations()) { List&lt;Map&lt;String, String&gt;&gt; list = annotation.getList(); list.get(index) </code></pre> <p>the index should be the index of the loop,how can I achieve it ? I need to get from the list the specific entry.</p> <p>Thanks!</p>
java
[1]
3,602,704
3,602,705
My background loop music doesn't "loop" good
<p>I have a background music loop. But it doens't loop well, there's a half second whithout music every time the loop is ending. The mp3 file is perfect, there isn't any second without music. Is it fault of MediaPlayer?</p>
android
[4]
4,925,918
4,925,919
Is there a jquery plugin to refresh certain areas of page
<p>I want to find out a plugin which can refresh certain areas of a page, without refreshing the entire page itself. I have a custom control kept inside a div that changes its contents only on refresh, so I am thinking to use something that can refresh only the div</p>
jquery
[5]
5,684,908
5,684,909
Editing the DataSource of a ComboBox
<p>I have a ComboBox with its DataSource set to an instance of a DataTable. When rows are added to the DataTable, they show in the ComboBox without additional code, but when a row is deleted, the ComboBox remains unchanged. A short summary of my code:</p> <pre><code>ComboBox selector = new ComboBox(); DataTable tbl = new DataTable(); PopulateTable() { DataRow row1 = tbl.NewRow(); row1["field1"] = 1; row1["field2"] = "Some Text"; tbl.Rows.Add(row1); DataRow row2 = tbl.NewRow(); row2["field1"] = 2; row2["field2"] = "More Text"; tbl.Rows.Add(row2); } PopulateSelector() { selector.DisplayMember = "field2"; selector.ValueMember = "field1"; selector.DataSource = tbl; } RemoveRow() { tbl.Rows[0].Delete(); } </code></pre> <p>At this point, the ComboBox <em>appears</em> to be correct, but clicking it resets it to its previous data. The DataTable remains correct, deleting the row causes no problem in that instance, I just can't make the ComboBox reflect the changes.</p>
c#
[0]
1,405,422
1,405,423
How to connect ireports from php
<p>I am developing a web application with PHP and MySQL. Now I am facing problem with selecting the reporting tool. I am developing in Windows XP environment. But the hosting server is Linux. Therefore I have selected iReports as it has Linux version too.</p> <p>I want at the clicking of a button from front end (which is written in PHP), the Jasper report should be generated. But how can I connect iReport with PHP code?</p> <p>I have learnt that iReport can connect MySQL with JasperServer (Don't know yet, how) but need help to connect it from PHP front end.</p>
php
[2]
3,995,856
3,995,857
When I tried to call a class in Java, an error occured
<p>When I tried to call a class called "ShowHistory" in Java, an error shows: "The type ShowHistory must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)"</p> <p>Here is my code:</p> <pre><code> public class ShowHistory extends JFrame implements ActionListener { ... } </code></pre> <p>The IDE recommended me to make this class to be an abstract class, but when I convert it to be abstract, another piece of code goes wrong:</p> <pre><code> ShowHistory frame = new ShowHistory(); </code></pre> <p>It shows: "Cannot instantiate the type ShowHistory".</p> <p>Is there any idea to solve this problem?</p>
java
[1]
3,744,911
3,744,912
Why my javascript alert doesn't show up
<p>I tested the code below in google chrome but alert shows up why ? (I took it from <a href="http://msdn.microsoft.com/en-us/magazine/cc163419.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/magazine/cc163419.aspx</a>)</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; function filter(pred, arr) { var len = arr.length; var filtered = []; // shorter version of new Array(); // iterate through every element in the array... for (var i = 0; i &amp;lt; len; i++) { var val = arr[i]; // if the element satisfies the predicate let it through if (pred(val)) { filtered.push(val); } } return filtered; } var someRandomNumbers = [12, 32, 1, 3, 2, 2, 234, 236, 632, 7, 8]; var numbersGreaterThan100 = filter(function (x) { return (x &gt; 100) ? true : false; }, someRandomNumbers); // displays 234, 236, 632 alert(numbersGreaterThan100); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
2,065,495
2,065,496
Issue with Singleton
<p>I am new to Android development. We are currently trying to port our existing framework on to Android. We have a core library (existing one) which exposes a singleton instance which provides us a set of flags based on which certain operations are performed. Now when i perform certain operations and flags of the single instance are modified. When i exit the application and restart it, my expectation was that these flags should have been reset to the default values, but it fails.. :-(. Ive read in several posts that the reference would still be active until the application is killed by the OS. Can someone suggest me how to overcome this issue. Any work around?</p>
android
[4]
1,676,040
1,676,041
json_encode gives unexpected result
<p>I want to encode an object using JSON to answer an AJAX request. First, I convert the object to an array (the result of this looks okey), then I use <code>json_encode</code> to encode the array to the JSON format, but I get an unexpected result. The obtained JSON string has the class name before the property names and the null character '\0000' appears in many places. All of my files are encoded using UTF-8. If I use <code>get_object_vars</code>, the I get the result <code>array = []</code>.</p> <p>How I can resolve this issue?</p> <p>I got result: <code>{"\u0000DB\u0000connection":null,"\u0000DB\u0000serverName":"localhost","\u0000DB\u0000userName":"root","\u0000DB\u0000password":null,"\u0000DB\u0000dbName":"thahtin"}</code></p> <p>Here is the code I used:</p> <pre><code>class DB { private $connection; private $serverName; private $userName; private $password; private $dbName; public function __construct() { $config = new Configuration(); $this-&gt;serverName = 'localhost'; //$config-&gt;getConfig("server"); $this-&gt;userName = 'root'; //$config-&gt;getConfig("userName"); $this-&gt;password = null; //$config-&gt;getConfig("password"); $this-&gt;dbName = 'thahtin'; //$config-&gt;getConfig("database"); } public function open() { if(!$this-&gt;connection) mysql_close($this-&gt;connection); $this-&gt;connection = mysql_connect($this-&gt;serverName, $this-&gt;userName, $this-&gt;password); if(!$this-&gt;connection) { die('Could not connect. Error: ' . mysql_error()); } mysql_select_db($dbName); } } $db = new DB(); echo json_encode((array)$db); </code></pre>
php
[2]
4,149,705
4,149,706
Creating a center-aligned thumbnail from image
<p>I'm trying to make a site with images on it, but I don't want to have the traditional thumbnail (where it's just a smaller image), I want something like this: <a href="http://imgur.com/r/funny" rel="nofollow">http://imgur.com/r/funny</a> </p> <p>Notice how all the images' thumbnails are 160x160 and only shows the center of the image. I'd like to do something along those lines.</p>
php
[2]
2,916,129
2,916,130
javascript one click select / deselect text in a div
<p>i would like to add a button that will Select / unselect the text inside a div on Click using javascript ..</p> <p>in example one click will select the text, next click will deselect the text and so on.</p>
javascript
[3]
4,101,089
4,101,090
How to change image size with this JS code
<p>Basically, I have a page where 2 random images get generated using this script:</p> <pre><code>&lt;script type="text/javascript"&gt; &lt;!-- var imlocation = "images/"; var currentdate = 0; var image_number = 0; function ImageArray (n) { this.length = n; for (var i =1; i &lt;= n; i++) { this[i] = ' ' } } image = new ImageArray(3) image[0] = 'image1.gif' image[1] = 'image2.gif' image[2] = 'image3.gif' var rand = 60/image.length function randomimage() { currentdate = new Date() image_number = currentdate.getSeconds() image_number = Math.floor(image_number/rand) return(image[image_number]) } document.write("&lt;img src='" + imlocation + randomimage()+ "'&gt;"); //--&gt; &lt;/script&gt; </code></pre> <p>and then repeated again using different variables so both images are random. I need the sizes of both images to be the same. CSS doesn't seem to be doing the trick using .img and specifying the height and width. Is there another way I could do it?</p>
javascript
[3]
630,665
630,666
Can I pass multiple args (patterns) for Javascript's replace()? If not, any good alternative?
<p>I'm taking the following ex URL <a href="https://support.dev.mysite.com/batch/" rel="nofollow">https://support.dev.mysite.com/batch/</a> and removing everything, but the environment (eg dev). The below code works fine.</p> <pre><code>var env = endPoint.replace("https://support.", "\n"); var envClean = env.replace(".mysite.com/batch/", "\n"); </code></pre> <p>I don't like repeating myself. I would like to look for both patterns in the string and remove them all at once. MDN has a good breakdown of replace() here - <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace" rel="nofollow">https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace</a> but it doesn't mention anything about multiple arguments.</p> <p>I've tried this:</p> <pre><code>var env = endPoint.replace("https://support." &amp;&amp; ".mysite.com/batch/", "\n"); </code></pre> <p>but it just parses the second arg and disregards the first. </p> <p>Does anyone have a cleaner way of doing this? I'm assuming I can search for multiple patterns via REGEX, any REGEX masters out there care to help?</p> <p>Cheers.</p>
javascript
[3]
1,713,461
1,713,462
c++ transfer file line by line in reverse order
<p>Good day!</p> <p>I have a code that suppose to transfer the file into another file in reverse order, line by line, but it does not work, maybe I forgot to add somethings:</p> <pre><code>while(cnvFile.good()) { getline(cnvFile, cnvPerLine); reverseFile &lt;&lt; cnvPerLine; reverseFile.seekp(0, ios::beg); } </code></pre> <p>Thanks..</p>
c++
[6]
5,925,153
5,925,154
Get current height of element by id
<p>I have an element as follows</p> <pre><code>&lt;div id="loadNavigation" style="width:20%"&gt;&lt;/div&gt; &lt;div id="loadContent" style="width:80%"&gt;&lt;/div&gt; </code></pre> <p>Essentially navigation is on the left, content on the right.</p> <p>Now I am dynamically resizing both <code>loadContent</code> and <code>loadNavigation</code> on page load to be at a minimum height of the browsers window height. Though at points more likely then not one of the div's will exceed the other in length if it exceeds window height. To prevent this from happening as an example I want to increase <code>loadNavigation</code> to the same size as <code>loadContent</code> by getting the height value of <code>loadContent</code>.</p> <p>So far I have tried:</p> <pre><code>function resizeAppWindow() { var windowHeight = getWindowHeight(); var contentElement = document.getElementById("content"); var contentHeight = (windowHeight - 25); contentElement.style.minHeight = contentHeight + "px"; var currentContentHeight = contentElement.style.height; var navigationElement = document.getElementById("navigation"); var differenceInHeight = currentContentHeight - windowHeight; var navigationHeight = (windowHeight + differenceInHeight); navigationElement.style.minHeight = navigationHeight + "px"; } </code></pre> <p>But <code>currentContentHeight</code> will return null. I beleive this is because the element has a <code>style="min-height:00px;"</code> but not an actual defined height?</p> <p>Any pointers in the right direction would be appreciated.</p>
javascript
[3]
880,584
880,585
how to distribute my task defined in example.py to two clients computers using mincemeat?
<p>I've downloaded the mincemeat.py with example from the</p> <p><a href="https://github.com/michaelfairley/mincemeatpy/zipball/v0.1.2" rel="nofollow">https://github.com/michaelfairley/mincemeatpy/zipball/v0.1.2</a></p> <p>example.py as follows :: </p> <pre><code>#!/usr/bin/env python import mincemeat data = ["Humpty Dumpty sat on a wall", "Humpty Dumpty had a great fall", "All the King's horses and all the King's men", "Couldn't put Humpty together again", ] datasource = dict(enumerate(data)) def mapfn(k, v): for w in v.split(): yield w, 1 def reducefn(k, vs): result = sum(vs) return result s = mincemeat.Server() s.datasource = datasource s.mapfn = mapfn s.reducefn = reducefn results = s.run_server(password="changeme") print results </code></pre> <p>It is used for word counting program.</p> <p>I've connected two computers in network by LAN. I have used one computer as a server and run example.py on it and on second computer as client , I've run mincemeat.py with following command line statement "python mincemeat.py -p changeme server-IP" .and it works fine.</p> <p>Now I have connected 3 computers in LAN by router.Then one machine work as a server and I want to run the example.py on it.and remaining two machines as client machines.</p> <p>I want to distribute the task to my two clients machines .So what is the process to distribute the task of the map and reduce to the two computers?How can i distribute my task defined in example.py, to two clients computers with their unique IP's respectively?</p>
python
[7]
3,065,155
3,065,156
Is there a typical pattern for handling wide character strings in exceptions?
<p>Standard C++'s <code>std::exception::what()</code> returns a narrow character string. Therefore, if I want to put a wide character string message there, I can't.</p> <p>Is there a common way/pattern/library of/for getting around this?</p> <p>EDIT: To be clear, I could just write my own exception class and inherit from it -- but I'm curious if there's a more or less <strong>standard</strong> implementation of this. <code>boost::exception</code> seems to do most of what I was thinking of....</p>
c++
[6]
660,711
660,712
How do you stop the iPhone from automatically compressing images?
<p>My designer friend is convinced that the iPhone is compressing his wallpaper images. I Googled it, and no luck. Is this a thing?</p>
iphone
[8]
1,201,689
1,201,690
Javascript filter partial op
<p>The function "filter" returns an array <code>[0,4]</code> but I don't understand how it gets that. Can you explain "partial"? Is it a built in function? I'm assuming that "op" applies the ">" operator to the numbers in the array. So since 5 is greater than 0 it gets added to the array "result". But how does "partial" work? </p> <pre><code>function filter(test, array) { var result = []; forEach(array, function (element) { if (test(element)) result.push(element); }); return result; } show(filter(partial(op["&gt;"], 5), [0, 4, 8, 12])); </code></pre>
javascript
[3]
4,939,259
4,939,260
How can I convert text into link using Jquery and assign a function using Jquery?
<p>How can I convert text into link using Jquery and assign a funtion? I have a table and I want to convert table’s last row’s first cell text into link and assign onclick function “DisplayDetails()”.</p> <p>My table name is “ScoreCardDataCurrentTable”.</p> <p>Thanks</p>
jquery
[5]
14,626
14,627
Different types of CATransition types available in iPhone sdk
<p>Do anyone knows the link to the different types of name for available CATransition.</p> <p>Like ripple,swift....</p> <p>I want to know all the available names.</p>
iphone
[8]
3,988,780
3,988,781
Stop jquery queuing events
<p>So,</p> <p>I have this demo site up:</p> <p><a href="http://webspirited.com/ha2/" rel="nofollow">http://webspirited.com/ha2/</a></p> <p>If you hover over the main header (not in ie). You will notice that the image changes a bit,</p> <p>This is what i want.</p> <p>However the keen eye will notice that if you hover on-off-on-off-on-off it will queue the events.</p> <p>How do i stop it from doing this behavior?</p>
jquery
[5]
1,375,783
1,375,784
Android: How to create a View consisting of an EditText?
<p>I'm creating an edit text :</p> <pre><code>EditText et=new EditText(this); et.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); </code></pre> <p>and a View :</p> <pre><code>View myView = new View(this); </code></pre> <p>I want to have (only) the EditText in this view. How can I do it ?</p>
android
[4]
2,707,115
2,707,116
converting "string" to "int" with a "/" between it
<p>I want to the user to type in the current date like, for example: </p> <pre><code>25/05/2011 </code></pre> <p>(everything together, just separated with a <code>/</code>)</p> <p>Then I want to separate this input into 3 <code>int</code> variables. <code>D</code> is the Day, <code>M</code> is the month and <code>Y</code> is the year.</p> <p>Here's what I've got so far:</p> <pre><code>#include &lt;iostream&gt; using namespace std; string TOGETHER; int D, M, Y; int main() { cin &gt;&gt; TOGETHER; /* What should I do here? */ cout &lt;&lt; "\n"; cout &lt;&lt; D &lt;&lt; "/" &lt;&lt; M &lt;&lt; "/" &lt;&lt; Y &lt;&lt; "\n"; return 0; } </code></pre>
c++
[6]
2,048,079
2,048,080
<hr> with display block is adding scroll bars if I dynamically change the margin
<p>I have created a hr tag with below style </p> <pre><code> hr{ /* margin:5%; */ height:10px; display:block; }​ </code></pre> <p><a href="http://jsfiddle.net/thKb8/4/" rel="nofollow">here</a> is the fiddle It is displayed properly. Occupying 100% width of the screen. But if I change the margin Dynamically through JavaScript Console. It is overflowing from screen. How can I make this auto adjustable based on margins.</p>
javascript
[3]
1,049,820
1,049,821
Subprocess in C# Application pauses unexpected
<p>I'm currently working on a service (well at this point it's still a Console Application, as this is a lot easier to debug). The basic task of this service is to watch a folder for new *.tif Files. As soon as the Application found a .TIF file in the folder it starts another Application with the following code:</p> <pre><code>ProcessStartInfo command = new ProcessStartInfo(commandPath, commandParams); command.RedirectStandardOutput=true; command.UseShellExecute=false; command.CreateNoWindow=true; Process process = new Process(); process.startInfo = command; process.Start(); process.WaitForExit(); </code></pre> <p>This console application then uses IrfanView to split the Multipage-TIF into multiple singlepage-TIF (I use basically the same code as above to do this). After that, I check for a Barcode on the Scanned image (with zxing library). The found Barcode is then compared to the Oracle Database. Afterwards the file is converted to PDF and moved to a specific location, based on the found Barcode.</p> <p>This console Application works perfectly, when I start it myself, but as soon as the "service" starts it, it will pause after a while and don't do anything until I close the "service"-console application. Then it finishes normally.</p> <p>What could be the problem?</p> <p>I tried to disable the Oracle, DB check and it worked. Afterwards I disabled my Logging class and it worked too. So my guess is, that I somehow use too much ressources or something like that. But where to start?</p> <p><strong>EDIT:</strong> Some additional information. I just debugged the process, as VS is able to attach to a process to debug. The command that hangs is Console.WriteLine (called from within the Console application which is called by my "service" console. Any way that a console in a subprocess can only have a certain amount of lines/chars? can a console-output stream have a deadlock or what is this?</p>
c#
[0]
5,556,377
5,556,378
In Python - how to execute system command with no output
<p>Is there a built-in method in Python to execute a system command without displaying the output? I only want to grab the return value.</p> <p>It is important that it be cross-platform, so just redirecting the output to /dev/null won't work on Windows, and the other way around. I know I can just check os.platform and build the redirection myself, but I'm hoping for a built-in solution.</p>
python
[7]
1,290,360
1,290,361
jQuery selector for last created div element
<p>I have several divs that are generated dynamically after a file is uploaded. Each file upload creates a div in this format:</p> <pre><code>&lt;div id="uploadifive-fileupload-queue" class="uploadifive-queue"&gt; &lt;div class="uploadifive-queue-item complete" id="uploadifive-fileupload-file-0"&gt; &lt;div id="inputs"&gt; some text &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Every item uploaded increments the id of the uploadifive-queue-item class to uploadifive-fileupload-file-0, uploadifive-fileupload-file-1, uploadifive-fileupload-file-2, etc.</p> <p>What I am trying to do is add a class to <code>#inputs</code>, but only the one just created.</p> <p>I've tried the following, but it applies the class to the wrong div (usually the first div)</p> <pre><code> $('#fileupload').uploadifive({ 'buttonClass' : 'btn btn-primary', 'buttonText' : 'Select Thumbnail', 'dnd' : false, 'fileSizeLimit' : 1000, 'method' : 'post', 'simUploadLimit' : 1, 'uploadScript' : './upload/', 'onUploadComplete' : function(file, data) { $('#inputs:last').addClass('alert-error'); } }); </code></pre> <p><code>#fileupload</code> is just the name of the form, here's the HTML:</p> <pre><code>&lt;form id="fileupload"&gt; &lt;input type="file" name="userfile" size="20" /&gt; &lt;/form&gt; </code></pre> <p>The divs are added directly underneath and are inside the same container.</p> <p>How can I select the correct div? </p>
jquery
[5]
5,380,073
5,380,074
Android: animation
<p>In my App I have an <code>ImageSwitcher</code>, and to buttons at the bottom (Next and Previous). I'm trying to set a smooth animation to <code>ImageSwitcher</code>, but everything looks awfully. Have any body knows smooth animation ? The best practice I think would be to create fade_in and fade_out animation...when I click next button first image should fade_in, and only after that next image should fade_out...But if to set to <code>ImageSwitcher</code> fade_in to AnimationIn and fade_out to animationOut, than when I will press next button fist image will fade_in and second image will fade_out at the same time, and that's looks awfully....Have any idea how to do that ? Thanks....</p>
android
[4]
4,842,890
4,842,891
Android Play background sound
<p>I am going to create call record application, There I need to play minute and recording notification sound. It should here to caller and receiver two parties. Is there any good example for such application?</p> <p>Thank You.</p>
android
[4]
300,572
300,573
How to set first TabBar selected programmatically on iPhone
<p>I have UITabBar in view which have 5 tabs. I am using <strong>didSelectItem</strong> delegate to open different view i.e. I am NOT using <strong>TabBarController</strong>. </p> <p>My problem is on view load I need first tab get selected by default. Is there any property in TabBar which we can set to make it selected?</p> <p>Thanks.</p>
iphone
[8]
1,012,582
1,012,583
table in android is not extending?
<p>i have have added rows in tables... but after adding some rows table have stop showing rows even though i have defined some textview....</p> <p>i have also added touch screen support in both emulator and xml... but still its not working in emulator and mobile both...</p>
android
[4]
1,761,574
1,761,575
Show Menu options vertically in Android
<p>I have a problem that I want to show menu options vertically means: one menu option is on the upper of two menu options that means there are three menu options two of them are at the bottom and last one is stays on the upper of rest.</p> <p>Please help me regarding this problem. Thanks in advance.</p>
android
[4]
5,042,793
5,042,794
PHPFreeChat nickname/username not showing and unable to send messages
<p>I am having a tons of problems when I've uploaded my site on the web especially in using the Phpfreechat.. in Localhost XAMPP everything in chat works fine but when i've uploaded and tested it on the web the chat can't retrieve, send messages, exit the room and create another channel. can someone help me? I have used firebug to check whether there's an error in the codes but unfortunately there's no error..</p>
php
[2]
5,429,123
5,429,124
Slice page and reveal div (like slide up and down together)
<p>I'm trying to create an affect which is like the page being sliced horizontally and opens up. It then pushes the content above it up and the content below down.</p> <p>So it's abit like jquery slideup 50% and slidedown 50%... however I can't find the jquery effect anywhere so I'm wondering if it's at all possible?</p> <p>Or whether I need to do a slidedown, then scroll to at the same time which might create a similar effect.</p> <p>Another designer designed this!! All help is very much appreciated Thanks</p>
jquery
[5]
2,912,733
2,912,734
without page load how to get response using asp.net
<p>I need a coding to get response from my desktop application to my web page using asp.net</p> <p>I send a request from my recharge.aspx page to desktop application.</p> <p><a href="http://122.172.208.202/MARSrequest/?operator=RA&amp;number=9900122334&amp;amount=100&amp;reqref=A0000001" rel="nofollow">http://122.172.208.202/MARSrequest/?operator=RA&amp;number=9900122334&amp;amount=100&amp;reqref=A0000001</a></p> <p>so my desktop application get the request and perform the task and send the response to other page that is responseparser.aspx</p> <p>the response like</p> <p><a href="http://www.abc.com/responseparser.aspx?ref=10293&amp;number=9894380156&amp;amount=100&amp;status=SUCCESS&amp;transid=547965399" rel="nofollow">http://www.abc.com/responseparser.aspx?ref=10293&amp;number=9894380156&amp;amount=100&amp;status=SUCCESS&amp;transid=547965399</a> &amp;simbal=1000</p> <p>so how to get response with out loading the responseparser page it is possible or any other idea to get the response.</p> <p>my doubt is without loading a page can able to perform some operation like insert a record or create text file using asp.net</p>
asp.net
[9]
5,080,769
5,080,770
Trimstart and TrimEnd not working as wanted
<p>I am testing to cut the strings via C#, but I am not getting the results correctly. It is still showing the full text exactString.</p> <pre><code>String exactString = ABC@@^^@@DEF char[] Delimiter = { '@', '@', '^', '^', '@', '@' }; string getText1 = exactString.TrimEnd(Delimiter); string getText2 = exactString.TrimStart(Delimiter); MessageBox.Show(getText1); MessageBox.Show(getText2); </code></pre> <p>OUTPUT:</p> <p><code>ABC@@^^@@DEF</code> for both getText1 and getText2.</p> <p>Correct OUTPUT should be ABC for getText1 and DEF for getText2.</p> <p>How do I fix it? Thanks.</p>
c#
[0]
1,625,189
1,625,190
Store Data in Encrypted format in java files?
<p>How to store data in Encrypted format or binary format in any file?? in File Handling using JAVA.</p>
java
[1]
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
42