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,954,264
4,954,265
PHP system specific line endings behaviour
<p>I was wondering what does it mean in layman's terms:</p> <blockquote> <p>pay attention to line endings - PHP uses a native function to parse the input, so a Mac file won't work on Unix</p> </blockquote> <p>An example of what this means will help.</p> <p>The text can be found here at <a href="http://php.net/get_meta_tags" rel="nofollow">http://php.net/get_meta_tags</a> under parameters filename.</p>
php
[2]
4,011,166
4,011,167
Building an Exception in C#
<p>I have inherited a code-base which uses a compiled logging library. I cannot update the logging library. This library has method that logs details for an Exception. The method takes a single Exception as a parameter. I'm now building a mobile application that will tie into this system. </p> <p>In this mobile application, I have a block of code that handles uncaught exceptions. I need to log those in the server. But now, I can only pass the details across the network in string format. Because of this, I have a service that accepts an error message, stack trace, and miscellaneous as strings. I need to take these strings and convert them into an Exception so I can pass them to my pre-existing library.</p> <p>How can I take a message and a stackTrace as strings and bundle them into an Exception? The challenge here is Message and StackTrace are read-only.</p> <p>Thank you!</p>
c#
[0]
3,525,253
3,525,254
SyntaxError: Non-ASCII character '\xa3' in file when function returns '£'
<p>Hi I'm trying understand why I'm getting this error.</p> <p>Say I have a function:</p> <pre><code>def NewFunction(): return '£' </code></pre> <p>I want to print some stuff with a pound sign in front of it and it prints an error when I try to run this program, this error message is displayed:</p> <pre class="lang-none prettyprint-override"><code>SyntaxError: Non-ASCII character '\xa3' in file 'blah' but no encoding declared; see http://www.python.org/peps/pep-0263.html for details </code></pre> <p>Can anyone inform me how I can include a pound sign in my return function. I'm basically using it in a class and it's within the '<strong>str</strong>' part that the pound sign is included.</p> <p>Regards</p> <p>SNIFFY</p>
python
[7]
3,631,596
3,631,597
check for null variables
<p>I have multiple variables which I set prior to creating an object, I want to check if any of those variables in null, if any variable then display an error. Is there a way to incorporate this in a foreach loop?</p> <p>For eg.</p> <pre><code>Var Var1 = blah1; Var Var2 = blah2; Var Var3 = blah3; Var Var4 = blah4; Var Var5 = blah5; foreach(var above, if any is null) Errmessage </code></pre> <p>Thanks in advance</p>
c#
[0]
4,635,139
4,635,140
Android ViewPagerIndicator with pictures
<p>I need to do something like ViewPagerIndicator, just so I can move something like the pictures in this application:</p> <p><a href="http://i46.tinypic.com/dfxhfq.png" rel="nofollow">http://i46.tinypic.com/dfxhfq.png</a></p> <p>Please some tips.</p>
android
[4]
3,851,726
3,851,727
How do you divide each element in a list by an int?
<p>I just want to divide each element in a list by an int.</p> <pre><code>myList = [10,20,30,40,50,60,70,80,90] myInt = 10 newList = myList/myInt </code></pre> <p>This is the error:</p> <pre><code>TypeError: unsupported operand type(s) for /: 'list' and 'int' </code></pre> <p>I understand why i am receiving this error. But frustrated why i can't locate a solution.</p> <p>Also tried:</p> <pre><code>newList = [ a/b for a, b in (myList,myInt)] </code></pre> <p>Error:</p> <pre><code>ValueError: too many values to unpack </code></pre> <p>Expected Result:</p> <pre><code>newList = [1,2,3,4,5,6,7,8,9] </code></pre> <p>Thanks in advance </p> <p>EDIT:</p> <p>The following code gives me my expected result</p> <pre><code>newList = [] for x in myList: newList.append(x/myInt) </code></pre> <p>but is there an easier/faster way to do this?</p>
python
[7]
1,293,856
1,293,857
Php string handling tricks
<p>Need to get the 10 word before and 10 words after for the given text . i mean need to start the 10 words before the keyword and end with 10 word after the key word.</p> <p>Given text : "Twenty-three" </p> <p>The main trick : content having some html tags etc .. tags need to keep that tag with this content only . need to display the words from 10before - 10after</p> <p>content is bellow :</p> <pre><code>removed </code></pre> <p>Thank you </p>
php
[2]
2,394,398
2,394,399
Self inflating ListView
<p>I've got a listview and it's adapter, which accepts a list of object data. Is it possible to extend the adapter or the listview itself to start track position, namely implement OnScrollListener. So far I've tried implementing adapter as OnScrollListener and extentding ListView with further implementation as OnScrollListener.</p> <p>My ultimate goal is to create an endless listview.</p> <p>Is it possible? Or the only way to do it is to use ListActivity ?</p>
android
[4]
3,407,245
3,407,246
Error converting replicasisland from SVN in Eclipse to an Android Project
<p>I have been trying this for hours without success.</p> <p><a href="http://replicaisland.googlecode.com/svn/trunk/" rel="nofollow">http://replicaisland.googlecode.com/svn/trunk/</a></p> <p>I have added the repository and successfully downloaded the project into the workspace using the option "check out as a project in the workspace" calling it replicaisland. I tired using the option "check out as project using the New Configuration Wizard" but when I selected and android project I had to enter details that I don't yet have. </p> <p>I right click on the project and select "convert to Android project" which gives me an error</p> <pre><code>Errors occurred during the build. Errors running builder 'Android Resource Manager' on project 'replicaisland'. Path must include project and resource name: /replicaisland Path must include project and resource name: /replicaisland </code></pre>
android
[4]
487,761
487,762
Jquery how do I add +1 to a number in a table
<p>So I am generating a table with php/mysql, and in this table are numbers in rows. I have a button that when clicked, adds +1 to this number value <strong>in the MySQL database</strong>. The problem is, I have to refresh the page for the new number to show up in the table.</p> <p>I am attempting to show the new number immediatly through a function on the <strong>success</strong> of the jquery button click event. So essentially I need to identify the HTML generated number in the table, then add +1 to it.</p> <p>The problem is, the table is generated with a <strong>while</strong> function in php, so each row gets its own ID on the fly.</p> <p>Hope this all makes sense.</p> <p>Here is my Jquery code so far.</p> <pre><code> $('.upArrow').click(function(){ //this is finding the uparrow button that adds +1 var row = $(this).attr('rowid'); $.ajax({ type: "GET", url: "upArrow.php?id="+row, cache: false, async: false, success: function(result){ //this is tricky part, how do I select the displayed number part of the // table, then Add 1? }, error: function(result){ alert('Error, please try again.'); } }); }); </code></pre> <p>Edit: Here is a piece of my HTML table:</p> <pre><code> &lt;td id="musicDisplay" colspan="2"&gt; &lt;div id="newUpArrow"&gt; &lt;a href="javascript:void(0)" class = "upArrow" rowid="' . $row['id'] . '"&gt;&lt;img src="../Img/upArrow.gif"/&gt; &lt;/a&gt; &lt;/div&gt; &lt;!--Here is the number I want to change.--&gt; &lt;div&gt;'. $row['points'] . '&lt;/div&gt; &lt;/td&gt; </code></pre>
jquery
[5]
3,497,649
3,497,650
include files in a method?
<p>i want to have a class that includes all files for me.</p> <p>eg.</p> <pre><code>Loader::loadZend // loads all zend libraries Loader::loadSymfony // loads all symfony components </code></pre> <p>if i include a file in a method, does this become globally available?</p> <p>it seems that it doesnt work.</p> <p>maybe i have done something wrong, or is there a workaround for this?</p> <p>thanks</p>
php
[2]
4,412,610
4,412,611
How to pass object to a function in this scenario
<p>I have the following piece of code:</p> <pre><code> NameX.functionA(functionB(Dictionary["___"])) </code></pre> <p>Instead of <em>_</em> I would like to make a reference to NameX in the form of a string, so that the program interprets it as </p> <pre><code> NameX.functionA(functionB(Dictionary["NameX"])) </code></pre> <p>How can I do this? I tried to use str(self), but it is clearly wrong. </p> <p>Thanks</p>
python
[7]
1,440,731
1,440,732
How to store a ratio in a single variable and read it back in C#
<p>Let's say I have a system that must store how many people voted on fighter A and how many on fighter B.</p> <p>Let's say ratio is 200:1</p> <p>How can I store that value in a single variable, instead of storing both values (number of voters on A and number of voters on B) in two variables. </p> <p>How you would do that?</p>
c#
[0]
5,568,490
5,568,491
Get keyCharValue with KeyCode and Modifiers
<p>I use the library <a href="http://code.google.com/p/jnativehook/" rel="nofollow">JNativeHook</a> which allows to listen to every event from my keyboard.</p> <p>It sends events <a href="http://code.google.com/p/jnativehook/source/browse/trunk/src/org/jnativehook/keyboard/NativeKeyEvent.java?spec=svn214&amp;r=214" rel="nofollow">NativeKeyEvent</a> but unlike the KeyEvent class, its method getKeyChar doesn't use the modifiers ! </p> <p>That's the reason why I would like to know if there is an easy way to obtain a char value with its keycode and its modifiers.</p> <p>For instance :</p> <ul> <li>keycode=65, modifiers=null : 'a'</li> <li>keycode=65, modifiers=MAJ : 'A'</li> </ul> <p>Thanks ! </p>
java
[1]
2,749,724
2,749,725
Dynamic table link to new page
<p>I have a dynamic table that populates using a mysql database. I have rows including the column titles 'bottle name', 'cost', 'size'. They are displayed in the browser using PHP and html.</p> <p>One of the columns in the sql database is 'description'. I have been set the task of creating a link from bottle name that will take you to a new page that displays a description of that particular bottle you clicked on. How would I go about creating a link to a page that php would be able to recognize as that particular bottle name in order to recover the description for it? Here is a snippet of my code so far in the populate display php file.</p> <pre><code> $row = mysqli_fetch_assoc($result); extract ($row); echo "&lt;tr&gt;\n &lt;td&gt;$bottlename&lt;/a&gt;&lt;/td&gt;\n &lt;td&gt;$cost&lt;/td&gt;\n &lt;td&gt;$size&lt;/td&gt;\n &lt;/tr&gt;\n"; </code></pre> <p>Any tips / examples are very much appreciated. Thanks</p>
php
[2]
5,278,291
5,278,292
jQuery - How to hide an element that is not contain the specific class
<p>Suppose I have the html code below, I want to ONLY display the "p" element with class="go-1", it is not good to write the statement to hide the element with class="2", class="3", class="100"... how can I write it in a smart way?</p> <p>The statement can be say as "if "p" class not equal to "go-1" then hide it"<br /> Thanks</p> <pre><code>&lt;p class="go-1"&gt;&lt;/p&gt; &lt;p class="go-2"&gt;&lt;/p&gt; &lt;p class="go-3"&gt;&lt;/p&gt; ... &lt;p class="go-100"&gt;&lt;/p&gt; &lt;p class="go-1"&gt;&lt;/p&gt; &lt;p class="go-2"&gt;&lt;/p&gt; &lt;p class="go-3"&gt;&lt;/p&gt; ... &lt;p class="go-100"&gt;&lt;/p&gt; &lt;p class="go-1"&gt;&lt;/p&gt; &lt;p class="go-2"&gt;&lt;/p&gt; &lt;p class="go-3"&gt;&lt;/p&gt; ... &lt;p class="go-100"&gt;&lt;/p&gt; </code></pre>
jquery
[5]
3,713,343
3,713,344
Javascript equivalent of php mktime
<p>Iam using mktime() function in php to get the seconds for given year,month,date and minutes as like</p> <pre><code>$seconds = mktime($hour,$minute,$month,$day,$year); </code></pre> <p>but I want to use the same in javascript...can anyone suggest me the way to use its equivalent function in javascript that takes above all parameters and returns number of seconds...I have searched so many sources but no one has given me the output.</p>
javascript
[3]
4,189,965
4,189,966
How to change with jQuery a data attribute of a set of elements?
<p>say I have a set of elements $elements. Say they all have a data attr named "amount". First one has data-amount = 1, second 2 and so on. Whats the simplest way to increment in x that value for all of them. y solution is</p> <pre><code>$elements.each(function(){ $(this).data('amount',$(this).data('amount')+=x); }); </code></pre> <p>Is there a better solution, without using the each statement? Thanks!</p>
jquery
[5]
5,331,990
5,331,991
How to eliminate the '\n' at the end of a txt file
<p>I'd like to eliminate the extra '\n' at the end of a txt file. Which function can be used to do this job in c / c++.</p> <p>Thanks advanced</p>
c++
[6]
322,573
322,574
In Symfony Form class get the value of submitted fields
<p>In symfony how I will get the value of $_REQUEST in a form class. I am getting the value of all form fields in <strong>action.class.php</strong> and templates. While submitting a form and it is validating I need to get the value of some form field. Please help me!</p>
php
[2]
271,665
271,666
Need to find whether checkbox in listview is checked or not
<p>I have created listview using layoutinflator. Listview contains checkbox and textview for each row. I am displaying items in a listview with checkbox checked by default.I can check\uncheck these items. </p> <p>Now on the same layout I have one button and under clickevent of this button I want to check which item has checkbox in checked state and which has not.</p> <p>Can anybody have any idea how to check this?</p> <p>My Inflator code is:</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; try { mydbadapter.open(); if (view == null) { LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = vi.inflate(R.layout.syncissue_row, null); } issue = (TextView) view.findViewById(R.id.issuedescription); checkbox = (CheckBox) view.findViewById(R.id.issueCheckBox); issue.setText(arrlstFaults.get(position)); checkbox.setChecked(true); } catch (SQLException e) { mydbadapter.close(); e.printStackTrace(); } finally { mydbadapter.close(); } return view; } </code></pre>
android
[4]
4,729,218
4,729,219
How to use javascript to swap images with option change?
<p>Hi everyone I need to make javascript code to swap images with option change. Here is the code:</p> <pre><code>&lt;select name="Color:"onchange="document.getElementById('myimage').src = this.value; "&gt; &lt;option value="images/taylormade_purelite_standbag_bk.jpg"&gt;Black/White&lt;/option&gt; &lt;option value="images/taylormade_purelite_standbag_by.jpg"&gt;Black/Yellow&lt;/option&gt; &lt;option value="images/taylormade_purelite_standbag_byr.jpg"&gt;Black/Yelow/Red&lt;/option&gt; &lt;option value="images/taylormade_purelite_standbag_by.jpg"&gt;Black/Yellow&lt;/option&gt; &lt;option value="images/taylormade_purelite_standbag_nr.jpg"&gt;Navy/Red&lt;/option&gt; &lt;option value="images/taylormade_purelite_standbag_nw.jpg"&gt;Red/Black/White&lt;/option&gt; &lt;option value="images/taylormade_purelite_standbag_rb.jpg"&gt;Black/Red&lt;/option&gt; &lt;option value="images/taylormade_purelite_standbag_wrb.jpg"&gt;White/Red/Black&lt;/option&gt; &lt;/select&gt; &lt;img src="images/taylormade_purelite_standbag_bk.jpg" id="myimage"&gt; </code></pre> <p>My problem is this: I need to have option values in plain text such as "Black/Yelow/Red" not a URL because this option value will show up in the check out page. Can anybody help me?</p>
javascript
[3]
225,339
225,340
Intercept an HTTP request at browser end to alter some html content
<p>I would like to do as follows. What would be the best way? A general answer will also be fine.</p> <p>I would like to intercept an HTTP request at the client end to alter some html content. For example, I go to CNN.com and rather than an article that's displaying "Two LA Dogs marry", it should say "Ridiculous title blocked".</p> <p>It should be smooth that even a secure certificate won't be disturbed.</p> <p>I am using C#.</p> <p>Thanks!</p> <p>UPDATE: Thank you all for your answers!</p>
c#
[0]
2,642,354
2,642,355
reloadData in tableView makes performance slow
<p>I'm working on the table view and im facing a problem such that my table is slowing down to display a data. What I have coded is</p> <pre><code>-(void) loadView { getDataForTableView(); } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return items.count; } -(void) getDataForTableView { // This method will do some stuff and will return the count of items [self.tableView reloadData] } </code></pre> <p>My table can reload and then display the content of <strong>items</strong> in table view. However, it it gonna take a while to do this....How we can speed up the progress so that the table view will display data faster. Please help if you have any hints on this issue. Thanks in advanced</p> <p><strong>UPDATE:</strong></p> <p>What i did is this:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"shoppingListCell"; MyCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; MyCustomCell.totalLabel.text = numberAsString; MyCustomCell.comment.text = currentItem.comment; return MyCustomCell; } </code></pre>
iphone
[8]
2,212,859
2,212,860
Trigger change event <select> using jquery
<p>is there anyway i could trigger a change event on select box on page load and select a particular option. </p> <p>i was trying to output something like <a href="http://jsfiddle.net/v7QWd/1/" rel="nofollow">this</a> </p> <p>update:</p> <p>i was able to change option by following code.</p> <pre><code>$(&lt;element&gt;).val(&lt;value-to-be-changed-to&gt;).trigger('change'); </code></pre> <p>Also the function executed by adding the trigger after binding the function to the event,</p> <p><a href="http://jsfiddle.net/v7QWd/5/" rel="nofollow">Here is the sample.</a> </p> <p>Thanks everyone.</p>
jquery
[5]
728,782
728,783
Save File to a remote Url
<p>first of all sorry for my english , not my main lang.</p> <p>I need to export some data to a remote folder from android. </p> <p>I have a file on android "file.xml" and i need to export it to a folder (under iis) "http://192.168.x.xx/folder/fileuploaded.txt"</p> <p>It seems most of the examples out there are using an upload script in php, but i need to do it only from android. Doing the opposite way (from remote url to android app) is easy with Url.openStream(), but i cannot find a working example to put back the file on the server. </p> <p>Maybe im missing something, this is my first android (and java btw) app.</p> <p>anyone could point me in the right direction?</p> <p>Thanks!</p>
android
[4]
3,099,142
3,099,143
C# program that replaces even numbers with the word even
<p>I am trying to write a program that replaces even numbers with the word "EVEN". So far, I have:</p> <pre><code>List&lt;int&gt; num = new List&lt;int&gt;(); for (int num1 = 0; num &lt; 101; num++) { num.add(num1) } foreach(int n in num1) { if (n/3) { num.Replace("EVEN") } } </code></pre> <p>Is this close or am I far off?</p>
c#
[0]
5,105,210
5,105,211
Production Apply Push Notification Certificate
<p>Is it possible for another Apple developer to push notifications to another application if they know the device token?</p>
iphone
[8]
4,026,706
4,026,707
How do I ask a function for the names of its parameters in Python?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/582056/getting-list-of-parameters-inside-python-function">Getting list of parameters inside python function</a> </p> </blockquote> <p>E.g. supposes I have</p> <pre><code>def foo(a, b='B'): return </code></pre> <p>How can I ask foo to tell me that it has required parameter 'a', and parameter 'b', which has 'B' as it's default value?</p>
python
[7]
5,042,705
5,042,706
jQuery how to code it more nicely
<p>How do you make this code shorter, i'm very new to jquery but i managed to build what i wanted, but is there another way to do this e.g more nicely. </p> <p>Thanks! </p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { $(".genre").click(function () { $(".sobox").hide(); $(".fobox").fadeIn() $("#notcurrent").css({"background":"#9aa0ae", "color":"#fefefe"}); $("#current").css({"background":"#2568be", "color":"#fff"}); }); $(".other").click(function () { $(".fobox").hide(); $(".sobox").fadeIn(); $("#current").css({"background":"#9aa0ae", "color":"#fefefe"}); $("#notcurrent").css({"background":"#2568be", "color":"#fff"}); }); }); &lt;/script&gt; </code></pre>
jquery
[5]
3,967,441
3,967,442
#define TRACE(...) doesn't work in C++
<p>I have the following preprocessor divective:</p> <pre><code>#ifndef NDEBUG #define TRACE printf #else #define TRACE(...) #endif </code></pre> <p>and example of usage is:</p> <pre><code>TRACE("TRACE: some parameter = %i\n", param); </code></pre> <p>In C all works perfectly well when I build both debug and release versions, but in C++ compiler emits the following:</p> <p>warning: invalid character in macro parameter name</p> <p>error: badly punctuated parameter list in `#define'</p> <p>and points these warning and error to the 'TRACE(...)' directive.</p> <p>How to write this in C++ correctly?</p>
c++
[6]
3,473,212
3,473,213
Looping through an image directory
<p>I need to loop through a .png image directory and insert the file name in a mysql database.</p> <p>This is what I have so far:</p> <pre><code>mysql_connect('localhost', 'admin', ''); mysql_select_db('database'); // Each file is formated like this $file = 'Abe+Froman+SK_HG.png'; $player_name = urldecode(str_replace("_HG.png", "", $file)); //echo $player_name; mysql_query("INSERT IGNORE INTO signatures SET gamertag = '".$player_name."'"); </code></pre>
php
[2]
3,395,236
3,395,237
Auto answering in android
<p>I have to perform a task of creating an Android Application that will pick all the calls, play a pre-recorded voice to the other party and cut the phone. Is it possible?</p> <p>Skeleton code is most welcome.</p>
android
[4]
3,743,492
3,743,493
My php variables are not being printed out.
<pre><code> &lt;?php if ( is_user_logged_in() ) { echo '&lt;a href="/community"&gt;&lt;img id="visit-the-forums" src="&lt;?php bloginfo('template_url') ?&gt;/images/visit-the-forums.png" alt="Check out the Forums!" /&gt;&lt;/a&gt;' } else { echo '&lt;a href="/community"&gt;&lt;img id="join-the-forums" src="&lt;?php bloginfo('template_url') ?&gt;/images/join-the-forums.png" alt="Join the Forums!" /&gt;&lt;/a&gt;' } ?&gt; </code></pre> <p>I think there is something wrong w/ the way I set up the "php bloginfo" code inside but I'm not sure how to fix it.</p>
php
[2]
5,119,657
5,119,658
Types in copy constructor
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1051379/is-there-a-difference-in-c-between-copy-initialization-and-direct-initializati">Is there a difference in C++ between copy initialization and direct initialization?</a> </p> </blockquote> <pre><code>Class A { public: //some member function call private: int x; char a; }; int main() { A a; A b; } </code></pre> <p>Hi can You tell me the Difference's in Between these when I call or initialize the objects of above class as</p> <pre><code>A a(b); A a=b; a=b; </code></pre>
c++
[6]
3,004,078
3,004,079
JavaScript solution for anagram of a palindrome
<p>I was asked to implement the same question as this in an interview recently:</p> <p><a href="http://stackoverflow.com/questions/8447222/anagram-of-a-palindrome">Anagram of a palindrome</a></p> <p>I could not provide an answer but am interested to know the JavaScript solution.</p>
javascript
[3]
3,475,829
3,475,830
How to attach EventArgs/custom params when you assign a delegate to the event?
<p>I have this code:</p> <pre><code>this.form.Resize += new EventHandler(form_Resize); </code></pre> <p>But I want to assign some objects for later access in the <code>form_Resize</code> event, how can I do that?</p> <p>and do I access the data in the EventArgs?</p>
c#
[0]
351,380
351,381
Printing a value makes the program work?
<pre><code>#include &lt;iostream&gt; #include &lt;cstdio&gt; using namespace std; bool numar(unsigned long long n) { return (n &gt; 99) &amp;&amp; ((n % 100) == 25); } int main() { freopen("numere.in", "r", stdin); freopen("numere.out", "w", stdout); int cnt = 0; unsigned long long n, a, Nblabla, N; while (scanf("%d", &amp;n) == 1) { if (numar(n)) { a = (n - 25) / 100; cout &lt;&lt; a; // This son of a *****. for (N = 1; true; N++) { Nblabla = N * (N + 1); if (Nblabla &gt; a) break; else if (Nblabla == a) { cnt++; } } } } printf("%d", cnt); return 0; } </code></pre> <p>Simply, if I comment that line (<code>cout &lt;&lt; a;</code>), the program stops working. If I leave it there, it works.<br> I'm using Code::Blocks, GNU GCC.</p> <p>This just checks if a number is the square of a number that ends with the digit <code>5</code>. (Base 10) (I am not allowed to use square roots) </p> <p>Before asking, no, this isn't homework. This is my submission to a subject of an online contest. </p> <p>Can anyone tell me why is this happening? </p>
c++
[6]
4,460,198
4,460,199
Python os.path.walk() method
<p>I'm currently using the <code>walk</code> method in a uni assignment. It's all working fine, but I was hoping that someone could explain something to me. </p> <p>in the example below, what is the <code>a</code> parameter used for on the <code>myvisit</code> method? </p> <pre><code>&gt;&gt;&gt; from os.path import walk &gt;&gt;&gt; def myvisit(a, dir, files): ... print dir,": %d files"%len(files) &gt;&gt;&gt; walk('/etc', myvisit, None) /etc : 193 files /etc/default : 12 files /etc/cron.d : 6 files /etc/rc.d : 6 files /etc/rc.d/rc0.d : 18 files /etc/rc.d/rc1.d : 27 files /etc/rc.d/rc2.d : 42 files /etc/rc.d/rc3.d : 17 files /etc/rc.d/rcS.d : 13 files </code></pre>
python
[7]
426,513
426,514
Is there any way to get a filename from a full path?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1418193/how-to-get-file-name-from-full-path-with-php">How to get file name from full path with PHP?</a> </p> </blockquote> <p>File Path : </p> <blockquote> <p>users_gallery/2012/August/14-August-2012/8/Sasasas/b_80.27016000 134489509114 08 2012kites-4v.jpg</p> </blockquote> <p>I there any way to take out the file name <code>b_80.27016000 134489509114 08 2012kites-4v.jpg</code> ?</p>
php
[2]
5,698,797
5,698,798
Hide Android "voice to Text" Dialog Box
<p>I am working with an Voice to Text Application where I need to keep Voice command Dialog in background, means I don't want to hide it again n again.</p> <p>Pls shows me how can I do this.</p>
android
[4]
2,645,506
2,645,507
Help!!! RegEx.Replace
<p>How do i achieve this directory format using the RegEx.</p> <pre><code>Input FileName(40 chars) : 000a2d0e62e43b0f680a6eb6019f9671b15ca291 output should looks like this: 00\0a2\d0e\62e43 get only the first 13th character. </code></pre> <p>Thanks a lot.</p> <p>johnL</p>
c#
[0]
5,638,527
5,638,528
Whats the best way to bring an already running app to the front in android?
<p>I have two apps that I want to be able to switch between without killing each different activity and without re-launching the activity I want to switch back too. </p> <p>Lets say I have a edittext in each activity and I want the text that is written to stay in that edittext view so that when this activity is brought to the front again it's still there. The problem is that I can't use savedinstancestate, shared preferences or a database to store the information. It should just be there while the application is running. So if it's killed in the background and the info disappears it's no problem.</p> <p>So what could be the best way of switching between two running applications within these two applications?</p> <p>André</p>
android
[4]
2,752,525
2,752,526
How to create sms backup in android
<p>I am creating a sample of sms backup and creating csv file. It is working fine in Emulator but its is not working on my handset (samsung galaxy Note). Here is the code please suggest how it can be fixed</p> <pre><code>while (curLog.moveToNext()) { Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null); cursor.moveToFirst(); do{ String msgData = ""; for(int id=0;id&lt;cursor.getColumnCount();id++) { writer.append(cursor.getString(cursor.getColumnIndexOrThrow("_id"))); writer.append(','); writer.append(cursor.getString(cursor.getColumnIndexOrThrow("address"))); writer.append(','); writer.append(cursor.getString(cursor.getColumnIndexOrThrow("body"))); writer.append(','); writer.append(cursor.getString(cursor.getColumnIndexOrThrow("read"))); writer.append(','); String SmsDate = cursor.getString(cursor.getColumnIndexOrThrow("date")); SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy"); String dateString = formatter.format(new Date(Long.parseLong(SmsDate))); writer.append(dateString); writer.append(','); String SmsTime = cursor.getString(cursor.getColumnIndexOrThrow("date")); SimpleDateFormat format = new SimpleDateFormat("HH:mm"); String timeString = formatter.format(new Date(Long.parseLong(SmsTime))); writer.append(timeString); writer.append(','); if (cursor.getString(cursor.getColumnIndexOrThrow("type")).contains("1")) writer.append("Inbox"); else writer.append("Sent"); writer.append('\n'); } }while(cursor.moveToNext()); } writer.flush(); writer.close(); </code></pre>
android
[4]
4,140,689
4,140,690
compress image while taking an image in android
<p>Hello I am developing a CAMERA APPLICATION. After taking an image the image will be save in sdcard. I want while saving in sdcard the size of the image should be 400kb to 500kb but now its taking more than 1mb. How to compress and save in sdcard after capturing the image.</p> <p>My code is</p> <pre><code> public void onClick(View v) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); imageName="MyCameraApp" + String.valueOf(System.currentTimeMillis()) + ".jpg"; File file = new File(Environment.getExternalStorageDirectory()+"/pictures", imageName); fileUri = Uri.fromFile(file); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } </code></pre>
android
[4]
688,177
688,178
socket programming using bufferedreader
<p>In my application I have 2 programmes, called <code>server.java</code> and <code>client.java</code>, <code>server.java</code> acts as a server and <code>client.java</code> acts as a client. From <code>server.java</code>, I am writing some data to <code>client.java</code>, by using the following code:</p> <pre><code>bufferedwriter.write(data); bufferedwriter.flush(); </code></pre> <p>to read the above data in client i have written the below code:</p> <pre><code>if(bufferedreader.ready()) while((a=in.read)!= -1) </code></pre> <p>I am able to receive data from server to client,but the problem is whenever I kept a breakpoint at <code>BufferedWriter</code>. flush in <code>server.java</code> programme and <code>if(bufferedreader.ready())</code> of client.java,it is not going to intented destination (i.e, in my application intended destination is <code>if(bufferedreader.ready())</code> of <code>client.java</code>), but whenever I am closing <code>server.java</code> debugging, the debugging point in client programme is enabling, can you please help me to solve this.</p>
java
[1]
5,961,058
5,961,059
random.choice always same
<p>I have a quick question. I'm currently using random.choice() to pick from a list and was wondering why it always calls the same item. It changes once I stop the program and restart it. Could anyone explain to me how the random class works and makes it so it does this?</p> <p>Thanks</p>
python
[7]
2,897,001
2,897,002
How I can make the Menu same this website www.chanel.com by using jquery
<p>Hello I'm new of the jQuery, I found this website <a href="http://www.chanel.com/" rel="nofollow">http://www.chanel.com/</a> and I like them menu so much, Ex when it mouse hover it popup the image and when mouse out image is gone and and see the background, So can I do like this in Jquery by using something like this?</p> <pre><code> &lt;ul&gt; &lt;li id="pic1"&gt; Link 1 &lt;/li&gt; &lt;li id="pic2"&gt; Link 2 &lt;/li&gt; &lt;li id="pic3"&gt; Link 3 &lt;/li&gt; &lt;ul&gt; &lt;div id="pic1"&gt;&lt;img src="pic1"&gt;&lt;/div&gt; &lt;div id="pic2"&gt;&lt;img src="pic2"&gt;&lt;/div&gt; &lt;div id="pic3"&gt;&lt;img src="pic3"&gt;&lt;/div&gt; </code></pre> <p>So how can i writhe the jQuery code please.</p> <p>Best Regards</p>
jquery
[5]
4,769,502
4,769,503
is it possible to disable implicit ToString() call?
<p>I'm wondering if there is a way to get a compilation error for this code:</p> <pre><code>var customer = new SomeCustomerClass(); Console.WriteLine("Customer address:" + customer); </code></pre> <p>so I will be forced to write something like this:</p> <pre><code>var customer = new SomeCustomerClass(); Console.WriteLine("Customer address:" + customer.FormatAddress()); Console.WriteLine("Customer accounts:" + customer.FormatAccounts()); </code></pre> <p>If "ToString" would be an interface, I could do that using explicit interface implementation in my class.</p> <p>Thanks.</p>
c#
[0]
69,824
69,825
How enable/disable item in contextmenu
<p>I can disable a item in the contextmenu with this:</p> <pre><code>menu.getItem(1).setEnabled(false); </code></pre> <p>in the onCreateContextMenu, but what if I later would like to set it to true within the same activity? How can I do that during runtime?</p> <p>EDIT: </p> <pre><code> // Create context menu @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // TODO Auto-generated method stub super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("Options for this image"); // Title for the menu MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_1_menu, menu); menu.getItem(1).setEnabled(false); } </code></pre> <p>This is where I want to change the item to enable:</p> <pre><code> // Handle return values from different activities protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == 1) { // Get value from intent String imageId = data.getExtras().getString("imageId"); // Show full screen image Bitmap bitmap = BitmapFactory.decodeFile(imageId); imageView.setImageBitmap(bitmap); } else if(requestCode == 2) { String contact1 = data.getExtras().getString("contactName"); String contact2 = data.getExtras().getString("test"); Toast.makeText(Activity_1.this, "" + "Value from activity 3: " + contact1 + " " + contact2, Toast.LENGTH_SHORT).show(); CHANGE MENU ITEM 1 TO ENABLE HERE!!!! } } } </code></pre> <p>}</p>
android
[4]
5,508,356
5,508,357
Checking if a line starts with contents in a list
<p>I have a list that looks like this:</p> <pre><code>List&lt;String&gt; messages = Arrays.asList("//", "/*", "*", "}", "{"); </code></pre> <p>I then read in a file and go through it line by line. I'd like to check to see if the beginning of the line matches any of what's in the list.</p> <p>I was doing it this way earlier, but this doesn't seem like it's the most efficient way to accomplish what I'm trying to do:</p> <pre><code>/* if (!strLine.startsWith("//") &amp;&amp; !strLine.startsWith("/*") &amp;&amp; !strLine.startsWith("*") &amp;&amp; !strLine.startsWith("}") &amp;&amp; !strLine.startsWith("{")) { System.out.println(strLine); } */ </code></pre> <p>Any suggestions on what would be the best way to do this?</p>
java
[1]
4,097,613
4,097,614
Plus equals operator to increase value each time
<p>I am sure this is very simple but I can't get seem to get this to work just right. Here is my code:</p> <pre><code>var zero = 10; function some(elem, num) { return elem += num; } console.log(some(zero, 10)); console.log(some(zero, 10)); console.log(some(zero, 10)); </code></pre> <p>From what I understand, I was expecting the variable in <code>zero</code> to increase each time by 10.. So, it would be 10, 20 and 30. Instead, I keep getting 10. Obviously, this isn't right.</p> <p>My question is, how would I increase the variable <code>zero</code> by 10 each time and save that value back to the variable <code>zero</code>?</p>
javascript
[3]
1,272,685
1,272,686
How to check if post field is from 8 - 20 characters long
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2492926/php-strlen-question">PHP strlen question</a> </p> </blockquote> <p>how to check if text from post field is 8 - 20 characters long? Is it done with strlen, and could you give me some example, please?</p>
php
[2]
4,903,901
4,903,902
Getting nearby locations
<p>I want to get nearby cities from current location depending upon distance, e.g, cities in radius of 100km,200km etc using the gps of iphone. How can i determine these cties as gps only gives the details of the current location.</p> <p>Thanks in advance</p>
iphone
[8]
4,864,426
4,864,427
python 2.7 question
<p>I recently upgraded from python 2.6 to python 2.7 and everytime I try todo "python setup.py install" I get.</p> <pre><code>'python' is not recognized as an internal or external command, operable program or batch file. </code></pre> <p>It worked fine with 2.6.</p>
python
[7]
1,505,371
1,505,372
vbulletin forum automatic reply
<p>I would like to create a php script that automatically reply pre-defined vb forum threads every X hours.</p> <p>any ideas on creation such task?</p> <p>should it use cron jobs or there is a differet work around for it...</p> <p>Thank you</p>
php
[2]
2,514,170
2,514,171
final total method PHP result
<p>I'm currently trying to create a final total method using PHP. So far I keep getting this error for the following code:</p> <p>Notice: Undefined variable: finalTotal</p> <p>The method does work and the final amount is calculated however I am not sure how to define the $finalTotal variable so no errors turn up. Any tips would be appreciated.</p> <p>Here is the code</p> <pre><code> $tot1=$row['productvalue']*$value; $finalTotal +=$tot1; } echo $finalTotal; </code></pre> <p>Any tips are appreciated</p>
php
[2]
5,017,817
5,017,818
Compile Error CS0305
<p>I'm new to C# programming and have hit a snag I cannot get past.</p> <p>I'm getting this compile error:</p> <blockquote> <p>CS0305: Using the generic type 'System.Collections.Generic.IEnumerable' reuires 1 type arguments</p> </blockquote> <p>with this code;</p> <pre><code>class Program { static void Main(string[] args) { Car c = new Car(); c.PetName = "Frank"; c.Speed = 55; c.colour = "Green"; Console.WriteLine("Name = : {0}", c.PetName); c.DisplayStats(); Garage carLot = new Garage(); // Hand over each car in the collection foreach (Car c in carLot) { Console.WriteLine("{0} is going {1} MPH", c.PetName, c.CurrentSpeed); } Console.ReadLine(); } class Car { //Automatic Properties public string PetName { get; set; } public int Speed { get; set; } public string colour { get; set; } public void DisplayStats() { Console.WriteLine("Car Name: {0}", PetName); Console.WriteLine("Speed: {0}", Speed); Console.WriteLine("Color: {0}", colour); } } public class Garage { private Car[] CarArray = new Car[4]; // Fill with some car objects on startup. public Garage() { carArray[0] = new Car("Rusty", 30); carArray[1] = new Car("Clunker", 55); carArray[2] = new Car("Zippy", 30); carArray[3] = new Car("Fred", 30); } } public IEnumerator GetEnumerator() { foreach (Car c in carArray) { yield return c; } } } </code></pre> <p>How can I resolve this?</p>
c#
[0]
3,958,490
3,958,491
What does the term "canonical form" or "canonical representation" in Java mean?
<p>I have often heard this term being used, but I have never really understood it.</p> <p>What does it mean, and can anyone give some examples/point me to some links?</p> <p>EDIT: Thanks to everyone for the replies. Can you also tell me how the canonical representation is useful in equals() performance, as stated in Effective Java?</p>
java
[1]
4,628,944
4,628,945
please define #define
<p>Could someone give me some examples of how to use #define in c#?</p> <pre><code>#define //preprocessor directive </code></pre> <p>what is the purpose of it? Here example from Microsoft which I still don't get:</p> <pre><code>// preprocessor_if.cs #define DEBUG #define MYTEST using System; public class MyClass { static void Main() { #if (DEBUG &amp;&amp; !MYTEST) Console.WriteLine("DEBUG is defined"); #elif (!DEBUG &amp;&amp; MYTEST) Console.WriteLine("MYTEST is defined"); #elif (DEBUG &amp;&amp; MYTEST) Console.WriteLine("DEBUG and MYTEST are defined"); #else Console.WriteLine("DEBUG and MYTEST are not defined"); #endif } } </code></pre>
c#
[0]
2,776,850
2,776,851
Any API for Siri
<p>now that we know that the iPhone has speech to text and text to speech capabilities, as demonstrated by Siri, is this going to be an API available to developers? has apple said anything about this?</p>
iphone
[8]
2,966,227
2,966,228
best way to implement a deck for a card game in python
<p>What is the best way to store the cards and suits in python so that I can hold a reference to these values in another variable?</p> <p>For example, if I have a list called hand (cards in players hand), how could I hold values that could refer to the names of suits and values of specific cards, and how would these names and values of suits and cards be stored?</p>
python
[7]
1,922,084
1,922,085
What does the following Python code do?
<pre><code>tmp = dict(zip(listToAppend, x_test)) # x_test is a data vector imported earlier from a file </code></pre>
python
[7]
2,063,768
2,063,769
Android onHoverEvent and onTouchEvent
<p>I have a class that is extending <code>View</code> and i want to use the stylus (galaxy note) for input as it has hovering capabilities. </p> <p>I have added listeners for both hover and touch events but i have this issue i can not get around nicely: when i touch the screen with the stylus i have a hover event generated with <code>ACTION_HOVER_EXIT</code> and a touch event with <code>ACTION_DOWN</code>.</p> <p>I would like to know if there is a way to know when i get an <code>ACTION_HOVER_EXIT</code> event if the stylus started to touch the screen or if it was moved away from it.</p> <p>The same is when i lift the stylus but still in the hover zone: one <code>ACTION_UP</code> and one <code>ACTION_HOVER_ENTER</code>. </p>
android
[4]
4,761,000
4,761,001
Music in background
<p>Who do I create an app that plays music in background of a call, audible to only the caller and the listener? Can any body suggest a method for doing it? I had tried to create a music service which is used for creating background service for apps, but it is not fully satisfying my goals. </p> <p>I created a background music service according to this <a href="http://www.codeproject.com/Articles/258176/Adding-Background-Music-to-Android-App" rel="nofollow">link</a>.</p> <p>EDIT: IDEA---want to play a music in the background of a call which is audible to the caller and listener when the state is offhook</p>
android
[4]
5,032,218
5,032,219
parse exception (unparseable date)
<p>I am getting parse exception when i execute the below code.Can anyone please help me out</p> <pre><code>private Boolean validateDateFormat(HttpSession session, PropertiesHandler props, String startDate,Date sqlDate) { logger.info("Enter validate"); Boolean isvalid = true; HashMap hashMap = new LinkedHashMap(); System.out.println("Entered validate block"); if (startDate == null || startDate.equals("")) { isvalid = false; hashMap.put("date", props.getText("error.date.compare.cannotbeblank")); session.setAttribute("errorMessage", hashMap); System.out.println("Map size " + hashMap.size()); logger.info("Exit validate"); return isvalid; } ArrayList&lt;CalendarDatepicker&gt; calList = new ArrayList&lt;CalendarDatepicker&gt;(); String whereClause = " cd.calendar_datepicker="+sqlDate; calList = (ArrayList&lt;CalendarDatepicker&gt;)dateTimePickerImpl.getCalendarDateDetailsByWhereClause(whereClause); System.out.append("appointment list size " + calList.size()); if(calList.isEmpty()) { isvalid=false; System.out.println("here"); hashMap.put("date", props.getText("error.date.compare.incorrectformat")); session.setAttribute("errorMessage", hashMap); System.out.println("Map size " + hashMap.size()); logger.info("Exit validate"); return isvalid; } </code></pre>
java
[1]
2,909,196
2,909,197
Modying Properties of a Class
<p>Finding a suitable question title and -tags for this question struck me rather hard.</p> <p>Basically I've built a game wherein several units/mobs will be present. Now I'm interested in building a system, so each unit can have effects/buffs/debuffs applied to them that will modify the properties of the unit. Examples of such effects could be a frost effect that'd slow the movement speed of the unit, a health boost and so forth. The plan was to have these effects implemented via scripting so it would be possible to create custom user effects.</p> <p>I'm looking for advice on how I could implement this. For now I've thought about creating a effect class. Then each applied effect would be an instance of the class, and would have a reference to the unit it was applied to. The effect would have at least two methods, an apply and unapply method for respectively applying- and unapplying.</p> <p>The problem with this, is that it doesn't allow for different ways of cumulative percentages. Like, should two times 10% increase on a value 100 equal 120 or 121.</p> <p>Not that it really matters, but it's being coded in C#</p>
c#
[0]
4,915,739
4,915,740
stream textfile to textbox c#
<p>Suppose i have a textfile which continuous to be updated with text, how can i display the contents in a textbox in windows form (in real-time)?</p> <p>for example. this is the contents of log.txt:</p> <pre><code>connected, bla bla bla disconnected, bla bla bla </code></pre> <p>PS: i want it to be displayed in textBox of Form1 (real time also) so everytime the text file has new text, the textbox displays it. Any ideas, pls help. thanks. also can u provide a sample working code. thanks</p>
c#
[0]
3,076,297
3,076,298
In Java, how to use reflection to get a static method and execute it?
<p>I have a bunch of static method names, how do I execute them. I think I can use reflection, but how to do that?</p>
java
[1]
3,788,928
3,788,929
displaying multiple frames in a php page
<p>I would like to create four frames with google maps in a php page and reload the frames with different set of style attributes on the same map when a particular checkbox is selected on the main page containing the four frames.I need some inputs on how to proceed with this.</p> <p>Thanks in Advance, Deepthi</p>
php
[2]
3,002,397
3,002,398
dismissing the NumberPad keyboard from a UIScrollView
<p>I have an application with UIScrollView added as a subview of UIView. This Scroll view has a textfield with keyboard type set to numberPad. Now the problem is , i want to dismiss the keyboard when i tap anywhere else in the scroll view. how can i do this ... ?</p>
iphone
[8]
748,502
748,503
What is The remote server returned an error: (400) Bad Request?
<p>I am trying to add contacts to the constant contact site n there i am getting following exception The remote server returned an error: (400) Bad Request.</p> <p>i am using ASp.net C# application for inserting my records.</p> <p>can any one tell me the solution ,or why i am getting the above error?</p> <p>Thanks in advance</p>
asp.net
[9]
1,457,761
1,457,762
Python question on parse routines with dicts, while loops, and assignments
<p>I have some code from a much-maligned Python resource, if you ask SO, but I am trying to divine Python’s parse routine from it, regardless its didactic merits.</p> <pre><code>def princess_lives_here(): #&lt;some messages and conditionals to keep you going in the text-based game&gt; #&lt;one of the conditionals end in a `return 'death'`, another function in ROOMS&gt; ROOMS = { 'death': death, 'princess_lives_here': princess_lives_here, } def runner (map, start): next = start while True: room = map[next] print "\n--------" next = room() runner(ROOMS, 'princess_lives_here') </code></pre> <ol> <li><p>What I am not sure about is how <code>princess_lives_here</code> is ever run in the while loop. I can only assume that it is run is the last line, but what looks like an assignment to me must be an execution of <code>room()</code>, i.e. <code>princess_lives_here</code>. Why, when and how is this execution performed?</p></li> <li><p>My second question is how, when, and why the while loop is run again, when the parsing routines hits <code>return 'death'</code>.</p></li> </ol> <p>I’ve created a gist with the entire code, in case you want the greater picture. It just takes up a lot of lines of code: <a href="https://gist.github.com/848228" rel="nofollow">https://gist.github.com/848228</a>.</p>
python
[7]
2,787,649
2,787,650
Copying object with const members to a non const object
<p>I have the following data container:</p> <pre><code>struct Node { explicit Node(const std::vector&lt;Data&gt;&amp; _data, const Value&amp; _value): data(_data), value(_value) { } const std::vector&lt;Data&gt; data; const Value value; }; </code></pre> <p>I wish to write a mock along these lines:</p> <pre><code>class MockVisitor: public IVisitor { public: virtual void operator()(const Node&amp; _node) { node = _node; } Node node; }; </code></pre> <p>However, I'm getting the error:</p> <pre><code>error C2582: 'operator =' function is unavailable in 'Node'. </code></pre> <p>I'm presuming this is because I can only assign to a const Node. Is there anyway for my to cast away this error? Remember this is only a mock class. I'm simply trying to record the value passed into operator()() so I can check it in my unit test.</p>
c++
[6]
980,612
980,613
Iphone terminal commands
<p>I`m working on school project and I want to use function system(""). For example system("ping www.google.com"). Is this function allowed by Apple ? It is possible to pass in App Store ? Thanx for any answer.</p>
iphone
[8]
1,802,740
1,802,741
How to run openGrads script commands using c#
<p>I have been encountering the error of Metafile not open. When I execute the c# program the command line opens up and shoots this error without performing the activity to be initiated by the script. How do I solve this? Here is the code where I pass all my commands--</p> <pre><code>static void Main(string[] args) { ProcessStartInfo info = new ProcessStartInfo(); ExecuteMultipleCommandsReturnProcess(@"C:\OpenGrADS\Contents\Cygwin\Versions\2.0.a9.oga.1\i686\opengrads.exe", " ", new List&lt;string&gt;() { "l", "open" }, null, null); } </code></pre>
c#
[0]
3,831,451
3,831,452
Free Webasyst alternative
<p>Is there any free alternative to webasyst files <a href="http://www.webasyst.net/files/" rel="nofollow">http://www.webasyst.net/files/</a> script and webasyst notes.</p>
php
[2]
187,569
187,570
How can I initialise a static member of a class after certain other initialisation has taken place?
<p>I want to be able to initialise the static member <code>scalingfactor</code> in the following class:</p> <pre><code>class ScalingRect: public Rect { public: static float scalingfactor; ... }; </code></pre> <p>I thought I'd initialise it using a static member function of another class like this in the .cpp</p> <pre><code>float ScalingRect::Rect = Engine::GetScaleFactor(); </code></pre> <p>However, I don't want to call <code>GetScaleFactor()</code> before the <code>Engine</code> class is ready. How can I ensure it gets called at the right time?</p>
c++
[6]
5,125,970
5,125,971
Javascript sliding image gallery, ... how?
<p>I was wondering of any of you could push me in the right direction :). I'm trying 2 make an image "sliding" gallery, but it is a little complicated. it has 2 have 3 or 5 "views" the mainview ( the one you are currently watching) a previous and a next. The previous and the next must dynamically load images and unload them when they are 2 positions out of view.</p> <p>So what it comes down to, i have 150 images i want to display in a sliding gallery and i only want to load 5 at a time if i scroll 2 the right image one should be unloaded and image 3,4,5 and 6 should be loaded and image 2 should be displayed. I have no real experience with Javascript.</p> <p>(It should look alot like iphone Photo App :))</p> <p>Kind Regards, Bart</p>
javascript
[3]
5,378,120
5,378,121
how to configure the php RAR Archive installer windows
<pre><code>&lt;?php $rar_arch = RarArchive::open('filename.rar'); if ($rar_arch === FALSE) die("Failed opening file"); $entries = $rar_arch-&gt;getEntries(); if ($entries === FALSE) die("Failed fetching entries"); echo "Found " . count($entries) . " extract\location"; if (empty($entries)) die("No valid entries found."); $stream = reset($entries)-&gt;getStream(); if ($stream === FALSE) die("Failed opening first file"); $rar_arch-&gt;close(); echo "Content of first one follows:\n"; echo stream_get_contents($stream); fclose($stream); ?&gt; </code></pre> <p><a href="http://php.net/manual/en/rar.installation.php" rel="nofollow">http://php.net/manual/en/rar.installation.php</a></p> <p>Erorr is:</p> <pre><code>Fatal error: Class 'RarArchive' not found in C:\Zend\Apache2\htdocs\CSV\example.php on line 2 </code></pre>
php
[2]
4,237,657
4,237,658
How to start video using intent android
<p>I am trying to start the video media type using intents. I am completely new to this. I would appreciate a heads up. </p>
android
[4]
5,923,140
5,923,141
Why is this PHP comparison failing?
<p>I'm trying to compare a defined code against a set of blocked country codes. In the following example the country code is getting caught in my if block:</p> <pre><code>$country_code = 'US'; if ($country_code == ("NG" || "RO" || "VN" || "GH" || "SN" || "TN" || "IN" || "ID" || "KE" || "CN" || "CI" || "ZA" || "DZ" || "RU")) { print "COUNTRY CODE: $country_code&lt;br&gt;"; } </code></pre> <p>I see this for my results"</p> <pre><code>COUNTRY CODE: US </code></pre> <p>I wouldn't expect 'US' to get caught...what am I missing?</p>
php
[2]
2,033,150
2,033,151
java interface problem
<p>Code:-</p> <pre><code>10. interface Foo { int bar(); } 11. public class Sprite { 12. public int fubar( Foo foo) { return foo.bar(); } 13. public void testFoo() { 14. fubar( 15. new Foo() { public int bar(){ return 1; } } 16. ); 17. } 18. } </code></pre> <p>-Am not being able to understand from line number 14 to 16.because I have never seen such thing fubar inside one method.Will any body please explain 14-16 no line?</p>
java
[1]
4,227,150
4,227,151
Node cannot be inserted at the specified point in the hierarchy" code: "3
<p>I have this:</p> <pre><code>window.PRINT = function() { $(arguments).each(function(Index,Value) { $('body').append(Value); }) }; </code></pre> <p>And I'm getting this:</p> <blockquote> <p>Node cannot be inserted at the specified point in the hierarchy" code: "3</p> </blockquote> <p>I'm trying to make a console.log that goes to the body.</p>
jquery
[5]
4,248,070
4,248,071
File.Move Error - System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv
<p>I have no idea why I'd get this error below. The filevPath when I debug is a completely valid (yes, the physical the image is definitely there physically on the hard drive in the filePath variable that is being passed) path and obviously is not the same path as the error is reporting which looks like some generic error:</p> <p>System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\someimage1.jpg'</p> <pre><code>private void RenameUploadedFile(string uploadedFileName) { string filePath = Path.Combine(WebUtil.UploadPath, uploadedFileName); if (File.Exists(filePath)) { try { string newfileName = uploadedFileName.Replace(uploadedFileName.Substring(0, uploadedFileName.IndexOf("-")), currenSessionID); File.Move(uploadedFileName, newfileName); } catch (Exception ex) { .ErrorLog("Image Copy Error: " + ex.ToString()); throw new ApplicationException("There was an error during a rename(move) operation on the Saved Item upload file: " + filePath + " error: " + ex.ToString()); } } else { .ErrorLog("File does not exist or path is invalid for at the following filepath: " + filePath); } } </code></pre>
c#
[0]
5,474,239
5,474,240
SQLite database location
<p>Using Eclipse to build an Android app. When I create/open a database (SQLite) my log indicates that its location is /data/data/package/databases/dbname. Is there a way to access this db using one of the Windows-based SQLite managers, eg; SQLite Database Browser. The path must be the path as it would be on the device, but I cannot find the DB on my Windows box. Any help appreciated by this Android novice.</p>
android
[4]
932,673
932,674
Multiplication in C#
<p>to get the value of a column i need to multiply the following value by .45, whats this best way of doing this ?</p> <pre><code>total = total + Convert.ToInt32(dtGetValues.Rows[i]["tot_amt"]); </code></pre> <p>i tried this but it does not work</p> <pre><code>total1 = total1 + Convert.ToInt32 (dtGetValues.Rows [i] ["total_amt" * .45]); </code></pre>
c#
[0]
1,434,475
1,434,476
Differences between Jar, Android Library and Android Library Project
<p>As I understand, the three ways of distributing my application are via Jar, Android Library and Android Library Project.</p> <p><strong>Jar</strong> - cannot contain resources or XML layouts (so this is out for me)</p> <p><strong>Android Library</strong> - I don't really know how this works but the Google API uses it...</p> <p><strong>Android Library Project</strong> - includes resources but allows the client free rein on the code as it is distributed as source.</p> <p>If I am to create a closed source application that requires drawables and XML files that I want to distribute to other Android programmers, what should I use? And can someone direct me to a tutorial on creating an <strong>Android Library</strong>?</p>
android
[4]
5,234,163
5,234,164
Layout of my Alpha Animation File
<p>First of all Im trying to animate a TextView view in one of my app's but it doesn't seem to work. I believe the answer lies in the alpha.xml file; I keep getting an error from this file but can't determine why:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;alpha xmlns:android="http://schemas.android.com/apk/res/android" android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="3000"&gt; &lt;/alpha&gt; </code></pre> <p>Also I later want to animate an entire activity before it appears. This screen will simply be the splash/load screen an should animate on over a period of time. </p> <p>Any ideas? Cheers</p> <p>The java code which uses it goes like this:</p> <pre><code>private void RunAnimations() { Animation a = AnimationUtils.loadAnimation ( this, R.anim.alpha ); a.reset(); TextView tv = (TextView) findViewById( R.id.welcomeMessage ); tv.clearAnimation(); tv.startAnimation( a ); } </code></pre> <p>The error in the XML file is:</p> <p>Multiple annotations found at this line: - Element type "alpha" must be followed by either attribute specifications, ">" or "/</p> <blockquote> <p>". - error: Error parsing XML: not well-formed (invalid token)</p> </blockquote> <p>:/</p>
android
[4]
220,699
220,700
Android: How to display formated code in TextView?
<p>I am writing an android application that will be displaying codes... specially java codes, or maybe jsp code as well. I was thinking about placing these codes in a TextView. However i dont know how to do this for android. I didnt find any tutorial or documentation on how to display formated text in a TextView. I know I can put html in there, so one direction would be format the code itself in html and then place it in the textview.</p> <p>Is there a better way to do that?</p> <p>Many thanks T</p>
android
[4]
5,694,736
5,694,737
How To Limit Properties Available On a Python Class
<p>Take the following class</p> <pre><code>class Person(object): def __init__(self, first_name, last_name): self.first_name = first_name self.last_name = last_name </code></pre> <p><em>How can I prevent the following usage?</em></p> <pre><code>p1 = Person('Foo', 'Bar') p1.firstname='Fooooooo' </code></pre> <p>The code above will execute successfully in Python, however, a mistake was made with the name of the property, i.e. its missing <code>_</code> between <code>first</code> and <code>name</code></p> <p><strong>UPDATE: This sounds like "Monkey Patching", why do I want to do this?</strong></p> <p>My intention is to simply help avoid the user from setting the wrong property, have the code execute, and see unexpected behavior and not be aware of the mistake immediately.</p> <p>What does the Pythonic way recommend here? </p>
python
[7]
47,105
47,106
joining string to next string in list
<p>I have a list with a large number of words in it: sentence = ['a','list','with','a','lot','of','strings','in','it']</p> <p>I want to be be able to go through the list and combine pairs of words according to some conditions I have. e.g.</p> <p>['a','list','with','a','lot','of','strings','in','it'] becomes ['a list','with','a lot','of','strings','in','it']</p> <p>I have tried something like:</p> <pre><code>for w in range(len(sentence)): if sentence[w] == 'a': sentence[w:w+2]=[' '.join(sentence[w:w+2])] </code></pre> <p>but it doesn't work because joining the strings, decreases the size of the list and causes an index out of range. Is there a way to do this with iterators and .next() or something?</p>
python
[7]
1,462,611
1,462,612
403 error in accessing an URL but works fine in browsers
<pre><code>String url = "http://maps.googleapis.com/maps/api/directions/xml?origin=Chicago,IL&amp;destination=Los+Angeles,CA&amp;waypoints=Joplin,MO|Oklahoma+City,OK&amp;sensor=false"; URL google = new URL(url); HttpURLConnection con = (HttpURLConnection) google.openConnection(); </code></pre> <p>and I use BufferedReader to print the content I get 403 error </p> <p>The same URL works fine in the browser. Could any one suggest. </p>
java
[1]
97,970
97,971
Has jQuery 1.8 changed how .data() returns the value?
<p>Related question: <a href="http://stackoverflow.com/questions/12622812/stop-jquery-data-from-converting">Stop jQuery .data() from converting</a> </p> <p>According to the documentation for <code>.data()</code>: </p> <blockquote> <p>Every attempt is made to convert the string to a JavaScript value (this includes booleans, numbers, objects, arrays, and null) otherwise it is left as a string. To retrieve the value's attribute as a string without any attempt to convert it, use the attr() method</p> </blockquote> <p>This is true for jQuery 1.7.2, but 1.8.2 does not do the conversion. Is this the new expected behavior?</p> <p>For example, with the HTML <code>&lt;div data-code-name="007"&gt;Bond, James&lt;/div&gt;</code></p> <p>jQuery v1.7.2 <code>$("div").data("codeName")</code> returns 7 Example: <a href="http://jsfiddle.net/dMHS4/" rel="nofollow">http://jsfiddle.net/dMHS4/</a></p> <p>jQuery v1.8.2 <code>$("div").data("codeName")</code> returns "007" Example: <a href="http://jsfiddle.net/dMHS4/2/" rel="nofollow">http://jsfiddle.net/dMHS4/2/</a></p>
jquery
[5]
3,398,423
3,398,424
force applied in x axis using UIAccelerometer
<p>I want to determine the force applied or the speed at which the iphone is moved in x axis using UIAccelerometer.</p>
iphone
[8]
5,187,315
5,187,316
How can I split a JavaScript string by white space or comma?
<p>If I try</p> <pre><code>"my, tags are, in here".split(" ,") </code></pre> <p>I get the following</p> <pre><code>[ 'my, tags are, in here' ] </code></pre> <p>Whereas I want</p> <pre><code>['my', 'tags', 'are', 'in', 'here'] </code></pre>
javascript
[3]
4,456,866
4,456,867
Javascript to create fence calclutor
<p>do you know if it is possible to build calculator to calculate fence, gates, etc. in JavaScript to get result similar to <a href="http://diy-vinyl-fence.com/content/16-fence-calculator" rel="nofollow">http://diy-vinyl-fence.com/content/16-fence-calculator</a> ?</p> <p>if you have any point, libraries, framework to use i would appreciate</p> <p>gerard</p>
javascript
[3]
1,984,208
1,984,209
I cant get to set desire time of AlarmCLock in Android
<p>Hi guys this is what i have so far:</p> <pre><code>PendingIntent sender = PendingIntent.getBroadcast(mainactivity, 0, intent, 0); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 10); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender); showmsg(); </code></pre> <p>the alarm comes after 10 seconds How can I make it in desire time i want, I have set a timepicker so how can i do it depending on the timepickers time to ring the alarm?</p> <p>Thanx.</p>
android
[4]
173,175
173,176
How to skip using __autoload?
<p>I have a php file which has multiple classes in it. I noticed that __autoload is being called when I instantiate any of the classes, even after the 'package' file has been autoloaded. This is worrying me, because surely if the initial 'package' .php file has been loaded, it is unnecessary overhead for __autoload when the classes have already been loaded. </p> <p>I probably made a hash of explaining that, so here is an example:</p> <pre><code>&lt;?php class Class1{}; class Class2{}; ?&gt; </code></pre> <p>Then in another file:</p> <pre><code>&lt;?php new Class1; new Class2; ?&gt; </code></pre> <p>__autoload will be used for both Class1 AND Class2's instantiation... even though they are housed in the same file.</p> <p>Is there a way to get around this?</p> <p>Sorry if my explanation isn't very good, I'd really appreciate any help or tips.</p>
php
[2]
3,935,480
3,935,481
iphone app new update popup
<p>I've seen apps the shows a dialog box when a new version of the app is available.</p> <p>How does it do that?</p>
iphone
[8]