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
399,539
399,540
Is there a java library that validates URNs?
<p>What's the easiest way to validate that a string is a valid <a href="http://www.ietf.org/rfc/rfc2141.txt">URN</a>?</p> <p><strong>Edit</strong> Using URI is not a correct solution! URIs are allowed to have all kinds of things that URNs can't, like <code>&amp;</code></p>
java
[1]
3,391,685
3,391,686
how to exit from currentrunloop
<p>I used NSRunloop in my application. While going from my current controller i need to exit from the run loop also. How can i exit from current run loop .</p> <p>Runloop is implemented as follows.</p> <pre><code>while(!completed) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];//[NSDate distantFuture] } </code></pre> <p>Thanks in advance..</p>
iphone
[8]
5,758,772
5,758,773
php5 shorthand variables
<p>I have seen most of the developers use <code>$name</code> instead of <code>$_GET['name']</code> and <code>$domain</code> instead of <code>$_POST['domain']</code>, is this shorthand by php5 and is it safe or any documentation for it.</p>
php
[2]
430,326
430,327
Android setContentView or Intents?
<p>I have a very simple 2 screen android app.</p> <p>Is there any downside to simply switching out the layouts via setContentView or should i be using intents?Don't want to bugger up my app if something is wrong with this.</p>
android
[4]
3,433,717
3,433,718
refresh page after jquery/javascript event?
<p>Can someone please show me how i can add an automatic page refresh after the following jquery event has taken place?</p> <p>Thanks. </p> <pre><code>&lt;script&gt; $(document).ready(function() { setTimeout(function() { $(".infobox-forum").fadeOut("slow", function () { $("infobox-forum").remove(); }); }, 2000); }); &lt;/script&gt; </code></pre>
javascript
[3]
4,180,032
4,180,033
java input output stream
<p>Does anyone have any good suggestions for creating a Pipe object in Java which is both an InputStream and and OutputStream since Java does not have multiple inheritance and both of the streams are abstract classes instead of interfaces?</p>
java
[1]
1,304,912
1,304,913
android radiobutton on listview
<p>is it possible to apply a radio group on the whole Listview?</p> <p>I have a listview where each item has some image, a text and a simple single radio button. When a user clicks on say the first items radio button, i want the previous selected radio button to be disabled. is this possible?</p> <p>How do u apply a radio group on all radio button items?</p> <p>my xml item layout looks like this</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;ImageView android:src="@drawable/card_colourblock_blue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/colourIcon" android:layout_centerVertical="true" android:layout_marginLeft="10dip"&gt;&lt;/ImageView&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:layout_toLeftOf="@+id/checkBox" android:id="@+id/text" android:layout_centerVertical="true" style="@style/Body" android:layout_toRightOf="@+id/colourIcon" /&gt; &lt;RadioButton android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Thanks</p>
android
[4]
2,891,165
2,891,166
Checking image name using javascript
<p>I'm changing the img src on click using javascript.</p> <p>I'm trying to determine whether to switch on or off.</p> <p>I'm testing the following:</p> <pre><code>var img_el = document.getElementById("on_off_img"); if ( img_el.src == 'img/on.png' ) { img_el.src = 'img/off.png' } else { img_el.src = 'img/on.png' } </code></pre> <p>My problem is that i never get a match - it looks like img_el.src returns the full URL... Is there a function to just test the actual filename instead of the full string to the file?</p> <p>Or is there a better way to manage the click?</p>
javascript
[3]
4,976,123
4,976,124
why i get this traceback?
<p>This is part of my code:</p> <pre><code>if ind_1&lt;&gt;0: rbrcol=[] brdod1=[] for i in range(27): if Add_Cyc_1[1,i]!=0: rbrcol.append(Add_Cyc_1[0,i]) brdod1.append(Add_Cyc_1[1,i]) Probrani_1=vstack((rbrcol,brdod1)) pok=0 for i in (rbrcol): pok+=1 broj1=0 for j in range(21): if SYS_STATE_1[i,j]==0: broj1+=1 if broj1 &lt;= Probrani_1[1,pok-1]: SYS_STATE_1[i,j]=123456 </code></pre> <p>And when i run program i get this:</p> <pre><code>Traceback (most recent call last): File "C:/Python26/pokusaj2.py", line 157, in &lt;module&gt; for i in (rbrcol): NameError: name 'rbrcol' is not defined </code></pre> <p>What i do wrong???</p>
python
[7]
2,866,593
2,866,594
running javascript in IE without warning 'the webpage you are trying to access wants to run activex control'
<p>is there anyway to stop popping up the warning message in IE when trying to execute javascript?</p> <p>I want some solution which does not need modifying the settings in the IE manually by the user.</p> <p>Thanks,</p>
javascript
[3]
373,037
373,038
php fun codeing
<p>hey I make a simple php table using nested for loop ... and it will be like this...</p> <pre><code>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 </code></pre> <p>but the problem is , i can not print this value using a loop inside the column .. so what will be the solution ??? please </p> <p><strong>my code :</strong></p> <pre><code>echo "&lt;table border=1&gt;\n"; for($row=1;$row&lt;=3;$row++) { echo "&lt;tr&gt;"; for($col=1;$col&lt;=5;$col++) { echo "&lt;td&gt;"; echo "MY PROBLEM HERE...I cant print column numbers \n"; echo "&lt;/td&gt;"; } echo "&lt;/tr&gt;"; } echo "&lt;/table&gt; \n"; </code></pre>
php
[2]
4,642,889
4,642,890
Opposite of finish()
<p>I know that finish() returns your activity back to your previous activity. Now I am curious if we are able to accomplish the opposite meaning forwarding back to the next activity that you backed off without doing an Intent. This is just a curiosity question.</p> <p>Is this possible? </p>
android
[4]
4,364,186
4,364,187
jQuery: How do I rewrite .after( content, content )?
<p>I've got this form working, but according to <a href="http://stackoverflow.com/questions/2932549/what-is-the-status-of-jquerys-multi-argument-content-syntax-deprecated-support">my previous question</a> it might not be supported: it isn't in the docs either way -- but the intention is pretty obvious in the code.</p> <pre><code>$(".section.warranty .warranty_checks :last").after( $('&lt;div class="little check" /&gt;').click( function () { alert('hi') } ) , $('&lt;span&gt;OEM&lt;/span&gt;') /*Notice this (a second) argument */ ); </code></pre> <p>What this does is insert <code>&lt;div class="little check"&gt;</code> with a simple <code>.click()</code> callback, followed by a sibling of <code>&lt;span&gt;OEM&lt;/span&gt;</code>. How else can I write this then? I'm having difficulty conjuring something working by chaining any combination of <code>.after()</code>, and <code>.insertAfter()</code>?</p> <p>I would expect this to work, but it doesn't:</p> <pre><code>$(".section.warranty .warranty_checks :last").after( $('&lt;div class="little check" /&gt;').click( function () { alert('hi') } ).after ( $('&lt;span&gt;OEM&lt;/span&gt;') ) ); </code></pre> <p>I would also expect this to work, but it doesn't:</p> <pre><code>$(".section.warranty .warranty_checks :last").after( $('&lt;span&gt;OEM&lt;/span&gt;').insertAfter( $('&lt;div class="little check" /&gt;').click( function () { alert('hi') } ) ); ); </code></pre> <p>-> <strong>Please see <a href="http://jsfiddle.net/U2WjX/" rel="nofollow">my jsfiddle</a> for examples (test case)</strong></p>
jquery
[5]
2,758,146
2,758,147
Setting variable by string name in javascript?
<pre><code>//window["Fluent"]["Include"] function setGlobalVariableByName(name,value) { var indexes = name.split("."); var variable = null; $.each(indexes, function() { if (variable == null){ variable = window[this]; }else{ variable = variable[this]; } }); variable = value; } setGlobalVariableByName("Fluent.Include.JqueryPulse",true); console.log(Fluent.Include.JqueryPulse) // prints false </code></pre> <p>this doesn't work, obviously. It would work if I just wanted to get the variable's value, but not for setting it.</p> <pre><code>window["Fluent"]["Include"]["JqueryPulse"] = true; console.log(Fluent.Include.JqueryPulse) // prints true </code></pre> <p>how could I achieve something like this without using eval?<br> I'd need some way to programmatically add array indices to this, I'd guess</p> <hr> <p>The following works, can you suggest a better way to code it in order to make it more DRY?</p> <pre><code>function setGlobalVariableByName(name,value) { var indices = name.split("."); var parent; $.each(indices, function(i) { if(i==indices.length-1){ if (!parent){ window[this] = value; }else{ parent[this] = value; } }else if (!parent){ parent = window[this]; }else{ parent = variable[this]; } }); } </code></pre> <hr> <pre><code>setGlobalVariableByName : function(name, value) { var indices = name.split("."); var last = indices.pop(); var parent; $.each(indices, function(i) { if (!parent){ parent = window[this]; }else{ parent = variable[this]; } }); if (!parent){ window[last] = value; }else{ parent[last] = value; } } </code></pre>
javascript
[3]
4,397,310
4,397,311
NullReferenceException when user control references usercontrol in parent user control
<p>I have a user control (uc1) which inherits from uc2. uc2 has a user control (uc3) declared in the markup. I am trying to access uc3 from uc1 but I get NullReferenceException. I thought due to inheritance uc3 would instantiate but looks like I am missing a step.</p> <p><strong>Clarification:</strong></p> <p>How does the child user control inherit the markup from the base class? The server controls in the base user control are null in the code behind of the base user control. Why?</p>
asp.net
[9]
3,391,421
3,391,422
throwing an exception in a setter (java)
<p>I'm creating a Cylinder class that calculates the volume and surface area of a cylinder object created in a test class that extends the Cylinder class, and want to know how I can test that the values passed through, as radius and height, are positive. I'm attempting to do this in the setter, and have the following java code </p> <pre><code>// only sets radius if it is a positive number public void setRadius(double radius) { if (radius &lt; 0.0) { throw new IllegalArgumentException("Can't have a negative radius."); } this.radius = radius; } public double getHeight() { return height; } // only sets height if it is a positive number public void setHeight(double height) { if (height &lt; 0.0) { throw new IllegalArgumentException("Can't have a negative height."); } this.height = height; } </code></pre>
java
[1]
2,450,786
2,450,787
Collections vs Arrays regarding sort()
<p>Collections vs Arrays regarding sort() What is the difference between these two regarding sort() method? I know Arrays' sort() is using binary search for sort(), what about Collections'? And how to choose which to use? Thanks!</p>
java
[1]
118,544
118,545
Any simple way to test null before convert an object to string
<p>I always write</p> <pre><code>Object o; if (o!=null) String s = o.toString(); </code></pre> <p>If there simple way to handle this case?</p>
java
[1]
5,661,530
5,661,531
Android:WebView
<p>I have an activity with 3 TextViews and 3 buttons at the bottom. I tried adding the WebView in between 2 textViews. I want the look of this WebView to be same as that of the textViews. Meaning the backgroud, the font the color. </p>
android
[4]
2,056,902
2,056,903
In C++, how do you print out several lines of text to the console?
<p>Let's say you wanted to print out one of those great ascii art images. How can you do that without "cout"ing each line individually?</p>
c++
[6]
2,177,875
2,177,876
How can I make a click event work on more than one selector?
<p>I have this code:</p> <pre><code> $("#menu").on('click', 'a', function (event) { javascript code ... }); $("#home").on('click', 'a', function (event) { javascript code ... }); </code></pre> <p>Is there some way I can combine these two as the javascript code for both is the same?</p>
jquery
[5]
2,645,132
2,645,133
Is it possible to run 2 processes paralel in android?
<p>I am interested if it's possible to run 2 lines of code simultaniously,</p> <p>let's say if i have some function funk(); funk1(); so i want them to be executed simultaniusly</p>
android
[4]
4,357,370
4,357,371
How can i have a look at the variables and its values during execution..?
<p>I want to know from where can i see all the values of the variables that my program uses. i know that using Log() i can see it placing it in the code ,where the values is to be known.But i dont want through the code,i want all the vales of all the variables declared in the program. </p> <p>For example, </p> <pre><code> String addressString = "No address found"; double lat = location.getLatitude(); double lng = location.getLongitude(); Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List&lt;Address&gt; addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() &gt; 0) { Address address = addresses.get(0); sb.append(address.getCountryName()); } addressString = sb.toString(); </code></pre> <p>In this i want to know the values that will be stored in variables addressString,lat,lng. But without using Log(). In there such method where i can view that. If anyone understood this please reply me.Thanks in advance.</p>
android
[4]
5,857,989
5,857,990
Can I write an array of UILocalNotifications to disk?
<p>I'm trying to use the following code to persist the current list of local notifications. NSArray explicitly lists the kind of objects it will work with, which implies I can not use this with an array full of UILocalNotification objects. However, UILocalNotifications does implement NSCoding, which led me to believe there must be an easy way to serialize/deserialize this list of objects. Do I need to do the encoding and file persistence myself? Also, is there a way to get more information about why the write failed?</p> <pre><code>- (NSString*)getSavedNotifsPath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [documentsDirectory stringByAppendingString:@"saved_notifs.plist"]; } - (void)prepareToHide { UIApplication* app = [UIApplication sharedApplication]; NSArray *existingNotifications = [app scheduledLocalNotifications]; if (! [existingNotifications writeToFile:[self getSavedNotifsPath] atomically:NO] ) { // alert [self showSomething:@"write failed"]; } } </code></pre>
iphone
[8]
5,254,245
5,254,246
Are the Sky Map APIs available?
<p>I'm looking to build an application similar to Google Sky Map, and was wondering if it was possible to hook into any of the APIs it uses. If so, which ones? If not, how else can it be done?</p> <p>From what i've read so far, I can do a search via an intent for any the objects in Google's sky map db.. but i'd like to have my own db of satellites going around the earth, and be able to track those, get reminders on fly-overs and so-on.. so i'd like to build this app, but i just need a jumping off point.</p> <p>Thanks!</p>
android
[4]
2,298,870
2,298,871
It there have any way to create the DLL with a header file by using visual C#?
<p>I am doing mine FYP by using the </p> <ol> <li>Visual C# </li> <li>Agilent VEE</li> </ol> <p>I am try to import the DLL file which created from C# into Agilent VEE but VEE required the header file and library file for the importing.</p> <p>Please kindly help me.</p>
c#
[0]
803,447
803,448
detecting if came back from child activity
<p>How can I detect if an activity came to focus after pressing back button from child activity, and how can I execute certain code at that time.</p>
android
[4]
5,116,765
5,116,766
how to return objects interface name/type?
<p>Is there a function or something to get the interface of an object?</p> <p>Like, for <code>&lt;p/&gt;</code> = <code>HTMLParagraphElement</code>, how would I retrieve it?</p> <p>Thanks in advance!</p>
javascript
[3]
4,057,908
4,057,909
JavaScript Onclick window.open will not work properly in IE
<p>I hope my question is one that is simple to answer, but unfortunately I don't have a great knowledge of javascript. I've spend a good portion of the day Googling the issue and trying various workarounds, but nothing has worked adequately thus far. </p> <p>I am running a very simple piece of JavaScript so that when an image is clicked a separate window opens. This will work in every other browser (including mobile) except for IE. Following is what I've included in my head tag - </p> <pre><code>&lt;script type="text/javascript"&gt; function open_win() { window.open("music/player/song-of-my-soul.html", "_blank, _top", "toolbar=no, location=no, directories=no, status=no, menubar=mo, scrollbars=yes, resizable=no, toolbar=no, copyhistory=yes, width=240, height=400,"); } &lt;/script&gt; </code></pre> <p>I have then created a div with a background image and hover image, that when clicked should open the above page. Following is the line I have placed within the div - </p> <p>a href="#" alt="Listen to Samples" title="Listen to Samples" class="play-link" onclick="open_win()"></p> <p>This works fine in every other browser, but will not work in IE. I have tried several ways to reference the JavaScript in the head, but none of them will work. </p> <p>The page that I'm testing this on can be seen at the following - <a href="http://www.christlikemusic.com/song-of-my-soul.php#" rel="nofollow">http://www.christlikemusic.com/song-of-my-soul.php#</a> The 'Play' button in the center towards the bottom is the image that I have linked. </p> <p>If anyone would have any ideas on how I might fix this I would be most grateful !</p> <p>David</p>
javascript
[3]
2,923,671
2,923,672
Prevent form from submit w/ jQuery
<p>I have a page that displays data. A user can click "edit" button and the text displays within a form. Basically I hide form and on click toggle text to hide and form to show. I need to make sure that the form can not be submitted, via page refresh or clicking Enter key, until it is visible and the user clicks submit button.</p> <p>How do I do that? </p> <pre><code>$("#dataForm").hide(); $("#editData").click(function() { $("#dataForm").toggle(); $("#dataText").toggle(); }); &lt;div id="dataForm"&gt; &lt;label&gt;Label 1&lt;/label&gt; &lt;input type="text"&gt; &lt;label&gt;Label 2&lt;/label&gt; &lt;input type="text"&gt; &lt;input type="submit"&gt; &lt;/div&gt; &lt;div id="dataText"&gt; Label 1: abc &lt;br&gt; Label 2: 123 &lt;br&gt; &lt;span id="editData"&gt;Edit&lt;/span&gt; &lt;/div&gt; </code></pre>
jquery
[5]
2,672,608
2,672,609
IllegalAccessError: accessing a protected method
<p>I have two classes.</p> <p>Class <code>A</code> has protected method <code>m()</code>, <code>a</code> is an instance of <code>A</code>.</p> <p>Class <code>B</code> is in the same package as class <code>A</code>.</p> <p>I am trying to access <code>a.m()</code> but I am getting <code>IllegalAccessError</code>...</p> <p>What's wrong?</p>
java
[1]
4,401,017
4,401,018
Calling finish() on an Android activity doesn't actually finish
<p>I'm calling <code>finish()</code> but my activity keeps on going.</p> <p>I have an activity which is invoked by a menu from the main activity screen. In my activity's <code>onCreate()</code> method I have the following code fragment:</p> <pre><code> // Make sure there are some events in the list. if (theEventArrayList.isEmpty()){ Toast.makeText(this, "Event List is empty", Toast.LENGTH_LONG).show(); finish(); } SummarizeCurrentEvent(); graphEvents(); </code></pre> <p>If the list is empty it puts up the Toast, and I can set breakpoint on the call to <code>finish()</code>. If I step from that in the debugger it goes to straight to <code>SummarizeCurrentEvent()</code>. I thought <code>finish()</code> would exit the activity. Is this not the case? Where can I find out more information about this method?</p>
android
[4]
4,041,510
4,041,511
How to access subprojects header file in main project
<p>I have one main project and another project which is added as a subprojects. I want to access header file which is defined in subproject into the main projects but unfortunate it is saying file not find error.</p> <p>Please have look on the attach image. what should I modify to access header files of subprojects?</p> <p><img src="http://i.stack.imgur.com/bppIK.png" alt="enter image description here"></p>
iphone
[8]
1,886,568
1,886,569
Output the total number of String Characters
<p>My Question is what method should I use if I wanted to get the total number of characters a user inputs? without using arrays, i tried using .length() but it did not return all characters say from the first and lastname, it only returned the first name. </p> <p>Here's an example of my code. (Please dont laugh im really new in programming :) )</p> <pre><code>System.out.print("Enter your first and last name: "); String yourName = keyboard.next(); System.out.println("Your name has a total of " + yourName.length() + " numbers"); </code></pre> <p>what happened was if i enter say "Neo Matrix" it would only return 3.</p> <p>I appreciate any help. thank you!</p>
java
[1]
388,823
388,824
What mode should I use when I create a folder for uploaded files
<p>I have this directory structure:</p> <pre><code>\htdocs \htdocs\uploadfiles\ </code></pre> <p>Now if a user's id is s001, then I should create a new folder for this user to store uploaded files.</p> <pre><code>\htdocs \htdocs\uploadfiles\ \htdocs\uploadfiles\s001\ </code></pre> <p>Here are my questions:</p> <pre><code>Q1&gt; What mode should I use for \htdocs\uploadfiles Q2&gt; What mode should I use for \htdocs\uplaodfiles\s001\ </code></pre> <p>Based on <code>http://www.elated.com/articles/understanding-permissions/</code> The function I use to create the folder for the user is as follows:</p> <pre><code>mkdir("/htdocs/uploadfiles/s001/", 0700); </code></pre> <p>That means only the owner of the s001 has access read/write/execute. But I don't know whether or not this is correct and practical.</p>
php
[2]
5,471,174
5,471,175
ASP.NET: Without using Membership API, how do you restrict resource files(e.g. jpg) to certain roles?
<p>It is easy to restrict access to aspx pages, just use role-checking logic in the code-behind. But resource files like a photo does not have a code behind to put role-checking logic, so how to restrict access?</p>
asp.net
[9]
2,693,997
2,693,998
File Explorer (File Selection) android
<p>I want to let the user select some files from his android device to upload it on server. how can i show a file explorer and let the user pick any(image/audio/vedio) file (single or multiple selection) to upload it.<br> how can i implement this.</p> <p>Please help.<br> thanks.. </p>
android
[4]
5,681,229
5,681,230
how to make layout to work on all size in android
<p>can anybody tell how to make layout to work on all size in android.if I used support screen is it work for all screen size ? can anybody tell how to do?</p> <pre><code>&lt;supports-screens android:resizeable=["true"| "false"] android:smallScreens=["true" | "false"] android:normalScreens=["true" | "false"] android:largeScreens=["true" | "false"] android:xlargeScreens=["true" | "false"] android:anyDensity=["true" | "false"] android:requiresSmallestWidthDp="integer" android:compatibleWidthLimitDp="integer" android:largestWidthLimitDp="integer"/&gt; </code></pre>
android
[4]
4,760,456
4,760,457
Dynamic memory allocation with default values
<pre><code>class A { private: int m_nValue; public: A() { m_nValue = 0; } A(int nValue) { m_nValue = nValue); ~A() {} } </code></pre> <p>Now in main if i call </p> <pre><code>A a(2);// 2 will be assigned for m_nValue of object A. </code></pre> <p>Now how do we do this if i want to define an array of objects. Also how do we do this if i dynamically create objects using operator new like </p> <pre><code>A *pA; pA = new A[5];// while creating the object i want the parameterised constructor to be //called </code></pre> <p>I hope the question is clear. Do let me know if more explanation is needed</p>
c++
[6]
4,806,613
4,806,614
How to select with jquery, similar elements from different DOM levels?
<p>I would like to select only the "mixitup" elements from the same level clicking on one of this elements.</p> <pre><code>&lt;div data-id="0"&gt; &lt;div class="mixitup"&gt;1&lt;/div&gt; &lt;div class="mixitup"&gt;2&lt;/div&gt; &lt;div class="mixitup"&gt;3&lt;/div&gt; &lt;/div&gt; &lt;div data-id="1"&gt; &lt;div class="mixitup"&gt;4&lt;/div&gt; &lt;div class="mixitup"&gt;5&lt;/div&gt; &lt;div class="mixitup"&gt;6&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I mean. If I click in the DIV with contents = 4, I would like to select the DIVs 4,5 and 6.</p> <p>Someone know a way to do it? thanks</p>
jquery
[5]
3,805,161
3,805,162
how to sort the list<Date, String> in Java according to Date
<p>I have some table names coming as i/p param to my method. I need to get the creationDate (date), count for each table and put it in a consolidated List)</p> <p>and then Sort the list according to the creationDate.</p> <p>Here is the Method:</p> <pre><code>public String getData(List tablename){ Lifecycle.beginCall(); EntityManager mgr = (EntityManager) Component.getInstance("entityManager"); List data = new ArrayList(); if (!tablename.isEmpty()) { Iterator itr = tablename.iterator(); while(itr.hasNext()) { String element = itr.next().toString(); Query q = mgr.createQuery("select to_date(s.creationDate), count(s)" + " from " + element + " s" + " group by to_date(creationDate)" + " order by to_date(creationDate)"); List dataTemp = q.getResultList(); data.addAll(dataTemp); } } } </code></pre> <p>Now I have List data, e.g.:</p> <pre><code>({["Jan 3, 2013 12:00:00 AM",10], ["Feb 3, 2013 12:00:00 AM",10], ["Jan 1, 2013 12:00:00 AM",10], ..........}) </code></pre> <p>Challenge here is i want this List to be sorted according to the date</p>
java
[1]
3,059,227
3,059,228
How to run the same asynctask more than once?
<p>I have my asyncTask run when the activity first starts, then if network connectivity is not available then i have a refresh button that tries to run the asyncTask to try again. But i get a debug error saying this..</p> <pre><code>07-29 18:14:21.290: ERROR/AndroidRuntime(9080): FATAL EXCEPTION: main 07-29 18:14:21.290: ERROR/AndroidRuntime(9080): java.lang.IllegalStateException: Cannot execute task: the task has already been executed (a task can be executed only once) 07-29 18:14:21.290: ERROR/AndroidRuntime(9080): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:541) 07-29 18:14:21.290: ERROR/AndroidRuntime(9080): at android.os.AsyncTask.execute(AsyncTask.java:499) 07-29 18:14:21.290: ERROR/AndroidRuntime(9080): at com.fttech.gameIT.MainMenu$1.onClick(MainMenu.java:90) </code></pre> <p>Is there anyway to run this twice?</p>
android
[4]
2,745,326
2,745,327
attr('selected','selected') not work in jquery
<pre><code>$('#sellist option').each(function(index) { var str ='4/5/8'; var substr = str.split('/'); if (substr[0] == $(this).attr('value')) { $(this).attr('selected','selected'); alert('hi'); ///For check } }); </code></pre> <p>Every thing works fine and <code>alert</code> is fired. I havent any error in console. But <code>#sellist option</code> is not selected which I want. What is my problem. Thanks.</p>
jquery
[5]
3,641,644
3,641,645
Javascript: Can't reference window from parent
<p>So i have a popup javascript calendar someone else wrote into my app. What i am trying to do is reference it from the window that opens it, but the normal way of assigning the window.open to a variable is not working. I think the issue is that the calendar, while being generated set itself as its opener.</p> <pre><code> var vWinCal = window.open("", "Calendar", "width=200,height=250,status=no,resizable=yes,top=200,left=200,status=yes,menubar=yes"); vWinCal.opener = self; vWinCal.focus(); var calc_doc = vWinCal.document; calc_doc.write (str_buffer); calc_doc.close(); </code></pre> <p>It this my problem? Is there a way around it?</p> <p>Thanks</p>
javascript
[3]
6,028,305
6,028,306
Java Pentaho Reporting TOC generation from selected Subreports in Masterreport?
<p>I need help on generating programmatically a toc from a list of selected subreports in a masterreport! I already add all jars needed in my classpath like (pentaho engine extension toc... api)</p> <p>Could someone help me pls with a howto or a sample</p> <p>best regards </p> <p>Marc</p>
java
[1]
4,503,981
4,503,982
Include headers of both base and inherited class in main
<p>I have a class <code>calendar</code> and a class <code>extendedCalendar</code> that inherits from <code>calendar</code></p> <p>I want to be able to create objects of both classes in main, so i include both of their headers in <code>main.cpp</code> :</p> <pre><code>#include "calendar.h" #include "extendedCalendar.h" </code></pre> <p>The problem is that <code>extendedCalendar.h</code> also has <code>#include "calendar.h"</code> in its header so compiler gives me an error:</p> <blockquote> <p>'calendar' : 'class' type redefinition</p> </blockquote> <p>How can i circumvent this ?</p>
c++
[6]
2,555,269
2,555,270
Strange use of strlen
<p>I tried to compile the follow sample code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;string&gt; using namespace std; int main () { if (strlen &lt;= 0) { cout &lt;&lt; "trace1" &lt;&lt; endl; return 0; } cout &lt;&lt; "trace2" &lt;&lt; endl; return 0; } </code></pre> <p>The strange thing is that it compiles successfully. Do you have any idea why?</p> <p>I have not declare the strlen as variable.</p>
c++
[6]
3,355,272
3,355,273
How do I add a time difference to an array with PHP?
<p>I have the following array structure in MySQL. There could be no items or many items; the example shows only three.</p> <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 1 ... [start_time] =&gt; 09:00:00 [finish_time] =&gt; 10:20:00 ... ) [1] =&gt; Array ( [id] =&gt; 2 ... [start_time] =&gt; 13:00:00 [finish_time] =&gt; 14:20:00 ... ) [2] =&gt; Array ( [id] =&gt; 23 ... [start_time] =&gt; 18:05:00 [finish_time] =&gt; 19:35:00 ... ) etc etc ) </code></pre> <p>I want to add the time difference between start_time and finish_time and find out the total time with PHP. </p> <p>For example, the above should produce 250min or 4 hr 10min (80 min + 80min + 90min). How do I do this?</p>
php
[2]
461,132
461,133
E/Trace(640): error opening trace file: No such file or directory (2)
<p>I installed Android SDK, JDK, Eclipse. My project name is Bible, and I build in eclipse Bible. In emulator this error shows <em>"Unfortunately, Bible has stopped"</em> and in Logcat this error message shows</p> <pre><code>E/Trace(640): error opening trace file: No such file or directory (2) shuttind down VM </code></pre> <p>How can I solve this?</p> <p><strong>Update</strong>: After a few minutes, in Logcat this message was added</p> <pre><code>com.example.bible Process Sending signal. PID: 623 SIG: 9 </code></pre>
android
[4]
3,025,727
3,025,728
Speed of Android mobile
<p>How to calculate the speed with which android mobile is moving, i.e user with mobile in his pocket/hand. Basically I would like to invoke some activity based on the user's speed, how will I calculate? based on what parameters in mobile. Thank you. </p>
android
[4]
490,100
490,101
Jquery Photogallery
<p>I am using following Jquery code for SlideShow</p> <pre><code>&lt;head&gt; &lt;title&gt;Simple Slide Show with jQuery&lt;/title&gt; &lt;script type='text/javascript' src='http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; var imgs = [ 'images/photo_1.jpg', 'images/photo_2.jpg', 'images/photo_3.jpg']; var cnt = imgs.length; $(function() { setInterval(Slider, 5000); }); function Slider() { $('#imageSlide').fadeOut("slow", function() { $(this).attr('src', imgs[(imgs.length++) % cnt]).fadeIn("slow"); }); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;img id="imageSlide" alt="" src="" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I have all all images named like photo_1.jpg, photo_2.jpg and soon.. i am not sure that how many images will be there in the directory.</p> <p>What i want to know is what code changes should i do so that </p> <p>1) The jpgs are displayed automatically from that folder ( the image name will be always photo_number.jpg , number will be starting from 1,2,3.. and soon.</p> <p>2) The slideshow should stop if there is no image available.</p> <p>Is this possible ?</p> <p>3) I dont want to use any Server Side Programming</p>
jquery
[5]
2,784,459
2,784,460
Read div value from webpage
<p>I haven't really found anything about this. I want to read data from a website. From my webpage I can read a div's value with </p> <pre><code>&lt;div class="tools"&gt;hammer&lt;/div&gt; var divs = document.getElementsByTagName("div"); for(var i=0; i&lt;divs.length; i++ ) { if(divs[i].className == "tools") { alert(divs[i].innerHTML); } } </code></pre> <p>Is it possible to set the URL of the desired webpage so this code would scrape that page? I know the classname and the url.</p> <p>Based on @cereallarceny's answer I created this code block but I see no alert when running the script:</p> <pre><code>$.ajax({ type: 'get', url: 'https://play.google.com/store/apps/details?id=com.viber.voip', crossDomain: true, //Very important, ensures you can get data from a domain that isn't your own! success: function() { var divs = document.getElementsByTagName("div"); for(var i=0; i&lt;divs.length; i++ ) { if(divs[i].className == "votes") { alert(divs[i].innerHTML); } } } }); </code></pre>
javascript
[3]
2,892,531
2,892,532
How can I stop an ASP.NET website from loading depending on a certain condition?
<p>How can i stop asp.net website?<br> I want check some condition and after that if something's wrong then stop website from loading.</p>
asp.net
[9]
1,458,433
1,458,434
How to know the formatting of Excel Cell
<p>Is it possible to figure out the Format of Excel cell i know there is .NumberFormat but it returns the formatting but not the type... basically i need to know if it is custom then it should return custom and if it is currency it should return Currency or any other datatype Please help me</p>
c#
[0]
5,008,339
5,008,340
Subsequence of strings
<p>I implemented a python function that returns the longest common subsequence of 2 strings. Now, I'd like to implement a function that returns the longest common subsequence of any number of strings.</p> <p>I found this help for 3 strings:</p> <pre><code>dp[i, j, k] = / 1 + dp[i - 1, j - 1, k - 1] if A[i] = B[j] = C[k] \ max(dp[i - 1, j, k], dp[i, j - 1, k], dp[i, j, k - 1]) otherwise </code></pre> <p>But I don't really understand this hint. So, I'd be thankful if anybody could help me. Best regards, Mark</p>
python
[7]
2,699,388
2,699,389
On-the-fly modifications of the links according to a set of rules (Greasekit / Javascript)
<p>I have an HTML page with loads of entries like this:</p> <pre><code>&lt;a href="https://www.example.co.uk/gp/wine/product?ie=UTF8&amp;amp;asin=123456789&amp;amp;tab=UK_Default" class="PrmryBtnMed" </code></pre> <p>I want to replace all this links so they instead are <a href="https://www.example.co.uk/gp/wine/order?ie=UTF8&amp;asin=1233456789" rel="nofollow">https://www.example.co.uk/gp/wine/order?ie=UTF8&amp;asin=1233456789</a></p> <p>So, it's quite a complicated search and replace. These are the instructions for a human: 1. Look at the URL. Only make a note of the number after 'asin='. (Forget everything before that and everything after that) 2. Then, form a new URL, using this ASIN. It will ALWAYS start like this:</p> <pre><code>https://www.example.co.uk/gp/wine/order?ie=UTF8&amp;asin= </code></pre> <p>with the number stuck on the end to form:</p> <pre><code>https://www.example.co.uk/gp/wine/order?ie=UTF8&amp;asin=123456789 </code></pre> <p>Kindly note</p> <ul> <li>rather than modifying the existing buttons, it would also be acceptable to add a new button [or link] near the original buttons</li> <li>both the original and new links point to the same domain</li> <li>I'm using Greasekit on a SSB called FluidApp, but I can switch to Greasemonkey on FireFox. </li> </ul> <p>I've just watched 40 JavaScript tutorial videos - man this language is hard! This seems extremely difficult. I would hugely appreciate any help/pointers. </p>
javascript
[3]
2,068,624
2,068,625
get data by id in grid view
<p>I have a table with threads for a forum, the thread name is a link and once clicked it passes the thread_id to the comments page, I need to know how to then display all the comments with the thread_id that is passed?</p> <p>Have tried:</p> <pre><code>&lt;asp:SqlDataSource ID="CommentsDataSource" runat="server" SelectCommand="select * from comments where thread_id=@thread_id" &gt; &lt;SelectParameters&gt; &lt;asp:QueryStringParameter Name="@thread_id" QueryStringField="thread_id" Runat="Server" /&gt; &lt;/SelectParameters&gt; &lt;/asp:SqlDataSource&gt; &lt;asp:GridView ID="GridView1" runat="server"&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="comment" HeaderText="Comment" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>but it doesn't work</p> <p>Thanks</p>
asp.net
[9]
3,731,565
3,731,566
How to use menu and onKeyDown() on the same activity
<p>I am developing an Android app. I have written my own code for back key event. For that i am catching events using this method public boolean onKeyDown(int keyCode, KeyEvent event) .....</p> <p>I also want to use Menu options I have used Inflator for that. But when I click on menu button, that event caught by my onKeyDown method.</p> <p>I am not expecting that, I expect to execute following methods,</p> <pre><code>public boolean onCreateOptionsMenu(Menu menu){ // creating menu using MenuInflator } public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case : return true; default: } } </code></pre> <p>How could I use both the things on the same activity?? Any Idea ???</p>
android
[4]
2,129,971
2,129,972
Need your suggestion with conversion
<p>We having a VB6 Windows Application and now user wants to convert this with latest C# Asp.net/Asp.Net MVC application.</p> <p>If Asp.net Web application is not possible, then we can opt for C# winform application.</p> <p>My question what are the migration tools available and what are the challenges in conversion.</p> <p>Please suggest?</p>
asp.net
[9]
5,527,625
5,527,626
How to check special characters with Regular Expressions?
<p>In javascript I check for some characters but I want to allow underscores and slashes but I don't know how. </p> <pre><code> alias: /^[a-z-Z0-9]{2,35}$/ </code></pre> <p>How to put / and _ so it has not special meaning to Regexes. </p>
javascript
[3]
4,920,455
4,920,456
Converting Canvas to Drawable
<pre><code>int x = 10; int y = 10; int r = 4; Paint mPaint = new Paint(); mPaint.setColor(0xFF0000); Canvas mCanvas = new Canvas(); mCanvas.drawCircle(x,y,r,mPaint); </code></pre> <p>Is there any way to convert <code>mCanvas</code> to a Drawable? My goal is to generate drawables with a certain shape and color.</p> <p>Thanks</p>
android
[4]
402,898
402,899
How to make a score counter for my Android app
<p>I'm quite a beginner with java and Android in general so I would like to ask how to easily make a score counter that would change every millisecond, so every millisecond they survive the score counter moves up 1. Something like <a href="http://d2fhka9tf2vaj2.cloudfront.net/tuts/062_scoreClass/Tutorial/15.jpg" rel="nofollow">this</a>.</p>
android
[4]
4,440,048
4,440,049
Android emulator takes time to run application
<p>When I am running my hello world codes with Android emulator, its take more time to run. If it take more time my debugging process goes slow, because each time I have to run emulator. Is there a way which I am missing, or emulator takes more time to run applications. </p>
android
[4]
4,057,634
4,057,635
Submitting form results that there is no error to another page
<p>i want to know how to send value form my_name in index.php below to result.php.</p> <p>below is the php code to check for errors after the input form. and how to send form results that there is no error to result.php</p> <p>here is index.php</p> <pre><code>&lt;?php if ($_POST["_submit_check"]) { if ($form_errors = validate_form()) { show_form($form_errors); } else { process_form(); } } else { show_form(); } function process_form() { //if doesnt makes error //i want to send result "my_name" to result.php header('Location: result.php'); } function show_form($errors = '') { if ($errors) { print implode('&lt;/li&gt;&lt;li&gt;&lt;br&gt;', $errors); print '&lt;/li&gt;&lt;/ul&gt;'; } print&lt;&lt;&lt;_HTML_ &lt;form method="POST" action="$_SERVER[PHP_SELF]"&gt; Your name: &lt;input type="text" name="my_name"&gt;$errors[0]; &lt;br/&gt; &lt;input type="submit" value="Submit"&gt; &lt;input type="hidden" name="_submit_check" value="1"&gt; &lt;/form&gt; _HTML_; } function validate_form() { $errors = array(); if (strlen($_POST['my_name']) &lt; 3) { $errors[] = "Your name must be at least 3 letters long."; } return $errors; } ?&gt; </code></pre> <p>here is result.php</p> <pre><code>&lt;?php //prints result form from index.php ?&gt; </code></pre>
php
[2]
2,330,280
2,330,281
i have a list in my customer.txt how to create a search function to print out the whole customer information using python
<p>Hi i have a list in my customer.txt file:</p> <pre><code>[1, 'Amin Milani Fard', 'Columbia College', 778] [33, 'Ali Sulemanji', 'Langara College', 4324442211] [32, 'Ali Sulemanji', 'Langara College', 4324442211] [325, 'Ali Sulemanji', 'Langara College', 4324442211] [2, 'Yuvin Ng','Dougles College',77839922003] [3, 'Ali Sulemanji', 'Langara College', 4324442211] </code></pre> <p>my job is to create a search function that can track the customer name. for eg. type in the customer name:Yuvin Ng and it will return the whole list from Yuvin Ng's line</p> <p>how can i do that? using python.</p> <pre><code>def search(n): name=input('Customer Name:') x=open('customerlist.txt','r') i=0 while i&lt;1000: # anyway this is out of desperation to make the function work... z=x.readline() print(z) i+=1 </code></pre> <p>im stuck... pleease help a.s.a.p thx you..</p>
python
[7]
2,609,575
2,609,576
flatten a list of variable length arrays
<p>how to convert this:</p> <pre><code>[2, 4, array([ 3.]), array([ 4.]), array([ 5., 4.])] </code></pre> <p>to</p> <pre><code>[2,4,3,4,5,4] </code></pre> <p>I've tried searching but the solutions work for</p> <pre><code>[array([ 2.]), array([ 4.]), array([ 3.]), array([ 4.]), array([ 5., 4.])] </code></pre> <p>and</p> <pre><code>[[2],[4],[3],[4],[5,4]] </code></pre>
python
[7]
676,939
676,940
Isn't a const variable at namespace scope implicitly static?
<p>I know that <code>static const int x = 42;</code> at namespace scope is equivalent to <code>const int x = 42;</code> because <code>const</code> variables are implicitly <code>static</code> (they must be declared <code>extern</code> to be given external linkage). Every translation unit that includes this declaration gets a local copy of <code>x</code>.</p> <p>Does this only apply to certain (perhaps integer?) types? I have the following code in a header file:</p> <pre><code>namespace XXX { static const char* A = "A"; static const char* B = "B"; static const char* C = "C"; // and so on } </code></pre> <p><strong>(PLEASE spare me the comments on why I should not be using C-style strings -- this is legacy code)</strong></p> <p>This header is included from several source files, and all is fine (each compilation unit gets its own copy of these <code>char*</code>'s). I would have thought that I could remove the <code>static</code> from these, as it is redundant, but when I do, I get link errors about the symbols being already defined in another object. What am I missing here? Are these <code>const char*</code>'s <strong>not</strong> implicitly static?</p>
c++
[6]
4,497,455
4,497,456
Check if string contains only combinations of array elements (numbers and words)
<p>I've searched for hours and can't find any example of what I'm trying to do. I can't even figure out what php function needs to be used, but I'm thinking probably a regex. I attempted to use in_array and it didn't work. I don't know enough about regexes to even set up a test. Here's the problem... Say my array is:</p> <pre><code>$sizeopts = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.5', ' Wide', ' Narrow', 'XS', 'Small', 'Medium', 'Large', 'XL'); </code></pre> <p>The textbox name is "size", and I want to only allow combinations of the above to be submitted. Example valid input: "10.5 Wide" or "3XL". Invalid input: "1X" or "2Wide" (missing the space in front of Wide). I have several different size arrays I need to validate. I'm not just using drop-downs because there are two many different possible combinations. Thanks for any help you can offer!</p>
php
[2]
2,897,294
2,897,295
How to unload a child user Control that is Loaded on parent control in asp.net
<p>I Am working with user controls in Asp.net.</p> <p>I am loading a user Control(Usercontro2) in a Control panel of a parent child control (Usercontro1).</p> <p>Now I want to unload the control on the click of link button of Usercontro2</p> <p>How can I do it in the Child user control.</p>
asp.net
[9]
1,381,978
1,381,979
How to set contact as favourite through coding?
<p>I need to toggle existing android contacts to favourite. I have a toggle button which is suppose to set/unset current contact as favourite.</p> <p>Any help regarding this is appreciated.</p> <p>Thanks in advance.</p>
android
[4]
532,027
532,028
how to create a package
<p>I just know how to create a package just by declaring it at the top of the class but I dont know the code for creating it </p> <pre><code>package myPackage; class test{ system.out.println("Hello every one"); } </code></pre> <p>please provide me the code to compile it </p>
java
[1]
4,442,943
4,442,944
converting Inline if to if else
<p>I am new to java and i want some help on converting the below inline if java code to if else.</p> <pre><code>public boolean equals(final Object obj) { boolean result = true; if (level != null ? !level.equals(log.level) : log.level != null) { result = false; } return result; } </code></pre>
java
[1]
4,766,753
4,766,754
When page is loading, display a image after 5 seconds swap with text
<p>I have a div that has content in it.</p> <pre><code>&lt;section id="latest-news"&gt; &lt;p&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.&lt;/p&gt; &lt;/section&gt; </code></pre> <p>But while the page is loading, I want a loading .gif to appear, wait about 5 seconds and the the text. With a fadeIn or slide down animation too. (The text would be hidden by default)</p> <p>I tried for an hour on this but I can't get it to work :/</p> <p>What is a way to do this?</p>
jquery
[5]
4,635,265
4,635,266
Custom Control Event Not Firing First Time
<p>My application runs from a single page (default.aspx) and loads custom controls based on what the user selects (this is done in the LoadPage event). </p> <p>The problem is that the FIRST time some new controls are loaded onto the page and a button is clicked, the page is NOT firing the Click event. This also happens when using a GridView and other controls.</p> <p>However, if I simply reload the page a second time, the events are fired properly. (this works successfully every time)</p> <p>Two questions: 1) Why would this occur? 2) How can I troubleshoot it better? I've tried checking the Request.Form(__EVENTTARGET) (which is blank)</p> <p>There are times when it works properly which suggests a PostBack issue - but it's not obvious.</p>
asp.net
[9]
2,161,266
2,161,267
How do I make a Home Screen Application not be recreated when pressing the home button
<p>Pardon my dodgy explanation in the title. What happens is: I'm trying to make a home screen application. So far so good, I made the app launcher that launches an application when executed. But, if for example I press the home screen to be taken back to my application, instead of continuing the activity from onResume() it relaunches the application from onCreate();</p> <p>this is the code i use to launch e new activity:</p> <pre><code>PackageManager pm=getPackageManager(); Intent intent = pm.getLaunchIntentForPackage(applications.get(c).pname); startActivity(intent); </code></pre> <p>Any idea how I can make it so that when I press the Home button it doesn't relaunch the whole app?</p>
android
[4]
3,585,315
3,585,316
add autoplay in this piece of code?
<pre><code>$(document).ready(function() { $('a.link').click(function () { $('#wrapper').scrollTo($(this).attr('href'), 200); setPosition($(this).attr('href'), '#cloud1', '0px', '5px', '20px', '30px') setPosition($(this).attr('href'), '#cloud2', '0px', '100px', '200px', '400px') setPosition($(this).attr('href'), '#cloud3', '0px', '15px', '30x', '45px') $('a.link').removeClass('selected'); $(this).addClass('selected'); return false; }); </code></pre>
javascript
[3]
3,441,702
3,441,703
How to instantiate a generic type object in C#?
<p>I have class like this:</p> <pre><code>public ClassA&lt;T&gt; where T : class{ ... } </code></pre> <p>Now I need to to create an object of ClassA in the constructor of ClassB:</p> <pre><code>public ClassB{ public ClassA&lt;?&gt; objA; public ClassB(string TypeInfo){ objA = new ClassA&lt;?&gt;(); // Suppose TypeInfo = 'ClassC', and the '?' // Should be derived from TypeInfo } ... } </code></pre> <p>I don't know what to replace '?' for, since the type can only be known at runtime... any ideas?</p>
c#
[0]
5,771,786
5,771,787
Update Application Feature in Android
<p>I want to put update application feature in android. can anyone tell me how to achive this functionality..?</p> <p>thanks for reading</p>
android
[4]
5,755,250
5,755,251
Fade (reduce opacity) image with jQuery only while mouse over
<p>I want to turn the opacity of the image to half when it is hovered (and return it to normal when the cursor is not hovering any more).</p> <p>I only succeed in making all the images <code>fadeTo</code>, but when the mouse is out the images still faded (and all the images fade. I just one the image under the cursor to fade).</p> <p>Any suggestions? </p> <p><strong>Code:</strong></p> <pre><code> /** * Opacity animation of blocks */ $j('#content div a').hover(function() { $j('#content div a img').fadeTo('slow', 0.5, function() { }); </code></pre>
jquery
[5]
3,953,565
3,953,566
How to handle session? When do we create a session id
<p>Hi all im facing a problem, and i need suggestion from the experts out here. There is Shopping cart module in my project that uses webservice .The workflow is </p> <ol> <li>Create session Id.( I have an xml input which returns me a long string as session id)</li> <li>Add Product to cart ( WHere i use the above session id and the product unique code as xm input)</li> <li>Get cart ( Here the input parameter in the xml is the sessionid.Means i will get a list product in that session)</li> <li>Delete from cart( Here the xml parameters are session id and product unique code)</li> </ol> <p>What i have done is while loading the splash screen i have written code to generate the session id and i keep it in the first location of a list for later use.</p> <pre><code> CartService cartService=new CartServiceImpl(); SterviceResponse ob = cartService.createPartnerSession(); Session session = new Session(); session.setSessionId(ob.getStringValue()); </code></pre> <p>Session.getSessionId() will return me the session id The program works fine if there is no internet problem,But if i switch off wifi in between the program will crash.Now i will have to restart the app to start a new session.Also i want to expire the session if the phone is idle for a particular period of time.</p> <p>What is the best way to store and handle session id in side the program?</p>
android
[4]
583,614
583,615
Looking for C# HTTP Component/Class
<p>I know HTTPRequest and Response are available, but I am looking for a HTTP component/class wrapper that I can plug straight into code with less hassle.</p> <p>Are there any free or paid components/classes like this?</p>
c#
[0]
5,334,398
5,334,399
Use method from another class on ArrayList with foreach loop?
<pre><code>public void verschuif1(){ for(Object x : puntenLijst){ x.verschuif2(3, 3); } } </code></pre> <p>puntenLijst is an ArrayList of object instances from another class. Now I tried to do something with a foreach loop that loops through all objects in the ArrayList and uses the method verschuif2() (from an other class) on it.</p> <p>But it doesn't seem to be working.</p> <p>Can anybody help me out?</p> <p>Thanks a lot!</p>
java
[1]
2,887,630
2,887,631
plugin to indicate a form element value has been changed
<p>A date selection HTML form section contains two drop downs - one for the day of the month, the other for the month.</p> <p>When selecting an invalid date such as 31st February, the day value is automatically updated to be valid (29th in the case of this form).</p> <p>I would like to unobtrusively highlight this automatic change to the user with a JQuery effect - for example, bu modifying the border of the updated element somehow, temporarily.</p> <p>Does anyone know of any JQuery plugins that could help here?</p>
jquery
[5]
3,142,751
3,142,752
a simple php logic
<p>I just saw this source code on a website, but I don't know what it means, can anyone tell me what it is? thank you so much.</p> <pre><code>private function buildCache() { !empty($this-&gt;cache_list) &amp;&amp; $this-&gt;cache-&gt;loadCache($this-&gt;cache_list); } </code></pre>
php
[2]
5,818,581
5,818,582
Cookies are not removing on Log Out
<p>I've got a problem, user can't Log Out because the $_COOKIE's are not actually deleting. I can't find out what could be the problem.</p> <p>This code is used only once at Log In:</p> <pre><code>// Log In $_SESSION['user_id'] = $row['user_id']; $_SESSION['username'] = $row['username']; setcookie('user_id', $row['user_id'], time() + 2592000); setcookie('username', $row['username'], time() + 2592000); </code></pre> <p>The code below is checking if cookies are set up to make users to be logged in when they relaunch their browser (the "keep me logged in" effect).</p> <pre><code>// Starting Session session_start(); // If the session vars aren't set, try to set them with cookies if (!isset($_SESSION['user_id'])) { // This check always equals true because cookies are not deleting on Log Out if (isset($_COOKIE['user_id']) &amp;&amp; isset($_COOKIE['username'])) { $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['username'] = $_COOKIE['username']; } } </code></pre> <p>This code is launched only once on Log Out:</p> <pre><code>// Log Out session_start(); if (isset($_SESSION['user_id'])) { $_SESSION = array(); if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time() - 2592000, '/'); } session_destroy(); } setcookie('user_id', '', time() - 2592000); setcookie('username', '', time() - 2592000); </code></pre>
php
[2]
2,894,020
2,894,021
is it possible to read contents of a div from another html using jquery?
<p>im trying to read the contents of myDiv which resides in a separate html file and do some appending in the current page,is this possible? i know there is load(), but it displays the whole html as it is.</p> <pre><code>$( ".myDiv" ).each(function(){ //do stuff }); </code></pre> <p>i have tried $('#result').load('ajax/test.html #container') route, but it loads the contents from #container in to the div with id #result.i want to read the contents of the div with id #container from ajax/test.html,make some changes then display it in the div with id #result... im trying to use the each function on a div that resides on another page,hope im making some sense</p>
jquery
[5]
3,357,052
3,357,053
Why is this 3n+1 saying that my submission is wrong?
<p>I am trying to solve the famous 3m+1 problem. Using this source code, I don't know why I'm getting wrong answer :/ Although, if I run it , it works fine.</p> <pre><code>#include &lt;iostream&gt; using namespace std; long int cycle(long int,long int); int main() { long int i=0, j=0; while (cin &gt;&gt; i &gt;&gt; j) { if(i &gt;= 0 &amp;&amp; j &gt;= 0 &amp;&amp; j&lt;= 1000000 &amp;&amp; i &lt;= 1000000) { cout &lt;&lt; i &lt;&lt; " " &lt;&lt; j &lt;&lt; " " &lt;&lt;cycle(i,j) &lt;&lt; endl; } } return 0; } long int cycle(long int start,long int end) { int largest_cycle = 0; int n =0; int counter =0; for(int j=start;j&lt;=end;j++) { n=j; counter =0; while(n != 1) { counter++; if( n % 2 == 0) n /=2; else n = (3*n) +1; if( n==1) counter++; } if(counter &gt; largest_cycle) largest_cycle = counter; } return largest_cycle; } </code></pre> <p>any help will be highly appreciated.</p>
c++
[6]
394,545
394,546
Extract first match from a string of text?
<p>Say I have the following string:</p> <blockquote> <p>hello my car is red and my shoe is blue</p> </blockquote> <p>I want to match the following words:</p> <blockquote> <p>blue, red, orange, purple</p> </blockquote> <p>So it searches the variable for those 4 words, and returns the first one - in my example the word returned would be 'red'. But if the car was blue, the word blue would be returned first as that is the first one it finds out the list of possible matches.</p> <p>How can I do this?</p>
php
[2]
875,630
875,631
Parsing an image with JAI
<p>I use JAI, because I want to work with a tif. I read the image into a PlanarImage</p> <p>The whole problem: Now I have to do some calculations on this image. First I have to read the RGB values, then do some calculations on blocks with 16x16 pixels.</p> <p>What's the best way to do this?</p> <p>Does anyone have an idea?</p>
java
[1]
2,568,383
2,568,384
android : how to send NFC data from dialogfragment?
<p>I have a question. I want to send NFC data at DialogFragment &lt;- it is show AlertDialog</p> <pre><code>public static class XDialogFragment extends DialogFragment { ... @Override public void onAttach(Activity activity) { // TODO Auto-generated method stub NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity); // Register callback to set NDEF message nfcAdapter.setNdefPushMessageCallback(new CreateNdefMessageCallback() { @Override public NdefMessage createNdefMessage(NfcEvent event) { ... return mes.getNdefMessage(); } }, activity); // Register callback to listen for message-sent success nfcAdapter.setOnNdefPushCompleteCallback(new OnNdefPushCompleteCallback() { @Override public void onNdefPushComplete(NfcEvent event) { ... } }, activity); super.onAttach(activity); } ... } </code></pre> <p>it doesn't work callback function (CreateNdefMessageCallback,OnNdefPushCompleteCallback)</p>
android
[4]
3,177,207
3,177,208
How to compress viewstate
<p>when i click on asp buttons it is giving me error as "The state information is invalid for this page and might be corrupted."</p> <p>on searching for this error,someone told me that viewstate is storing large amount of data.</p> <p>so i want to compress the viewstate. can anybody tell me how to compress the viewstate in asp.net project c# 3.5</p>
asp.net
[9]
3,936,916
3,936,917
in php i need one line if condition for time compare
<p>i have to value</p> <pre><code> $mo=strtotime($input_array['MondayOpen']); $mc=strtotime($input_array['MondayClose']); </code></pre> <p>now i need a if condition to display an error on below conditions</p> <ol> <li>if one of them($mo or $mc) are empty, null or blank.</li> <li>if close time($mc) is less than open time($mo)</li> </ol> <p>means if both are empty(null) or $mc>$mo then go further</p> <p>please suggest optimized one line if condition for this</p> <p>i know it seems very basic question, but i m facing problem when both are null either i was using simple</p> <pre><code>if(($mo==NULL &amp;&amp; $mc!=NULL) || ( $mo&gt;=$mc &amp;&amp; ($mo!=NULL &amp;&amp; $mc!=NULL)) ) </code></pre>
php
[2]
3,182,173
3,182,174
Load function doesn't work with IE
<p>I can't get load function to work with IE. In Google Chrome my website runs fine. I tried to fix the issue with "no-cache" strategy, but no luck. What else should i do to make it work with IE?</p> <p>Source:</p> <pre><code>&lt;meta http-equiv="Cache-control" content="no-cache"&gt; &lt;script type="text/javascript" src="ayarlar/jquery-1.7.1.min.js"&gt;&lt;/script&gt; &lt;/script&gt; &lt;style type="text/css"&gt; .slaytGosterimi { position: relative; left:10%; top:15%; } body { background:#000000 ; } .ustBackground { position: relative; left:15%; width:70%; height:100%; background:#F4F4F4; } &lt;/style&gt; &lt;div class="ustBackground"&gt; &lt;!--Slayt gösterisi içeriği!--&gt; &lt;div class="slaytGosterimi" id="slaytGosterimi"&gt; &lt;script type="text/javascript"&gt; $("#slaytGosterimi").load('slaytGosterim.htm'); &lt;/script&gt; &lt;/div&gt; &lt;!--Slayt gösterisi içeriği!--&gt; &lt;/div&gt; </code></pre>
jquery
[5]
4,127,800
4,127,801
Python why variable and return show difference value from print variable?
<pre><code>&gt;&gt;&gt; pkt = sniff(count=2,filter="tcp") &gt;&gt;&gt; raw = pkt[1].sprintf('%Padding.load%') &gt;&gt;&gt; raw "'\\x04\\x00\\x00\\x00\\x00\\x00\\x00\\x00g\\xc4|\\x00\\x00\\x00\\x00\\x00'" &gt;&gt;&gt; print raw '\x04\x00\x00\x00\x00\x00\x00\x00g\xc4|\x00\x00\x00\x00\x00' </code></pre> <p>Raw yield different output when use print</p>
python
[7]
1,527,745
1,527,746
Does Tail Recursion will be optimize in php
<p>by this question: <a href="http://stackoverflow.com/questions/6171807/does-php-optimize-tail-recursion">Does PHP optimize tail recursion?</a></p> <p>php will not optimize the tail recursion</p> <p>but i try in my machine, (php 5.3.10)</p> <p>two programe for fibonacci, one is normal recursion but another is tail recursion</p> <p>the time which programes used is different a lot:</p> <p><img src="http://i.stack.imgur.com/k4Ysm.png" alt="enter image description here"></p> <p>and i feel confused about that, who can tell me why the tail recursion is faster then normal recursion if php does not optimize it?</p> <p>fibonacci.php:</p> <pre><code>&lt;?php function fibonacci($n) { if ($n &lt; 2) { return $n; } return fibonacci($n - 1) + fibonacci($n - 2); } var_dump(fibonacci(30)); </code></pre> <p>fibonacci2.php:</p> <pre><code>&lt;?php function fibonacci2($n, $acc1, $acc2) { if ($n == 0) { return $acc1; } return fibonacci2($n-1, $acc2, $acc1 + $acc2); } var_dump(fibonacci2(30, 0, 1)); </code></pre>
php
[2]
4,685,218
4,685,219
Cannot use greater key-length than 8 bits in DESEngine
<p>I'm doing a project where I need to use DESEngine. I'm unable to use a key length of more than 8 bits. Is it possible to use a greater key-length?</p>
java
[1]
594,463
594,464
Ads reducing by more than half on Iphone?
<p>For some odd season, the Ads, either IADs, or from ADmob not showing as often as it used to on my apps on IPhone. </p> <p>The number dropped by more than half. </p> <p>Obviously my revenue is tanking result of that,</p> <p>what could go wrong?</p>
iphone
[8]
3,768,103
3,768,104
Exporting grid to excel
<p>I used this code for exploring grid to excel.I got this code from net.</p> <pre><code>protected void Button1_Click(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GridView1.AllowPaging = false; GridView1.DataBind(); GridView1.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); } </code></pre> <p>When I am using this code,grid data get display in excel,but that does not have vertical and horizontal lines.It shows gridview column name as link not normal text.I have not used any theme to gridview and columns are autogenerated.One column say col3 contain more description so it's data get displayed at top when second row start,still it's discription shown in cell2.So I wanted to add vertical and horizontal lines,in that.So it is easy to come to know which data of belong to which id.I want to format col 1 also which is of number format only and decimal places zero.</p> <pre><code> 1 col1 col2 col3 hjhhjhjhjhjhjhjhjhjhjbbv gfgfgfuiuiuiuiui 2 9.12E+11 gkjj etwtrtrwqtrtttwwtretqwfe dear member gffgf 3 565E+11 hghgh </code></pre>
asp.net
[9]
4,606,164
4,606,165
Application compatibility between versions
<p>I can run my application on 1.5, 1.6 and 2.0 emulator and on a 1.5 device without any problems. But some of my users are reporting force close and strange menu entries (see the attachment) using 1.6 and higher version devices. Any ideas?</p> <p><img src="http://taypo.com/00.png" alt="alt text"></p> <p>This screen should look like this: <a href="http://www.taypo.com/blog/WindowsLiveWriter/TurkceKlavye0.7_6F1/settings_0.7_2.png" rel="nofollow">http://www.taypo.com/blog/WindowsLiveWriter/TurkceKlavye0.7_6F1/settings_0.7_2.png</a></p> <p>And the code that generates this screen is: </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;PreferenceCategory android:title="@string/general_settings"&gt; &lt;CheckBoxPreference android:title="@string/haptic_feedback" android:defaultValue="true" android:summary="@string/haptic_feedback_summary" android:key="vibrate" /&gt; &lt;CheckBoxPreference android:title="@string/sound_feedback" android:defaultValue="false" android:summary="@string/sound_feedback_summary" android:key="sound" /&gt; &lt;CheckBoxPreference android:title="@string/auto_caps" android:defaultValue="true" android:summary="@string/auto_caps_summary" android:key="auto_caps" /&gt; &lt;/PreferenceCategory&gt; &lt;PreferenceCategory android:title="@string/layout_settings"&gt; &lt;ListPreference android:title="@string/keyboard_layout" android:defaultValue="TRQ" android:key="kbd_layout" android:entries="@array/layout_names" android:entryValues="@array/layout_values" /&gt; &lt;/PreferenceCategory&gt; &lt;/PreferenceScreen&gt; </code></pre>
android
[4]
5,608,331
5,608,332
How do I rewrite binary data in Java
<p>I'm trying to figure out how to replace binary data using Java. below is a PHP example of replacing "foo" to "bar" from a swf file.</p> <pre><code>&lt;?php $fp = fopen("binary.swf","rb"); $size = filesize("binary.swf"); $search = bin2hex("foo"); $replace = bin2hex("bar"); $data = fread($fp, $size); $data16 = bin2hex($data); $data16 = str_replace($search, $replace, $data16); $data = pack('H*',$data16); header("Content-Type:application/x-shockwave-flash"); echo $data; ?&gt; </code></pre> <p>How do I do this in Java.</p>
java
[1]