Unnamed: 0
int64 65
6.03M
| Id
int64 66
6.03M
| Title
stringlengths 10
191
| input
stringlengths 23
4.18k
| output
stringclasses 10
values | Tag_Number
stringclasses 10
values |
---|---|---|---|---|---|
4,297,771 | 4,297,772 | how to read an image file in asp.net c# using asp:fileupload? | <p>I used the code below for upload an image. Please let me know that why this code does not work at all. I am also using updatePanal and multiview control for tab controlling.</p>
<pre><code><asp:FileUpload ID="fuPhoto" runat="server"/>
<div style="margin-top:20px;text-align:center;">
<asp:Button ID="btnAddMemberInfo" runat="server" Text="Add" Width="100px" onclick="btnAddMemberInfo_Click" />
</div>
public byte[] GetPhtoStream()
{
byte[] bufferPhoto = new byte[fuPhoto.PostedFile.ContentLength];
Stream photoStream = fuPhoto.PostedFile.InputStream;
photoStream.Read(bufferPhoto, 0, fuPhoto.PostedFile.ContentLength);
return bufferPhoto;
}
protected void btnAddMemberInfo_Click(object sender, EventArgs e)
{
Photo = GetPhtoStream(); //Photo represent for the database field which datatype is image
}
</code></pre>
| c# | [0] |
3,152,864 | 3,152,865 | How to import csv files as data for bootstrapping | <p>I'm trying to import a csv file to my grails project, what I'm trying to do is to build a map based on that csv file which is a list of countries (countries.csv) and use the map as a bootstrap data.</p>
<p>any ideas would be much appreciated</p>
| java | [1] |
2,423,462 | 2,423,463 | Distance Between Two GEO Locations | <p>I have two GEO locations. How can I calculate the distance between them?</p>
| javascript | [3] |
4,983,877 | 4,983,878 | Access Denied error on reading a Message Queue | <p>I have a private message queue and when I want to read its messages I get a access denied error and it crashes.
Previously for learning purposes I had written two separate applications, put a button on each of them, press the button on this one, create a queue and put a message in it, now click on the button on the other one, read the message and show it! And it was Working So I copy pasted THE SAME code to my real project and getting this Accss Denied Error...<strong>THE ONLY DIFFERENCE</strong> is that in my real project the message sender is inside the OnCreated event of a FileSystemWatcher which is running as a Windows Service...but does it make a difference? </p>
<p>I can copy paste the code too <strong>but</strong> like I said code is Working fine in my sample project and I have copy pasted the exact same code for my real project. So I have no clue what is wrong.
Any ideas?</p>
<p><strong>UPDATE</strong>: Now I also noticed that I cannot even DELETE it by going to Control Panel and trying to delete it, again getting "Access Denied" error. </p>
| c# | [0] |
2,875,155 | 2,875,156 | Reading lines from Python queues | <p>I'm dipping my toes into Python threading. I've created a supplier thread that returns me character/line data from a *nix (serial) /dev via a Queue.</p>
<p>As an exercise, I would like to consume the data from the queue one line at a time (using '\n' as the line terminator).</p>
<p>My current (simplistic) solution is to put() only 1 character at a time into the queue, so the consumer will only get() one character at a time. (Is this a safe assumption?) This approach currently allows me to do the following:</p>
<pre><code>...
return_buffer = []
while True:
rcv_data = queue.get(block=True)
return_buffer.append(rcv_data)
if rcv_data == "\n":
return return_buffer
</code></pre>
<p>This seems to be working, but I can definitely cause it to fail when I put() 2 characters at a time.</p>
<p>I would like to make the receive logic more generic and able to handle multi-character put()s.</p>
<p>My next approach would be to rcv_data.partition("\n"), putting the "remainder" in yet another buffer/list, but that will require juggling the temporary buffer alongside the queue.
(I guess another approach would be to only put() one line at a time, but where's the fun in that?)</p>
<p>Is there a more elegant way to read from a queue one line at a time?</p>
| python | [7] |
5,636,296 | 5,636,297 | instanceof Vs getClass( ) | <p>I see gain in performance when using getClass () and == operator over instanceOf operator.</p>
<pre><code> Object str = new Integer("2000");
long starttime = System.nanoTime();
if (str instanceof String) {
System.out.println("its string");
}else {
if (str instanceof Integer) {
System.out.println("its integer");
}
}
System.out.println((System.nanoTime()-starttime));
starttime = System.nanoTime();
if(str.getClass() == String.class){
System.out.println("its string in equals");
}else{
if(str.getClass() == Integer.class){
System.out.println("its integer");
}
}
System.out.println((System.nanoTime()-starttime));
</code></pre>
<p>Is there any guideline, which one to use (getClass ( ) and instanceOf)?
Please post your views.</p>
<p>Edit:</p>
<p>Given a scenario , I know exact classes to be matched , that is String, Integer (these are final classes)etc.
Is using instanceOf operator bad practise ?</p>
| java | [1] |
4,447,128 | 4,447,129 | Licensing/Securing an asp .net web application | <p>Basically I have an asp.net application which is installed on clients servers to work alongside an existing desktop application. What can I do to stop a client copying the files and installing somewhere else and running it so they can't stop paying but continue to use the system?</p>
| asp.net | [9] |
194,162 | 194,163 | Filter contentresolver query by date and time - Android | <p>I'm using the "MediaStore.Images.Media.EXTERNAL_CONTENT_URI" to query for photos stored on the sd-card. Now I only want photos that were added after some specific date. I'm using the "contentResolver.query()" method to query but I don't understand how to filter by Date_ADDED or DATE_MODIFIED. Can this be done?</p>
<p>Thanks for help!</p>
| android | [4] |
60,871 | 60,872 | Slidetoggle called when dropdown option is focused | <p><a href="http://jsfiddle.net/EhTJF/" rel="nofollow">http://jsfiddle.net/EhTJF/</a></p>
<p>Linked is an example of the issue I am running into.
When an element is hovered over, slidetoggle() is called to show a drop down list. When attempting to select an option in the ddl, slidetoggle() is called again and forces the ddl and the toggled element to collapse. </p>
<p>Any ideas of what I am doing incorrectly?</p>
<p>*Edit</p>
<p>The indented functionality is to allow a user to select an option from the drop down list and then afterwards allow the element to automatically toggle up.</p>
| jquery | [5] |
4,125,651 | 4,125,652 | How to program a simple music player? | <p>I've just completed a tutorial on C# language syntax from <a href="http://www.csharp-station.com/Tutorial.aspx" rel="nofollow">http://www.csharp-station.com/Tutorial.aspx</a>
I'd like to get started programming a simple music player for practice. The music player should be able to index all the music files in a folder and be able to play them at random. Would someone point me to the right direction as to where I should start? Maybe a sample code from an opensource program? Thanks</p>
| c# | [0] |
3,540,309 | 3,540,310 | Calling inflate() multiple times in an Android view | <p>I have a View that inherits from LinearLayout that inflates itself. After it has been created and inflated I wanted the ability to inflate a different layout. However, calling inflate() a second time seems to have no effect. Only if I close the activity and open it again is the state reflected in the UI.</p>
<p>Is it possible to call inflate multiple times to dynamically change the layout?</p>
<p>My inflate code is pretty simple:</p>
<pre><code>layoutInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutInflater.inflate(R.layout.my_layout, this, true);
</code></pre>
| android | [4] |
962,048 | 962,049 | Avoiding PopupWindow dismissal after touching outside | <p>I would like to use a PopupWindow with following behaviours/features:</p>
<ul>
<li>It is focusable (has interactive controls inside eg. buttons)</li>
<li>The View 'under' popupwindow has to consume the touches outside the popup properly</li>
<li>.. but the popupwindow has to stay on screen even after clicking outside</li>
</ul>
<p>I've found bunch of posts regarding PopupWindow but none of them asked question how to deal with such situation..</p>
<p>I think I tried every possible combination of setOutsideTouchable(), setFocusable(),setTouchable() but I'm stuck. Popup deals with clicks on it properly, but it's dismissed always when touching outside.</p>
<p>My current code is :
</p>
<pre><code>View.OnTouchListener customPopUpTouchListenr = new View.OnTouchListener()
{
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
Log.d("POPUP", "Touch false");
return false;
}
};
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout= (LinearLayout)inflater.inflate(R.layout.insert_point_dialog, null);
PopupWindow pw = new PopupWindow(layout,400,200,true);
pw.setOutsideTouchable(true);
pw.setTouchable(true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.setTouchInterceptor(customPopUpTouchListenr);
pw.showAtLocation(frameLayout, Gravity.BOTTOM, 0, 0);
</code></pre>
<p>My general goal is to create a floating window which behaves like a 'tools palette' in software like gimp: has some controls inside, stays on top until closed by 'X' button, and allowing to interact with controls outside-under it..
Maybe there's some better way to do this, not a PopupWindow? But I still haven't found more suitable control.</p>
| android | [4] |
3,569,878 | 3,569,879 | c#: SetScrollPos (user32.dll) | <p>I want to have 2 (rich)texboxes (vc# 2k8) with same scrolling... so when I scroll tb1 the tb2 scrolls to the same position. I use this functions:</p>
<pre><code>[DllImport("user32.dll")]
static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw);
[DllImport("user32.dll")]
public static extern int GetScrollPos(IntPtr hwnd, int nBar);
</code></pre>
<p>That works fine but</p>
<pre><code>int pos = GetScrollPos(tb1.Handle, 1);
SetScrollPos(tb2.Handle, 1, pos, true);
</code></pre>
<p>only sets the scrollbar to the same position but down update the text in there.
tb2.Update() oder Refresh won't work...</p>
<p>Please help. Ty</p>
| c# | [0] |
3,584,180 | 3,584,181 | OpenPop.Pop3 error | <p>I'm trying to connect to a exchange server using OpenPop library and when I try to connect it says "Server is not available", this is my code:</p>
<pre><code> Pop3Client Client = new Pop3Client();
Client.Connect("srv", 25, false);
Client.Authenticate("usr", "pass");
</code></pre>
<p>Can you show my what did I do wrong?
Thanks</p>
| c# | [0] |
1,037,350 | 1,037,351 | How to calculate dynamic size on scrollview for iphone? | <p>I have dynamic no of textviews and their size can also be dynamic, after each text view there are also dynamic no of labels, and each item is place on scroll view, so that scroll view also has dynamic size, So Someone guide me how to accomplish this task?
forgive me if this is repetitive question plz! </p>
| iphone | [8] |
5,704,335 | 5,704,336 | Embedding Gmaps in HTML | <p>I am working on embedding Google maps on HTML...</p>
<p>I want a javascript code that works same as creating one we do in Mymaps of Google maps. I want to add the function markers, polyline and polylines on a road..</p>
<p>I tried hard to do the same but did get exactly the look and the polylines doesnot work</p>
<p>I will be very thankful if I get the answer</p>
| javascript | [3] |
4,601,693 | 4,601,694 | Selecting a specific Tab in a TabActivity from a PendingIntent sent from a Notification | <p>I've got a TabActivity with 4 tabs in it. I have a service that is running - this service runs even after my TabActivity has been destroyed.</p>
<p>When the Service receives an event, I create a notification. The TabActivity may, at this time, be destroyed, or just running in the background. </p>
<p>How can I create a Notification/PendingIntent that will bring either launch the TabActivity if it is not currently running, or bring it to the front if it already is, and focus a specific tab based on the event?</p>
<p>I've thought about registering a broadcast receiver programmatically from within the TabActivity, and with this I'll be able to focus the tab, but how would I make the TabActivity the active Activity?</p>
| android | [4] |
5,957,222 | 5,957,223 | Plotting in java? | <p>I have an array of dimension of[20][20], filled with values of 0 & 1's. I would like to plot a graph similar to that of a weather image. Where 1's represents an activity with some colour and zero with no activity... What are essential things that I would require to begin plotting</p>
<p>Thank You
Jeet </p>
| java | [1] |
2,087,760 | 2,087,761 | What's the proper way to share an enum across multiple files? | <p>I would like to use the same enum in both the client and server parts of my current (C++) project, but am unsure of the proper way to do this. I could easily just write the enum in it's own file and include that in both files, but that feels like it's poor practice. Would putting it in a namespace and then including it in both be the right way to do it?</p>
<p>I know this is a bit subjective, if there's a better place for "best practice" questions please direct me to it.</p>
<p>Edit (elaboration): I'm sending data from the client to the server and in this case I'd like tell the client about changes in state. However, I'd like to avoid sending all of the information that makes up a state every time I'd like to change it, instead I want to just send a number that refers to an index in an array. So, I figure the best way to do this would be with an enum, but I need the same enum to be on both the client and server so that they both understand the number. Hope that makes sense.</p>
| c++ | [6] |
2,598,991 | 2,598,992 | jQuery selector not replacing text | <p>I have a table and I am trying to replace text in what should be the sibling of the filename td but it doesn't seem to be working.</p>
<p>Here's what I'm trying:</p>
<pre><code>var current = $(".filename:contains('image.jpg')").siblings();
current.find(".filesize").text('new text');
</code></pre>
<p>The HTML:</p>
<pre><code><table id="uploadifive-fileupload-queue" class="table table-striped uploadifive-queue">
<tbody>
<tr class="uploadifive-queue-item complete" id="uploadifive-fileupload-file-0">
<td class="preview">thumb</td>
<td class="filename">image.jpg</td>
<td class="filesize">100x100</td>
<td class="fileinfo">Failed</td>
<td class="fileactions">Create Thumbnail</td>
<td class="filedelete"><button class="btn btn-danger">Delete</button></td>
<tr>
</tbody>
</table>
</code></pre>
| jquery | [5] |
4,931,707 | 4,931,708 | When we send messages to multiple numbers at atime, how to know for which number we are getting getResultCode()? | <p>i am developing android sms application in which i send message to multiple numbers. i want to get resultant code for all numbers.When we send messages to multiple numbers at atime, how to know for which number we are getting getResultCode()?
is there any example code for this type of coding.?</p>
| android | [4] |
3,321,170 | 3,321,171 | SESSION destroys after POST | <p>I'm developing a site for someone where users can post problems to a website and the Admin of the company can view the problems and give a solution for it. I use one page that takes care of the login handling and a mysql db. The problem is that i can log in, it shows me another panel(userpanel), but whatever other button i click, it takes me back to the login panel.
It used to work as i was able to post data to my database. but suddenly after some changes on my website, it stopped working (and i can't find the problem anymore.)</p>
<p>When i log in, $_SESSION["LoggedIn"] gets a value and goes to the other panel on the same page with http post. when i click a button there, it seems that $_SESSION["LoggedIn"] is removed again because i check with isset if the user is logged in, otherwise it shows the userpanel.</p>
<pre><code>//check user logged in
if (isset($_SESSION['LoggedIn'])) {
//Problem posted
if (isset($_POST["plaatsen"])) {
//Processing - plaatsen
postProblem();
}
} else {
//do login thing
</code></pre>
<p>}</p>
<p>I've attached my code here and i hope anyone can help me out.</p>
<p>Index.php: <a href="http://pastebin.com/BZSirUTT" rel="nofollow">http://pastebin.com/BZSirUTT</a></p>
<p>Functions.php: <a href="http://pastebin.com/7Hknhm9r" rel="nofollow">http://pastebin.com/7Hknhm9r</a></p>
<p>Website: <a href="http://php.olvgroeninge.be/~sac.26A-07/php/Oefeningen/Oefening3/index.php" rel="nofollow">http://php.olvgroeninge.be/~sac.26A-07/php/Oefeningen/Oefening3/index.php</a> (it's in dutch)</p>
| php | [2] |
2,984,043 | 2,984,044 | Loading an outbuffer to a string in javascript? | <p>How to load the output buffer into a string using javascript ?</p>
<p>for example in php</p>
<pre><code><?php ob_start(); ?>
hello world !
<?php $string = ob_get_contents(); ?>
</code></pre>
| javascript | [3] |
2,748,519 | 2,748,520 | CGMakePoint(X,Y) for a image | <p>I am new to iPhone development. can any one let me know what is <code>CGMakePoint(x,y)</code> and what x, y stands for and how to get CGPoint x and y value for a image.?</p>
| iphone | [8] |
5,753,922 | 5,753,923 | Android Code - Radom number generation for calling activity | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/363681/generating-random-number-in-a-range-with-java">Generating random number in a range with Java</a><br>
<a href="http://stackoverflow.com/questions/6029495/how-can-i-generate-random-number-in-specific-range-in-android">How can I generate random number in specific range in Android?</a> </p>
</blockquote>
<p>Here is my scenario
From the Mainactivity ; On click of a Button i want to generate a random number from 1 to 4
Based on the output, i want to write an if-else that will call 4 different activities</p>
<p>So on click, if 4 is generated, then call activity 4
Next time 1 can be generated and should call activity 1
and so on ....</p>
<p>Can someone please help me with this code?</p>
| android | [4] |
3,996,336 | 3,996,337 | Cannot connect to port 8080 when using the python module for Stanford NER | <p>I am a complete rookie at this (this might be the reason why I'm stuck), but I have spent 2 days trying to find an answer for my problem with no luck whatsoever.
Here's the deal: I have downloaded the python module for Stanford NER, because I need to extract entities from text. In the readme file there was a suggestion on how it should be used, which was the following:</p>
<pre><code>import ner
tagger = ner.HttpNER(host = 'localhost', port = 8080)
tagger.get_entities("University of California is located in California, United States")
</code></pre>
<p>The problem is that I have little (almost zero) experience with python and when executing it i get the following error message:<br>
[Errno 10061] No connection could be made because the target machine actively refused it </p>
<p>I don't know why I get this message, since port 8080 is not used or blocked. I have even tried to disable the firewall and the antivirus, but nothing changed.</p>
<p>I assume my question is kind of a newbie question, but I have searched for almost two days to figure out what is wrong.</p>
<p>Thank you in advance! </p>
| python | [7] |
5,154,386 | 5,154,387 | Saving the image in perticular location is not working for Second time Using SendKeys option in Python | <p>I did the code for copy and save in directory for second time in "C:/Dirs" How can I save in in this folder for multiple times</p>
<pre><code>import SendKeys
SendKeys.SendKeys("""
{LWIN}
{PAUSE .25}
mspaint.exe{ENTER}
{PAUSE 1}
^{c}
{PAUSE 1}
^{v}
{PAUSE 1}
^{s}
{PAUSE 1}
C:/Dirs{ENTER}
""")
</code></pre>
| python | [7] |
584,591 | 584,592 | Custom Theme resets after performing search | <p>I am setting a custom theme in a "Contacts" application the following way...</p>
<pre><code>public void onCreate(Bundle savedInstanceState) {
if ("Red".equalsIgnoreCase( getIntent().getStringExtra( "Theme" )))
{
super.setTheme(R.style.red);
}
else if ("Green".equalsIgnoreCase( getIntent().getStringExtra( "Theme" )))
{
super.setTheme(R.style.green);
}
else if ("Blue".equalsIgnoreCase( getIntent().getStringExtra( "Theme" )))
{
super.setTheme(R.style.blue);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mainDBHelper = new DBHelper(this);
/*
* added for the search functionality
*/
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
name = intent.getStringExtra(SearchManager.QUERY);
}
</code></pre>
<p>This works great, but after using the search functionality the theme is changed back to the default. I have a separate activity where you can select your theme. That activity starts a new mainActivity intent with the String(putExtra): Red, Green, or Blue. Can someone tell me what changes I need to make to prevent this? </p>
| android | [4] |
4,274,555 | 4,274,556 | PHP Both kinds of quotes in variables | <p>I used to know this, but I guess it slipped my mind.
What's the code you put in the beginning and the end of a variable in php to allow both kind of quotes?</p>
| php | [2] |
3,596,425 | 3,596,426 | Close popup problem on button click | <p>I create info_popup.xml ( simple, I have textview and imagebutton on popup). I show in my main activity, but I don't know how to close that popup on click on btnExitInfo button. What to put in click listener to close pw ? I tried with GONE but it doesn't work, it is still there .</p>
<pre><code> LayoutInflater inflater = (LayoutInflater) currentActivity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.info_popup,
null, false), 230, 230, true);
pw.showAtLocation(currentActivity.findViewById(R.id.main),
Gravity.CENTER, 0, 0);
final View popupView=inflater.inflate(R.layout.info_popup, null, false);
ImageButton btnExitInfo=(ImageButton)popupView.findViewById(R.id.btnExitInfo);
btnExitInfo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//popupView.setVisibility(View.GONE);
}
});
</code></pre>
| android | [4] |
168,347 | 168,348 | Jquery load more on scroll | <p>I am trying to load data from load_second.php into result div. When I scroll down on first time it loads the data from load_second.php, however, I want to keep that data and when I scroll again it should load more data. Any help would be greatly appreciated.</p>
<pre><code><script type='text/javascript'>$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
$('#result').load('load_second.php');
}
});
</script>
<div id='result'></div>
</code></pre>
| jquery | [5] |
2,231,416 | 2,231,417 | MultiPart Data in Javascript | <p>Can anyone help me to know:
How to send text and image type data through multipart data form in javascript to my api. Please help me in getting the solution of my question.</p>
<pre><code>function apiCall(url){
var myJsonObj ;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("POST",url,true);
xmlhttp.send();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
// document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
myJsonObj = JSON.parse(xmlhttp.responseText);
if(myJsonObj.SS == "TRUE"){
window.location = "index.jsp";
}
}
}
}
</code></pre>
<p>This set of code is not working for sending Multipart data.</p>
<p>Thanks In Advance.</p>
| javascript | [3] |
1,230,539 | 1,230,540 | How to call a method on specific time in java? | <p>Is it possible to call a method in java at specific time? for example: If i have a peice of code like this:</p>
<pre><code>class Test{
....
// parameters
....
public static void main(String args[]) {
// here i want to call foo at : 2012-07-06 13:05:45 for instance
foo();
}
}
</code></pre>
<p>How this can be done in java? </p>
| java | [1] |
3,453,157 | 3,453,158 | Functions defined in header / cpp file behaves different | <p>File: A.h</p>
<pre><code>class A
{
public:
struct x X;
int show()
{
x.member_variable ? 0: -1;
}
};
</code></pre>
<p>Now if A.cpp is complied which includes A.h (which is actually in a huge project space) we see that x.member_variable value is not as expected. But if remove the show() method and place it in A.cpp the code behaves fine - meaning that x.member_variable value is correct.</p>
<p>How such a thing may happen - one thing we saw from objdump is that if the function is defined in A.h the the method is treated as inline function which otherwise is not if defined in A.cpp?</p>
<p>How the code can behave differently altogether?</p>
| c++ | [6] |
2,193,499 | 2,193,500 | Find location of part of an image on screen? | <p>I have an image, 480px wide. It is mostly transparent but has a tab protruding from it. Is there a way to get the x-coordinates of the left and right edge of the protrusion? It will stretch depending on screen size, so I don't think I can hard code it.</p>
<blockquote>
<p><em><strong></em>__<em>_</em>__<em>_</em>__</strong>[====]<strong><em>_</em>__</strong></p>
</blockquote>
| android | [4] |
598,244 | 598,245 | Why does this undefined variable refer to an element's id | <pre><code><div id="myDiv"></div>
alert(myDiv); // alerts '[html HTMLDivElement]'
</code></pre>
<p>I don't understand how this seems to work. I thought you must specify the div element's id with <code>getElementById();</code></p>
| javascript | [3] |
3,694,460 | 3,694,461 | jFeed not parsing images inside RSS feed | <p>Suggestions on how to fix this? </p>
<p>It's imperative that I use javascript, sadly, or I would have been using SimplePie eons ago.</p>
| jquery | [5] |
2,302,089 | 2,302,090 | How do I complete exercise 3 from "Art & Science of Java", Chapter 4? | <p>I have to write a program that reads in a positive int, and then calculates and displays the sum of the first N odd ints. For example, if N is 4, the program should display the value 16, which is 1 + 3 + 5 + 7.</p>
<p>Here's what I have so far, but I've come up against a brick wall, and would appreciate a point in the right direction. </p>
<pre><code>import acm.program.*;
public class OddIntegers extends ConsoleProgram {
public void run() {
println("This program adds the number of odd numbers");
int n = readInt("Enter a positive number: ");
int b = 1;
for (int i = 0; i < n; i++);
b = b + (b + 2);
println("The total is " + b);
}
}
</code></pre>
| java | [1] |
3,536,480 | 3,536,481 | change mode of android phone as day, night, automatic | <p>Can I change android phone mode day, night, automatic in programatically...</p>
<p>UiModeManager manager = (UiModeManager)getSystemService(Context.UI_MODE_SERVICE);
manager.setNightMode(UiModeManager.MODE_NIGHT_YES);</p>
<p>this is not working for me.... </p>
<p>shall i set any permission in androidmaifest.xml for this???</p>
| android | [4] |
3,891,232 | 3,891,233 | Rotate the Simulator at launch Time | <p>i m working on a project in which i want to rotate the ipad at the launch time.i have done coded for it.But it still not working. code i have written-</p>
<p>in .m file</p>
<pre><code>-(void)viewWillAppear:(BOOL)animated
{
[[UIDevice currentDevice]setOrientation:UIInterfaceOrientationLandscapeRight];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation = UIInterfaceOrientationLandscapeRight);
}
</code></pre>
| iphone | [8] |
4,789,718 | 4,789,719 | Call base class member functions from subclass members | <pre><code>public class A
{
...
public virtual void PrintMe() { /* do A */ }
}
public class B : A
{
...
public override void PrintMe() { /* do B */ }
}
public class C : B
{
...
public override void PrintMe() { /* do C */ }
private void Fun()
{
// call C::PrintMe - part one
PrintMe();
// call B::PrintMe - part two
base.PrintMe();
// call A::PrintMe - part three
???
}
}
</code></pre>
<ol>
<li><p>Is the code of part two correct?</p></li>
<li><p>How to call <code>A::PrintMe</code> inside <code>C::Fun</code>?</p></li>
</ol>
| c# | [0] |
3,050,081 | 3,050,082 | How is a dynamic array different from statically bound array in C++? | <p>I am learning C++ and I just read about dynamic arrays and how it lets you set the length of an array during runtime rather than during compile time. However, you don't need a dynamic array to do this. So what is the point of a dynamic array; when would you use it? I feel like I am missing something obvious so any insight is much appreciated. Thanks!</p>
<pre><code>// Static binding.
int size = 0;
cout << "Enter size of array:" << endl;
cin >> size;
int array[size];
int array_length = sizeof(array) / sizeof(int);
cout << "Number of elements in array: " << array_length << endl;
// I just set the length of an array dynamically without using a dynamic array.
// So whats the point of a dynamic array then?
</code></pre>
| c++ | [6] |
1,130,036 | 1,130,037 | How to convert img src to $pdf->ezImage | <p>I am trying to get the code </p>
<pre><code><img src="barcodegen.php?barcode=' . $order->products[$i]['model'] . '">
</code></pre>
<p>converted to </p>
<pre><code>$pdf->ezImage
</code></pre>
<p>by ezpdf, any help will be appreciated.</p>
<p>Sam</p>
| php | [2] |
2,226,185 | 2,226,186 | retrive data as json from php to iPhone | <pre><code>-(void)viewDidLoad {
NNString *myStringJson = [[NSString alloc] initWithContentofURL:[NSURL URLwithString@" "]];
if([myStringJson length == 0]){
[myStrinJson release];
return;
}
SBJSON *parser = [[SBJSON alloc] init];
listArray = [[parser objectWithString:myStringJson] copy];
[parser release];
}
</code></pre>
| iphone | [8] |
1,828,486 | 1,828,487 | I want to know how to make this .live() in jquery | <p>i was wondering how i could get this to be live? I have a text box that is fetched via ajax, and its excluding already loaded scripts i have cause of the dom I'm assuming. Any who, I've played with .live() but i usually have an element to hook it to ex/ <code>$('blah').live();</code>, but i found myself scratching my head on this one lol</p>
<pre><code>(function($) {
$.fn.charCount = function(options){
// default configuration properties
var defaults = {
allowed: 140,
warning: 25,
css: 'counter',
counterElement: 'span',
cssWarning: 'warning',
cssExceeded: 'exceeded',
counterText: ''
};
var options = $.extend(defaults, options);
function calculate(obj){
var count = $(obj).val().length;
var available = options.allowed - count;
if(available <= options.warning && available >= 0){
$(obj).next().addClass(options.cssWarning);
} else {
$(obj).next().removeClass(options.cssWarning);
}
if(available < 0){
$(obj).next().addClass(options.cssExceeded);
} else {
$(obj).next().removeClass(options.cssExceeded);
}
$(obj).next().html(options.counterText + available);
};
this.each(function() {
$(this).after('<'+ options.counterElement +' class="' + options.css + '">'+ options.counterText +'</'+ options.counterElement +'>');
calculate(this);
$(this).keyup(function(){calculate(this)});
$(this).change(function(){calculate(this)});
});
};
})(jQuery);
</code></pre>
| jquery | [5] |
672,407 | 672,408 | Adding external JavaScript file into DOM via JavaScript | <p>I need to load an external JavaScript file that is generated by a PHP script, I also want to pass any query string parameters to the script as well, I came up with the following solution: </p>
<pre>
<code>
<script><br/>var url = 'http://example.com/scripts/js.php?foo=bar';<br/>url += location.search.replace(’?',’&’);<br/><br/>var s = document.createElement(’script’);<br/>s.setAttribute(’type’,'text/javascript’);<br/>s.setAttribute(’src’, url);<br/><br/>// get the script’s ‘outer html’ and add it to the document.<br/>var t = document.createElement(’div’);<br/>t.appendChild(s);<br/>document.write(t.innerHTML);<br/><br/></script>
</code>
</pre>
<p>This works in all browsers except IE (go figure), I believe the problem is that the generated script also downloads more JS, which seems to hang... Is there a better way to do something like this?</p>
<p><strong>UPDATE</strong>
If I load the page by pressing Ctrl + F5, everything works fine...why is this? The script at <a href="http://example.com/scripts/js.php" rel="nofollow">http://example.com/scripts/js.php</a> are a bunch of document.write calls.</p>
| javascript | [3] |
2,966,159 | 2,966,160 | Return if a given int is an exponent of 2 C# | <p>Given a method of the bool data type that takes in an int variable, what is a <strong>single</strong> line of code that would determine if the int is an exponent of 2 or 2^n.....2,4,8,16,32 etc. I know of a way using a while loop and if statements, but I'm looking for it to be on one line.</p>
| c# | [0] |
5,308,737 | 5,308,738 | Java 1.3 library for web service | <p>I have Java 1.3 application and I need to connect them with web service. Is it possible to find some (.jar) library.</p>
| java | [1] |
5,505,069 | 5,505,070 | jquery can not trigger function from generated content | <p>I'm trying to delete one of the items which are generated by entering text and clicking the "add another" link in the linked example, but the jquery does not trigger from the generated content. If I attach the event handler to another object the function triggers but not from the generated links, any way to fix this? In the code below; when the user clicks a link with the class delLink I want the surrounding div of that link and all elements in that div removed (erased).</p>
<pre><code><div class="regItm">
<input properties...><a class="delLink" properties...>X</a>
</div>
<div class="regItm">
<input properties...><a class="delLink" properties...>X</a>
</div>
...
...
</code></pre>
<p><a href="http://jsfiddle.net/KYkJn/2/" rel="nofollow">http://jsfiddle.net/KYkJn/2/</a></p>
| jquery | [5] |
3,411,712 | 3,411,713 | trying to follow Bucky tutorials | <p>While following <a href="http://www.youtube.com/watch?v=OVfUq2DPKKg" rel="nofollow">this Youtube tutorial</a> (see the relevant code below) I get the following error:</p>
<blockquote>
<p>error line 6<br>
error: expected constructor destructor or type conversion before'('</p>
</blockquote>
<p>What might cause this error and how do I solve it?</p>
<pre><code>#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <time.h>
void myfun(int);//using own function
myfun(8);//pow(4.0,10.0)
using namespace std;
int main()
{
double num1;
srand(time(0));// to get a true random number
double num2;
num1 = pow(3.0, 9.0);//2 to the power of 4
cout << num1 <<endl;
num2 = rand() %100;//random number out of 100
cout << "\nrandom number = " << num2 << endl ;
return 0;
}
void myfun(int x)
{
using namespace std;
cout << "my favourite number is " << x << endl;
}
</code></pre>
| c++ | [6] |
1,399,338 | 1,399,339 | Jquery access div in table cell | <p>I'm trying to access the first div with a class from hovering on a table row;</p>
<p>Here is my html:</p>
<pre><code><table id='search_job_results_table'>
<tbody>
<tr>
<td><div style='position:relative'><div class='search_job_tooltip'>blah blah</div></div></td>
</tr>
</tbody>
</table>
</code></pre>
<p>I've tried with the following:</p>
<pre><code>$(function () {
$('table#search_jobs_result_table tbody tr').mouseover(function () {
$(this).children().next('div.search_job_tooltip').css('display', 'block');
});
});
</code></pre>
<p>The hovering works part works, as I can wak an alert in there and it triggers, but not setting the css of that div. I always get stuck on this for some reason, any ideas?</p>
| jquery | [5] |
5,958,118 | 5,958,119 | PHP difference between shuffle and array_rand | <p>What exactly is the difference between <code>shuffle</code> and <code>array_rand</code> functions in PHP? Which is faster if there is no difference.</p>
<p>Thanks</p>
| php | [2] |
4,797,080 | 4,797,081 | zero length arrays | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1036666/what-is-the-usage-of-array-of-zero-length">What is the usage of array of zero length?</a> </p>
</blockquote>
<p>What is the purpose of zero length arrays.Are they of any use or just like that because the syntax allows? </p>
| java | [1] |
983,761 | 983,762 | Using zip file without extracting in java | <p>Iam facing a problem that, we have a .zip file that contains some text files. Now iam using java to access that files. If it is not in the zip file i can read and print on my console easily using FileInputStream. But iam unable to read a file from .zip file....</p>
<p>Please help me get rid of this.....Iam using j2se only..</p>
| java | [1] |
1,102,352 | 1,102,353 | Only top corners rounded in <shape> | <p>I am trying to have the top corners of a shape rounded and the bottom just straight, but I'm having a problem with my shape it's saving </p>
<blockquote>
<p>error!
UnsupportedOperationException: null</p>
</blockquote>
<p>When I have </p>
<pre><code><corners android:radius="10dp" android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp" android:topRightRadius="10dp"
android:topLeftRadius="10dp" />
</code></pre>
<p></p>
<p>I have tried putting 1dp in the bottom corners and taking out the android:radius="10dp", but still gives me an error.</p>
<p>Android 2.2 with Eclipse</p>
<p>Can any one help me?</p>
| android | [4] |
364,985 | 364,986 | Javascript new Array and join() method | <p>Inspired by <a href="https://www.destroyallsoftware.com/talks/wat" rel="nofollow">this popular speech</a> I wanted to figure out some issue related to creating arrays. Let's say I am creating new array with:</p>
<p><code>Array(3)</code></p>
<p>In console I am getting:</p>
<p><code>[undefined, undefined, undefined]</code></p>
<p>Which is pretty obvious. Let's say I am doing joining on that array:</p>
<p><code>Array(3).join()</code></p>
<p>As a response I am getting:</p>
<p><code>",,"</code></p>
<p>Which is pretty understandable as well, because these are three empty strings, separated by commas, I suppose. But when I am trying to do:</p>
<p><code>Array(3).join("lorem")</code></p>
<p>I am getting string with only two repeat of ”lorem”:</p>
<p><code>"loremlorem"</code></p>
<p>Why there are two, not three repeats of that word?</p>
| javascript | [3] |
4,573,347 | 4,573,348 | Check if a variable contains a numerical value in Javascript? | <p>In PHP, it's pretty easy:</p>
<pre><code>is_numeric(23);//true
is_numeric("23");//true
is_numeric(23.5);//true
is_numeric(true);//false
</code></pre>
<p>But how do I do this in Javascript?
I could use a regular expression, but is there a function for this?</p>
| javascript | [3] |
3,574,614 | 3,574,615 | Weird jQuery error | <p>I was going along minding my jQuery business, when all of a sudden, I tried to do this:</p>
<pre><code>var myVariable = 'some-id-here';
$('#' + myVariable).addClass('some-class');
</code></pre>
<p><strong>Everything went fine and dandy until I closed my browser</strong>. After I reopened the page, jQuery threw this weird error:</p>
<pre><code>Uncaught Syntax error, unrecognized expression: #
</code></pre>
<p>I was able to replace the second line with this and have it work, but I am curious why the first part didn't work after I closed and reopened my browser.</p>
<pre><code> $(document.getElementById(myVariable)).addClass('current');
</code></pre>
| jquery | [5] |
3,135,010 | 3,135,011 | Remove everything but the domain with PHP | <p>My current js formula removes http://, https://, www and anything after '/'.</p>
<pre><code> function cleanUrl(url) {
return url.replace(/^(http(s)?:\/\/)?(www\.)?/gi,"");
}
</code></pre>
<p>E.G:
<a href="http://www.google.com/piza" rel="nofollow">http://www.google.com/piza</a>
returns google.com</p>
<p>How can I do remove everything but the domain in one step but with PHP?</p>
| php | [2] |
2,050,051 | 2,050,052 | replace all commas | <p>I have a form where I have a couple hundred text boxes and I'd like to remove any commas when they are loaded and prevent commas from being entered. Shouldn't the follow code work assuming the selector is correct?</p>
<pre><code>$(document).ready(function () {
$("input[id*=_tb]")
.each(function () {
this.value.replace(",", "")
})
.onkeyup(function () {
this.value.replace(",", "")
})
});
</code></pre>
| jquery | [5] |
6,003,215 | 6,003,216 | Android - How to show AlertDialog before finishing activity? | <p>I'm trying to implement this code</p>
<pre><code> if(someCondition){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("message")
.setPositiveButton("Yes", this)
.setNegativeButton("No", this);
builder.show();
}
finish();
</code></pre>
<p>The problem is that the activity calls finish() before dialog is shown up so it throws the following exception</p>
<pre><code>MyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40704090 that was originally added here
</code></pre>
<p>How to handle that?</p>
| android | [4] |
2,057,858 | 2,057,859 | Need checkbox change event to respond to change of checked state done programmatically | <p>(jQuery 1.4.4) I have a checkbox that has a .change() listener that works fine for when the user clicks the checkbox, but now I also need it to fire when I programmatically change the checkbox in jQuery, using .attr('checked', 'checked'). I'm perfectly happy to use other methods to make this work. Thanks.</p>
<pre><code>$('#foo').attr('checked', 'checked'); // programmatically change the checkbox to checked, this checks the box alright
$('#foo').change( function() {
// this works when user checks the box but not when the above code runs
}
</code></pre>
| jquery | [5] |
2,507,745 | 2,507,746 | Print PHP string in new lines | <p>Anything wrong with this code? I want it to print the name and address - each on a separate line, but it all comes up in one line.</p>
<p>Here's the code</p>
<pre><code><?php
$myname = $_POST['myname'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$address3 = $_POST['address3'];
$town = $_POST['town'];
$county = $_POST['county'];
$content = '';
$content .="My name = " .$myname ."\r\n";
$content .="Address1 = " .$address1 ."\n";
$content .="Address2 = " .$address2 ."\n";
$content .="Address3 = " .$address3 ."\n";
$content .="town = " .$town ."\n";
$content .="county = " .$county ."\n";
echo $content;
?>
</code></pre>
<p>It looks like the '\n' character is not working.</p>
| php | [2] |
2,187,683 | 2,187,684 | How to count elements inside an element specified by object? | <p>I bet this has a simple answer.</p>
<p>I want to count the number of TD elements inside a row, yet i can't seem to find the right syntax.</p>
<pre><code>var row = $('#album_cell'+currentCell).parent();
var n = $("td",row).length();
</code></pre>
<p>This returns an error obviously as i don't know how to specify that. Any help?</p>
| jquery | [5] |
4,425,624 | 4,425,625 | Hide a div to subscribers(user role) in one page (is_page) | <p>Hello have been looking at this for quite a while and cant seem to resolve it was hoping someone more familiar with the wordpress core and php could share some idea.</p>
<p>What I want to accomplish essentially is to Hide a div that permits buddypress users (the subscrivers) from adding new topics to a group forum. But I dont want this to be hidden from all the forums just 1 of them. So I need 2 pieces 1 that determines whether someone is a subscriber or an admin. so its only hidden to the subscriber. and 2 that it hides it from only 1 page.</p>
<p>Example of potential code just need to fit it together (all code would go in the functions.php unless there is another way)</p>
<pre><code><?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
have info link or whatever in here
<?php } ?>
</code></pre>
<p>Thats for the frontpage but similarly you can get the page by ID </p>
<p>For role I saw this </p>
<pre><code>is_admin()
</code></pre>
<p>I would assume there is a </p>
<pre><code>is_subscriber()
</code></pre>
<p>and from there you can do an if in the php something like
if is_subscriber() and is_page( 42 )
call .js file and from there add a class that hides the div I want to hide by jquery</p>
<p>Thats as far as I got from what I know and looking around. I would greatly appreciate any and all assistance.</p>
| php | [2] |
4,845,396 | 4,845,397 | Value selected option dropdownbox | <p>I've got a dynamic dropdownbox:</p>
<pre><code>function chgAantal(i,artNr,lengte){
var aantal=document.getElementById("aantal_"+i).value;
if(isNaN(aantal)){
alert('Voer een geldig aantal in...');
document.all["error_"+i].src="/images/fout.gif";
ok=0;
}
else{
location.href="addcart.asp?act=change&aantal="+aantal+"&artNr="+artNr+"&lengte="+lengte+"&bdr=<%=bdr%>";
}
}
<select onchange='chgAantal(\""+i+"\",\""+artNr+"\",\""+lengte+"\")' name='aantal_"+i+"' value='"+aantal+"'/>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
</select>
</code></pre>
<p>When I change the value in (for example) 7, the value changes in the script. But I can't see the selected value, the value displaying is always 1.
How can I display the selected value?</p>
<p>I hope you understand me!</p>
<p>Regards,</p>
<p>Fraak</p>
| javascript | [3] |
5,343,445 | 5,343,446 | Android Internal Memory Issue | <p>I have a game published on Android Market. Some users reported that it cannot be purchased and downloaded.The price won't show up to buy. My game is about 70mb, is it because of sized is too big for the internal memory of those phone so Google Market disabled the purchase? </p>
<p>Any help will be appreciated. </p>
| android | [4] |
356,849 | 356,850 | OutOfMemoryError behavior in Java | <p>I always thought that an <code>OutOfMemoryError</code> restarts the JVM.<br>
But I am seeing a behavior where an <code>OutOfMemoryError</code> occurs this is not caught from the code (actually I don't even know if this is possible)<br>
and the <code>JVM</code> continues (a core dump is produced though).<br>
Can anyone help me understand this behavior? </p>
| java | [1] |
4,155,206 | 4,155,207 | Declaring inherited generics with complex type constraints | <p>I have an interface with a single generic type parameter:</p>
<pre><code>public interface IDriveable<T> where T : ITransmission { ... }
</code></pre>
<p>I also have a class that has a type parameter that needs to be of that interface type:</p>
<pre><code>public class VehicleFactory<T> where T : /* ??? */
</code></pre>
<p>There is a problem here with this declaration. I can't put "IDriveable", because that has no type parameters and doesn't match the type signature of IDriveable. But I also don't want to put IDriveable<U> either, because then VehicleFactory has to know what <em>kind</em> of IDriveable it's getting. I want VehicleFactory to accept <em>any</em> kind of IDriveable.</p>
<p>The proposed solution a coworker had was to use:</p>
<pre><code>public class VehicleFactory<T, U> where T : IDriveable<U>
</code></pre>
<p>But I don't like this, since it's redundant. I have to say the "U" type twice:</p>
<pre><code>var factory = new VehicleFactory<IDriveable<AllWheelDrive>, AllWheelDrive>();
</code></pre>
<p>What should go in the question marks? </p>
| c# | [0] |
1,692,317 | 1,692,318 | Where can I find documentation to support this behavior? | <p>I'm looking over some previous developers code and I come across this line:</p>
<pre><code>location.href = '#' + variable;
</code></pre>
<p>Which has the effect of updating <code>location.hash</code>. Remove the '#' and of course it redirects to the non-existent url. Playing around a bit it seems I can set the hash via <code>location.href</code> as long as the value starts with '#'. This line or similar is used a lot, but I can't seem to find any documentation the supports this behavior of it updating <code>location.hash</code> by setting <code>location.href</code> this way. </p>
<p>I would like to see something showing this isn't just a happy accident that this works so I don't have to re-code all the situations where this is used. Anything you can link me to would help. </p>
<p>Would it be better to just changes these to properly set the <code>location.hash</code> anyway?</p>
<p>Thnks</p>
| javascript | [3] |
3,206,715 | 3,206,716 | android.net.wifi.WifiManager.MulticastLock lock; cant be resolved in Jmdns Demo | <p>i,m new in android.. tryining to run Jmdns demo availlable with jmdns library but problem occured is .net.wifi.WifiManager.MulticastLock lock; cant be resolved ? </p>
| android | [4] |
159,077 | 159,078 | Maximum number of local variables in a Java Method | <p>I understand the importance of <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle" rel="nofollow">Single Responsibility Principle</a>, but technically speaking do we have any upper bound on the number of local variables (that which are stored in stack frames) within each java method. And is that upper bound equal to the maximum stack size, ie., can i have a stack frame of size equal to the maximum stack size configured?</p>
| java | [1] |
4,440,375 | 4,440,376 | iPhone SearchBar with Buttons Underneath? | <p>How would one implement a search field like the one used on the iPhone Mail application. When you attempt to search it shows up 4 buttons under the search bar with the fields you can search. The search bar actually moves up to cover the navigation bar and exposes those buttons.</p>
<p>I'd like to do something similar in my application where you can specify what exactly you are searching for. I think the mail search is a little difference since it also has a cancel button?</p>
<p>How would you accomplish this and what components would you use?</p>
| iphone | [8] |
3,835,677 | 3,835,678 | Java file cannot access methods even though class file is in same directory | <p>I was given only a .class file for homework and need to write a program that accesses its methods. Well, I have the .class file in the same directory, but I cannot access its methods, so my program won't compile! I've tried on JGrasp and Eclipse. Both 'cannot find symbol' (the method name).</p>
<p>I am absolutely positive that I am using the right method names. Why isn't it working?? </p>
<p>This is my code in Hw.java</p>
<pre><code>public class Hw {
public static void main(String[] args)
{
int[] a1 = {1, 2, 3, 4, 5};
int[] a2 = {5, 4, 3, 2, 1};
int[] a3 = {1};
int[] a4 = {2, 5, 3, 1, 4};
int[] a5 = {1, 2, 1};
System.out.println(sortA(a1));
System.out.println(sortA(a2));
System.out.println(sortA(a3));
System.out.println(sortA(a4));
System.out.println(sortA(a5));
}
}
</code></pre>
<p>And the error I'm getting in JGrasp:</p>
<p>Hw.java:11: error: cannot find symbol
System.out.println(sortA(a1));<br>
^
symbol: method sortA(int[])
location: class Hw</p>
| java | [1] |
4,761,702 | 4,761,703 | Show ajax loader image until an actual image is loaded | <p>So I have a page with little picture thumbnails on it and one big area in the middle of the page for full size photo.</p>
<p>When user clicks on a thumbnail, a full size picture is shown in the middle of the page. I just change the src attribute of the image in the middle like this to achieve that:</p>
<pre><code>$('img#fullsize').attr('src', path); // path is built earlier in the jQuery code
</code></pre>
<p>The problem is that when the fullsize image is too large what it does is that the fullsize image in the middle disappears and nothing is there until the new full size image starts loading (and sometimes it can take cca 5 seconds until new image starts loading during peak hours). What I would like is to show an ajax loader gif image until the fullsize photo starts loading. How can I do that?</p>
<p>Thanks.</p>
| jquery | [5] |
5,585,878 | 5,585,879 | Is there a way to prevent the post viewed by the visitor? | <p>Supposed the page is <code>example.com/blog/data.php</code>. I am using <code>file_get_contents</code> to get the content in another script page. Now, i want to:</p>
<ol>
<li>Forbid google search to crawl and index the data.php page. </li>
<li>Forbid the visitor to access it</li>
</ol>
<p>Is there a way to achieve this?</p>
| php | [2] |
3,507,460 | 3,507,461 | Collection in Java | <p>Quick Question...
Can collections in Java hold more than one type? Or do they all have to be the same type?</p>
<p>thanks</p>
| java | [1] |
613,099 | 613,100 | How to set timer in show progress method | <p>How do I set a timer in the <code>showprogress</code> method?</p>
<p>My code is below, which shows a progress bar when submit button is clicked and waits for an XML response from server. How do I set timer in this <code>showprogress</code> method so it stops after 15 seconds?</p>
<pre><code>private void showProgress()
{
myProgressDialog = ProgressDialog.show(
LoginScreen.this, null, "Processing please wait...", true);
}
if (activeNetworkInfo.isConnected()) {
btnLogin.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String pinemptycheck = pin.getText().toString();
String mobileemptycheck = mobile.getText().toString();
if (pinemptycheck.trim().equals("")||(mobileemptycheck.trim().equals("")))
Toast.makeText(getApplicationContext(), "Please Enter Correct Information", Toast.LENGTH_LONG).show();
}
showProgress();
postLoginData();
</code></pre>
| android | [4] |
912,721 | 912,722 | Getting a list value from key/value pair | <p>If I have a list with key/value pair, how do I get the value of the key?</p>
<p>I'm working with this code snippet:</p>
<pre><code>>>> items = {'fees':[('status','pending'), ('timeout',60)], 'hostel':[('status',
'pending'), ('timeout','120')]}
>>> print [items[i] for i in items.keys()]
[[('status', 'pending'), ('timeout', '120')], [('status', 'pending'), ('timeout'
, 60)]]
>>>
</code></pre>
<p>I'm expecting this:</p>
<pre><code># get timeout. I know this line is wrong
timeout = items.get(i)
# Put the transaction item in a queue at a specific timeout
# period
transaction_queue(i, block, timeout)
def transaction_queue(item, block=False, timeout):
return queue.put(item, block, timeout)
</code></pre>
<p>Thanks for helping out.</p>
<p>I can't answer until 7 hours as at writing.</p>
<p>So, the answer is:</p>
<pre><code>>>> for key, value in items.iteritems():
... for val in value:
... print "\t{0} : {1}".format(val[0], val[1])
...
status : pending
timeout : 120
status : pending
timeout : 60
>>>
</code></pre>
<p>Thanks to Vincent Vande Vyvre</p>
| python | [7] |
2,895,295 | 2,895,296 | How to get information of particular user from facebook,twitter,google? | <p>I am trying to build a web app in java like following </p>
<p>the user enters his/her mail id and password if the user mail id and password are same in </p>
<pre><code>Facebook
Twitter
Google
Buzz
LinkedIn
</code></pre>
<p>than fetch the information like post and twit etc which belong to that user. I googled and found that sociallib provides the solution but could not get it exactly. so provide me some good examples</p>
| java | [1] |
4,900,733 | 4,900,734 | How to increase rows in NSMutableArray? | <pre><code>NSString *categoryStr = categoryName.text;
NSLog(@"Category Name:--->%@",categoryStr);
appDelegate.categoryData = [[NSMutableDictionary dictionaryWithObjectsAndKeys:
categoryStr, @"name",image ,@"image", nil] mutableCopy];
[appDelegate.categories addObject:appDelegate.categoryData];
NSLog(@"Category Data:--->%@",appDelegate.categories);
</code></pre>
<p>My problem is that every time I got only one rows means appDelegate.categories returns 1 row but I want to increment appDelegate.categories (NSMutableArray).</p>
| iphone | [8] |
1,724,544 | 1,724,545 | How to use static/helper method in a class? | <p>Below I have created a class. I am trying to use the method gcd(a,b) in the initialization of a Fraction object. However, when I was trying to do this it would not work WITHOUT the 'Fraction' part of "Fraction.gcd(a,b)". I used @staticmethod here, but it does absolutely nothing, i.e. my code works the same without it. </p>
<p>Is there anyway I can call gcd without putting "Fraction." in front of it. In Java I would normally create a static method and then just call it. I could very easily put the GCD code inside of the init, but I am trying to learn here!</p>
<p>I am missing a lot here. Can anyone explain: static methods, helper methods in a class and pretty much how I can use various methods inside of a class?</p>
<pre><code>class Fraction(object):
def __init__(self, a, b):
if( Fraction.gcd(a,b) > 1):
d = Fraction.gcd(a,b)
self.num = a/d
self.denom = b/d
else:
self.num = a
self.denom = b
@staticmethod
def gcd(a,b):
if a > b: a,b = b,a
while True:
if b % a == 0: return a
a, b = b%a, a
def __repr__(self):
return str(self.num) + "/" + str(self.denom)
</code></pre>
| python | [7] |
1,870,729 | 1,870,730 | Delet hyperlink is not responding if the row as data with apostrophe in javascript | <p>I have Form, which displays 5 column data. The last colum is the delete option, which is an hyperlink.</p>
<p>when i try to delete the row, the row is successfully deleted if the column data is not containing any apostrophe.
But when i have data with apostrophe (eg : test's), the delete link is not responding.
:(</p>
| javascript | [3] |
3,169,140 | 3,169,141 | how to invoke a service's android method since void onclick function? | <p>hello I'm trying to invoke a service's android method since a public void onclick and i have one mistake, it tell that i need insert "AssignemetOperator Expression" to complete the expresion, but i don't see where it's the mistake.
i put de code here
the mistake is on the boolean ret=bindService(.........
it´s inside of public void onClick
idcamarero was created how a global variable
thanks</p>
<p>View.OnClickListener buttonhandler=new View.OnClickListener() { </p>
<pre><code> public void onClick(View v) {
EditText id_camarero = (EditText) findViewById(R.id.id_camarero);
String numero = id_camarero.getText().toString();
idcamarero=Integer.parseInt(numero);
//Register the actions we want to receive via broadcast
//MyService.LocalBinder.
boolean ret= bindService(new Intent(MainActivity.this, MyService.class), androidServiceConnection, BIND_AUTO_CREATE);
IntentFilter filter = new IntentFilter(MyService.DATA_RECEIVED_INTENT);
registerReceiver(androidListener, filter);
if((numero.trim().equals(""))||(existe==false)){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
// set title
alertDialogBuilder.setTitle("Fallo de id");
// set dialog message
alertDialogBuilder
//.setMessage("Click salir para finalizarprograma")
.setCancelable(false)
.setPositiveButton("Salir",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, close
// current activity
MainActivity.this.finish();
}
})
.setNegativeButton("Reintentar",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
else{
// Intent intent= new Intent(GestorRestauranteActivity.this,MenuMesas.class);
// intent.putExtra("id", numero);//enviamos el id de camarero a la actividad que invocamos
// startActivity(intent);
finish();
}
}
};
</code></pre>
| android | [4] |
5,587,164 | 5,587,165 | adding run time on my java program | <p>i have my Java program and i would like to add code that show the run time for calculating, but i have no idea how can i do that?</p>
| java | [1] |
3,098,788 | 3,098,789 | jquery doesn't remove div always on mouseleave | <p>This is very annoying. After you rollover on image, if you rollout from left, top or right edges red box disappears. But if you rollout from bottom edge red box sometimes disappears sometimes not. Why is that?</p>
<p><a href="http://jsfiddle.net/f98r3/2/" rel="nofollow">http://jsfiddle.net/f98r3/2/</a></p>
<p><em><strong>Edit:</em></strong>
Another weird thing is, when you check console log, mouseleave fires but doesn't remove div!!!.</p>
<p><em><strong>Edit 2:</em></strong>
Ok both answers solved the problem but still I wonder how on earth console.log logs the mouseleave in the original code but doesn't trigger remove()?</p>
| jquery | [5] |
4,307,672 | 4,307,673 | How to get a session value from a second table? | <p>I have two tables for the users; a login table and the user profile table.</p>
<p>I want to compare a value from 'userprofiletable' to another value from another table called posts. If the value is equal, it shows a list.</p>
<p>I have the following code. The problem is that it is not comparing the value in the posts table with the value of the session from user profile table.</p>
<p>Could someone help me please?</p>
<pre><code><?php
$limit = '5';
$dbreq = 'SELECT * FROM `posts` ORDER BY `pos` DESC';
$dbdata = mysql_query($dbreq);
while($dbval = mysql_fetch_array($dbdata))
{
if (($dbval['city'] == $_SESSION['student_city'])) { //checks for last 4 accomodation
if ($limit >= '1') {
echo '<tr><td><a href="acomod.php?view='.$dbval['id'].'">'.$dbval['title'].'</a></td></tr>';
$limit = $limit -'1';
}
}
}
?>
</code></pre>
<p>I also want to get the value of userprofiletable and post it in the posts table. For example, when somebody make a new post.</p>
| php | [2] |
3,247,048 | 3,247,049 | on click of any of the 3 "chkmain" radio buttons the "child" and "child1" should be enabled | <pre><code><input type="radio" id="chkMain" name="chkMain"/>
<input type="radio" id="chkMain1" name="chkMain" />
<input type="radio" id="chkMain2" name="chkMain" />
<input class="child" type="checkbox" id="chk1" disabled="true" />
<input class="child" type="checkbox" id="chk2" disabled="true" />
<input class="child" type="checkbox" id="chk3" disabled="true" />
<input class="child" type="checkbox" id="chk4" disabled="true" />
<input class="child" type="checkbox" id="chk5" disabled="true" />
<input class="child" type="checkbox" id="chk6" disabled="true" />
<input class="child" type="checkbox" id="chk7" disabled="true" />
<input class="child1" type="radio" id="tone1" disabled="true"/>
<input class="child1" type="radio" id="tone2" disabled="true"/>
<input class="child1" type="radio" id="tone3" disabled="true"/>
$(function()
{
$("input[id^='chkMain']").onclick(function() {
//var otherCks = $("input[id^='chkMain']").not(this);
if ($(this).is(":checked")) {
$(".child").attr("disabled", true);
otherCks.removeAttr("disabled");
} else {
$(".child").removeAttr("disabled");
otherCks.attr("disabled", true)
}
});
$("#chk_all").click(function() {
var checked_status = this.checked;
$("input[id^=chk]").each(function () {
this.checked = checked_status;
});
});
});
</code></pre>
| jquery | [5] |
3,524,435 | 3,524,436 | Android: NullpointerException at vibrate | <p>I am using the following code , but its giving the nullpointer exception at vibrate.</p>
<pre><code>public Server(DroidGap gap, WebView view) //constructor
{
mAppView = view;
mGap = gap;
}
public Server(Context context) //constructor
{
mcontext=context;
}
public void run() //run method
{
try {
InetAddress serveradd = InetAddress.getByName(serveraddress);
}
catch (UnknownHostException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
DatagramPacket packet=new DatagramPacket(buf,buf.length);
try
{
c.socket.receive(packet);
dat=new String(packet.getData());
if(dat!=null)
{
((Vibrator)mGap.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(800);
cordovaExample.activity.sendJavascript("displayreciever('"+dat+"')");
}
Log.d("UDP", "s: ReceivedJI: '" + new String(packet.getData()) + "'");
} //end of try block
catch (IOException e)
{
e.printStackTrace();
}
//end of catch block
} //end of run method
</code></pre>
<p>I am getting nullpointer Exception at the followingline</p>
<pre><code>((Vibrator)mGap.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(800);
</code></pre>
<p>I am not able to find out the reason</p>
<p>Any help will be appreciated,</p>
| android | [4] |
752,448 | 752,449 | What's the best way to return the name of the current property? | <p>This code shows a property that calls out to a method to get that property's name:</p>
<pre><code>public string Foo { get { return MyName(); } }
string MyName([System.Runtime.CompilerServices.CallerMemberName]
string propertyName = null)
{
return propertyName;
}
</code></pre>
<p>Is there a better way?</p>
| c# | [0] |
2,733,138 | 2,733,139 | if statement executing when condition is false | <p>I'm tinkering with a projecteuler problem and I encountered the following really odd behaviour. And I can't for the life of me figure out whats going on. </p>
<p><img src="http://i.imgur.com/0Ds4I.png" alt="Screenshot"></p>
<p>As the screenshot shows. The condition evaluates to false, and the if-statment executed as if it was true. </p>
<p>I feel like I'm going crazy here. </p>
<p>Updated code: <a href="http://ideone.com/L7KMu" rel="nofollow">http://ideone.com/L7KMu</a></p>
<p>Edit: The actual values for next.x and next.y just prior to the condition are
0.324583, 9.97891</p>
<p>The are unchanged after the if statement. </p>
| c++ | [6] |
4,621,240 | 4,621,241 | Function (callable) objects with inherited properties | <p>Is there any way to create a function/callable object that inherits properties from another object? This is possible with <code>__proto__</code> but that property is deprecated/non-standard. Is there a standards compliant way to do this?</p>
<pre><code>/* A constructor for the object that will host the inheritable properties */
var CallablePrototype = function () {};
CallablePrototype.prototype = Function.prototype;
var callablePrototype = new CallablePrototype;
callablePrototype.hello = function () {
console.log("hello world");
};
/* Our callable "object" */
var callableObject = function () {
console.log("object called");
};
callableObject.__proto__ = callablePrototype;
callableObject(); // "object called"
callableObject.hello(); // "hello world"
callableObject.hasOwnProperty("hello") // false
</code></pre>
| javascript | [3] |
4,989,492 | 4,989,493 | How to strtotime date format like this | <p>I would like to strtotime dateformat like this - Fri Jun 15 05:38:11 +1000 2012 How could I do that? Basically I need to strtotime it, then do the following - <code>$ago = time()-strtotime(Fri Jun 15 05:38:11 +1000 2012);</code> and then do this - </p>
<pre><code>$ago = $ago / (60*60*24);
echo $ago.' days ago';
</code></pre>
<p>So I need one thing - strtotime(Fri Jun 15 05:38:11 +1000 2012) which will work as it need to work.</p>
<p>If this type of date cannot be strtotime, then how can I edit it, so it could be strtotime?</p>
| php | [2] |
4,040,026 | 4,040,027 | I have an int value; now how do I present it in a TextView to the user? Android | <p>Beginning I should say that I am very new to programming. </p>
<p>I am building an android application which includes a calculator function. What I want to do is on button click to get the user input from two EditTexts, add them together and then display the result in a TextView. Similar questions have been covered by others, but what they don't cover is how do you actually display the result in a TextView (or at least I didn't find one myself). So I tried the following which was suggested in many posts:</p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.team2);
//finds the references for the view in the layouts
b_t2p_ok = (Button) findViewById(R.id.bOK2);
EditText1 = (EditText) findViewById(R.id.etPaixnidi2);
EditText2 = (EditText) findViewById(R.id.etPontoi2);
b_t2p_ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//First I am trying to do this for one EditText
String myEditValue = etPaixnidi20.getText().toString();
int myEditNum = Integer.parseInt(myEditValue);
myEditNum.setText(textOut);
}
});
}
</code></pre>
<p>However when I try to display the int myEditNum in a TextView(textOut1) using the setText() method I get an error for the setText method (saying: ''Cannot invoke setText(TextView) on the primitive type int'').</p>
<p>I also tried (below) to convert int myEditNum to a String and then display it to a TextView but still doesn't work as I get the folloing error for the setText method: ''The method setText(TextView) is undefined for the type String''.
EditText myEdit = (EditText) findViewById(R.id.edittext1);</p>
<pre><code>String myEditValue = myEdit.getText().toString();
int myEditNum = Integer.parseInt(myEditValue);
String texting = Integer.toString(myEditNum);
texting.setText(textOut1);
</code></pre>
<p>Why does this happen and how do I fix this?</p>
| android | [4] |
3,238,559 | 3,238,560 | Sharing Android NDK Lib | <p>The Native Code of the Android application is going alone with application as lib file in the APK file. Suppose if I want to share a native code between two different applications, Is there any trick avail apart from the below:</p>
<ol>
<li>Adding the lib with every application</li>
<li>Copy the lib in to system/lib folder and dynamically link it with application. (If we build just only the applications then we cannot use this).</li>
</ol>
| android | [4] |
1,720,039 | 1,720,040 | ASP.NET validators validate on mouse up | <p>I have a compare validator on a Password field compared it to a password repeat field. If there is a validation error the error doesn't disappear until the lost focus event is fired. The client wants this changed to be the key up event.</p>
<p>What is the best way of going about this?</p>
| asp.net | [9] |
4,899,136 | 4,899,137 | Whiteboard Making | <p>Hy!!
I want to make a Whiteboard app, but i don't know how to make only some pixels black and let the others white.</p>
| android | [4] |
5,717,199 | 5,717,200 | Calling a local drive from javascript | <p>I have a folder in D:\testDownload .I want to open the folder on click of a button.
How to place the code inside the javascript function.</p>
<p>function open(){</p>
<p>}</p>
| javascript | [3] |
4,650,176 | 4,650,177 | Displaying images | <p>My instructor gave us example code that is very similiar to the code below. I haven't heard back from him yet and wanted to find out why my code won't work properly. Could someone give me some advice on what I'm doing wrong or an easier method to display images. Thanks for your time.</p>
<pre><code><%@ WebHandler Language="VB" Class="images" %>
Imports System
Imports System.Web
Imports System.Data.SqlClient
Public Class images : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim id As String = context.Request.QueryString("ImageId")
Dim userId As Integer = 4
Dim conn As New System.Data.SqlClient.SqlConnection
Dim cmd As New System.Data.SqlClient.SqlCommand
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
cmd.Connection = conn
cmd.CommandText = "SELECT Image FROM mrg_Image WHERE UserId=@userId"
cmd.Parameters.AddWithValue("@userId", userId)
conn.Open()
Dim file_bytes As Byte() = cmd.ExecuteScalar()
Dim file_bytes_stream As New System.IO.MemoryStream(file_bytes)
'During the build - The next line of code is highlighted green with the error message of, "Parameter is invalid"
Dim the_image As New System.Drawing.Bitmap(file_bytes_stream)
context.Response.ContentType = "image/jpg"
the_image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
conn.Close()
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
</code></pre>
| asp.net | [9] |
2,919,842 | 2,919,843 | Correct pattern for registering a receiver? | <p>I need to register a receiver. I have been using the following pattern:</p>
<pre><code>@Override
protected void onResume() {
super.onResume();
registerReceiver(myReceiver, new IntentFilter(...));
}
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(myReceiver);
}
private BroadcastReceiver myReceiver = new BroadcastReceiver() {
...
});
</code></pre>
<p>I'm getting crash reports from marketplace about my unregisterReceiver() call:</p>
<pre><code>java.lang.IllegalArgumentException: Receiver not registered
</code></pre>
<p>I thought this could not be possible, but it seems this is the correct pattern instead:</p>
<pre><code>private Intent mIntent;
@Override
protected void onResume() {
super.onResume();
if (mIntent == null) {
mIntent = registerReceiver(myReceiver, new IntentFilter(...));
}
}
@Override
protected void onPause() {
super.onPause();
if (mIntent != null) {
unregisterReceiver(myReceiver);
mIntent = null;
}
}
private BroadcastReceiver myReceiver = new BroadcastReceiver() {
...
});
</code></pre>
<p>Is the above the correct pattern? I guess it's possible for registration to fail, and we have to keep the result from registerReceiver(), and check it in onPause() before making the call to unregister()?</p>
<p>Thanks</p>
<hr>
<p>I am basing the change off of this question:
<a href="http://stackoverflow.com/questions/5036451/problem-with-broadcastreceiver-receiver-not-registered-error">Problem with BroadcastReceiver (Receiver not registered error)</a></p>
<p>I've only ever seen the first pattern above, never one where you check the intent response - any clarification would be great.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.