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
2,652,485
2,652,486
position of UITabbar
<p>I try to place UITabbar on iPhone window using CGRectMake. But I found that the Y position is different from the display in Interface Builder.</p> <p>Is there anyone met the same problem?</p> <p>Using CGRectMake to locate the x,y position, is it possible cause the refusing from App stoe due to compatible reason?</p> <p>Thanks</p> <p>interdev</p>
iphone
[8]
1,813,542
1,813,543
The equals() method in Java works unexpectedly on Long data type
<p>Let's first consider the following expressions in Java.</p> <pre><code>Integer temp = new Integer(1); System.out.println(temp.equals(1)); if(temp.equals(1)) { System.out.println("The if block executed."); } </code></pre> <p>These all statements work just fine. There is no question about it. The expression <code>temp.equals(1)</code> is evaluated to <code>true</code> as expected and the only statement within the <code>if</code> block is executed consequently.</p> <hr> <p>Now, when I change the data type from <code>Integer</code> to <code>Long</code>, the statement <code>temp1.equals(1)</code> is unexpectedly evaluated to <code>false</code> as follows.</p> <pre><code>Long temp1 = new Long(1); System.out.println(temp1.equals(1)); if(temp1.equals(1)) { System.out.println("The if block executed."); } </code></pre> <p>These are the equivalent statements to those mentioned in the preceding snippet just the data type has been changed and they behave exactly opposite. </p> <p>The expression <code>temp1.equals(1)</code> is evaluated to <code>false</code> and consequently, the only statement within the <code>if</code> block is not executed which the reverse of the preceding statements. How?</p>
java
[1]
2,429,399
2,429,400
Passing intent to another android app
<p>I know that another application accepts intent type: vnd.android.cursor.item/postal-address</p> <p>I can make it show by calling:</p> <pre><code>Uri dataUri = Uri.parse("test"); Intent intent = new Intent(android.content.Intent.ACTION_VIEW); intent.setDataAndType(dataUri, "vnd.android.cursor.item/postal-address"); </code></pre> <p>Question is, how to pass well formated address?</p> <p>E.g. i I pass Uri dataUri = Uri.parse("content://com.android.contacts/data/2057"); it works, but I want to pass new address (not from Contacts).</p> <p><strong>UPDATE</strong>: This external application has two intent-filters:</p> <p>intent-filter: action: 'android.intent.action.MAIN' category: 'android.intent.category.DEFAULT' data: mimeType: 'vnd.android.cursor.item/postal-address'</p> <p>intent-filter: action: 'android.intent.action.MAIN' category: 'android.intent.category.DEFAULT' data: mimeType: 'vnd.android.cursor.item/postal-address_V2' scheme: 'content' host: 'com.android.contacts'</p> <p>Thank you.</p>
android
[4]
2,553,436
2,553,437
iPhone-SDK:Remove white spaces from a paragraph string?
<p>I have two paragraph in a string. But the contents are having many spaces in between the paragraph string. I want to remove the spaces from this big paragraph string. I tried using NSString *outPutStr = [outPutStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; But it doesn't remove empty spaces that are there in the paragraph string. It does nothing.</p> <p>Can someone please guide me with sample?</p> <p>thanks.</p> <p>Clave/</p>
iphone
[8]
4,053,308
4,053,309
remove and rebinding li tags to ul is not working
<p>I am trying to rebind the li tags by removing it and again rebinding it. The ul tag is generated dynamically. My code to remove the li tags is this...</p> <pre><code>$("#ulActivity li").remove(); </code></pre> <p>this line is removing all li tags perfectly, but append new set of li is not working...</p> <pre><code>$.each(objTaskActivityList, function(i,v){ $("#ulActivity ul").append('&lt;li&gt;&lt;a onclick="javascript:openfile(\''+v.DOCName+'\')"&gt;'+v.DOCName+'&lt;/a&gt;&lt;/li&gt;'); }); </code></pre> <p>where i am doing mistake..</p>
jquery
[5]
4,811,561
4,811,562
Need a scenario where would fail Array.ConstrainedCopy()
<p>Just playing around with some of the APIs in .NET and I can't seem to find a way to cause Array.ConstrainedCopy() fail.</p> <p>According to MSDN, it's treated as an atomic operation. If it fails during the copy, the entire call fails resulting in no elements being copied as opposed to its Array.Copy() counterpart.</p> <p>Can someone demonstrate this or tell me how to do this?</p> <p>This code fails in both types of copy. I'd like to see an example of Array.Copy() only copying some elements to get a better understanding of where I might use either forms of copy.</p> <pre><code>object[] yer = new object[] { "as", "qwe", "re", 1 }; string[] copy = new string[yer.Length]; Array.ConstrainedCopy(yer, 0, copy, 0, yer.Length); // runtime error Array.Copy(yer, 0, copy, 0, yer.Length); //runtime error </code></pre>
c#
[0]
58,521
58,522
Missing something when writing to a Text File
<p>I simply want to be able to log the path of certain files to a text file. I have the following to do the logging.</p> <pre><code>static void LogFile(string lockedFilePath) { Assembly ass = Assembly.GetExecutingAssembly(); string workingFolder = System.IO.Path.GetDirectoryName(ass.Location); string LogFile = System.IO.Path.Combine(workingFolder, "logFiles.txt"); if (!System.IO.File.Exists(LogFile)) { using (System.IO.FileStream fs = System.IO.File.Create(LogFile)) { using (System.IO.StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(lockedFilePath); } } } else { using (System.IO.FileStream fs = System.IO.File.OpenWrite(LogFile)) { using (System.IO.StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(lockedFilePath); } } } } </code></pre> <p>but If I call it in a Console App like this </p> <pre><code>foreach (string f in System.IO.Directory.GetFiles(@"C:\AASource")) { Console.WriteLine("Logging : " + f); LogFile(f); } Console.ReadLine(); </code></pre> <p>The only file that is listed in the resulting text file is the last file in the dir. What am I doing wrong?</p>
c#
[0]
5,958,513
5,958,514
Jquery remove table element
<p>I have some jquery code that removes a table row. The problem is when I remove it, it forces my page to goto the top. The table row has a remove link that removes itself. I am assuming this is the issue that makes it scroll back to the top. I have tried setting the focus of another element outside to be focused after the removal but no joy. I have now used the offset and scrolled to it, but it looks awful. Anybody know how to stop the repositioning.</p> <p>Thanks</p>
jquery
[5]
993,714
993,715
how can i add Uiimagepickerview in tabbaritem?
<p>how can i add Uiimagepickerview in tabbaritem like this image.Kindly go through the below link to view the image.. i need like this image.so pls help me. <a href="http://artoftheiphone.com/wp-content/uploads/2010/02/ShopSavvy-Barcode-Sacnner.png" rel="nofollow">http://artoftheiphone.com/wp-content/uploads/2010/02/ShopSavvy-Barcode-Sacnner.png</a></p>
iphone
[8]
1,022,263
1,022,264
Reload Page After Delete in PHP
<p>I have made this function to delete the record from the table. When the delete operation is done, the page displays all data(including the deleted one), But, I need to refresh or reload the page to see the results after I have deleted the row. How it can be done in following code? Thanx in advance!! </p> <pre><code> public function deletedata(){ if(isset($_GET['del_id'])){ $delete_id = $_GET['del_id']; $query ="DELETE FROM tbl_data WHERE project_id ='".$delete_id."' "; $this-&gt;databaseObject-&gt;getConnection()-&gt;query($query); } </code></pre>
php
[2]
3,123,701
3,123,702
Is there a C# language construct/framework object to apply a function to each line of a file?
<p>What I'm looking for is something along these lines:</p> <pre><code>var f = UsefulFileObject(@"c:\temp.log"); f.ForEachLine( (line) =&gt; line.Trim() ); </code></pre> <p>After that I'd expect each line in the file to be trimmed.</p> <p>Is there such an object in the framework already or should I start making my own one?</p>
c#
[0]
1,593,364
1,593,365
Python : convert a hex string
<p>//Duplicated question are deleted</p> <p>I would like to convert a hex string like this:</p> <pre><code>b'\x0f\x00\x00\x00NR09G05164\x00' //this is what i received from socket </code></pre> <p>to something like:</p> <pre><code>0f0000004e52303947303531363400 </code></pre> <p>How can I achieve this with Python?</p>
python
[7]
2,592,905
2,592,906
What are the possible reasons for NoClassDefFoundError when querying Environment?
<p>This is the offending line of code:</p> <p><code>String state = Environment.getExternalStorageState();</code></p> <p>Why does it throw NoClassDefFoundError in some rare cases (never on my development device, but on some users' devices)?</p> <p>The target systems are Android 3.1 and higher, I don't know which system it crashed on. The exact message I get from bugreport is: <code>java.lang.NoClassDefFoundError: android.os.Environment</code>.</p>
android
[4]
4,050,993
4,050,994
What is the equivalent of php's print_r() in python?
<p>Or is there a better way to quickly output the contents of an array (multidimensional or what not). Thanks.</p>
python
[7]
5,674,758
5,674,759
Scroll to element
<p>How do I determine the index number of the element which text label matches to the one clicked?</p> <p>I have a list:</p> <pre><code>&lt;ul&gt; &lt;li data-cont="item one"&gt;this is one&lt;/li&gt; &lt;li data-cont="item 2"&gt;this is second&lt;/li&gt; &lt;li data-cont="one more"&gt;this is another one&lt;/li&gt; &lt;/ul&gt; ... &lt;div&gt;item one&lt;/div&gt; &lt;div&gt;item 2&lt;/div&gt; &lt;div&gt;one more&lt;/div&gt; </code></pre> <p>When one of LIs is clicked my screen needs to scroll down to one of the matched DIVs later on the page.</p> <pre><code>$('#li').click(function(){ var scrollNow = $(this).attr('data-cont'); $('html, body').animate({ scrollTop: $( // here I need to scroll down to the item by index... ).offset().top }, 500); }); </code></pre>
jquery
[5]
376,930
376,931
Can't invoke a closure wrapped in a closure?
<p>If I wrap a closure in another closure, I can't invoke the nested closure. Why not? I think an example illustrates the problem best.</p> <p>This PHP code:</p> <pre><code>function FInvoke($func) { $func(); } FInvoke(function () { echo "Direct Invoke Worked\n"; }); </code></pre> <p>Works as expected and prints "Direct Invoke Worked".</p> <p>However, If I slightly modify it to add another level of indirection, it fails:</p> <pre><code>function FInvoke($func) { $func(); } function FIndirectInvoke($func) { FInvoke(function () { $func(); }); } FIndirectInvoke(function () { echo "Never makes it here"; }); </code></pre> <p>The failure message is "Fatal error: Function name must be a string in file.php on line X"</p>
php
[2]
3,301,836
3,301,837
Disabling user from turning toggling airplane mode
<p>I don't know whether this can be done but, I want my app to toggle airplane mode on/off. Ok that's simple. But on toggling it off, the user should not be able to toggle it on by going into android settings. This should be disabled. Only the app should be able to revert the changes back. Or atleast till the app is closed. Any idea ?</p>
android
[4]
4,090,894
4,090,895
Is the strings.xml in the values folder necessary?
<p>I want to have different language values folders (Ex: values-en, values-de, values-fr). Every folder will have a version of the strings.xml file. My question is: do I have to keep the default strings.xml file in the values folder, or one of the specific strings.xml files will be used if I deleted the default file?</p>
android
[4]
5,489,443
5,489,444
Mouse Dragging problem
<p>i'm having the problem of capturing all the coordinate value of pixels while dragging with the mouse using mousedragged event in java while i'm dragging slowly i'm able to get all the coordinate value of pixels but when i'm doing it fast i'm getting only one third of the pixel coordinate values for example if i drag it slowly i'm getting 760 pixel values but when i'm doing it fast i'm getting only 60 pixel coordinate values please help me </p> <p>I need all the points because i'm going to use all those points for the signature comparision... Project Description : User will put the sign using mouse in log in page, this sign will be compared with the sign which the user already put in sign up page...</p> <p>I'm going to compare the sign using the pixel values, so by getting all the coordinate values only i can compare the sign... pls help me...</p>
java
[1]
3,843,148
3,843,149
Change the (backgound?) color behind a flipping view?
<p>I have 2 views which transition into each other using the ...</p> <blockquote> <p>[UIView setAnimationTransition:UIAnimationTransitionFlipFromLeft forView:self.view cache:YES]</p> </blockquote> <p>My views both have a black background and when they flip over the colour underneath is white. I want to change this to something else. How do I do this? I have tried searching but I am not really sure which search terms to use.</p> <p>Any suggestions would be great</p>
iphone
[8]
1,715,846
1,715,847
Can't get view to render in a RelativeLayout
<p>I have a relative layout, and want a left-aligned view that fills its height:</p> <pre><code>&lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#FF0" &gt; &lt;LinearLayout android:id="@+id/stripe" android:layout_width="20dp" android:layout_height="fill_parent" android:background="#F00" android:layout_alignParentLeft="true" android:layout_alignParentTop="true"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/stripe" android:layout_alignParentTop="true" android:text="Some long string." /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>I see the 20dp width reserved for "stripe", but don't get a red fill as expected. I'm sure the "stripe" view has its visibility set to VISIBLE (and not INVISIBLE). Any idea why this wouldn't be working? </p> <p>Thanks</p>
android
[4]
1,571,119
1,571,120
loading data into each textbox line by line
<pre><code>private void sessionText() { try { System.IO.TextReader r = new System.IO.StreamReader("saved.txt"); this.textBox1.Text = r.ReadLine(); r.Close(); } catch (Exception x) { MessageBox.Show("Exception " +x); } } </code></pre> <p>It reads the line into textBox1 but now I'm expanding my application. I added 5 more textBoxes and now I'm trying to load the data in each one saved line by line. How can I load each line into the next textbox?</p> <pre><code>Line 0 -&gt; textBox1 Line 1 -&gt; textBox2 Line 2 -&gt; textBox3 </code></pre>
c#
[0]
221,843
221,844
why is '<' showing as &lt;
<p>I am outputting a string form my java class like this</p> <pre><code>String numQsAdded = "&lt;div id='message1'&gt;"+getQuestion()+"&lt;/div&gt;"; </code></pre> <p>This string is being sent back to the client side as a XMLHttpRequest. So, in my jsp page I have a javascript alert method that prints out the string returned from the server. it translates '&lt;' to <code>&amp;lt;</code> and '>' to <code>&amp;gt;</code></p> <p>how can i avoid this?</p> <p>I have tried changing my string to:</p> <pre><code>String numQsAdded = "&amp;lt;div id='message1'&amp;gt;"+getQuestion()+"&amp;gt;/div&amp;lt;"; </code></pre> <p>but this has even worse effects. then '&amp;' is translated as 'amp'</p>
java
[1]
2,681,592
2,681,593
Animate the Div top & left postion based on the scrolling
<p>I am trying to achieve the below 2 points like as in this site " <a href="http://unfold.no/" rel="nofollow">http://unfold.no/</a> " </p> <ol> <li><p>Red background Div and Black background div top &amp; left position are animated based on<br> scrolling.</p></li> <li><p>Fixed Top navigation(right side at top position) color is changed once Red or Black divs are reached(overlapped) the Top navigation.</p></li> </ol> <p>Using the below code i am able to animate the Div positions but it is not working like as <a href="http://unfold.no/" rel="nofollow">http://unfold.no/</a> site.</p> <pre><code>$(document).ready(function () { var prv = 0; $(window).scroll(function () { var current = $(window).scrollTop(); if (current &gt; prv) { $('#div-about').animate({ top: "-=" + current / 5, left: "-=" + current / 14 }, 400, "easeOutExpo"); prv = current; } else { $('#div-about').animate({ top: "+=" + current / 4, left: "+=" + current / 12 }, 400, "easeOutExpo"); prv = current; } }); }); </code></pre> <p>please help me to achieve these 2 points.</p>
jquery
[5]
5,588,507
5,588,508
Convert date to string with limited precision
<p>I'm using <code>dateString = date.strftime('%Y-%m-%d %H:%M:%S.%f')</code> on this date: <code>2012-06-28 16:11:17</code> which returns <code>2012-06-28 16:11:17.999771</code> which for some reason is unparseable by Objective-c. How can I limit the last part of the string to 3 decimal places rather than 6?</p>
python
[7]
562,294
562,295
js generated form
<p>I have a js generated form (i.e. I echo a form from js code). </p> <p>So I wrote a submit handler that is activated when that form is submitted using:</p> <pre><code>$(document).ready(function(){ $('#form-coures').submit(function(event){ </code></pre> <p>At least this is what I want to achieve. </p> <p>The issue here is that when I submit that form the handler isn't called?!</p> <p>Any ideas?</p> <p>Note: if I define that same form not through js everything works fine.</p>
jquery
[5]
4,270,336
4,270,337
Combine big files
<p>I'm trying to join two big files (like the UNIX cat command: cat file1 file2 > final) in C++.</p> <p>I don't know how to do it because every method that I try it's very slow (for example, copy the second file into the first one line by line)</p> <p>¿What is the best method for do that?</p> <p>Sorry for being so brief, my english is not too good</p>
c++
[6]
5,807,961
5,807,962
Optimising a four-state data structure
<p>I am manipulating <em>many</em> instances of the same data structure which can have one of four states. Currently I implement the states using <code>True</code>/<code>False</code> pairs:</p> <pre><code>(True, True) (True, False) (False, True) (False, False) </code></pre> <p>With those data-structures I repeatedly apply two functions <code>f</code>, <code>g</code> where</p> <pre><code>g((True, True)) = (True, False) g((True, False)) = (True, True) g((False, True)) = (False, False) g((False, False)) = (False, True) </code></pre> <p>and</p> <pre><code>f((True, True)) = (False, False) f((True, False)) = (False, True) f((False, True)) = (True, False) f((False, False)) = (True, True) </code></pre> <p>Can I improve upon this data structure for those two functions? (I want to optimise for speed.)</p>
python
[7]
2,296,558
2,296,559
how to include dynamically in php
<p>Hello I would like to include dynamically in php...</p> <p>where I could send as parameter the pages that I want, only pages and not the directory ...</p> <p>was trying as below but did not work:</p> <p>this is the Loadclassphp.php:</p> <pre><code>&lt;?php class Loadclass{ public static function load($url) { foreach($url as $b) { include "$b.php"; } } } ?&gt; </code></pre> <p>and here is where i call:</p> <pre><code>include_once 'Loadclassphp.php'; $arr = array(1 =&gt; "menu",2 =&gt; "client"); Loadclass::load($arr); </code></pre> <p>thanks for the help...</p>
php
[2]
2,174,146
2,174,147
How can I access table cells in particular column to convert format
<p>I got from AJAX query a string like this:</p> <blockquote> <p>var ansverStr = "[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"15\",\"Regent Street\",1343329406000]\r\n[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"13\",\"Golders Green\",1343329883000]\r\n[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"176\",\"Tottenham Ct Rd\",1343329612000]\r\n[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"91\",\"Trafalgar Sq\",1343329514000]\r\n[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"11\",\"Fulham Broadway\",1343329434000]\r\n[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"87\",\"Wandsworth\",1343330102000]\r\n[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"6\",\"Willesden Gar\",1343329673000]\r\n[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"91\",\"Trafalgar Sq\",1343329871000]\r\n[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"11\",\"Fulham Broadway\",1343329743000]"</p> </blockquote> <p>Then created a dynamic table for it</p> <blockquote> <p>var element;</p> <p>element = '' + ansverStr.split('\r\n').map(function(line){ return '' + JSON.parse(line).map(function(cell){ return '' + cell + ''; }).join('') + ''; }).join('') + ''; document.getElementById("bStop").innerHTML=element;</p> </blockquote> <p>The last field in ansverStr substrings is a time.</p> <p><strong>The question: How can I access to those values in dynamic table to convert them into time format</strong></p>
javascript
[3]
1,036,391
1,036,392
Will setting a file's modification time to the future with touch() work accross the board?
<p>I have a caching class that has a flat file driver, meaning you can cache arbitrary data to a flat file using a key and expiration time, then retrieve this data using the same key.</p> <p>Expire duration must be set with the setCache method in order to work with other drivers (as opposed to having an expiration duration argument on the getCache method, even though this would make determining whether the cache has expired much easier, as I could just compare it to the files last modification time).</p> <p>Currently I prepend a timestamp (+ expire duration) to the beginning of the file. When a user tries to getCache related to that file, the method opens the file and strips off the first line to get this timestamp. It then uses that timestamp to figure out whether or not that cache has expired. This is not very efficient obviously.</p> <p>I recently came accross a PHP function touch(), which allows me to set a file's last modification time to an arbitrary value. This sounds awesome because it would allow me to (instead of the above mentioned method of figuring out if the cache has expired), set the file's last modification time to some point in the future. I can then check this time to see if the cache has expired yet.</p> <p>I really REALLY want to be able to use this. My application is distributed however, and since this function works with the environment, I am not sure if I should trust this function to work as expected accross the board on different systems. Does anyone have any information or resources about the compatability of this function?</p>
php
[2]
4,488,445
4,488,446
How can I overlay traffic data on googlemaps
<p>I am using Google maps API for android application development. I have traffic data for a certain city in my database, which should be displayed on Google map with different colors. How can I overlay that data on Google maps for specified city/county? Do I need to use KML or such kind of stuff for coordinates of city/county? Thanks, Chanukya</p>
android
[4]
103,630
103,631
jQuery - How do I test what type of selector is passing the value?
<p>I am using the latest and greatest jQuery. I am trying to make my code efficient and reusable throughout a specific site and want consolidate a block.</p> <p>I have a piece of code that listens for a save button being clicked. When the save button is clicked, it figures out which selector was click and gets its id and value.</p> <p>This code works perfectly for text boxes. I just want to be able to run select boxes, radio buttons, and check boxes through it too. I need to handle the data differently depending on whether it's a checkbox, radio, or text field.</p> <p>If I know the id of a selector, how can I easily test which type of selector it is?</p> <p>In pseudocode:</p> <pre><code>if (SelectorType == 'radio') { // do radio stuff } else if (SelectorType == 'text') { // do test field stuff } else if (SelectorType == 'checkbox') { // do checkbox stuff } </code></pre> <p>ANSWER</p> <p>This is what I was trying to get at: </p> <pre><code> var ThisField = $(this).parent().parent().children("td:eq(1)").children(":input").attr("id"); var FieldType = $("#"+ThisField).prop("type"); if (FieldType == "select-one") { alert("You are trying to save select box info!"); } else if (FieldType == "text") { alert("You are trying to save text info!"); } else if (FieldType == "checkbox") { alert("You are trying to save checkbox info!"); } else if (FieldType == "radio") { alert("You are trying to save radio info!"); } </code></pre>
jquery
[5]
878,712
878,713
php syntax error on line 5
<pre><code> &lt;?php $vc=$_POST['versioncode']; if ($vc == 1.0.2){ echo 1; // for correct version code } else { echo 0; // for incorrect version code } ?&gt; </code></pre> <p>I get this error. Parse error: syntax error, unexpected T_DNUMBER in /hermes/bosweb26b/b865/ipg.synamegamescom/giveaway/versioncheck.php on line 5</p>
php
[2]
2,494,587
2,494,588
Total C# newb - How do I get data from public interface to use?
<p>Just to reinstate <strong>total C# NEWB</strong>.</p> <p>Okays so:</p> <p>There is a public interface in the project with a value as follows:</p> <pre><code>Name3D MyName3D { get; set; } </code></pre> <p>Now in another location I am using a public sealed class, I added the namespace / using System.Interfacename. Now I want to set it like follows:</p> <pre><code>private readonly Interfacename m_MyName3D ; private const string 3DName = ##; </code></pre> <p>How would i go aobut setting it up so ## is the value of MyName3D. Again I haven't done anything like this before. Just wanted to give it a try?</p> <p>Would be really appreciated if I could get some detail onto how it works.</p> <p><strong>Update One</strong></p> <p>Do you mean this?</p> <pre><code>using Interfacename; public sealed class InfoController : AsyncController { private readonly Interfacename m_MyName3D ; private const string 3DName = ##; </code></pre>
c#
[0]
2,007,507
2,007,508
Problem with memory usage measurment
<p>I have some C# functions, and I want to measure their memory usage in bytes. I used GC.GetTotalMemory as follows:</p> <pre><code>long val1 = GC.GetTotalMemory(false); // my code long val2 = GC.GetTotalMemory(false); long result = val2 - val1 ; </code></pre> <p>I tried to pass both true and false as argument for GC.GetTotalMemory, but I do not know why I get negative result value, when I subtract val1 from val2 .... Another issue is that GC.GetTotalMemory give different values in each excution, I think it is not accurate </p> <p>Can anyone know why I get a negative result value ? is it because of the argumenet (true or false), although I tried them both and got negative result value too</p> <p>Can anyone know why I get different values in each excution of the C# function ?</p> <p>Please if anyone has a better efficient way to measure memory usage in bytes for C# function in Windows, please tell me and thanks alot </p>
c#
[0]
4,073,203
4,073,204
the return statement is available and the compiler still asks for it
<p>I have the below posted method, and as shown it return Boolean data type. I wrote the return statement but though, the compiler gives me an error saying: this method must return a result of type boolean.</p> <p>Java code:</p> <pre><code>public boolean isExistGuess(int guess, ArrayList&lt;Integer&gt; arraylist) { boolean found = false; if (arraylist.isEmpty()) return false; for (int i=0; i &lt; arraylist.size(); i++) { if (arraylist.get(i) == guess) return true; else continue; } } </code></pre>
java
[1]
2,626,656
2,626,657
Create voting poll user control with result in asp.net
<p>I want to create a voting poll user control in asp .net which displays results at the same time. The user control i need is free one. or the code to create it</p>
asp.net
[9]
5,571,689
5,571,690
security captcha image not dispalyiing in 000webhost
<p>I have uploaded my website on 000webhost but in my registration form the security captcha image is not displaying while it is displaying in my localhost.</p> <p>My captcha code is:</p> <pre><code>&lt;?php include_once('includes/session.php'); $_SESSION['secure']=rand(1000,9999); header('content-type:image/jpeg'); $text=$_SESSION['secure']; $font_size=25; $image_width=200; $image_height=40; $image=imagecreate($image_width,$image_height); imagecolorallocate($image,255,255,255); $text_color=imagecolorallocate($image,0,0,0); for($x=1;$x&lt;=40;$x++) {$x1=rand(1,120); $x2=rand(1,120); $y1=rand(1,120); $y2=rand(1,120); imageline($image,$x1,$y1,$x2,$y2,$text_color); } imagettftext($image,$font_size,0,15,30,$text_color,'MAGNETOB.TTF',$text); imagejpeg($image); ?&gt; </code></pre> <p>And I'm displaying captcha as:</p> <pre><code>&lt;img src="captcha1.php" id="captcha" /&gt; </code></pre> <p>What's wrong with my code?</p>
php
[2]
5,269,287
5,269,288
How to get user details in asp.net Windows Authentication
<p>I am using windows Authentication and accessing user name as.</p> <pre><code>IIdentity winId = HttpContext.Current.User.Identity; string name = winId.Name; </code></pre> <p>but i want to get other details like User full name and EmailID.</p>
asp.net
[9]
3,342,960
3,342,961
one issue related to ArrayObject in php
<pre><code> &lt;?php class ExtendedArrayObject extends ArrayObject { private $_array; public function __construct() { if (is_array(func_get_arg(0))) $this-&gt;_array = func_get_arg(0); else $this-&gt;_array = func_get_args(); parent::__construct($this-&gt;_array); } } $newArray = new ExtendedArrayObject(array(1,2,3,4,5,6)); ... ?&gt; </code></pre> <p>Above code is taken from a book. </p> <p>Question: what is the usage of this line: <code>else $this-&gt;_array = func_get_args();</code>? why we need to set up a <code>if...else...</code>here?</p>
php
[2]
3,065,570
3,065,571
Call a C++ function from a C++ library in Linux
<p>I want to call a function from C++ library on linux. I have a shared object of that library. I want to call method getAge() that return an int from ydmg library.</p> <p>Following is the code that I have written:</p> <p>testydmg.cpp</p> <pre><code>#include "ydmg/bd.h" #include "yut/hash.h" #include "dlfcn.h" extern "C" int getAge(); class testydmg{ public: testydmg::testydmg(const yutHash&amp; user){ } testydmg::testydmg(){ } testydmg::~testydmg(){ } int testydmg::getFunction(){ void *handle; int (*voidfnc)(); handle = dlopen("ydmg.so",RTLD_LAZY); if(handle == NULL){ printf("error in opening ydmg lib"); } else { voidfnc = (int (*)())dlsym(handle, "getAge"); (*voidfnc)(); printf("class loaded"); } ydmgBd obj; obj.getAge(); printf("Inside getFunction()..."); dlclose(handle); } }; </code></pre> <p>I compile and link the code as below:</p> <blockquote> <p>gcc -fPIC -shared -l stdc++ -I/home/y/libexec64/jdk1.6.0/include -I/home/y/libexec64/jdk1.6.0/include/linux -I/home/y/include testydmg.cpp -o libTestYdmg.so libydmg.so</p> </blockquote> <p>Then I check for the method in the new shared object i.e. libTestYdmg.so</p> <blockquote> <p>nm -C libTestYdmg.so | egrep getAge I get nothing by running the above command.</p> </blockquote> <p>Does it mean that it did not get the method getAge() from the library. Could you please correct where I am going wrong ?</p>
c++
[6]
2,697,688
2,697,689
applyPattern() in SimpleDateFormat gives NullPointerEcxeption with white space in java
<p>I have this code that formats the date to this pattern dd-MM-yyyy:</p> <pre><code> SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S"); sdf.applyPattern("yyyy-MM-dd"); Date date_out = null; try { date_out = sdf.parse(date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } sdf.format(date_out); </code></pre> <p>However when I change separator from "-" to white space or slash "/" I get NullPointerEcxeption on the format() line. Does SimpleDateFormat accept white space or any other character as date separators? </p>
java
[1]
3,370,288
3,370,289
MPMoviePlayerViewController playing movie only in landscape mode
<p>I want to play the video only in landscape mode in iPhone SDK.40(MPMoviePlayerViewController). It should not support portrait mode play back. How do we do this. </p>
iphone
[8]
4,303,303
4,303,304
jQuery parsing XML .each undefined issue
<p>I have a simple xml file that I'm looping over to set a ValueObject for each item node. Each VO created is added to a LinkedList data structure. The linkedList is instantiated outside the .each() loop. However, for some reason, my linkedList instance returns "undefined" inside the loop. For instance:</p> <pre><code>Model.prototype.setData = function(data) { this.data = data; this.linkedList = new LinkedList(); this.startItem = $(data).find('slideShow').attr('startItem'); this.currentID = this.startItem || 1; $(data).find('item').each(function() { var imageVO = new ImageVO(); imageVO.id = $(this).find('id').text(); imageVO.image = $(this).find('image').text(); imageVO.title = $(this).find('title').text(); console.log(this.linkedList) //undefined this.linkedList.addNode(imageVO); }); this.linkedList.currentNode = this.linkedList.findNodeByIndex(this.currentID); } </code></pre>
jquery
[5]
3,789,643
3,789,644
Add leading zero's to string, without (s)printf
<p>I want to add a variable of leading zero's to a string. I couldn't find anything on Google, without someone mentioning (s)printf, but I want to do this without (s)printf.</p> <p>Does anybody of the readers know a way?</p>
c++
[6]
5,427,236
5,427,237
Internet is not getting connected in android
<p>I have created an app in android and it requires some data to be transfered over internet. I have written the codes but I don't see any data transfer on my device. Am I missing any point? Any suggestion will be appreciated.</p>
android
[4]
4,820,429
4,820,430
Strange code timing behavior in Java
<p>In the following code:</p> <pre><code>long startingTime = System.nanoTime(); int max = (int) Math.pow(2, 19); for(int i = 0; i &lt; max; ){ i++; } long timePass = System.nanoTime() - startingTime; System.out.println("Time pass " + timePass / 1000000F); </code></pre> <p>I am trying to calculate how much time it take to perform simple actions on my machine.</p> <p>All the calculations up to the power of 19 increase the time it takes to run this code, but when I went above 19(up to max int value 31) I was amazed to discover that it have no effect on the time it takes. It always shows 5 milliseconds on my machine!!!</p> <p>How can this be?</p>
java
[1]
1,837,758
1,837,759
absolute path source php
<p>This is maybe just a trivial question, but I don't really know what is the best practice to include, says javascript, img, or css using absolute path</p> <p>What I am really using right now is using the code like this</p> <pre><code>&lt;?php $prefix = '//'; $rootFolder = $prefix . $_SERVER['HTTP_HOST']; ?&gt; </code></pre> <p>so then when i want to include something like jquery, I would just type the code like this</p> <pre><code>&lt;script type="text/javascript" src="&lt;?php echo $rootFolder ?&gt;/jquery-1.7.1.min.js"&gt;&lt;/script&gt; </code></pre> <p>is this good enough? Or should I modify the prefix to "http://" or maybe there is some better way using another superglobal variable and such?</p> <p>thanks in advance :)</p>
php
[2]
4,238,435
4,238,436
how to ask for user input in a function. Python related
<p>Is there a way to ask for user input while defining a function? for example here's a simple function:</p> <pre><code>def sum3(a,b,c): add=a+b+c return add </code></pre> <p>in the above code, is there a way I can ask the user to enter 3 numbers. say, when the program runs the user sees a prompt saying "please enter 3 numbers"</p>
python
[7]
4,234,211
4,234,212
how to get position from Spinner adapter
<p>i fill spinner with generic Arraylist of cat Categeory type </p> <p>now i want to get position of Specific Item from it , i try code below but it always return S</p> <p>if (Singleton.getCategory() != null) {</p> <pre><code> cat item =new cat(); String cat= Singleton.getCategory().toString(); int catid= Singleton.getCategoryid(); item.setName(cat); item.setcatId(catid); int spinnerPosition=selcategaryadapter.getPosition(item); //set the default according to value selCategary.setSelection(spinnerPosition); } </code></pre> <p>here is how i fill spinner </p> <pre><code> JSONArray jsonarray=JSONFunction.getJSONCategary(); JSONObject json1=null; ArrayList&lt;eexit&gt; listCategory= new ArrayList&lt;eexit&gt;(); try { for(int i=0;i&lt; jsonarray.length();i++) { json1=jsonarray.getJSONObject(i); arrayCategary[i]=json1.getString("Name") cat item=new cat(); item.setName(json1.getString("Name")); item.setcatId(Integer.parseInt(json1.getString("CategoryID"))); listCategory.add(item); } } catch (Exception e) { // TODO: handle exception } ArrayAdapter&lt;eexit&gt; selcategaryadapter = new ArrayAdapter&lt;eexit&gt;(Activity.this,R.layout.spinner_layout, listCategory); selcategaryadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); selCategary.setAdapter(selcategaryadapter); selCategary.setPrompt("Select Category"); </code></pre>
android
[4]
2,040,384
2,040,385
JDBC connection open or closed?
<p>I have a Java application with a JDBC connection, which performs many different tasks. My question is what is best for performance:</p> <ul> <li>To have an open connection for the duration of the application running?</li> <li>Close and reopen connection based on what tasks are performed and create new connection variables?</li> </ul>
java
[1]
873,258
873,259
Same number different formats in PHP
<p>I have two numbers in PHP. 81.0000 and 81. While they are equal in reality I cannot get them to be equal in PHP. </p> <p>I have tried casting both numbers to float and they still won't come thought as equal.</p> <p>Anyone have any idea how I can have these two numbers be the same?</p>
php
[2]
1,007,857
1,007,858
Memory leaked (activity leak) caused by CookieSyncManager?
<p>I used MAT tool in Eclipse to investigate a memory leak issue and found that, occasionally, a CookieSyncManager thread instance leaks my activity. The path from my activity to GC root is as following:</p> <pre><code>com.mycompany.myapp.MyActivity --&gt; mContext com.android.internal.policy.impl.PhoneFallbackEventHandler --&gt; mFallbackEventHandler android.view.ViewRoot --&gt; target android.os.Message --&gt; &lt;java local&gt; java.lang.Thread CookieSyncManager Thread </code></pre> <p>MyActivity called CookieSyncManager.createInstance(this.getApplicationContext()); in onCreate(), but it doesn't use any webview. It only contains some animations. I don't understand why it is leaked by CookieSyncManager. Can someone help?</p> <p>Thanks.</p>
android
[4]
1,051,873
1,051,874
Problem in implementing my own switch class
<p>I am trying to implement a custom switch case just for fun..</p> <p>The approach is that I have created a class that inherits a dictionary object</p> <pre><code>public class MySwitch&lt;T&gt; : Dictionary&lt;string, Func&lt;T&gt;&gt; { public T Execute(string key) { if (this.ContainsKey(key)) return this[key](); else return default(T); } } </code></pre> <p>And I am using as under</p> <pre><code> new MySwitch&lt;int&gt; { { "case 1", ()=&gt; MessageBox.Show("From1") }, { "case 2..10", ()=&gt;MessageBox.Show("From 2 to 10") }, }.Execute("case 2..10"); </code></pre> <p>But if I specify <strong>"case 2"</strong> it gives a default value as the key is not in the dictionary.</p> <p>The whole purpose of making <strong>"case 2..10 "</strong> is that if the user enters anything between <strong>case 2 to case 10</strong>, it will execute the same value.</p> <p>Could anyone please help me in solving this?</p> <p>Thanks</p>
c#
[0]
3,040,620
3,040,621
Loop thru a list and stop when the first string is found
<p>I have a list and I want to extract to another list the data that exist between top_row and bottom_row. I know the top_row and also that the bottom_row corresponds to data[0] = last integer data (next row is made of strings, but there are also rows with integers which I'm not interested).</p> <p>I've tried several things, but w/o success:</p> <pre><code>for row,data in enumerate(fileData): if row &gt; row_elements: #top_row try: n = int(data[0]) aux = True except: n = 0 while aux: #until it finds the bottom_row elements.append(data) </code></pre> <p>The problem is that it never iterates the second row, if I replace while with if I get all rows which the first column is an integer.</p> <p>fileData is like:</p> <pre><code>*Element, type=B31H 1, 1, 2 2, 2, 3 . . . 359, 374, 375 360, 375, 376 *Elset, elset=PART-1-1_LEDGER-1-LIN-1-2-RAD-2__PICKEDSET2, generate </code></pre> <p>I'm only interested in rows with first column values equal to 1 to 360.</p> <p>Many thanks!</p>
python
[7]
2,389,132
2,389,133
Using javascript to check which CDN jQuery is cached from on the client
<p>Can I use JavaScript to check whether JQuery is (already) downloaded (cached) on the target web browser (user) or not? For Example:</p> <pre><code>If (JQuery-from-Microsoft-CDN-downloaded) Then use http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.js Else if (JQuery-from-Google-APIs- downloaded) Then use http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js Else if (JQuery-from-code.jquery.com- downloaded) Then use http://code.jquery.com/jquery-1.4.4.min.js Else use jQuery from my own website. </code></pre> <p>Means that using the ability of javascript to check whether one of them is downloaded on the target User (Web Browser), if not then use jQuery from my own website otherwise if true then use that version of JQuery that is downloaded on the target User.</p>
jquery
[5]
4,458,363
4,458,364
Delete old files - an hour ago or more than an hour ago
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6411451/how-can-i-delete-files-older-than-1-hour">How can I delete files older than 1 hour?</a> </p> </blockquote> <p>the code down below delete all files inside a folder called " Images ". No complains everything works as it should, but is there a way to <strong>only</strong> delete the file which was created an hour ago or more then hour ago instead? Please show me how, I'm trying to learn by doing, please. Try to re-use the same code down below for better understanding and also to help users PHP programmer around the world</p> <pre><code>&lt;?php define('PATH', 'Images/'); function destroy($dir) { $mydir = opendir($dir); while(false !== ($file = readdir($mydir))) { if($file != "." &amp;&amp; $file != "..") { chmod($dir.$file, 0777); if(is_dir($dir.$file)) { chdir('.'); destroy($dir.$file.'/'); rmdir($dir.$file) or DIE("couldn't delete $dir$file&lt;br /&gt;"); } else unlink($dir.$file) or DIE("couldn't delete $dir$file&lt;br /&gt;"); } } closedir($mydir); } destroy(PATH); echo 'all done.'; </code></pre>
php
[2]
1,719,998
1,719,999
How to get OS version of remote computer
<p>My Android application knows an IP address of a remote desktop computer. Is it possible to get any information about it's OS? (Mac or Win)</p>
android
[4]
2,260,822
2,260,823
Spatial Vector, Color Vector
<p>Say you have two things (spatial vector, color vector) that are conceptually different (pos in space vs color) yet they actually end up needing the same types of operations - overloaded plus, minus, scalar multiply.</p> <p>A nice solution in the Cg programming language was they actually aliased member names .xyzw and .rgba. So in Cg you can do</p> <pre><code>float4 vector = float4( 4, 3, 2, 1 ); float red = vector.r ; float x = vector.x ; // both red and x will have the value 4.0. </code></pre> <p>So the question is: How do you deal with things that are conceptually different but programmatically the same? I could simply use a class Vector and "remember" that .x = .r, .y = .g and so on, which isn't that hard but appears somehow misleading.</p> <p>The other option is to totally repeat the code in Vector and Color.</p> <p>Which is better? <em>Repeating code</em> for readability's sake, or <em>just living with the bad naming</em>?</p>
c++
[6]
4,599,700
4,599,701
event.preventDefault(); not working with .on in jQuery
<p>As of jQuery 1.7 <code>.live</code> has been deprecated and replaced with <code>.on</code>. However, I am having difficulty getting jQuery <code>.on</code> to work with <code>event.preventDefault();</code>. In the below example, clicking the anchor tag takes me to the linked page instead of preventing the default browser action of following the link.</p> <pre><code>jQuery('.link-container a').on('click', function(event) { event.preventDefault(); //do something }); </code></pre> <p>However, the same code with <code>.live</code> works without any hiccups.</p> <pre><code>jQuery('.link-container a').live('click', function(event) { event.preventDefault(); //do something }); </code></pre> <p>I am using jQuery version 1.7.1 that ships with Wordpress 3.3.1 currently. What have I got wrong here?</p> <p>Regards, John</p>
jquery
[5]
5,655,322
5,655,323
Ping url and get status in java
<pre><code> URLPing urlPing = new URLPing(); PingResponse pingResponse = urlPing.ping(URLName); if(pingResponse.getResponseCode() == 200){ response = true; } else{ response=false; } </code></pre> <p>This is what i have tried at present.</p>
java
[1]
3,808,785
3,808,786
How to Simplify Javascript Dynamic IDs?
<p>I am new to JS and I'm running a CMS, I have a dynamic Ids, my concern is, I would to simplify IDs to lessen JS codes by adding arrays of IDs.</p> <p>Can you guys help me how to simplify this code</p> <pre><code>$x1(document).ready(function () { // // Id1 = #options_1_text // Id2 = #option_2_text // Id3 = #option_3_text // Id(n) = so on.. $x1("#options_1_text").miniColors({ letterCase: 'uppercase', change: function (hex, rgb) { logData('change', hex, rgb); } }); $x1("#options_2_text").miniColors({ letterCase: 'uppercase', change: function (hex, rgb) { logData('change', hex, rgb); } }); $x1("#options_3_text").miniColors({ letterCase: 'uppercase', change: function (hex, rgb) { logData('change', hex, rgb); } }); // so on.. }); </code></pre> <p>You're help is greatly appreciated! </p> <p>Thanks!</p>
javascript
[3]
844,027
844,028
Unable to build Eclipse library projects after ADT update
<p>I have a main project (mainapp) I am developing for Android under Eclipse. It uses the facebook-android-sdk library (fblib) which is a separate Eclipse project with it's project properties checked as "Library". Under the project properties > android section for mainapp, I have fblib added as a library. everything works fine. </p> <p>I needed to create a new version of mainapp which uses different database files (assets subdirectory). To do this, I created a new Eclipse project (newapp) and setup mainapp as a library under project properties > android. </p> <p>Everything was working fine until the latest ADT update. I am getting errors trying to build/run newapp (Conversion to Dalvik format failed with error 1). If I go to mainapp and uncheck "Library" from project properties > android, I can build mainapp as a regular application and it seems to work just fine.</p> <p>I've searched for multiple jar files in project directories, updated proguard to 4.8beta, deleted/added jars to the build path, removed exports, added exports, deleted dependencies, added "lib" directories, cleaned, restarted, rebooted and pretty much anything else google would turn up, but to no avail. </p> <p>It was all working fine with ADT 16 so I'm really confused here. Has adding a library project to an application, which also incorporates a library project, become somehow deprecated? I just can't seem to get this working.</p>
android
[4]
2,838,716
2,838,717
Assignment to None
<p>I have a function which returns 3 numbers, e.g.:</p> <pre><code>def numbers(): return 1,2,3 </code></pre> <p>usually I call this function to receive all three returned numbers e.g.:</p> <pre><code>a, b, c = numbers() </code></pre> <p>However, I have one case in which I only need the first returned number. I tried using:</p> <pre><code>a, None, None = numbers() </code></pre> <p>But I receive "SyntaxError: assignment to None".</p> <p>I know, of course, that I can use the first option I mentioned and then simply not use the "b" and "c" variables. However, this seems like a "waste" of two vars and feels like wrong programming.</p>
python
[7]
1,868,234
1,868,235
how to take picture from camera using iphone app
<p>I have implemented picture taking while pressing UI Button butwhen ever i pressed the button got app crashed.</p> <p>Here is the source code.</p> <pre><code>.h file @interface Camera : UIViewController &lt;UIImagePickerControllerDelegate&gt; { UIImagePickerController *mPicture; } @property (nonatomic, retain) UIImagePickerController *mPicture; .m file @implementaion Camera @synthesize mPicture; -(void)pictureButtonPushed { UIImagePickerControllerSourceType mType = UIImagePickerControllerSourceTypeCamera; if ([UIImagePickerController isSourceTypeAvailable:mType]) { mPicture.sourceType = mType; [self presentModalViewController:mPicture animated:YES]; } } </code></pre> <p>Thanks in advance</p>
iphone
[8]
2,421,074
2,421,075
How to create a Very VERY Simple proxy to a specific page/feed
<p>I have a simple problem. Living in Ch*na we don't have access to much of the social media sites. So I want to create a php file that fetches the content of a blocked rss file and output's itself as that rss.</p> <p>unblockedserver.com/twittfeed.php?id=23038034</p> <pre><code>&lt;?php $id = (int)$_GET['id']; $url='http://twitter.com/statuses/user_timeline/'.$id .'.rss'; header("Content-Type: application/xml; charset=ISO-8859-1"); $feed = getthecontentfromthe($url);? // what goes here? echo $feed; </code></pre> <p>The main site handles the caching and generally the url/page will be a secret, so i hope this will be simple enough.<br> Cheers</p>
php
[2]
2,878,651
2,878,652
Advanced JavaScript split
<p>I have to split this string here in JavaScript:</p> <pre><code> hl=windows xp \"windows xp\" </code></pre> <p>to three words.</p> <p>I used:</p> <pre><code> keywords = keywords.split(/ /); </code></pre> <p>But then i got 4 words: </p> <pre><code>windows xp \"windows xp\" </code></pre> <p>How could i split this string to just 3 words?</p> <p>EDIT: and how do i remove the \".</p>
javascript
[3]
2,566,335
2,566,336
Do templates shorten the size of source or binary or both
<p>I read that templates are complied into different entities so does that mean the binary size will be same as we have complied it using different functions?</p>
c++
[6]
1,088,645
1,088,646
C++, reference "constructor"
<pre><code>template&lt;typename T, typename R&gt; T f(R &amp;r) { return T(r); } int main() { int o; f&lt;int&amp;&gt;(o); } </code></pre> <p>Is this ok? Comeau didnt complain, so I assume <code>int&amp;(...)</code> form is fine?</p> <p>reason example:</p> <pre><code> typename boost::mpl::if_c&lt; (rank == 1), reference, tensor_ref&lt;typename detail::array_ref&lt;A&gt;::type&gt; &gt;::type operator[](const int &amp;i) { typedef typename boost::mpl::if_c&lt; (rank == 1), reference, tensor_ref&lt;typename detail::array_ref&lt;A&gt;::type&gt; &gt;::type T; return T(detail::array_ref&lt;A&gt;::generate(this-&gt;data())); } </code></pre>
c++
[6]
5,460,244
5,460,245
C# alternative or more current data access then Enterprise Libraries
<p>Currently I basically add references to Microsoft.Practices.EnterpriseLibrary.Common .Data .ObjectBuilder</p> <p>I find myself creating holding class like 'Product' then have another class that makes a list like Products : List</p> <pre><code>public class Products : List&lt;Product&gt; { public Products() { } public void SelectAll() { Database db = DatabaseFactory.CreateDatabase(); using (IDataReader r = db.ExecuteReader(cmd)) { while (r.Read()) { this.Add(new Product(Convert.ToInt32(r["PRODUCT_ID"]), r["NAME"].ToString()) )); } } } } Products p = new PRoducts() p.SelectAll(); </code></pre> <p>now I have all my products which is nice. </p> <p>this is okay, but i've been using it for a couple of years. I've heard about LINQ and Entity Framework but not really taken the step also played with nHibernate but not really taken to any. Is wrong to still be using this method.</p>
c#
[0]
1,450,275
1,450,276
Exception on this line of code
<pre><code>if(str.contains("final")) { id = Integer.parseInt(str.substring(18, str.length() - 6)); } System.out.println(id); </code></pre> <p>This line of code <code>id = Integer.parseInt(str.substring(18, str.length() - 6));</code> I got the output as "final year" but it throws an illegalnumberformat exception For input string: " final Year"</p> <pre><code>at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at Product.main(Product.java:47) </code></pre> <p>How to solve this issue?</p> <p>I have a text file which has both string and int in it like </p> <p>final year 93 93 90 91.<br> In this input given,I need to find the "final year" string and display the count of the number's below it without repetition.How can I do that</p>
java
[1]
1,073,082
1,073,083
jQuery: show() keeps adding display:block
<p>I'm having a little issue right now that has turned into a festering wound.</p> <p>I've recreated Google Business Hours for setting which hours during the week that a company is open, or whether they are closed on that day. Now, if they are closed, the user can select a checkbox and the times DIV hides. Right now I'm using .show() and .hide()</p> <p>Now, let's say that a user closes the fist day and decides to "apply all" to the rest of the days of the week... I loop through and close the remaining 6 days. However, if a user has modified a day in the middle of the week, the .show() or .hide() functions automatically add "display: block" ... this messes up the loop.</p> <p>Why is jQuery adding this styling when it was never there originally, and is there a clean way of removing it within a loop before I apply the .show() or .hide()?</p>
jquery
[5]
2,930,069
2,930,070
declaring a scalar variable @@SA_CONSOLE_HOSTNAME
<p>//The query which I gave in looks like</p> <p>//insert into tablename(host, instance) values(@SA_CONSOLE_HOSTNAME, value), in the tablename I have created columns host and instance where host would be my local machine name. I dont want to enter the machine name every time the code is run in a different system so created a variable and assigned machine name to it, </p> <p>//I have created a stub and passed the machinename to it</p> <pre><code>String scriptAndStub; scriptAndStub = "DECLARE @SA_CONSOLE_HOSTNAME VARCHAR(256)\n" + \\ creating a variable "SET @SA_CONSOLE_HOSTNAME = @HOSTNAME@\n"; scriptAndStub += script; executeScript.CommandText = scriptAndStub; executeScript.Parameters.AddWithValue("@HOSTNAME@", Environment.MachineName); \\passing machine name </code></pre> <p>//when I click the check syntax button on the text box its generating the error </p> <pre><code>private void btnSyntaxCheck_Click(object sender, EventArgs e) { try { tsStatus.Text = "Checking Syntax..."; LogMessage(DA_Base.Constants.ERROR_LEVEL_DEBUG, "SQLScripting::SyntaxCheck", "Query: " + rtbScript.Text); using (SqlCommand myCommand = new SqlCommand(string.Empty, Connection)) { foreach (string script in Regex.Split(rtbScript.Text, "^GO\r?$", RegexOptions.Multiline | RegexOptions.IgnoreCase)) { if (!String.IsNullOrEmpty(script)) { myCommand.CommandText = "SET PARSEONLY ON\n" + script; myCommand.ExecuteNonQuery(); } } } tsStatus.Text = "Checking Syntax Complete. No errors reported."; } catch (Exception exc) \\error has been caught here.... { tsStatus.Text = exc.Message; MessageBox.Show(exc.Message, "SQL Syntax Check"); } } } } </code></pre>
c#
[0]
1,983,245
1,983,246
TypeError: 'int' object is not iterable. Why am i getting this error? please help
<pre><code>def get_top_k(frequency, k): temp = frequency key = "" tvalues = [] values = [] kk = int(k) i = 0 for i in temp.keys(): key = i num = [int(frequency[key])] tvalues += num tvalues = bubble_sort(tvalues) i = 0 for i in kk: num = [int(tvalues[i])] values += num print(values) i = 0 result = {} for i in kk: result += {(str(temp[values[i]])):(int(values[i]))} return result </code></pre>
python
[7]
1,332,552
1,332,553
update Ui with TimeTask in android
<p>I am running a countdown timer in android and i want to show this countdown to the user in an Activity with a TextView. How can i do this? Has any one done this before?</p>
android
[4]
5,727,881
5,727,882
Notify a User if Exception happens not in Activity class
<p>My <code>Activity</code> holds a member <code>member_one</code> which holds another member <code>member_two</code> which can throw an <code>Exception</code>. I need to show user a <code>Toast</code> if this <code>Exception</code> happens. In order to show a <code>Toast</code> I need to throw <code>Exception</code> from <code>member_tow</code> to <code>member_one</code> and then from <code>member_one</code> to my <code>Activity</code>. This approach leads to big changes and I don't want to do so. May be I just think wrong, is there any easy way to handle the exception?</p>
android
[4]
5,992,237
5,992,238
Check if redirect from other url
<p>Let's say my site is example.com people can visit by directly type in "example.com" in the browser to open it up.</p> <p>However I want to check if people visit my site from other sources, like google or other referrals. Then I'd like to add jquery modal for those visitors. Is it doable? Thanks!</p>
jquery
[5]
1,954,770
1,954,771
sorting objects in java
<p>i want to do nested sorting . I have a course object which has a set of applications .Applications have attributes like time and priority. Now i want to sort them according to the priority first and within priority i want to sort them by time.</p>
java
[1]
2,445,696
2,445,697
Implementation of selection sort in Java
<p>I think I have done the selection sort but I am not sure. Is this really an implementation of selection sort?</p> <pre><code>static void selectionSort() { int min = Integer.MIN_VALUE; int n = 0; for(int I=0; I&lt;arraySize; I++) { min = dataArray[I]; for(int j=I; j&lt;n; j++) { if(dataArray[min]&lt;dataArray[j]) { min = j; if(dataArray[min] &lt; dataArray[I]) { int temp = dataArray[I]; dataArray[I] = dataArray[min]; dataArray[min] = temp; } } } } } </code></pre>
java
[1]
5,462,406
5,462,407
HttpRequestValidationException when signing out
<p>On my master page I have a LoginStatus control which allows users to sign out of the application. The problem is that if within the page, the user enters invalid data like "&lt;test&gt;" and then, <em>without</em> submitting the form, the user clicks "sign out" a HttpRequestValidationException is raised. When the user clicks "sign out", any pending input is going to be discarded anyway.</p> <p>What I ended up doing is using javascript to call reset() on the form when the user clicks "sign out." This circumvents the HttpRequestValidationException problem adequately. Does anyone have other suggestions for how to deal with this scenario?</p>
asp.net
[9]
1,902,987
1,902,988
How to send feedback/review/edit content in the Android Dev guide?
<p>Is there any official/effective way for sending feedback for the Android Developer's guide? I noticed a mistake (a page recommends using a method that the documentation lists as deprecated) and was wondering if there is a way to point it out to someone working on the site, but I wasn't able to find anything. </p>
android
[4]
2,373,615
2,373,616
error: Use of unassigned local variable
<p>I have this method:</p> <pre><code>public static void Add(int _Serial, string _Name, long? _number1, long? _number2) { // ... } </code></pre> <p>and use this code for send date to method:</p> <pre><code>long? _num1; long? _num2; if (txtNumber1.Text != null &amp;&amp; txtNumber1.Text != "") { _num1= long.Parse(txtNumber1.Text); } if (txtNumber2.Text != null &amp;&amp; txtNumber2.Text != "") { _num2= long.Parse(txtNumber2.Text); } Add(22, "Kati", _num1, _num2) </code></pre> <p>but Error <code>_num1</code> &amp; <code>_num2</code> in <code>Add(...)</code>.</p> <p>Error:</p> <blockquote> <p>Use of unassigned local variable '_num1'</p> <p>Use of unassigned local variable '_num2'</p> </blockquote>
c#
[0]
913,717
913,718
C# Richtext box MouseOver
<p>How to get the <code>MouseOver</code> text in a <code>RichTextBox</code>. I have tried using <code>GetCharIndexFromPosition</code> by passing it the cursor location. But it is always giving me the index of a character which is close to the mouse location, even if I am moving the mouse onto the <code>RichTextBox</code> (empty space) it is giving some character index which is closer to the mouse location.</p>
c#
[0]
5,245,656
5,245,657
Parsing groupings of strings (Python)
<p>I have a string that looks something like this:</p> <pre><code>[["Name1","ID1","DDY1", "CALL1", "WHEN1"], ["Name2","ID2","DDY2", "CALL2", "WHEN2"],...]; </code></pre> <p>This string was taken from a website. There can be any amount of groupings. How could I parse this string and print just the Name variables of each grouping?</p>
python
[7]
2,962,336
2,962,337
Set a DIV height equal with of another DIV
<p>I have two DIVs, .sidebar and .content and I want to set .sidebar to keep the same height with the .content.</p> <p>I've tried the following:</p> <pre><code>$(".sidebar").css({'height':($(".content").height()+'px'}); $(".sidebar").height($(".content").height()); var highestCol = Math.max($('.sidebar').height(),$('.content').height()); $('.sidebar').height(highestCol); </code></pre> <p>None of these are working. For the .content I don't have any height since will increase or decrease based on the content.</p> <p>Please help me. I have to finish up a web page today and this (simple) thing is giving me headaches.</p> <p>Thank you!</p>
jquery
[5]
4,938,874
4,938,875
JQuery Select Element Based On Criteria
<p>I have a drop down box for each row inside a table</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;th&gt; &lt;select name="priorityID" id="priorityID"&gt; &lt;option label="Important" value="1" selected="selected"&gt;Important&lt;/option&gt; &lt;option label="semi important" value="2"&gt;semi important&lt;/option&gt; &lt;option label="normal" value="3"&gt;normal&lt;/option&gt; &lt;option label="not important" value="4"&gt;not important&lt;/option&gt; &lt;/select&gt; &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt; &lt;select name="priorityID" id="priorityID"&gt; &lt;option label="Important" value="1" selected="selected"&gt;Important&lt;/option&gt; &lt;option label="semi important" value="2"&gt;semi important&lt;/option&gt; &lt;option label="normal" value="3"&gt;normal&lt;/option&gt; &lt;option label="not important" value="4"&gt;not important&lt;/option&gt; &lt;/select&gt; &lt;/th&gt; </code></pre> <p> </p> <p>The issue is now whenever the <code>priorityID</code> changes, I need to call a JQuery function to update the database. Now since each row has its own drop down box, how to write the JQuery in such a manner that at the JQuery side, it can capture which row's drop down box firing the event?</p>
jquery
[5]
5,114,063
5,114,064
How can i call class from aspx file?
<p>i have a class which is in App_Code/Kerbooo.cs <br>i want to call that class's method from aspx file (not from code behind) <br>is it possible? if it is, how can i do? <br>thank you very much already now.</p>
asp.net
[9]
4,252,007
4,252,008
C# streamreader split question
<p>What i'm trying to do is open a config file. For each object this config file references it uses the tags BEGINOB ENDOB. I'm trying to read the while thing and Split on ENDOB, and IF the first set contains BEGINOB+"\r\n"+"13" write all the contents to a console line. I have this code here but i'm having a hard time figure out my split.</p> <pre><code>using (FileStream redfs = new FileStream(redfoldertarget, FileMode.Open)) using (StreamReader rdrred = new StreamReader(redfs)) { while (!rdrred.EndOfStream) { string linesplitnew = "ENDOB"; string[] redsplitline = rdrred.ReadToEnd().Split(Convert.ToString(linesplitnew)); string redpullline = "BEGINOB"+"\r\n"+"13"; if(redsplitline.Contains(redpullline)) { Console.WriteLine(redsplitline); } } } </code></pre>
c#
[0]
1,405,128
1,405,129
How can you run a Java program without main method?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8605137/printing-message-on-console-without-using-main-method">Printing message on Console without using main() method</a> </p> </blockquote> <p>Can someone suggest how can a JAVA program run <strong>without</strong> writing a <strong>main method</strong>..</p> <p>For eg:</p> <pre><code>System.out.println("Main not required to print this"); </code></pre> <p>How can the above line be printed on console <strong>without</strong> using the <strong>public static void main(String arg[])</strong> in the class.</p>
java
[1]
1,627,238
1,627,239
Why is there no "external" access modifier?
<p>Maybe I'm missing something but shouldn't C# have an external access modifier for methods? Ie an modifier that make an method public but only for other classes, ie the the method cannot be called by the class itself?</p> <p>Wouldn't that be useful for things like public methods that do locking to ensure that the lock isn't reentred from within the class?</p>
c#
[0]
719,147
719,148
insert data into database using php
<p>Hi please I am trying to insert data from a url into my data base when I enter data directly, it works but when I try to use the url method it stops working. </p> <p>Can u please help look through the code and c what i am doing wrong</p> <p>Heres my code:</p> <p> <pre><code>$flight_Number = $_GET['FlightNumber']; $arrival_Status = $_GET['ArrivalStatus']; $recipient_Email = $_GET['EmailAddress']; if (!$con) { die('Could not connect: ' . mysql_error()); } ***mysql_query("INSERT INTO landed (priKey, flightNumber, arrivalStatus, recipientEmail, confirmStatus) VALUES ('', '".$flight_Number."','".$arrival_Status."', '".$recipient_Email"' ,'')");*** #mysql_query("INSERT INTO landed (priKey, flightNumber, arrivalStatus, recipientEmail, confirmStatus) #VALUES ( '', '$_GET[FlightNumber]','$_GET[ArrivalStatus]','$_GET[EmailAddress]', '')"); #mysql_query("INSERT INTO landed (priKey, flightNumber,arrivalStatus, recipientEmail, confirmStatus) #VALUES ( '', 'AK81','Landed', 'soulreaver19802001@yahoo.com', '')"); echo "Database updated with: " .$flight_Number. " ".$arrival_Status.; mysql_close($con); </code></pre> <p>?></p>
php
[2]
2,814,684
2,814,685
Table row length in javascript show one extra
<p>I have a table with an id of <code>myPicks</code> and when I execute the code below, the result is always one more than of the number of rows I have? Is this how it's suppose to behave? Thanks.</p> <pre><code>var table =document.getElementById("myPicks"); var rowCount = table.rows.length; </code></pre>
javascript
[3]
5,586,769
5,586,770
jQuery select elements with incrementing ID's
<p>I would like to select list items based on their incrementing ID's but I am having a bit of trouble. Thoughts? </p> <pre><code>$(document).ready(function () { var listCount = 1; $('#listitem-' + listCount + ' a').hover(function() { $('#anotheritem-' + listCount).show(); return false; }); listCount++; }); </code></pre> <p>HTML:</p> <pre><code>&lt;ul id="cap"&gt; &lt;li id="listitem-1"&gt;&lt;a href="#"&gt;content 1&lt;/a&gt;&lt;/li&gt; &lt;li id="listitem-2"&gt;&lt;a href="#"&gt;content 2&lt;/a&gt;&lt;/li&gt; &lt;li id="listitem-3"&gt;&lt;a href="#"&gt;content 3&lt;/a&gt;&lt;/li&gt; &lt;li id="listitem-4"&gt;&lt;a href="#"&gt;content 4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div style="display:none;" id="anotheritem-1"&gt;hello 1&lt;/div&gt; &lt;div style="display:none;" id="anotheritem-3"&gt;hello 3&lt;/div&gt; &lt;div style="display:none;" id="anotheritem-3"&gt;hello 3&lt;/div&gt; &lt;div style="display:none;" id="anotheritem-4"&gt;hello 4&lt;/div&gt; </code></pre> <p>UPDATED Question. I'm trying to achieve the following revision of the answer:</p> <pre><code>$('.listitem_to_hover').hover(function () { var senderID = sender.id.replace('listitem-', ''); $('#anotheritem-' + senderID).show(); }, function () { var senderID = sender.id.replace('listitem-', ''); $('#anotheritem-' + senderID).hide(); }); </code></pre>
jquery
[5]
402,312
402,313
JQuery Change Class With Animate
<p>I am making a side menu that pops out when you click the tab. I have come to the point where I do not know how to continue on, I need the class on the tab div to change to "sideopen" when it is clicked. I have tried <code>attr();</code> and I also tried <code>removeClass();</code> and <code>addClass();</code> but to no avail.</p> <p>Here is the code on JSFiddle: <a href="http://jsfiddle.net/bGKvR/" rel="nofollow">http://jsfiddle.net/bGKvR/</a></p> <p>Also, I am a newbie to JS/JQuery so any advice to cleaning the code up is extremely appreciated.</p>
jquery
[5]
1,323,875
1,323,876
Why does List<T> implement IList<T>, ICollection<T> and IEnumerable<T>?
<p>If you go to definition of <code>List&lt;T&gt;</code> you would see the following:</p> <pre><code>public class List&lt;T&gt; : IList&lt;T&gt;, ICollection&lt;T&gt;, IEnumerable&lt;T&gt; </code></pre> <p><code>IList&lt;T&gt;</code> already inherits from both <code>ICollection&lt;T&gt;</code> and <code>IEnumerable&lt;T&gt;</code>.</p> <p>Wouldn't it have been sufficient if <code>List&lt;T&gt;</code> only implemented <code>IList&lt;T&gt;</code>?</p>
c#
[0]
566,179
566,180
How to add a 'new button' near to a new product(only) in asp dot net storefront ml8?
<p>When a new product is added, a small new image should be shown near to that product in the product listing page. The old products in the same page should not have this image near it. I am using storefront ml8+xml+xsl.</p>
asp.net
[9]
191,341
191,342
FileSystemWatcher, unsubscribe from the event
<p>I'm fooling around with the FileSystemWatcher in 4.0. I find this very useful but am getting caught in a loop. I'm trying to monitor whenever an ini is changed and change it back to the correct default (long story) however the change event copying over the new file is causing it to drop into a loop ... Any Ideas > ? I played around with the idea of deleting and recreating thefile to avoid triggering the changed event but this leads to another set of issues with the program that I'd rather avoid. Also I'd imagine I could overwrite the text but this also poses the same issue. Thanks in advance for the help</p> <pre><code> static void Main() { Watch (@"\\NoFault2010\Lexis\Data\Setup\", "tmconfig.ini", true); } static void Watch (string path, string filter, bool includeSubDirs) { using (var watcher = new FileSystemWatcher (path, filter)) { watcher.Changed += FileChanged; watcher.EnableRaisingEvents = true; Console.WriteLine("Do Not Close ... \n\nThis is a Temporary Configuration Manager for Time Matters ... \n\n\nI'm Listening ............"); Console.ReadLine(); } } static void FileChanged (object o, FileSystemEventArgs e) { string _right_stuff = @"\\NOFAULT2010\Lexis\Data\Templates\Programs\tmconfig.ini"; string _working = @"\\NOFAULT2010\Lexis\Data\Setup\tmconfig.ini"; System.Threading.Thread.Sleep(2000); File.Copy(_right_stuff, _working, true); Console.WriteLine("File {0} has been {1}", e.FullPath, e.ChangeType); MAIL_IT("SQLMail@lcjlawfirm.com", "TM Master.INI has been altered", "Check the Master INI and Yell At Ecopy Guy " + e.ChangeType + e.FullPath); } </code></pre> <p>How would I unsubscribe from the event to avoid entering into this loop.</p>
c#
[0]
5,068,825
5,068,826
How to add alert dialog onKeyDown?
<p>I have this code on my application </p> <pre><code>@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent a = new Intent(this,a_stages.class); a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(a); return true; } return super.onKeyDown(keyCode, event); } </code></pre> <p>now I want to add an alert dialog that will ask the user if he/she wants to go, for example on another page, if the user clicks on yes, it will intent to a specific page and if the user clicks on cancel, dialog.cancel();.</p> <p><strong>EDIT</strong> I tried this code but I got an error on the line "Intent a = new Intent(this,a_stages.class);" that says "The constructor Intent(new DialogInterface.OnClickListener(){}, Class) is undefined" </p> <pre><code>@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(bq1.this); // Setting Dialog Title alertDialog.setTitle("Go back to home"); // Setting Dialog Message alertDialog.setMessage("Are you sure you want to go back to home?"); // Setting Positive "Yes" Button alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int which) { Intent a = new Intent(this,a_stages.class); a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(a); } }); // Setting Negative "NO" Button alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke NO event dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } return super.onKeyDown(keyCode, event); } </code></pre>
android
[4]
1,351,035
1,351,036
Java Millis to nanoseconds
<p>I have just started to learn Java, and I want to make random array and to measure time. I used <code>System.currentTimeMillis();</code> at the beginning of filling my array, and the same at then and. Then I wanted to convert milliseconds to nanoseconds and used <code>long total=TimeUnit.MILLISECONDS.toNanos(time1);</code> but trouble occurred:</p> <pre><code>import java.util.*; import java.util.concurrent.TimeUnit; public class main { public static void main(String[] args) { long time1,time2,time3; int [] array = new int[10]; Random rand =new Random(100); time1=System.currentTimeMillis(); for(int i=0;i&lt;array.length;i++){ array[i]=rand.nextInt(100); } time2=System.currentTimeMillis()-time1; long total=TimeUnit.MILLISECONDS.toNanos(time1); System.out.println("Time is:"+time1 ); } } </code></pre> <p>In the end I got 'Time is:1361703051169;' I think that something's wrong with this.</p>
java
[1]