Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
3,531,505
3,531,506
PHP array_diff weirdness
<p>This is such a simple problem but the PHP doc does not explain why it is happening.</p> <p>I have this code:</p> <pre><code>var_dump($newattributes); var_dump($oldattributes); var_dump(array_diff($newattributes, $oldattributes)); </code></pre> <p>For briefity I am going to omit large parts of the structure I am actually using (since each is 117 elements long) and cut to the case.</p> <p>I have one array called <code>$newattributes</code> which looks like:</p> <pre><code>array(117){ // Lots of other attributes here ["deleted"] =&gt; int(1) } </code></pre> <p>And another called <code>$oldattributes</code> which looks like:</p> <pre><code>array(117){ // Lots of other attributes here ["deleted"] =&gt; string(1) "0" } </code></pre> <p>Which looks different right? According to <code>array_diff</code>: no. The output I get from <code>array_diff</code> is:</p> <pre><code>array(0) { } </code></pre> <p>I have read the documentation page however it says:</p> <blockquote> <p>Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same.</p> </blockquote> <p>And I am not sure how "1" can object equal "0".</p> <p>So am I seeing some caveat with <code>array_diff</code> I didn't take into consideration?</p>
php
[2]
3,035,677
3,035,678
.net DirectoryInfo wild card pattern to handle exclusion
<p>The following method call returns all xml files in the given directory. </p> <pre><code>FileInfo[] Files = Directory.GetFiles("*.xml"); </code></pre> <p>I would like to get all XML files in the directory where the fileName does not end with "_update.xml"</p> <p>for example.... if I have the following files</p> <pre><code>ABC.xml ABC2.xml ABC3_update.xml </code></pre> <p>then I want a call that will only return:</p> <pre><code>ABC.xml ABC2.xml </code></pre> <p>Is this possible?</p>
c#
[0]
3,734,020
3,734,021
Export a html page to pdf with everything that's written on it, after submit button
<p>I need to export html page to pdf file with everything that's written in it, after I press submit button. It will open new page, with info, and I need for script to automatically make .pdf file (already uploaded to webserver), and get the link from file. Could you give me some easy example (if available, without any plugins, or other features that I must download, I would prefer clean PHP).</p>
php
[2]
5,615,972
5,615,973
Application force closes on call
<p>I have This application that "runs it the background" well its supposed to. the problem is when I get a phone call the application forcecloses. How would I get it to truly run in background?</p>
android
[4]
2,152,348
2,152,349
Using an array to set variable name
<p>I'm trying to use some mysql data in creating part of a variable name to refer to another variable already declared elsewhere. Basically how can I get the $damage_name be part of the if statement boolean check?</p> <pre><code>$conditions = array( 'bent_num' =&gt; 0, 'spine_torn' =&gt; 0, 'pages_torn' =&gt; 0, 'water_damage' =&gt; 0, 'pages_highlighted' =&gt; 0, 'pages_noted' =&gt; 0, 'taped' =&gt; 0, 'stained' =&gt; 0, 'mold' =&gt; 0, 'scratched' =&gt; 0 ); while ($row = mysql_fetch_assoc($res)) { $damage_name = $conditions[$row['type']]; if (isset($conditions[$row['type']]) &amp;&amp; $_SESSION[SELL_is_ . $damage_name . ]; == 'y') { $condition_score = $condition_score - $row['value']; } } </code></pre>
php
[2]
1,358,053
1,358,054
Kinetic JS func is not return object
<pre><code>function create(x,y,imagePath,imageWidth,imageHeight) { return new Kinetic.QImage({ x: x, y: y, image: images.Grid, width: imageWidth, height: imageHeight, }); } var a = create(100,100,images.Grid,96,96); </code></pre> <p>Why didn't this work?</p>
javascript
[3]
1,200,177
1,200,178
Progressbar togther with asyncTask
<p>I want to use a progressbar on my screen isntead of progressDialog.</p> <p>I have inserted a progressBar on my XML-view file, and I want to make it show when it loads and when disable it when not loading, </p> <p>so I was using visible, but it takes place, so rest of the data comes down, </p> <p>How should I use progressbar in a asynctask, and how can I make it show, and disshow</p>
android
[4]
3,237,568
3,237,569
PHP mkdir: Permission denied problem
<p>I am trying to create a directory with PHP mkdir function but I get an error as follows: <code>Warning: mkdir() [function.mkdir]: Permission denied in ...</code>. How to settle down the problem?</p>
php
[2]
700,546
700,547
Google Play Developer Console dashboard, where is it?
<p>I've been searching on stackoverflow and other places, but all I find is that the dashboard has been updated and it's accessible from developer console listings page. All I see next to my app is "x total installs" etc, no link to any dashboard?</p>
android
[4]
5,487,838
5,487,839
php array help. Getting the correct content
<p>I have an array like so:</p> <pre><code>Array ( [level] =&gt; Array ( [0] =&gt; Array ( [lvlName] =&gt; name [lvlEnt] =&gt; ent ) ) [title] =&gt; Array ( [0] =&gt; Array ( [title] =&gt; a title [titleDesc] =&gt; desc here ) ) [navBar] =&gt; Products [pageContent] =&gt; About ) </code></pre> <p>Can someone please tell me how to get the pageContent?</p> <p>Here is the code that I am using but I am getting undefined indexes. I have no idea where I am going wrong.</p> <pre><code>foreach($bigArr as $key=&gt;$val) { if($key['pageContent'] != null) { foreach($val as $fkey=&gt;$fval) { echo $fkey['pageContent']; } } } </code></pre> <p>The loops give me:</p> <pre><code>PHP Notice: Undefined index: pageContent PHP Warning: Invalid argument supplied for foreach() </code></pre> <p>Can someone please give me a hand with this? Thanks</p> <p>EDIT: The invalid argument is what has me perplexed.</p>
php
[2]
4,582,880
4,582,881
Java select a file location
<p>I'm not sure if this is even possible as I can't find anything about it after quite a few Google searches.</p> <p>What I would like to do is on event open up a file dialog box and allow the user to select a folder and then store that folders full directory in a string. So if a user selected a folder in C:\Windows\Example the directory would be stored in String fileDir = C:\Windows\Example;</p> <p>Does this make sense? I hope so as I'm struggeling to find the answer. I do apperciate the help, thanks in advance for looking and more thanks if you help me :) </p>
java
[1]
80,143
80,144
Java Remote File Options
<p>I've recently started an internship and I'm having some issues with Java in the enterprise environment. I've been assigned the task of porting the functionality of an old windows shell script to java so it may be ran on one of our JVMs.</p> <p>The shell script runs on one of the Windows servers and grabs the previous days log files from a couple of linux boxes then FTPs them to another Windows machine. </p> <p>I'm not quite sure how to achieve this functionality using java. I only can SSH into the linux boxes. I have got the connection working for the Windows file share, just not sure of the best way to connect to the linux boxes. </p> <p>I've considered using one of the SSH libraries, but would prefer to avoid using a third party library. </p> <p>Any insight would be great. Thanks!</p>
java
[1]
3,221,121
3,221,122
Associative array - move an element to first position
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5783750/php-add-item-to-beginning-of-associative-array">PHP - add item to beginning of associative array</a> </p> </blockquote> <p>have associative array:</p> <pre><code>$myarray=array("key1"=&gt;"value1","key2"=&gt;"value2"); </code></pre> <p>Need to add a new element to array:</p> <pre><code>$myarray["keynew"]="valuenew"; </code></pre> <p>So now $myarray is:</p> <pre><code>Array ( [key1] =&gt; value1 [key2] =&gt; value2 [keynew] =&gt; valuenew ) </code></pre> <p>How can I move the new added element ("keynew"=>"valuenew") to the first position of the array?</p> <p>I have an workaround, but I don't like it.</p> <pre><code>$myarray=array("key1"=&gt;"value1","key2"=&gt;"value2"); $myarray["keynew"]="-valuenew"; asort($myarray); $myarray["keynew"]="valuenew"; //$myarray=Array ( [keynew] =&gt; valuenew [key1] =&gt; value1 [key2] =&gt; value2 ) </code></pre> <p>Thank you.</p>
php
[2]
940,575
940,576
shorthand way to create dictionary key if it does not exist
<p>I have a dictionary of zoo animals. I want to put it into the dictionary in a nested dictionary but get a KeyError because that particular species has not been added to the dictionary.</p> <pre><code>def add_to_world(self, species, name, zone = 'retreat'): self.object_attr[species][name] = {'zone' : zone} </code></pre> <p>Is there a shortcut to checking if that species is in the dictionary and create it if it is not or do i have to do it the long way and manually check if that species has been added?</p>
python
[7]
1,954,204
1,954,205
Fastest way to remove all multiple occurrence items from a list?
<p>What is the fastest way to remove all multiple occurrence items from a list of arbitrary items (in my example a list of lists)? In the result, only items that occur a single time in the list should show up, thus removing all duplicates.</p> <p>input: [[1, 2], [1, 3], [1, 4], [1, 2], [1, 4], [1, 2]]</p> <p>output: [[1, 3], ]</p> <p>This solution was slow:</p> <pre><code>output = [item for item in input if input.count(item)==1] </code></pre> <p>This solution was faster:</p> <pre><code>duplicates = [] output = [] for item in input: if not item in duplicates: if item in output: output.remove(item) duplicates.append(item) else: output.append(item) </code></pre> <p>Is there any better solution, probably by first sorting the list? Any ideas are appreciated.</p>
python
[7]
2,189,345
2,189,346
Receiving an ACTION_SEND intent from the Gallery
<p>I am trying to receive an image from the Android Gallery via an ACTION_SEND intent. I have set the proper intent filters and the Gallery opens my app. Now I want to know how to get at the image data. I can't find any examples on the internet of how this is done. I figure the path is somewhere in intent.getData() but how exactly do I pull that image from the gallery?</p>
android
[4]
2,806,369
2,806,370
Efficient programming
<p>What are some examples of increasing efficiency, improving performance? This is a broad question, so feel free to talk about any examples of where you rewrote code and made it run faster...</p>
c++
[6]
1,924,428
1,924,429
PHP Zip File Empty?
<p>I have a script that creates a zip files from files in a certain directory. After Download, for a lot of users - the zip file is empty. However, for other users - the file isn't empty. Is it something I'm doing wrong?</p> <pre><code>header('Content-type: application/zip'); header('Content-Disposition: attachment; filename="'.$id.'.zip"'); header('Cache-Control: private'); ob_clean(); flush(); readfile("".$id.".zip"); exit; </code></pre>
php
[2]
739,948
739,949
Which of these are getting called?
<p>Say I have the following code:</p> <pre><code>struct date { int day; int month; int year; }; class mydateclass { public: int day; int month; int year; }; mydateclass date; date.day; </code></pre> <p>Which <code>date</code> variable is being referred to? The <code>date</code> instance named <code>mydateclass</code>, or the <code>date</code> struct?</p>
c++
[6]
260,676
260,677
The operation could not be completed.Access is denied
<p>I have formatted my computer and windows 7 enterprise edition is installed. <br/>I installed Microsoft visual studio 2005.<br/> Now while opening my old asp.net programs it shows </p> <p>"<code>The operation couldn't be completed.</code><br/><code>Access is denied."</code></p> <p>Please help me</p>
asp.net
[9]
4,512,313
4,512,314
how to make software faster
<p>It seem that when I re run my .net application , it became much faster than before , why ?</p> <p>Also is there anyway for my software to be run faster on startup ?</p> <p>regards</p>
c#
[0]
649,246
649,247
how to bind the asp.net dropdownlist items to the datatable columns of sql server?
<p>Below is my code...</p> <pre><code>SqlCommand da = new SqlCommand("select time_stamp,'" + DropDownArray[i].SelectedItem.ToString() + "' from data_104 where time_stamp between '" + FromTime_DropDown.SelectedValue.ToString() + "' and '" + ToTime_DropDownList.SelectedValue.ToString() + "' order by time_stamp", con); SqlDataReader dr = da.ExecuteReader(); Individual_Chart.Visible = true; Individual_Chart.DataSource = dr; Individual_Chart.Series[i].XValueMember = "time_stamp"; Individual_Chart.Series[i].YValueMembers = DropDownArray[i].SelectedItem.ToString(); Individual_Chart.DataBind(); con.Close(); </code></pre> <p>even though dropdown item name and column name of table are same i'm getting the error that the selected item not found. ex: "PV Voltage not found"</p>
asp.net
[9]
4,427,000
4,427,001
C# text formating problem
<p>What I have is a text file that contains lines in the following format</p> <pre>Apple000010095|C:\il_ig\IMPED_IMS\AR001\AR\00\01\|00\{95-99}.TXT; 01\00.TXT; 01\00.TXT|7</pre> <p>Format is: Begining File | Location | files ;=multi entry| total files for all entries </p> <p>so for the above text I would need to export to a new file:</p> <pre>Apple000010095|C:\il_ig\IMPED_IMS\AR001\AR\00\01\|00\{95-99}.TXT|5 Apple000010100|C:\il_ig\IMPED_IMS\AR001\AR\00\01\|01\00.TXT|1 Apple000010101|C:\il_ig\IMPED_IMS\AR001\AR\00\01\|01\01.TXT|1 </pre> <p>any help would be awesome!</p>
c#
[0]
4,561,858
4,561,859
Selected Listbox item to be displayed in textbox using jquery
<p>I have a task to Append Selected multiple items being selected from a listbox to a Textbox. I have tried Implementing the code using Jquery as:</p> <pre><code>$("#&lt;%= ListBlankToken.ClientID %&gt;").change(function () { var SelectedITem = $("#&lt;%= ListBlankToken.ClientID %&gt;").select.toString(); $("#&lt;%= txtManagedocumentpage.ClientID %&gt;").append(SelectedITem); }); </code></pre> <p>It doesn't append selected item into a textbox.Thanks for any assistance.</p>
jquery
[5]
4,855,653
4,855,654
Newbie in jQuery - focusIn and out on textareas
<p>I'm stuck with my code. I use the focusin() function to detect the user interaction on a textarea. My concept: </p> <ul> <li>first init => all are collapsed with auto-height (50px)</li> <li>first focus-in => the focused element will be expanded to more pixels (150px)</li> <li>and now, I know, every time I get a new focusin on any of my elements, I had one, that are currently opend. Therefore I created a primitive routine for that idea:</li> </ul> <hr> <pre><code>var active = false; myTextAreas.focusin(function() { if (active == true) { myTextAreas.animate({"height" : 50}, 300); $(this).animate({"height" : 150}, 500); } else { $(this).animate({"height" : 150}, 500); active = true; }; </code></pre> <p>myTextAreas => Object with my HTML-elements (textareas). First time => do the else, second time => always the if-statement, which resizes all elements every time back AND than move my element up to more height. It works principally, BUT the first time when I do my little script, my box is resizing first and against the end the other box, which are the new focused-in-one, are starting too early with the new animate() function. Then it works... hmmm. But I think my code is not so pretty?</p> <p>One feature I miss in my concept. When I focusout of any textarea, I want to animate all elements back, similar to the effect in my if-statement. But how can I say, do that, but only on the rest of my elements and not on my focus-in-textareas? </p> <p>Maybe my concept is bad? I'm opened for a new one ... by the way.</p>
jquery
[5]
147,379
147,380
viewport tutorial
<p>I am making a game on Android and have created the 3D objects from blender.The object has been loaded perfectly with the help of Min3D (3ds format) but the following problem arises: 1. the texture is not loaded and the problem arises.</p>
android
[4]
605,850
605,851
how to GetType of List<String> in c#?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/721870/c-how-can-i-get-type-from-a-string-representation">C# How can I get Type from a string representation</a> </p> </blockquote> <p>how can i get the type of <code>"List&lt;String&gt;"</code> in c# using <code>Type.GetType()</code>?<br> i have already tried</p> <pre><code> Type.GetType("List&lt;String&gt;"); Type.GetType("System.Collections.Generic.List.String");//or [String] </code></pre> <p>note that i can't use <code>typeof</code> since the value i am getting the type of is a string. </p>
c#
[0]
288,279
288,280
Derived from a base class that implements an interface
<p>I get from <a href="http://rads.stackoverflow.com/amzn/click/0321245660" rel="nofollow">Effective C#</a> Item 23 that the following code should print: <code>MyDerivedMessage</code></p> <pre><code>namespace ConsoleApplication1 { interface IMsg { void message(); } public class MyMessage : IMsg { public void message() { Console.WriteLine("MyMessage"); } } public class MyDerivedMessage : MyMessage { public new void message() { Console.WriteLine("MyDerivedMessage"); } } class Test { static void Main() { MyDerivedMessage mdm = new MyDerivedMessage(); IMsg im = mdm as IMsg; im.message(); } } } </code></pre> <p>Book:</p> <pre><code>public class MyDerivedClass : MyClass { public new void Message() { Console.WriteLine("MyDerivedClass"); } } </code></pre> <p>The addition of the IMsg keyword changes the behavior of your derived class so that IMsg.Message() now uses the derived class version:</p> <pre><code>MyDerivedClass d = new MyDerivedClass(); d.Message(); // prints "MyDerivedClass". IMsg m = d as IMsg; m.Message(); // prints " MyDerivedClass " </code></pre> <p>How come I still get <code>MyMessage</code> printed after I add "new" to <code>MyDerivedMessage::message()</code> ?</p>
c#
[0]
2,513,238
2,513,239
jquery - troubleshooting this jquery code
<p>I am writing this routine where users can click on 3 buttons and the help divs will appear.</p> <p>If the users click on any of the 3 buttons, the help divs will toggle and appear accordingly. This appears to be done correctly with the code.</p> <p>If the users click on the "close" button inside the help div, the help div will disappear. This seems to be done correctly too.</p> <p>If the users click outside of the help window (but not on the buttons), the window will also close. This seems to be OK too. </p> <p>But I am getting into a roadblock where I want the help window to stay open if the users click anywhere inside the help window except the close button.</p> <p>My code is on jsfiddle here <a href="http://jsfiddle.net/nzMAw/2/" rel="nofollow">http://jsfiddle.net/nzMAw/2/</a>, I commented out the jquery line (near the end) that is giving me the problem. It does not seem to get executed correctly when the script is run for the first time. That is if I press any button for the first time, the help window will popup, but it will close if I click inside the window. But after that, when I press the button again to open up the help window, the problematic code prevents the 'close' from closing the window. </p> <p>I really appreciate any insight here.</p> <p>TIA</p> <pre><code>$(function(){ $(document).click(function(event){ var id = event.target.id; //var id=$(this).attr('id'); //alert (id); if (id == 'close') { $(".aa").fadeOut("slow"); } else if (id == '1' || id == '2' || id == '3' ) { $(".aa").filter('#'+id+"div").fadeToggle("slow").end().not('#'+id+"div").fadeOut("slow").end(); //2 ends for not and filter destructive methods. } else { //$(".aa").click(function(){ return false; });//this statement is the problem $(".aa").fadeOut("slow"); } }); }); </code></pre>
jquery
[5]
1,166,735
1,166,736
Java Scope: Returning an object instantiated inside a method - Is it dangerous?
<p>I'm a student in Java class and learned something about Java today that made my gears turn. When I asked the teacher how and why, he wasn't sure about the behavior. Can anyone explain why the following example works?</p> <pre><code>class Example { public int ex_val; public Example (int a) { this.ex_val = a; } public int getExVal () { return this.ex_val; } } </code></pre> <p>If I were to create an instance of "Example" inside a method of another class and "return" the object, it can successfully make the jump out of it's original scope and be used subsequently.</p> <pre><code>class ParentObject { // Instance Variables public Example a; public ParentObject (int number) { // Initialize instance variable object from out-of-scope instantiation this.a = genExample(number); // Verify scope creep System.out.println(this.a.getExVal()); } public Example genExample (int a) { return new Example(a); } } </code></pre> <p>This DOES work, but is this behavior stable? Can I count on this? Can the garbage collector jump in between the return statement of one method and assignment statement of the calling function? Am I running the risk of failure based on my OS's version of the JVM? This seems like handy functionality if it can be relied upon.</p>
java
[1]
5,179,239
5,179,240
javascript storing key value inside object
<p>I have some json strings that look like that:</p> <pre><code>var TheJson = "{Key:[array of objects]}" </code></pre> <p>Key is actually a date and the json contains arrays of objects. I want to add this object to another object <code>HistoryOfData</code>, sort of like the <code>.push</code> method on arrays. Basically, I want the <code>HistoryOfData</code> object to have key value nested objects where the keys are dates and the values are arrays of data.</p> <p>How do I push an object into another object? </p>
javascript
[3]
3,731,012
3,731,013
Capturing image from Camera, it stores at sdcard/dcim folder
<p>I am capturing image by using camera in my app.</p> <p>1) it saves image at sdcard, with the name which i passed in intent.</p> <p>2) also saving the image at sdcard/dcim folder</p> <p>I do not want camera to save image at location mentioned in # 2. i am deleting image from the location in #1. and want to delete image from location in #2 too.</p> <p>Below is the code snippet for capturing image.</p> <pre><code> SD_CARD_TEMP_DIR = Environment.getExternalStorageDirectory() + File.separator + "tempImage.jpg"; file =new File(SD_CARD_TEMP_DIR); Intent takePictureFromCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePictureFromCameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); startActivityForResult(takePictureFromCameraIntent, TAKE_PICTURE_WITH_CAMERA); </code></pre>
android
[4]
2,326,963
2,326,964
Calculating future date using php strtotime() not give right answer
<p>I want to get future date after specific date for this i use <code>strtotime()</code> function but it not work for me</p> <p>then I use following code</p> <pre><code>$d1='2012-11-08'; $d2=date($d1, strtotime('+3 days')); echo $d2; </code></pre> <p>output is 2012-11-08 2012-11-08</p> <p>not 2012-11-11</p> <p>but output is not 2012-11-11 output is 2012-11-08 i can't solve this what is error i do and how i solve this? </p>
php
[2]
1,003,527
1,003,528
jQuery, .empty() and memory
<p>my application (ASP.NET MVC) shows a page which loads data constantly, at certain intervals.</p> <p>The jQuery script calls a controller and this one renders a different partial view, based on certain conditions.</p> <p>This partial view is the appended to the DOM with jQuery; previous elements are removed with the empty() method.</p> <pre><code> $(document).ready(function() { var ScheduledAction = function(func, times, interval) { var ID = window.setInterval(function(times) { return function() { if (times &gt; -1) { if (--times &lt;= 0) window.clearInterval(ID); } func(); } } (times), interval); }; ScheduledAction(function() { LoadAppointments(); }, -1, &lt;%=Model.RefreshTimeout %&gt;); }); function LoadAppointments() { $("#AppointmentsList").empty(); $('#loading').html("&lt;img src='Images/bigloader.gif' /&gt;"); $.get(UrlAction, function(data) { if (data != '') { $('#AppointmentsList').append(data); $('#loading').empty(); } else { $('#loading').fadeOut(3000, function() { $('#loading').empty(); }); } }); } </code></pre> <p>The controller (UrlAction) returns a partial view. For Each roundtrip the partial view is different. Once the partial view contains just an image. In the other situation is a div with some infos.</p> <p>I've realized that after one day the browser loads something like 600Mb of memory. What am I doing wrong?</p>
jquery
[5]
5,258,697
5,258,698
URL rewriting in ASP.NET turning http://site.com/abcd into http://site.com/page.aspx?id=abcd
<p>I have a problem in my web forms ASP.NET app where I would like to rewrite a url from</p> <p><a href="http://site.com/abcd" rel="nofollow">http://site.com/abcd</a> </p> <p>into </p> <p><a href="http://site.com/page.aspx?id=abcd" rel="nofollow">http://site.com/page.aspx?id=abcd</a></p> <ul> <li>the <strong>abcd</strong> part will be unique and I cant create a folder for it</li> <li>I want the users to always see the <strong>http://site.com/abcd</strong> url</li> <li>would the solution be the same in Windows Azure?</li> </ul> <p>Can somebody please help me with some hints?</p> <p>Thank You!</p>
asp.net
[9]
3,130,758
3,130,759
Monitor applications
<p>how to monitor external applications(like notepad/word/exce/media players..) from java</p>
java
[1]
4,776,373
4,776,374
Serialize FileOutPut stream
<p>I have 2 classes: One that simulates a "server" and a second one. The idea is the server writes a file away with all the required data (usernames, psw, friends, etc...).</p> <p>Basicly the check login and register user code is all located in the server class and works just fine.</p> <p>But the problem occurs when i want to pass a List from the other class to the server class. In the server class this Lists also exists (for initializing (only once singleton)). This list is used to store all the info.</p> <p>So the intention is adding the data from other the class to the server class. (adding in the existing list for example phonenumbers).</p> <p>But then i get the error while trying to log in: </p> <pre><code>java.io.InvalidClassException: Implement.Server; local class incompatible: stream classdesc serialVersionUID = ... </code></pre> <p>What could be the cause of such a error? Both classes implement Serializable.</p>
java
[1]
2,907,014
2,907,015
I am having abc.mdf database in D drive and i want to use in my website using web.config?
<p>I am having abc.mdf database in D drive and i want to use in my website and i have tried as in web.config</p> <p></p> <p><strong>and i got following error</strong></p> <blockquote> <p>An attempt to attach an auto-named database for file D:\abc.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.</p> </blockquote> <p>I am sure database doesn't exists anywhere else.Please help</p>
asp.net
[9]
2,991,978
2,991,979
modified BufferedReader to ignore last line
<p>I want to use something like BufferedReader to read lines from a file but if the last line in the file does not end with a newline character, I would like it to be ignored. The standard BufferedReader will return the last line up to EOF, which is not what I want. So far, the best thing I've come up with is to copy the BufferedReader source, modify one line about handling EOFs and call it something like BufferedCompleteLineReader.. this doesn't seem very good though. Does anyone have a better idea?</p> <p>The background is there are multiple readers making requests to read a file that is periodically appended with a new line of text (i.e. a log file) but each new line is only valid if it ends with a newline char. If I read the last line while it's being modified I'll get bad data. But I don't want to impose file locking because performance is more important to me than completeness (for the reader).</p>
java
[1]
2,925,716
2,925,717
Invoke a constructor with the help of typeof
<p>I'm attemping a bit of a dance to get some classical polymorphism in javascript; something like</p> <pre><code>function Inherit(base, sub) { var baseType = typeof base; sub.prototype = new baseType(); } </code></pre> <p>Anyone have a clue as to how to do this without having to new up base prior to passing it in?</p>
javascript
[3]
2,953,349
2,953,350
Did Android Stop your thread when your device turn to sleep
<p>I am using </p> <pre><code>HandlerThread bThread = (new HandlerThread("backendHandler_thread", Process.THREAD_PRIORITY_BACKGROUND); bThread.start(); backendHandler = new Handler(bThread.getLooper()); </code></pre> <p>then </p> <pre><code>backendHandler.postDelay(xxx, xxxx); </code></pre> <p>and found that this task don't run when the device turn to sleep and will come back to run after it wake up</p> <p>I am testing on Samsung i9000 with original 2.1 Rom</p>
android
[4]
5,016,137
5,016,138
Button after click doesn't work
<p>I have a strange problem. When I run app and click button (btn_eng or btn_pl) i see log in logcat ("Erase dialog" or "Erase dialog PL") but next time when i click it does't show up and button doesn't do their onClick action. I tried to make buttons to change language. In my app I have a dialog with data form Resources (string array) and when I change language i want erase dialog and make new with adequate data.</p> <pre><code> //public static Activity act; -&gt; before onCreate(..) this.act = this; Button btn_eng = (Button) findViewById(R.id.btnEN); btn_eng.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d("XXX", "Erase dialog"); act.removeDialog(1); Locale locale = new Locale("en"); Locale.setDefault(locale); Configuration config = act.getBaseContext().getResources().getConfiguration(); config.locale = locale; act.getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); act.setContentView(R.layout.main); } }); Button btn_pl = (Button) findViewById(R.id.btnPL); btn_pl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d("XXX", "Erase dialog PL"); act.removeDialog(1); Locale locale = new Locale("pl"); Locale.setDefault(locale); Configuration config = act.getBaseContext().getResources().getConfiguration(); config.locale = locale; act.getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); act.setContentView(R.layout.main); } }); </code></pre>
android
[4]
1,988,577
1,988,578
Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive
<p>I'm trying to up load my site and I'm getting this error message:</p> <blockquote> <p>Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.</p> </blockquote> <pre><code>&lt;compilation debug="true" targetFramework="4.0"&gt; </code></pre> <p>The site works fine on my local pc but won't open when I loaded it to my host at tried to view it on line. </p>
asp.net
[9]
5,189,525
5,189,526
Music Player in android
<p>I have a music Player activity which receives stream url in onCreate method. While clicking on radio name it will play it. But how I can navigate to this running Music Player, onClick of Button from anywhere without sending intent to it.</p> <p>Help me.....</p>
android
[4]
2,304,679
2,304,680
Python Balanced sports schedule generation
<p>I have the following code sample</p> <pre><code>import itertools import random set_size = 2 schedule = set() teams = range(10) for comb in itertools.product(teams, repeat=set_size): comb = sorted(list(comb)) if len(set(comb)) == set_size: schedule.add(tuple(comb)) schedule = list(schedule) random.shuffle(schedule) home = {} for game in schedule: if home.has_key(game[0]): home[game[0]] += 1 else: home[game[0]] = 1 print home </code></pre> <p>It generates a valid schedule but the issue is some of the teams are very lopsided for home games. </p> <p>For example a print out of home is</p> <pre><code>{0: 5, 1: 3, 2: 5, 3: 5, 4: 5, 5: 5, 6: 5, 7: 5, 8: 4, 9: 3} </code></pre> <p>The key is the team and the value is the number of home games. If I have 10 teams in a league I expect some teams to get 5 home and others to get only 4 but some get 5 while others are getting only 3</p>
python
[7]
805,809
805,810
Is there a way to make an android app respond to hardware buttons while phone locked?
<p>I'm working on my first android app. So far I have an activity that reacts to clicks on the hardware volume controls. That's was easy to do, but I'm wondering if there is a way to make it so the app responds to these events from the hardware buttons even while the phone is locked?</p> <p>I'm really looking for a confirmation of whether or not this can be done. If someone could confirm and give me the general idea of how to do it that would be awesome.</p>
android
[4]
619,741
619,742
How to properly use global variables inside of class methods
<p>Currently I am re-vamping some code that I currently have written something like this:</p> <pre><code>&lt;?php global $foo; $foo = "foo"; class foo{ function bar(){ global $foo; return $foo."bar"; } } $class = new foo(); echo foo-&gt;bar(); //returns 'foobar'; ?&gt; </code></pre> <p>This works, just fine. My question is, is this the correct way to include the variables? Some of my class files have upwards of 20 global variables, that have to be redefined as global in every method that they are used in.</p>
php
[2]
4,742,999
4,743,000
PHP Datetime::format
<p>I would like to create a function which validates a date string.</p> <p>My module displays a date, and in the backend there are some example formats the user can use to display the date on the frontend, and also an advanced date format input where he can specify a date format string like 'H:i:s' or whatever he wants.</p> <p>If no advanced format option is specified, it uses the default format.</p> <p>To check the validity of the enterred format in the input, I thought I can do :</p> <p>$now = new Datetime('now');</p> <p>if (!$now->format($format)) .... false format</p> <p>But the format method doesn't return false if $format = x or efkjfkefefje, it just returns the string itself.</p> <p>I would like it to return false if there is a caracter that differs from the specified caracters here : <a href="http://www.php.net/manual/en/function.date.php" rel="nofollow">http://www.php.net/manual/en/function.date.php</a></p> <p>But there are so many cases. For example 'H:i:s' would be valid but 'His' Won't be.</p> <p>I don't want it to parse the ':' or '/', I mean we can consider that 'H/i/s' is valid, because it's an input for advanced users only.</p> <p>I would like it to return false if a caracter differs from the list here <a href="http://www.php.net/manual/en/function.date.php" rel="nofollow">http://www.php.net/manual/en/function.date.php</a> or if there is no space between caracters : 'His' is not valid whereas the 3 caracters alone are.</p> <p>I'm not very familiar with regex.</p>
php
[2]
533,030
533,031
On static and non-static initializing blocks in Java
<p>I originally thought that static blocks were for static variables but the compiler allows both A and B to compile and run, what gives?<br /> <strong>A</strong></p> <pre><code> private static final Map&lt;String,String&gt; m = new HashMap&lt;String,String&gt;(); { m.put("why", "does"); m.put("this","work"); } </code></pre> <p><strong>B</strong></p> <pre><code> private static final Map&lt;String,String&gt; m = new HashMap&lt;String,String&gt;(); static{ m.put("why", "does"); m.put("this","work"); } </code></pre> <p>Running <code>System.out.println(Main.m.toString());</code> for <strong>A</strong> prints </p> <blockquote> <p>{} </p> </blockquote> <p>but running the same for <strong>B</strong> prints out in Yoda-speak</p> <blockquote> <p>{this=work, why=does}</p> </blockquote>
java
[1]
4,253,380
4,253,381
How can I read the JSON data element value?
<p>I guess this html is right </p> <pre><code>&lt;span id="tag_8" data-translations="{&amp;quot;en&amp;quot;:&amp;quot;cat&amp;quot;}" class="myTag selected"&gt;chat&lt;/span&gt;at # generated with : # %span.myTag{:id =&gt; "tag_" + tag_id.to_s, :'data-translations' =&gt; translations(tag_id).to_json}= tag </code></pre> <p>I am trying to read the translation from within a jquery script , but it's failing :</p> <pre><code>selectedTag = $('#tag-list li span.myTag.selected:first') console.log 'translations: ' + selectedTag.data("translations", "en") =&gt; translations: [object Object] #however console.log 'translations: ' + selectedTag.data("translations") =&gt; translations: {"en"=&gt;"cat"} </code></pre>
jquery
[5]
2,257,907
2,257,908
Dealing with two DateTimePicker too error prone?
<p>So often, I want the user to select a start date and a finish date. But just selecting date is not enough, we also have to alter the data.</p> <p>By default, the <code>DateTimePicker.Value</code> are like</p> <pre><code>Value 1: 2012-01-01 10:12:09 Value 2: 2012-01-02 10:12:09 </code></pre> <p>When the user selects two dates, it should be obvious that he meant</p> <pre><code>Value 1: 2012-01-01 00:00:00 Value 2: 2012-01-02 23:59:59 </code></pre> <p>I often forget to do the non-intuitive </p> <pre><code>DateTime start = dateTimePicker1.Value.Date; DateTime finish = dateTimePicker2.Value.Date.AddDays(1).AddSeconds(-1); </code></pre> <p>What more effective way of dealing with this have you found?</p>
c#
[0]
5,111,551
5,111,552
Thread-safe setting of a variable (Java)?
<p>Given the following code:</p> <pre><code>public class FooBar { public static volatile ConcurrentHashMap myConfigData = new ConcurrentHashMap(); } public class UpdaterThread implements Runnable { run { //Query the Data from the DB and Update the FooBar config Data FooBar.myConfigData = ConfigDataDAO.getLatestConfigFromDB(); } } </code></pre> <p>The Thread-Class will update the myConfigData Membervariable regularly (via an Executor every 5 minutes). Is the setting of of myConfigData in the "external" Thread threadsafe (atomic), or do I have to synchronize every Read and Write operation to the myConfigData Variable?</p> <p>EDIT: The question is not whether ConcurrentHashMap is threadsafe (it is according to javadoc) but rather the setting of the ConcurrentHashMap itself in the myConfigData Member variable. This variable might be read and written "at once" by several threads so the question is whether the setting is atomic or not. I think this can be generalized to "Is the setting of a Java reference variable atomic or not?".</p> <p>(I also made it volatile. This is a different issue and has nothing to do with atomicity - my question - but rather "visibility in other threads" and the happens-before relationship.)</p>
java
[1]
4,873,315
4,873,316
Making copies of Objects in Java
<p>I have this Java code:</p> <pre><code>boolean[][] defaultBoard = {{false, false, false}, {false, false, false}, {false, false, false}}; Board board = new Board(defaultBoard); Board nextBoard = new Board(defaultBoard); nextBoard.getBoard()[1][5] = true; board.printBoard(); </code></pre> <p><code>printBoard</code>:</p> <pre><code>public void printBoard() { for (boolean row[] : board) { for (boolean cell : row) { System.out.print( cell ? "#" : "." ); } System.out.println(); } System.out.println(); } </code></pre> <p>But it returns</p> <pre><code>... .#. ... </code></pre> <p>Which makes me think that <code>nextBoard</code> and <code>board</code> have got the same memory address. My question is: How do create a copy of <code>nextBoard</code> so that when <code>nextBoard</code> is edited, <code>board</code> isn't edited as well?</p>
java
[1]
1,190,116
1,190,117
Android application as server and Web application as Client
<p>Need to create the android emulator as a server and the web application as a client. Is it possible to invoke the application in the emulator from the web app client. </p>
android
[4]
117,314
117,315
Can I use Process class to start a process on another machine
<p>I want to start a Java service on another machine using C# programming.</p> <p>Can I use Process class for this?</p> <p>If it is not possible to use Process class, can any body suggest the right way of doing it.</p> <p>I can start the service by executing a batch file. But I am not sure how to run a batch file remotely using C#. </p> <p>Please help me.</p>
c#
[0]
1,342,476
1,342,477
How to create a social network app on Android
<p>I want to build a social network app for Android. But, I don't know where to start. I tried to search in <a href="http://developer.android.com" rel="nofollow">http://developer.android.com</a> and many other tutorials. But, I didn't understand in data storage. In web development (PHP) for example, we need server and database (MySQL). How about the android app? I need to know the concept in developing social network app for Android, such as to store users' posts, comments, uploaded photos, google map data and so on. I don't want the code, I'm asking for idea and concept in developing social network app for Android.</p> <p>Any links to the suitable sites for me to start would be appreciated. Thanks.</p>
android
[4]
3,241,111
3,241,112
Playing Audio file
<p>I use the following code to play audio from sdcard. But it doesn't play, even doesn't throw error. My file is in the following path /sdcard/media/blueeye.mp3. Any suggestions.</p> <pre><code>public void audioPlayer(){ //set up MediaPlayer MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource(mp.setDataSource(getExternalFilesDir() + "/media/blueeye.mp3"); ); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { mp.prepare(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } mp.start(); } </code></pre>
android
[4]
502,574
502,575
how to disable the flash button using javascript
<p>In my application i'm using swf upload library to upload the images. Now i need to disable that flash button.any suggestions would be appreciative.</p> <p>thanks mani</p>
javascript
[3]
3,300,537
3,300,538
How to delete an element from an array in php without array search?
<p>Delete an element from an array in php without <code>array_search</code></p> <p>I want to delete an array element from array, but I dont know the array <code>key</code> of that element only value is known</p> <p>It is possible by <code>array_search</code> with value, first to find the key and then use <code>unset</code> </p> <p>Is there any inbuilt array function to remove array element with array value ?</p>
php
[2]
2,271,926
2,271,927
Variable Scope in JavaScript
<pre><code>var obj = { Variable: 1, Name: function() { Variable += 1; } return this.Variable } var obj = { Name: function() { var Variable = 1; Variable += 1; } return Variable } </code></pre> <ol> <li>Now what is the difference between these two? </li> <li>Does these two give different outputs.</li> </ol>
javascript
[3]
1,512,625
1,512,626
checking resources in xml and displaying icons for the resources in android
<p>hai every one. i am new to android. in my project i had some problems reading xml files. In my xml i have included some audios and videos paths and i want to read the xml file through the code and i want to display some images n my view if there are some audio or video files. can any body tel how to read the xml file. thanking you in advance</p>
android
[4]
5,124,351
5,124,352
org.apache.commons.net.ftp.FTPClient.storeFile freezing interaction and animations
<p>I'm using org.apache.commons.net.ftp.FTPClient to communicate with an ftp server via an android app I'm making that records video and then uploads it to the ftp server. Everything is fine until I call storeFile at which point the app prevents any interaction until the uploading is completed. Is there any way around this? I'm currently developing for API lvl 12. My set up is as follows I have a class that calls a service in the background to handle recording of the video as well as the ftp setup. In the FTP class I have any of my fptclient interaction within asynctasks. Here is my method for uploading the file:</p> <pre><code>public boolean upload(String srcFilePath, String desFileName, String desDirectory) { if(!isLoggedIn()) { return false; } boolean status = false; try { status = new AsyncTask&lt;String, Void, Boolean&gt;(){ @Override protected Boolean doInBackground(String... args) { boolean status = false; try { String srcFilePath = args[0]; String desFileName = args[1]; String desDirectory = args[2]; FileInputStream srcFileStream = new FileInputStream(srcFilePath); // change working directory to the destination directory if (changeDirectory(desDirectory,true)) { status = mFTPClient.storeFile(desFileName, srcFileStream); } srcFileStream.close(); return status; } catch (Exception e) { Log.d(TAG, "upload failed"); e.printStackTrace(); return false; } } }.execute(srcFilePath, desFileName, desDirectory).get(); } catch (InterruptedException e) { e.printStackTrace(); return status; } catch (ExecutionException e) { e.printStackTrace(); return status; } return status; } </code></pre> <p>Any help would be immensely appreciated!</p> <p>Devunwired's post worked! Hoorah!</p>
android
[4]
5,116,101
5,116,102
Alternative to ImageList Tag
<p>I asked this question earlier <a href="http://stackoverflow.com/questions/6409097/get-image-from-list-view">Get image from list view</a></p> <p>To which i got a reply of "Use the tag field". However after spending all morning trying to do this and the Tag field always being null i got curious and stumbled across this</p> <p><a href="http://connect.microsoft.com/VisualStudio/feedback/details/115832/imagelist-does-not-preserve-the-tag-property-of-images-added" rel="nofollow">http://connect.microsoft.com/VisualStudio/feedback/details/115832/imagelist-does-not-preserve-the-tag-property-of-images-added</a></p> <p><code>When creating an ImageList and adding an image that has the "Tag" property set to a non-null value, the ImageList does not retain the Tag value for the image. When retrieving the image at a later time from the ImageList, the Tag property of the image is null.</code></p> <p>Now i am pretty stuck, what alternatives are there to using Tag?</p> <p>Thank you</p> <p>foreach file in the pdf collection</p> <p>add it to the image list</p> <p>determine other files to add</p> <p>add to the image list</p> <p>set ListviewImages to imagelist pictures`</p> <p>Now i want to use the item clicked (a ListViewItem) and determine how to open it (a pdf does a certain task, a custom icon does something else)</p> <p>Sorry i cant be more precise but i am worried about posting work data/code</p>
c#
[0]
3,474,855
3,474,856
How to calculate mouse coordinate based on resolution c#
<p>i am trying to develop a remote desktop apps with c#. so i have couple of question regarding mouse coordinate calculation based on picture box</p> <ol> <li><p>suppose i have picture box and i want to capture mouse coordinate when i will move my mouse on that picture box in c#?</p></li> <li><p>if i click at location (200, 300) on my picture box. then how can i determine<br> programmatically resolution of picture box and convert that (200,300) coordinate based on that resolution.</p></li> <li><p>when i will send (x, y) coordinate to other machine and if that pc has resolution have like 1024x768 then what logic i need to use to convert (x, y) according to that pc resolution</p></li> </ol> <p>if possible help me with small sample code for my question. thanks</p>
c#
[0]
4,785,827
4,785,828
Extends Android APIs
<p>I work with Eclipse and implement some applications using the Android Emulator.</p> <p>I'd like to know:</p> <ol> <li>is it possible to extend Android APIs with other .jar file?</li> <li>If it's possible, how can I extend the APIs? I just have to add libraries to the project or do I copy it to the $ANDROID_HOME/platforms/android-8/tools/lib</li> </ol>
android
[4]
4,548,405
4,548,406
Encryption using rijndael
<p>I'm quite new in programming .I wrote the below code in order to prompt the user for a password to encrypting a file, But it just work when the length of password is 8, What can I do on order to accepting any number of characters for the password?</p> <pre><code> string pass = textBox2.Text.ToString(); string password = @"" + pass + ""; UnicodeEncoding UE = new UnicodeEncoding(); byte[] key = UE.GetBytes(password); FileStream fsCrypt = new FileStream(@"c:\\users\\new", FileMode.Create); name = fsCrypt.Name; RijndaelManaged RMCrypto = new RijndaelManaged(); CryptoStream cs = new CryptoStream(fsCrypt, RMCrypto.CreateEncryptor(key, key), CryptoStreamMode.Write); FileStream fsIn = new FileStream(filename, FileMode.Open); int data; while ((data = fsIn.ReadByte()) != -1) cs.WriteByte((byte)data); </code></pre>
c#
[0]
113,451
113,452
Service Unavailable 503 when trying to update to ASP.NET 4
<p>I am trying to update my web application from 3.5 to 4.0. I've changed to ASP.NET 4.0 Integrated application pool and removed from web.config all the unnecessary tags.</p> <p>When I try now to access my site it says:</p> <blockquote> <pre><code>Service Unavailable </code></pre> <p>HTTP Error 503. The service is unavailable.</p> </blockquote> <p>When I look in EventViewer for details I see:</p> <pre><code>Application pool 'ASP.NET 4.0 (Integrated)' is being automatically disabled due to a series of failures in the process(es) serving that application pool. </code></pre> <p>For one of the previous events I notice for instance:</p> <pre><code>A process serving application pool 'ASP.NET 4.0 (Integrated)' terminated unexpectedly. The process id was '4040'. The process exit code was '0xfffffffe'. </code></pre> <p>I am not able to find other details for this issue which gets me desperate..Can you please give me any clue?</p>
asp.net
[9]
456,097
456,098
Key keeps the old name after renaming it
<p>This is my code:</p> <pre><code>foreach ($all_orders as $order){//the $all_orders array contains a number of arrays, so it's a multidimensional array $order["Order Rank"]=$order[0]; unset($order[0]); } </code></pre> <p>after renaming the key with the new key and when i print the array:</p> <pre><code>print_r($all_orders); </code></pre> <p>i got the old key name (which is 0):</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; 1 ) </code></pre> <p>why it's not :</p> <pre><code>Array ( [0] =&gt; Array ( ["Order Rank"] =&gt; 1 ) </code></pre> <p>am i missing something? thanx in advance.</p>
php
[2]
632,977
632,978
How to enable userinteraction in tableview when coming back to tableview
<p>In my app I am doing tableView. By clicking row, the new view will navigate. Before navigation of new view, application is processing data from server. Until processing of data finished, view will not navigate. In this time period I want to disable userinteraction of tableview, so user can not select further rows.</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { tableView.userInteractionEnabled = NO; } </code></pre> <p>Note that, When I again come back to the tableview, user will again allowed to select any row. I do not have any idea, how can I enable userinteracation again. </p>
iphone
[8]
4,893,633
4,893,634
Refactoring a method picker class
<p>I'm working on some existing code. After a few hours, I've boiled this problem down to a method picker class. I find this class to be difficult to follow. Is it possible to achieve this type of method picking functionality in a simple way?</p> <pre><code>public class MethodPicker { private delegate string SomeFunc(MethodPicker item); static readonly Dictionary&lt;string, SomeFunc&gt; test = new Dictionary&lt;string, SomeFunc&gt;(); static MethodPicker() { test.Add("key1", Func1); test.Add("key2", Func2); test.Add("key3", Func3); } public string RunTest(string Name) { string somestring = test[Name].Invoke(this); return somestring; } public static string Func1(MethodPicker entity) { return "func1 runs"; } public static string Func2(MethodPicker entity) { return "func2 runs"; } public static string Func3(MethodPicker entity) { return "func3 runs"; } } </code></pre>
c#
[0]
1,024,888
1,024,889
C++ compilers implementing dynamic initialization after main
<p>The C++ standard section 3.6.2 paragraph 3 states that it is implementation-defined whether dynamic initialization of non-local objects occurs after the first statement of main().</p> <p>Does anyone know what the rationale for this is, and which compilers postpone non-local object initialization this way? I am most familiar with g++, which performs these initializations before main() has been entered.</p> <p>This question is related: <a href="http://stackoverflow.com/questions/6372032/dynamic-initialization-phase-of-static-variables">Dynamic initialization phase of static variables</a> But I'm specifically asking what compilers are known to behave this way.</p> <p>It may be that the only rationale for this paragraph is to support dynamic libraries loaded at runtime, but I do not think that the standard takes dynamic loading issues into consideration.</p>
c++
[6]
3,765,967
3,765,968
related to php arithmetic
<pre><code>$y = 013; echo $y + 5; //this result in 16 </code></pre> <p>I can not figure it out how its ans is 16? Can any one help?</p>
php
[2]
2,851,415
2,851,416
create moving text for android
<p>is there any way to implanted way to create a moving text [ croos text ] </p> <p>for example open meida o\player , in status bar you can see music titile will be move under buttons .</p> <p>It is good idea for showing large texts , </p> <p>how can I do this .</p>
android
[4]
4,362,624
4,362,625
Why is PackageInfo.requestedPermissions always null?
<p>I'm trying to enumerate all the permissions used by all the installed packages, however when I check the <a href="http://developer.android.com/reference/android/content/pm/PackageInfo.html#requestedPermissions" rel="nofollow">requestedPermissions</a> property for each of my installed packages it is always null.</p>
android
[4]
5,802,406
5,802,407
Any body Help me ...I need xml as back end
<p>Any body Help me ...I need xml as back end..then search the xml file for username and password and then login ...</p>
php
[2]
4,670,109
4,670,110
Error"Cannot implicitly convert type 'string' to 'System.Type'
<p>I am getting an error for the sorting in the format "dd-mmm-yyyy" it should sort date,month,year wise when binding to grid</p> <p>"Cannot implicitly convert type 'string' to 'System.Type'" </p> <pre><code>DataView dw = PurchaseRequestDetails.Tables[0].DefaultView; DateTime NowDate = System.DateTime.Now; string NewDate = NowDate.ToString("dd-MMM-yyyy"); dw.Table.Columns["RequiredDate"].DataType = NewDate.ToString(); dw.Sort = "RequiredDate ASC"; foreach (DataRowView dr in dw) { System.Diagnostics.Debug.WriteLine("RequiredDate: " + dr["RequiredDate"].ToString()); } dgvPurReq.DataSource = dw; dgvPurReq.DataBind(); </code></pre>
c#
[0]
2,477,642
2,477,643
are virtual destructors in novtable interfaces okay?
<p>I have a Visual Studio 2008 C++03 project where I have an interface class that is declared <code>_declspec( novtable )</code>. For example:</p> <pre><code>class _declspec( novtable ) IFoo { public: virtual void FooDo() const = 0; }; class Foo : public IFoo { public: ~Foo() { printf( "~Foo()\r\n" ); }; void FooDo() const { printf( "FooDo()\r\n" ); }; }; int main( int argc, char* argv[] ) { IFoo* foo = new Foo(); foo-&gt;FooDo(); delete foo; return 0; } </code></pre> <p>Because <code>IFoo</code> does not have a virtual destructor, the concrete <code>Foo</code> destructor is never called.</p> <p>Output:</p> <pre><code>FooDo() </code></pre> <p>Desired Output:</p> <pre><code>FooDo() ~Foo() </code></pre> <p>But, in <a href="http://msdn.microsoft.com/en-us/library/k13k85ky%28v=vs.71%29.aspx" rel="nofollow">MSDN</a>, there is a dire warning against calling functions in interface classes declared <code>novtable</code>. "<em>If you attempt to instantiate a class marked with novtable and then access a class member, you will receive an access violation (AV)</em>." So adding a <code>virtual ~IFoo() { };</code> member sounds like it could be a Bad Thing. (although in my testing, it seems to work fine.)</p> <p>How does one properly get the desired behavior from this?</p>
c++
[6]
3,789,791
3,789,792
Xcode Organizer - Devices showing yellow light
<p>Got the developer certificate to test app on iphone entered device identifier, connected iphone as a device in the organizer it shows yellow light. In software version it shows 5.1 as installed on iphone device. It displays that it does not match any of the versions of iOS supported for development with this installation of the iOS SDK. Please restore the device to a version of the OS listed below</p> <p>Xcode Supported iOS Versions Latest 5.0 (9A334) 4.3 (8F190) 4.3 4.2 4.1 4.0.2 4.0.1 4.0</p> <p>Eventhough got latest version but still i restored iphone but still got yellow light not changing to green any idea how to fix this issue.</p> <p>Thanks for help.</p>
iphone
[8]
4,199,646
4,199,647
UIwebview loader on iphone
<p>this code works fine , its show activityIndicator loading and hide after loading but lets say <strong>if its on loading stage and then i go back then my apps quit</strong> , so how to avoid this</p> <p>if i go back quickly withiut site fully loaded then it quits ( i think activityIndicator is culprit)</p> <p>**</p> <pre><code>- (void)webViewDidStartLoad:(UIWebView *)webView { [activityIndicator startAnimating]; // myLabel.hidden = FALSE; } - (void)webViewDidFinishLoad:(UIWebView *)webView { [activityIndicator stopAnimating]; activityIndicator.hidesWhenStopped=TRUE; //myLabel.hidden = TRUE; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { self.title=@"KKH Website"; [super viewDidLoad]; NSURL *requestUrl = [NSURL URLWithString:@"http://www./index.html"]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:requestUrl]; [aWw loadRequest:requestObj]; } </code></pre> <p>** updates</p> <p><strong>if i link uiwebview delegate to fileowner then its creating isuee , but i need delegate also since i want to show loading</strong> </p>
iphone
[8]
2,400,124
2,400,125
c++ passing string to varargs
<pre><code>#define LOG(format,...) Logger::Log(format,__VA_ARGS__) #define STRIP(netIp) GeneralUtils::inet_ntop_(netIp) string GeneralUtils::inet_ntop_(unsigned int netIp){ char strIP[INET_ADDRSTRLEN]; in_addr sin_addr; sin_addr.s_addr = netIp; inet_ntop(AF_INET, &amp;sin_addr.s_addr, strIP, sizeof strIP); return string(strIP); } </code></pre> <p>when calling to :</p> <pre><code>LOG("src %s dst %s" ,STRIP(src_ip_)); </code></pre> <p>i get compilation error:</p> <pre><code>cannot pass objects of non-trivially-copyable type ‘std::string {aka struct std::basic_string&lt;char&gt;}’ through ‘...’ </code></pre> <p>I understand that varargs is c compatible , so i cannot send string to it. Is there a simple way to bypass it? Will it be correct to fix it like this:</p> <pre><code>#define STRIP(netIp) GeneralUtils::inet_ntop_(netIp).data() </code></pre>
c++
[6]
3,911,710
3,911,711
Android: TabActivity, Creating Menu
<p>i have created 3 tabs using the TabActivity. The class declaration is like this.</p> <p><em><strong>public class ABTM extends TabActivity</em></strong> {</p> <p>........ some code ..........</p> <p>}</p> <p>now i want to create a Menu with three menu items. but the problem is that the </p> <p>**@Override public boolean OnCreateOptionsMenu(Menu menu){</p> <p>}** </p> <p>gives error. It says that i should remove the @Override. When i remove the @Override the error is gone and the application runs fine but pressing the menu button does nothing.</p> <p>What am i doing wrong here? </p>
android
[4]
3,487,305
3,487,306
How to find out the month from a date when the date format is - day-month-year?
<p>Would you please kindly tell me how to find out the month from a date when the date format is like following?</p> <pre><code> 01/12/2011 Day-Month-year </code></pre> <p>Thanks :)</p>
php
[2]
719,435
719,436
Where can a JavaScript be located in a web page?
<p>I'm very new to JS and I'm wondering how it can work with in the web page and the HTML document.</p>
javascript
[3]
1,372,379
1,372,380
how to add contact from the aplication?
<p>i want to add contact number,name etc from the my application.Is it possible?If yes then please help me.</p>
iphone
[8]
5,642,899
5,642,900
Call a method from an activity from an adapter
<p>I am working with an adapter which has several buttons on each item of the ListView. I have, for example two buttons. One for save and another for delete. </p> <p>When I click on them, I want the adapter to refresh. I have a method on my activity that does that: Update the adapter. I made it since I couldn't make the Notify methods of the adapter work. </p> <p>I am sending the Activity to the adapter as a parameter and then call the update method from the adapter since I am setting the OnClick methods of each button in the adapter. </p> <p>The problem is that it doesnt seem to work always. I am guessing it has to do something about the cycle of the activity and Android cleaning memory however I can't seem to understand where is the problem.</p> <p>I am aware this is some ugly way of doing it, so what should be the best way of doing this?</p> <p>Summary: I need to refresh the adapter from the adapter itself when I delete an item of the ListView or update it (BaseAdapter)</p> <p>Edit: I am adding some code. This is my constructor of my adapter:</p> <pre><code>public SpendingPlanAdapter(Context context, SpendingPlan sp, int month, int year, money.activities.SpendingPlan act) </code></pre> <p>Inside the adapter I have an OnCLickListener attached to a button. I am calling the update method like this (Result is the result of a database insert):</p> <pre><code>if (result){ Toast.makeText(context, context.getResources().getString(R.string.succesfully_deleted), Toast.LENGTH_LONG).show(); act.updateAdapter(); } else { Toast.makeText(context, context.getResources().getString(R.string.oops), Toast.LENGTH_LONG).show();} </code></pre> <p>And this is my UpdateAdapter method:</p> <pre><code>public void updateAdapter(){ SpendingPlanAdapter adapter = new SpendingPlanAdapter(getApplicationContext(), currentSp, currentMonth, currentYear, this); limitList.setAdapter(adapter); } </code></pre>
android
[4]
3,861,165
3,861,166
casting delegate using errorbox returns fault
<p>Im completely stumped on where to go from here. </p> <p>heres my line of code that i cant get past.</p> <pre><code> if (error.GetReaction(ErrorReaction.InformUser) == null) { error.SetReaction(new ErrorReactionClass(ErrorReaction.InformUser, (CachedAnonymousMethodDelegate1 != null) ? CachedAnonymousMethodDelegate1 : (CachedAnonymousMethodDelegate1 = new Method(ErrorMessageBox.ShowDialog)), "OK", "")); } </code></pre> <p>i get the following errors from this</p> <p>Error 30 'System.Windows.Forms.DialogResult System.Windows.Forms.Form.ShowDialog()' has the wrong return type<br> Error 31 An object reference is required for the non-static field, method, or property 'System.Windows.Forms.Form.ShowDialog()'</p>
c#
[0]
2,787,193
2,787,194
What is the difference between System.IO.File and System.IO.FileInfo
<p>Why there are two class for the almost same purpose System.IO.File and System.IO.FileInfo.</p>
c#
[0]
2,680,837
2,680,838
jQuery change event not fired in IE6
<p>am using jquery to bind an event to a text input. The event simply performs an ajax call.</p> <p>Problem is my code works fine in Firefox, but the event is never triggered in IE6. Heres my code:</p> <pre><code> &lt;/script type="text/javascript" src="/js/jquery/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // Turn off caching for Ajax $.ajaxSetup({ cache: false }); var ajaxCallURL = "http://&lt;?php echo $_SERVER['HTTP_HOST']; ?&gt;/check"; $(document).ready(function() { $("#test").change(function() { alert("Event fired"); $('#result').load(ajaxCallURL,null, function(responseText) { alert("Ajax call successful"); }); }); }); &lt;/script&gt; &lt;input style="WIDTH: 30em" id="test" name="test" value="" type="text"/&gt; &lt;div id="result"&gt;&lt;/div&gt; </code></pre> <p>After typing in the text box, both alerts are shown in Firefox, but nothing in IE6.</p> <p>I also should say that the element is being created using Zend_Dojo classes, but i cant see an issue with using Dojo and jQuery as its works fine in Firefox.</p> <p>Am thinking it must be that the event is never bound to the element in IE due to maybe Dojo is not fully loaded in IE when $(document).ready is called....</p> <p>Any ideas anyone??</p> <p>Many thanks</p>
jquery
[5]
3,031,517
3,031,518
php: how to read only txt files in a directory
<p>i have a folder called XXX it contains .jpg .gif .txt .... etc</p> <p>i want only to read .txt files how to do that ?</p> <p>Thanks </p>
php
[2]
375,139
375,140
Java HttpURLConnection no cookies at login
<p>I'm currently trying to do a login with HttpURLConnection and then get the session cookies...</p> <p>I already tried that on some test pages on my own server, and that works perfectly. When i send <code>a=3&amp;b=5</code> i get <code>8</code> as cookie (PHP page adds both together)! But when i try that at the other page, the output is just the page as if I just sent nothing with POST :(</p> <p>General suggestions for improvement are welcome! :)</p> <p>My Code:</p> <pre><code>HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("useragent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0"); conn.setRequestProperty("Connection", "keep-alive"); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); out.writeBytes("USER=tennox&amp;PASS=*****"); out.close(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; String response = new String(); while ((line = in.readLine()) != null) { response = response + line + "\n"; } in.close(); System.out.println("headers:"); int i = 0; String header; while ((header = conn.getHeaderField(i)) != null) { String key = conn.getHeaderFieldKey(i); System.out.println(((key == null) ? "" : key + ": ") + header); i++; } String cookies = conn.getHeaderField("Set-Cookie"); System.out.println("\nCookies: \"" + cookies + "\""); </code></pre>
java
[1]
3,599,058
3,599,059
Detect when a particular application (not mine) becomes visible / not visible to the user
<p><strike>I am currently trying to write an app that will change certain settings automatically (turn off sound, etc) when an application becomes active and to revert back to the original settings when the application is no longer active. </strike></p> <p><strong>EDITED</strong> Sorry, I believe I explained the question poorly. I am currently trying to write an app that will be able to detect when a certain application (for example, youtube app) becomes visible to the user, meaning that the user has just launched/navigated to the youtube app. </p> <p>When I detect this, I want to perform certain setting changes, such as turning off the phone's sound (I have already figured this part out). And then, when I detect that the youtube app is no longer visible to the user, I want to restore the settings back to what they were.</p> <p>What I want to know is the mechanism to detect when any application at all (not my application) becomes visible / not visible to the user. </p> <p>Kind of like what the app Tasker does.</p> <p>I am trying to figure out how it accomplishes this. There does not seem to be any broadcast receivers that will notify on applications becoming active. One way that I can think of is to create a service that constantly polls the currently running tasks.. but this seems like it will give very bad performance.</p> <p>Is there any alternative that someone may suggest?</p> <p>Thank you in advance</p>
android
[4]
1,968,787
1,968,788
Getting confused with Reference Casting and Widening w.r.t Objects in java
<p>With primitives and their Wrappers I understood the concept of Widening. But with respect to other Objects I am getting confused with Widening and implicit Casting. As example</p> <pre><code> Class Animal{ } Class Dog extends Animal{ public static void main(args String[]){ Dog d = new Dog(); d.go(d); } void go(Animal a){ } } </code></pre> <p>Edit: the question is which one is preferred widening or casting and why?</p>
java
[1]
1,294,487
1,294,488
jquery image gallery next/prev issue
<p>I have below code in my page I am able to run next image click but prev image click not working. On click "next" it shows me div1 - div2 - div3 but on click prev its not showing me anything.</p> <p>My HTML:</p> <pre><code>&lt;div id="slideshow"&gt; &lt;img.prev&gt; &lt;img.next&gt; &lt;div1&gt; &lt;div2&gt; &lt;div3&gt; &lt;/div&gt; </code></pre> <pre class="lang-js prettyprint-override"><code>$("#slideshow &gt; div:gt(0)").hide(); // this works fine $('.next').live('click', function() { $('#slideshow &gt; div:first') .fadeOut(0) .next() .fadeIn(1000) .end() .appendTo('#slideshow'); }) ; // this is not working $('.prev').live('click',function(){ $('#slideshow &gt; div:first') .fadeOut(0) .prev() .fadeIn(1000) .end() .appendTo('#slideshow'); }); </code></pre>
jquery
[5]
677,216
677,217
anchor tag inside a repeater with runat = "server" acting strange
<p>I have following code inside my asp.net repeater inside itemtemplate. </p> <pre><code>&lt;a runat = "server" href = "StoreCategory/testing.aspx"&gt;dsdsdsd&lt;/a&gt; </code></pre> <p>Now, I would think that this link would point to mydomain.com/StoreCategory/testing.aspx (which it does if runat = "server" is not in there)</p> <p>However, if I keep runat = "server" there, the link turns out to be mydomain.com/testing.aspx. It drops StoreCategory! Why do you think it is doing that? </p> <p>I figured out part of the problem, the reason is the current page is StoreCategory.aspx. However, why only runat = "server" is getting confused and how to tell it not to get confused is beyond me, hmm.</p>
asp.net
[9]
4,349,325
4,349,326
writing admin pages using asp.net
<p>I am going to create a couple asp.net pages with login page. I am thinking about Forms authentication. The users are around 1000 to 5000. What is the best way to achieve this? I appreciate any help.</p> <p>Thanks..</p>
asp.net
[9]
3,828,098
3,828,099
Assigning to an IList< > or a List< >?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8717582/why-use-ilist-or-list">why use IList or List?</a> </p> </blockquote> <p>I have the following:</p> <pre><code>public class CityViewModel { public CityViewModel() { Details = Enumerable.Range(1,10).Select(x =&gt; new City.Detail()).ToList(); } public string Topic { get; set; } public City City { get; set; } public IList&lt;City.Detail&gt; Details { get; set; } } </code></pre> <p>The suggestion as a way to create Details was given to me. What I am unsure about is why the following line is declared as an IList:</p> <pre><code>public IList&lt;City.Detail&gt; Details { get; set; } </code></pre> <p>Would it not be more correct to declare this as:</p> <pre><code>public List&lt;City.Detail&gt; Details { get; set; } </code></pre> <p>Can someone explain the difference to me.</p>
c#
[0]
132,848
132,849
related to abstract class reference holding object of its derived class
<p>class A is abstract and class B extends class A now class A reference can hold object of class B,that is</p> <pre><code>A aObj = new B(); </code></pre> <p>and assume class B has some extra methods.... like</p> <pre><code>class A { public show(); } class B extends A { public show(){} public method1(){} private method2(){} } </code></pre> <p>now tell me what things variable aObj can access from class B can it access everything?</p>
java
[1]
1,212,052
1,212,053
How to create and manage custom themes for whole Android system?
<p>I know how to create and apply styles and themes thanks to <a href="http://developer.android.com/guide/topics/ui/themes.html" rel="nofollow">http://developer.android.com/guide/topics/ui/themes.html</a>. However, this method only works for our own activity or application.</p> <p>I'd like to create themes that could dress the whole system (i.e. all activities). Of course, I'd like to select one of these theme by programing. If I could customize the status bar as well, it would be perfect.</p> <p>I didn't find out documentation about that. Can you help me?</p> <p>Thanks!</p>
android
[4]
876,188
876,189
Problems accessing public method of another class
<p>I currently use two classes, <code>ircBot(extends pircbot</code>) and <code>ircRobotti(extends Robotti)</code>.</p> <p>I'm trying to compile the class files on a shell but i'm getting an error:</p> <blockquote> <p>./ircBot.java:26: cannot find symbol symbol : method lisaaJonoon(int) location: class Robotti annaRobo().lisaaJonoon(suunta);</p> </blockquote> <p><code>lisaaJonoon()</code> is defined in <code>ircRobotti</code> and it's public.</p> <p>Any ideas what might cause the error?</p>
java
[1]
5,087,148
5,087,149
Implementing smooth div toggle
<p>I am trying to recreate the "div toggle" effect on this page, but with jQuery:</p> <p>cordon-bleu.se</p> <p>I want this effect, but working like the above page: the visible div hides when you click to show another:</p> <p>sohtanaka.com/web-design/easy-toggle-jquery-tutorial/</p> <p>My javascript so far is:</p> <pre><code>$(document).ready(function(){ $("h2.menutrigger").click(function(){ $('.active').removeClass('active').slideToggle("slow"); $(this).next().addClass('active').slideToggle("slow"); }); }); </code></pre> <p>These are the divs I am trying to toggle:</p> <pre><code>&lt;div class="menuitem active"&gt; &lt;img src="images/img_header.png" style="margin: 15px auto;"/&gt; &lt;/div&gt; &lt;h2 class="menutrigger"&gt;&lt;a href="#"&gt;Historia&lt;/a&gt;&lt;/h2&gt; &lt;div class="menuitem"&gt; &lt;p&gt;Bla bla&lt;/p&gt; &lt;p&gt;Bla Bla&lt;/p&gt; &lt;/div&gt; &lt;h2 class="menutrigger"&gt;&lt;a href="#"&gt;Spisar&lt;/a&gt;&lt;/h2&gt; &lt;div class="menuitem"&gt; &lt;p&gt;Bla bla&lt;/p&gt; &lt;/div&gt; </code></pre> <p>And this is my (relevant) css:</p> <pre><code>.menuitem { height: 385px; background-color: #000; display:none; } .active { display: block; } </code></pre> <p>You can see <a href="http://rutinerad.com/projekt/cb_test/" rel="nofollow">here</a> how it works right now.</p> <p>I appreciate any help I can get.</p>
jquery
[5]