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 |
---|---|---|---|---|---|
209,663 | 209,664 |
how to use the openadator to send the database's content to socket(netstream)
|
<p>I want to change the database to the netstream and send it to the sockt, but I have no idea how to change the database to netstream, what should I do</p>
<p>Thanks</p>
|
java
|
[1]
|
3,887,019 | 3,887,020 |
How to stop affecting more than one class with jQuery?
|
<p>I created this simple function and it works fine apart from the fact that I have more than one ".cta-mask" on the page. What do I need to do to stop affecting all the ".box-hover" when hover one of the ".cta-mask". Code bellow:</p>
<pre><code>$(document).ready(function() {
//header box
$('.box-hover').css('opacity' , '.6');
$('.cta-mask').hover(function(){
$('.box-hover').stop().animate({left:'-12px', opacity:'0.8'},{queue:false,duration:300})
}, function(){
setTimeout(function() {
$('.box-hover').stop().animate({left:'-190px', opacity:'.6'},{queue:false,duration:600})
}, 500)
});
});
</code></pre>
<p>Thank you for your help in advance.</p>
|
jquery
|
[5]
|
826,850 | 826,851 |
Changing Object Parameter Names On-The-Fly
|
<p>If I have the following:</p>
<pre><code>var myObj = { "Foo":{"prop1":"abc", "prop2":123 }, "Bar":{"prop1":"def", "prop2":456 } };
</code></pre>
<p>Is there a quick and safe way to modify the object such that it becomes:</p>
<pre><code>{ "Foo":{"prop1":"abc", "prop2":123 }, "Bar":{"PROP1":"def", "PROP2":456 } }
</code></pre>
<p>I'd like to change the casing of the property names of the Bar property on-the-fly. Is this possible?</p>
|
javascript
|
[3]
|
92,309 | 92,310 |
Class extending Application in Android project library?
|
<p>I have a project (in Eclipse) which I've turned into an Android Project Library so as to re-use some of the code in another similar project. I think I've shot myself in the foot however as I'm getting the error:</p>
<pre><code>Unable to start activity ComponentInfo{com.test.scroller1/com.lib.scrolltest.ScrollTestActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.lib.scrolltest.resAppVars
</code></pre>
<p>com.lib.scrolltest is my Project Library which instantiates a class extending Application (resAppVars). In the onCreate() method I call:</p>
<pre><code>mRav = (resAppVars) getApplicationContext ();
</code></pre>
<p>This way, I can use methods in the mRav object which would otherwise be a lot of duplicated code in other classes (such as passing a query to a generic select statement which returns an ArrayList of results).</p>
<p>What's the problem here? It seems I've hit a limitation in the way I've implemented the Application class. </p>
|
android
|
[4]
|
4,724,871 | 4,724,872 |
selected value does not change in asp:Dropdownlist
|
<p>I have a simple dropdownlist(ffg)...</p>
<pre><code><asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true" BackColor="LightSteelBlue" Font-Size="X-Small"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged1" Style="z-index: 102; left: 37px; position: absolute; top: 85px" Width="331px"
</asp:DropDownList>
</code></pre>
<p>which I bind data to usind the onpageload event...</p>
<pre><code>DropDownList2.DataSource = td.DataSet
DropDownList2.DataSource = td
DropDownList2.DataTextField = td.Columns("Name").ColumnName.ToString
DropDownList2.DataValueField = td.Columns("VendorCode").ColumnName.ToString
DropDownList2.DataBind()
</code></pre>
<p>and an <code>onleselectedindexchaged</code> event where I try to retreive the new value like this...</p>
<pre><code>Protected Sub DropDownList2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.TextChanged
Dim url As String = "sp_menu.aspx?sp=" & DropDownList2.SelectedValue
Session.Remove("sp")
Session("sp") = DropDownList2.SelectedValue
Session("spnm") = DropDownList2.SelectedItem.Text & " (" & DropDownList2.Text & ")"
Response.Redirect(url)
End Sub
</code></pre>
<p>But it always brings the first value no matter which one is clicked on the dropdownlist.
Please help!</p>
|
asp.net
|
[9]
|
689,625 | 689,626 |
C++ size aware data type/parameter
|
<p>I am not sure, but I think I have once seen a method signature that looked like this (in the constructors):</p>
<pre><code>class Buffer {
Buffer(char_with_size *data) { ... };
Buffer(char *data, size_t len) { ... };
};
</code></pre>
<p>In the first constructor call an array/pointer parameter can passed of which the compiler automatically knows its size. So, I always know the size of the char buffer passed.</p>
<p>Does anyone know if this really exists in c++?</p>
|
c++
|
[6]
|
2,856,093 | 2,856,094 |
Use the device's internal memory
|
<p>Can I use the internal memory to store your application files there? In other words, when suddenly, the device will not SD card. In particular, I need to create there a folder where I was later going to copy your files.</p>
|
android
|
[4]
|
3,231,224 | 3,231,225 |
a potentially dangerous request.form with Freetextbox
|
<p>I am using a control called FreeTextBox and when i am click on update button i am getting the error "A potentially dangerous Request.Form value was detected from the client (fTxtContent="tyretyeryteyterty...").". and for that i don't want to disable the page level property i.e validaterequest to false. Is there any good idea to deal with this error.</p>
<p>Please Help me ASAP.</p>
|
asp.net
|
[9]
|
1,321,354 | 1,321,355 |
Android: Possible to preserve data when upgrading app?
|
<p>Is it possible to preserve file-persisted data when upgrading an app? For example my app stores data under /data/data/mypkg/store. I would like the store directory to be preserved when user upgrades my app.</p>
|
android
|
[4]
|
1,372,024 | 1,372,025 |
c# Delegate and Dispatcher problem
|
<p>i get this error when trying this:</p>
<blockquote>
<p>ERROR method name expected. </p>
</blockquote>
<p>How should i do to correct the problem</p>
<pre><code>delegate void DelegateFillList(DeliveryDoc[] deliveryDocs);
private void FillListViewAssignment(DeliveryDoc[] docs) {
if(lvMyAssignments.Dispatcher.CheckAccess()) {
lvMyAssignments.ItemsSource = docs;
lvAllOngoingAssignments.ItemsSource = docs;
if(m_tempDeliveryDocs != null) {
txtblockHandOverCount.Text = m_tempDeliveryDocs.Length.ToString();
}
} else {
lvMyAssignments.Dispatcher.BeginInvoke(
new DelegateFillList(FillListViewAssignment(docs)), null);
}
}
</code></pre>
|
c#
|
[0]
|
488,974 | 488,975 |
Bluetooth simply application
|
<p>I want to ask you about some bluetooth library which I can use to implement simply application. I want to connect two devices by bluetooth. In application I want to have two buttons and I want to send from one device to second device by bluetooth which button was push. How I can do that? Any idea or tutorials can recommend me?</p>
|
android
|
[4]
|
460,140 | 460,141 |
How to close an accordion content when re-clicking the accordionbutton?
|
<p>There is a <code>JQuery</code> <code>accordion</code> :</p>
<pre><code><script type="text/javascript" >
$(document).ready(function() {
$('div.accordionButton').click(function() {
$('div.accordionContent').slideUp('slow');
$(this).next().slideDown('slow');
});
$("div.accordionContent").hide();
});
</script>
</code></pre>
<p>When I first click an object <code>div</code> "accordionButton" then its sub-content is shown by slide. How to hide this sub-content by re-clicking the object div "accordionButton" ?</p>
|
jquery
|
[5]
|
3,540,390 | 3,540,391 |
Potential malicious uses of javascript?
|
<p>In Firefox 6, you can no longer put javascript in the address bar because of security risks such as recent scripts on facebook. I understand it can simulate just about anything you can click, like removing friends and spamming wall posts, but what's the absolute worst? It can only manipulate the page you're on because of cross-domain iframe javascript being disabled, unless it sends an XMLHttpRequest based on cookie data. </p>
<p>What exactly were the scripts on facebook doing that made it such a big problem? What's the worst that can be done?</p>
|
javascript
|
[3]
|
2,554,174 | 2,554,175 |
PHP function parameters don't work properly?
|
<p>I'm trying to set up a website using MVC, but I'm stuck at the very beginning.</p>
<p>In project0/application/controllers I have a pages.php file which looks like:</p>
<pre><code><?php
class Pages extends CI_Controller {
public function view($page = 'home')
{
if (!file_exists('application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
}
}
</code></pre>
<p>and in project0/application/views/pages two files named home.php and about.php, containing a "Hello world".</p>
<p>When I want to visit <a href="http://project0/index.php/pages/view/about" rel="nofollow">http://project0/index.php/pages/view/about</a>, it gives me the 404 error: it seems the home.php or about.php files are not existing.</p>
<p>Can somebody help me out?</p>
|
php
|
[2]
|
3,691,123 | 3,691,124 |
Null Pointer Exception in Linked List
|
<p>Removed for academic integrity. Thank You.</p>
|
java
|
[1]
|
684,795 | 684,796 |
Arc drawable ProgressBar
|
<p>I am new to Android and I need help.<br>
Long searched for a solution to this problem, but found nothing. Howe to make an arc <code>ProgressBar</code> using drawable resources?</p>
|
android
|
[4]
|
5,806,816 | 5,806,817 |
Python : updating values in a dictionary
|
<p>I have the following dictionary -></p>
<pre><code>key : (time,edge_list)
</code></pre>
<p>Now I want to increment all time values by 1. How do I do that?</p>
<pre><code>dict_list = dict(key:(time+1,edge_list) for key:(time,edge_list) in dict_list)
</code></pre>
|
python
|
[7]
|
1,535,305 | 1,535,306 |
whats wrong with this program
|
<pre><code>#include <iostream>
using namespace std;
int main ()
{
double testscore;
cout << " Enter your test score and i will tell you the letter grade you earned ";
cin >> testscore;
switch (testscore)
{
case (testscore < 60.0):
cout << "your grade is F.\n";
break;
default:
cout << "that score isnt valid\n.";
}
return 0;
}
</code></pre>
|
c++
|
[6]
|
862,881 | 862,882 |
In JQuery, what does it mean to 'wire up' an object?
|
<p>I have the task of 'wiring up' an input box and a submit button on a web page to allow a user to enter their own message. I am new to programming and was curious as to what the 'wiring up' part in JQuery means. Any advice or examples will help. Thanks in advanced! </p>
|
jquery
|
[5]
|
3,412,203 | 3,412,204 |
jquery prevent double tapping the same element
|
<p>Hy, i'v got a horizontal css menu. When clicked on a tab i do a toggle to switch between the css selected class. This class just removes the bottom-border and colors the font, so it seems like it's an active tab. That's al fine, problem is, i would not like to toggle again when clicking on the same tab that's active.</p>
<p>Example: </p>
<p>-> click on home
-> | <strong>Home</strong> | tab selected.
-> click on home again
-> | Home | tab deselected. </p>
<p>This is the on ready code: </p>
<pre><code>$('#tabmenu li').click(function(e) {
$(this).toggleClass("clicked");
$("#tabmenu li").not(this).removeClass("clicked");
});
</code></pre>
<p>CSS:</p>
<pre><code>#tabmenu li.clicked {
/*remove a piece of UL bottom-border*/
border-bottom: 1px solid #fff;
margin-bottom: -1px;
/*make it show active*/
border-top:1px solid #7C798E;
border-left:1px solid #7C798E!important;
border-right:1px solid #7C798E;
}
#tabmenu li.clicked a { color:#000070;}
</code></pre>
<p>PS.</p>
<p>I thought of doing something like: </p>
<p>... //which element are you
...//temp save
....// are you the same as last one?
.....// YES? -> do nothing, NO -> toggle.</p>
<p>Is there a more brighter way to do this? thx. </p>
|
jquery
|
[5]
|
5,540,685 | 5,540,686 |
How to call masterpage function in a usercontrol page?
|
<p>I want to call masterpage public function on usercontrol cs page.</p>
<p>whether this user control is called on the master page.</p>
<p>My user control is on the master page and i want to calling this master page function in this usercontrol.</p>
|
asp.net
|
[9]
|
3,887,676 | 3,887,677 |
Difference between 'new operator' and 'operator new'?
|
<p>What is difference between "new operator" and "operator new"? </p>
<p>Thanks.</p>
|
c++
|
[6]
|
2,592,647 | 2,592,648 |
append part of java byte array to StringBuilder
|
<p>How do I append a portion of byte array to a StringBuilder object under Java? I have a segment of a function that reads from an InputStream into a byte array. I then want to append whatever I read into a StringBuilder object:</p>
<pre><code>byte[] buffer = new byte[4096];
InputStream is;
//
//some setup code
//
while (is.available() > 0)
{
int len = is.read(buffer);
//I want to append buffer[0] to buffer[len] into StringBuilder at this point
}
</code></pre>
|
java
|
[1]
|
314,074 | 314,075 |
Call this (public) function inside private function
|
<p>I have the following javascript: (<a href="http://jsfiddle.net/Mansfield/7XEYD/2/" rel="nofollow">JSFiddle</a>)</p>
<pre><code>$(function () {
function Cat()
{
this.Meow = function (sound) {
alert("Meow: " + sound);
}
this.Kick = function () {
MakeNoise();
}
var MakeNoise = function () {
Meow("noise");
//Cat.Meow("noise");
//self.Meow("noise");
//this.Meow("noise");
}
}
var c = new Cat();
c.Kick();
});
</code></pre>
<p>When I call the <code>Kick</code> function, I get the error "Meow is not defined" (with any of the four things I tried in the <code>MakeNoise</code> function).</p>
<p>I also tried prototyping like so but that gave me the same error:</p>
<pre><code>Cat.prototype.Meow = function (sound) {
return this.Meow(sound);
}
</code></pre>
<p>I've sure this has a terribly straightforward solution, but I can't figure out how to successfully call the <code>Meow</code> function of the "Cat" class. How can I do this?</p>
<p>As an aside, does this architecture make any sense at all? My intention was to have <code>Kick</code> and <code>Meow</code> as public functions, and <code>MakeNoise</code> as private.</p>
|
javascript
|
[3]
|
2,777,963 | 2,777,964 |
use excel file to fill dropdownlist in c#?
|
<p>I have an excel file that I want To use one of it's column to fill dropdown list ,I do it but I can't Remove Duplicate data.How Can I distinc datat table before that? Or How Can I Access to each coulmn of excel in c#?</p>
<p>Or how can I write in two sheet of excel ? and read from each sheet to fill dropdownlist with one sheet and fill another sheet to fill gridview in c#?</p>
|
c#
|
[0]
|
3,102,594 | 3,102,595 |
Display a Message on Closing an Activity
|
<p>So, when the user force closes an activity, I want to display a custom message (Toast) to the user. Any suggestions? I tried putting the Toast in my <code>onPause()</code> / <code>onStop()</code> methods, but they cause the program to crash.</p>
<p>And no, I'm not trying to spam the user with messages everytime he/she force closes an activity. I just want to display the Toast when a <em>particular</em> activity is closed. </p>
|
android
|
[4]
|
4,348,669 | 4,348,670 |
Parameters(integers)
|
<p>I am a beginner in java and i am doing practiceit questions from the internet.I stumbled upon this question and i got stuck.</p>
<p>Write a method called distance that accepts four integer coordinates x1, y1, x2, and y2 as parameters and computes the distance between points (x1, y1) and (x2, y2) on the Cartesian plane.
For example, the call of distance(1, 0, 4, 4) would return 5.0 and the call of distance(10, 2, 3, 5) would return 7.615773105863909.</p>
<pre><code>public static int distance(int x1,int y1,int x2,int y2){
int d=(x2-x1)*(x2-x1)-(y2-y1)*(y2-y1))^0.5;
return (double)d;
}
</code></pre>
<p>2 things i will like to clarify.How come when i use ^,they keep giving me an error to say it cannot be applied.Secondly,i try casting double inside one of number in the equation.But it keeps giving me an error too.</p>
|
java
|
[1]
|
6,003,709 | 6,003,710 |
Cannot call method toUpperCase of undefined
|
<pre><code>if (json.ScheduleCareProviderScheduledPatientsGetResult.Appointments[i].Patient.Firstname.toUpperCase().indexOf(searchBarValue.toUpperCase()) == 0) {
</code></pre>
<p>Why do i get this error. </p>
|
javascript
|
[3]
|
5,929,692 | 5,929,693 |
python NotImplemented constant
|
<p>Looking thru decimal.py and it uses NotImplemented at many special methods e.g.</p>
<pre><code>class A(object):
def __lt__(self, a):
return NotImplemented
def __add__(self, a):
return NotImplemented
</code></pre>
<p><a href="http://docs.python.org/library/constants.html">Python docs says</a></p>
<blockquote>
<p>NotImplemented:
Special value which can be returned by the “rich comparison”
special methods (<strong>eq</strong>(), <strong>lt</strong>(),
and friends), to indicate that the
comparison is not implemented with
respect to the other type.</p>
</blockquote>
<p>It doesn't talk about other special methods and neither describes the behavior</p>
<p>It seems to be a magic object which if returned from other special methods raises TypeError, and in “rich comparison” special methods does nothing</p>
<p>e.g.</p>
<pre><code>print A() < A()
</code></pre>
<p>prints True, but</p>
<pre><code>print A() + 1
</code></pre>
<p>raises TypeError, so I am curious whats going on and what is the usage/behavior of <strong>NotImplemented</strong></p>
|
python
|
[7]
|
1,705,462 | 1,705,463 |
Getting data from a webpage
|
<p>I have an idea for an App that would really help me out in work but I'm not sure if it's possible.</p>
<p>I want to run a C# desktop application that will ask for a value. When a value is supplied, the application will open a browswer, go to a webpage and add the value into a form on an online website. The form is then submitted and a new page is loaded that contains a table of results. I then want to extract the table of results from the page source and write code to parse the result values.</p>
<p>It is not important that the user see's this happen in an actual browser. In other words if there's a way to do it by reading HTTP requests then thats great.</p>
<p>The biggest problem I have is getting the values into the form and then retrieving the page source after the form is submitted and the next page loads.</p>
<p>Any help really appreciated.</p>
<p>Thanks</p>
|
c#
|
[0]
|
2,338,668 | 2,338,669 |
How to send data to one html file from another using jQuery
|
<p>So, I have 2 html files with their own javascript files
file1.html and file1.js
file2.html and file2.js</p>
<p>I am loading file2.html in my file1 page using this code in file1.js:</p>
<pre><code> $.get("file2.html", function (deals) {
$('#wrapper').html(deals); //deals is JSON object i want to send
function2(deals);
});
</code></pre>
<p>And in file2.html I have function2 as:</p>
<pre><code> function function2 (deals){
alert(JSON.stringify(deals));
</code></pre>
<p>}</p>
<p>The second html page (file2) successfully loads into file1's #wrapper div but it doesnt get the JSON object deals/
What should i do..please help</p>
|
jquery
|
[5]
|
4,681,388 | 4,681,389 |
why is stroull() not working on a byte array with hexadecimal values?
|
<p>here is some new test code with regards to my long issue.
I figure that if i code my stuff as long long then that is half the battle in porting.
the other half would be to make it into big endian so it can work on any 64 bit system.
so i did the following:</p>
<pre><code>#include <iostream>
#include "byteswap.h"
#include "stdlib.h"
using namespace std;
int main()
{
char bytes[6] = {0x12,0x23,0xff,0xed,0x22,0x34};
//long *p_long = reinterpret_cast<long*> (bytes);
long long *p_long = reinterpret_cast<long long*> (bytes);
std::cout<<"hex="<<std::hex<<*p_long<<"LE"<<std::endl;
*p_long = bswap_64(*p_long);
std::cout<<"hex="<<std::hex<<*p_long<<"BE"<<std::endl;
return 0;
}
</code></pre>
<p>this seems to me the simplest way of doing it. the problem now is at using bswap...i get the following output</p>
<p>hex=34563422edff2312LE
hex=0BE</p>
<p>i got all the bytes in the first as LE. but now it seems the 64bit swap function is not working. I think this would solve the issue i am having. </p>
<p>considering that i will be operating on a 20 byte array. i am also not sure how i would use pointers to do that. i am thinking i would need an array of long long pointers to get all this stuff stored and then call the byteswap on each to swap the values in each of those pointers. I personally have not done pointer incrementation via sizeof(long) to increment before.</p>
|
c++
|
[6]
|
625,599 | 625,600 |
check if folder is share and set to folder access rules - everyone
|
<p>How do I check if a folder is shared? This is my code to set access rules for folder - </p>
<pre><code> FileSystemSecurity fs = File.GetAccessControl(FilePath);
fs.AddAccessRule(new FileSystemAccessRule("everyone",
FileSystemRights.ReadPermissions, AccessControlType.Deny));
File.SetAccessControl(FilePath, fs);
</code></pre>
<p>"Everyone" gets only read Permission</p>
|
c#
|
[0]
|
2,422,713 | 2,422,714 |
print and format output
|
<p>I have a simple script:</p>
<pre><code>now = datetime.datetime.now()
print "%d%d%d%d%d" % ( now.year, now.month, now.day, now.hour, now.minute )
</code></pre>
<p>result:</p>
<pre><code>20111124149
</code></pre>
<p>How to get result:</p>
<pre><code>201111241409
</code></pre>
<p>?</p>
|
python
|
[7]
|
5,706,424 | 5,706,425 |
How are iPhone emoji apps made?
|
<p>Does anyone know how it is done?</p>
<p>They seem to be enabling japanese language settings.. But how? </p>
<p>It's impossible to search for it, because of all the outrage over Emoji apps in the app store.</p>
<p>Thanks a bunch!</p>
|
iphone
|
[8]
|
5,769,591 | 5,769,592 |
Warn Users when application crashes or exited and Post crashlog- iPhone
|
<p>Hii People,</p>
<p>i want to set up a default exception handler for all application exceptions or crashed ,</p>
<p>The goal is to display a alertview to display the crash log and warn users that application is unstable to continue and exit with some time interval and collect those crash logs and post to client server for error handling.</p>
<p>Any suggestions ?</p>
|
iphone
|
[8]
|
4,315,778 | 4,315,779 |
calculate the total and display
|
<p>I have array with decimal value 1.19, 1.44, 4.59 and so-on</p>
<p>How to calculate sum and alert.</p>
|
javascript
|
[3]
|
5,867,977 | 5,867,978 |
Comparing Two Arrays resulting into Third Array
|
<p>I have two Arrays:</p>
<pre><code>firstArray=[['AF','AFGHANISTAN'],['AL','ALBANIA'],['DZ','ALGERIA'],['AS','AMERICAN SAMOA']]
secondArray=[[1,'AFGHANISTAN'],[3,'AMERICAN SAMOA']]
</code></pre>
<p>So I just need an Array which is like</p>
<pre><code>thirdArray=[[1,'AF'],[3,'AS']]
</code></pre>
<p>I tried <code>any(e[1] == firstArray[i][1] for e in secondArray)</code>
It returned me True and false if second element of both array matches. but i don't know how to build the third array.</p>
|
python
|
[7]
|
2,108,782 | 2,108,783 |
Get string between delimiters from file in C#
|
<p>Maybe the question is familiar but I need an explanation in this case.</p>
<p>Let's assume that I have a file called <code>test.txt</code>. It has the following content:</p>
<pre><code>An example of this line. The line has more than 20 characters.
[sql]SELECT * FROM LINE WHERE aLine = '123'[/sql]
blah blah blah blah...
</code></pre>
<p><strong>OR what's about</strong></p>
<pre><code>An example of this line. The line has more than 20 characters.
[sql]SELECT * FROM
LINE
WHERE aLine = '123'[/sql]
blah blah blah blah...
[sql] SELECT * FROM ME[/sql]
etc..er
[sql]
SELECT * FROM ALL
[/sql]
</code></pre>
<p>I want to get a string between <code>[sql]</code> and <code>[/sql]</code> delimiters.</p>
<p>How to do that ? With Regular expression ?</p>
<p>Thanks for patience ...</p>
|
c#
|
[0]
|
1,352,812 | 1,352,813 |
Extending Int to implement interface in c#
|
<p>Is it possible in C# (and I think it's not) to extend <code>int</code> to implement an interface (without creating a wrapper class)?</p>
<p>I have an interface like so</p>
<pre><code>public interface IActionLoggerObject
{
string GetForLogging();
}
</code></pre>
<p>I would like to (conceptually) be able to do this:</p>
<pre><code>public class int:IActionLoggerObject
{
string IActionLoggerObject.GetForLogging() { return "s"; }
}
</code></pre>
|
c#
|
[0]
|
2,190,298 | 2,190,299 |
Help with syntax in order to replace url by another
|
<p>Using jQuery, I am trying to automatically replace every...</p>
<p>www.mywebsite.com/blog/category/categoryname</p>
<p>by</p>
<p>www.mywebsite.com/blog/#categoryname</p>
<p>...in my page.</p>
<pre><code>$("a[href^='...']")
.each(function()
{
this.href = this.href.replace(...);
}
);
</code></pre>
<p>Can someone help with the syntax please?</p>
|
jquery
|
[5]
|
3,430,122 | 3,430,123 |
PHP: How to display page before the script is over?
|
<p>My script consists of two parts.
The first part generates HTML page.
The second part loads a resourse from the net and saves it into a file.
Loading is a long operation and can take up to 10 seconds.
The first and the second parts are completely indepenent (loading has no impact on the look of the page).</p>
<p>At the end of the first part I call flush(), that makes page displayed instantly.</p>
<p>However, embedded SWF movie is not displayed at this moment.</p>
<p>SWF is the key element of the page and it must be displayed as fast as possible.
It is embedded in the page with SwfObject library.
And the problem is that SwfObject starts to open SWF on "onLoad" event of the page.</p>
<p>But "onLoad" event comes at the end of the <em>second</em> part.
That is "onLoad" can occure in 10 seconds.
So in spite flush() call the user has to wait for 10 seconds in vain.</p>
<p>Is it possible to solve the task on PHP side?
Is it possible to run "loading" task (the second part) in a separate process?
Is it possible to tell the browser before the second part starts, that the page is reay and you can broadcast the "onLoad" event.</p>
<p>Thanks for reading this very long story.</p>
|
php
|
[2]
|
2,064,220 | 2,064,221 |
ReflectionClass::newInstance/newInstanceArgs generates undefined property
|
<p>When I try to create a new instance with constructor arguments via the <code>ReflectionClass</code> object I get this notice:</p>
<blockquote>
<p>Notice: Undefined property: ReflectionClass::$newInstanceArgs in XXX on line 93</p>
</blockquote>
<p>On line 93 I simply try to instanciate the reflection by:</p>
<pre><code>$obj = new $reflection->newInstanceArgs([$arg1]);
</code></pre>
<p>The notice is generated by newInstance as well:</p>
<pre><code>$obj = new $reflection->newInstance([$arg1]);
</code></pre>
<blockquote>
<p>Notice: Undefined property: ReflectionClass::$newInstance in XXX on line 93</p>
</blockquote>
<p>The class I'm trying to instantiate looks like this:</p>
<pre><code>class ObjectName
{
public function __construct ($str = "")
{}
}
</code></pre>
<p>I can't seem to find the problem. Am I doing something wrong here?</p>
|
php
|
[2]
|
2,037,857 | 2,037,858 |
Do database update notifications only happen within the same Activity/Fragment context?
|
<p>I've got a FragmentActivity that shows a list of items and clicking on one starts a new Activity which allows the user to edit that item. This is all using the new <code>CursorLoader</code> support from the v4 compat library. Everything is working (finally!) but when I return from the Edit, the changes are not showing up in the list.</p>
<p>I suspect this is due to the cursor just being reloaded upon resuming the "List" activity and perhaps since it is a separate activity it does not receive any "update" notification from the edit Activity? All the database updates are doing notification as:</p>
<pre><code>getContext().getContentResolver().notifyChange(uri, null);
</code></pre>
<p>Is this working as it's supposed to (i.e. notifications only happen within one context) and I need to force a <code>restartLoader</code> operation when returning from the edit?</p>
<p>Or (as usual) is something else going on?</p>
|
android
|
[4]
|
4,041,790 | 4,041,791 |
javascript update parent html
|
<p>I'm trying to update the innerHTML of a div tag that's within the parent window from within an iframe. How do I access the parent window?</p>
|
javascript
|
[3]
|
2,528,150 | 2,528,151 |
Reading, Parsing and Writing to a file
|
<p>I have an assignment to read a text file, separate the lines and then save it to a new text file. I have to write separate classes for reading and writing of data. Assumption: Each sentence ends with a period.
I have only been able to read a file.</p>
|
c++
|
[6]
|
3,769,778 | 3,769,779 |
assets location for a sideloaded app on Kindle Fire
|
<p>I develop an app for android and install it to Kindle Fire by file manager. I would like to check that all the assets are in place (actually, some are loaded at runtime from my site via http). </p>
<p>The problem is - I cannot find the assets on the device when I look for them in file manager/explorer. Do I miss something obvious?</p>
<p>A second, related question. Will the assets be in a different place when the app is downloaded from Amazon after being accepred to Appstore?</p>
|
android
|
[4]
|
801,857 | 801,858 |
Javascript in list
|
<p>What's the easiest way to check to see if a number is in a comma delimited list?</p>
<pre><code>console.log(provider[cardType]);
//returns: Object { name="visa", validLength="16,13", prefixRegExp=}
if (ccLength == 0 || (cardType > 0 && ccLength < provider[cardType].validLength)) {
triggerNotification('x', 'Your credit card number isn\'t long enough');
return false;
} else {
if ($('.credit-card input[name="cc_cvv"]').val().length < 3) {
triggerNotification('x', 'You must provide a CCV');
return false;
}
</code></pre>
|
javascript
|
[3]
|
4,590,443 | 4,590,444 |
Select first 2 words with jQuery and wrap them with <span> tag
|
<p>How can I select with jQuery the first two words in a sentence, wrap them with a span tag and add a br tag after it?</p>
<p>Something like this:</p>
<pre><code><p><span>Lorem ipsum</span><br/> quosque tandem</p>
</code></pre>
<p>But add the span and br tag dynamically.</p>
<p>I can only do that for the first word with this code:</p>
<pre><code>$('p').each(function(){
var featureTitle = $(this);
featureTitle.html( featureTitle.text().replace(/(^\w+)/,'<span>$1</span><br/>') );
});
</code></pre>
<p>Thanks!!</p>
|
jquery
|
[5]
|
1,226,933 | 1,226,934 |
How to grab base32 from selected file?
|
<p>I have a website where you select a picture and you upload it - but how would I do it so it shows a preview of the image?</p>
<p>I have a javascript that shows the selected files in a list - but I plan to show a preview of the image via Base32 - but how would I go about doing this?</p>
<p>I've tried looking it up, but found no answers..</p>
<pre><code> function listFiles() {
var input = document.querySelector("input[type='file']");
var ul = document.querySelector("#bag>ul");
while (ul.hasChildNodes()) {
ul.removeChild(ul.firstChild);
}
for (var i = 0; i < input.files.length; i++) {
var li = document.createElement("li");
li.innerHTML = input.files[i].name;
ul.appendChild(li);
}
}
</code></pre>
<p>I'm fairly new to this, so please try to do your best to explain it to me. Thanks!</p>
|
javascript
|
[3]
|
5,770,616 | 5,770,617 |
How to find the factors of a number and return it in a list in python
|
<p>This is the code I have right now. I can't get it to return the right results for the question. </p>
<pre><code>def problem(n):
myList = [1,n]
for i in range(1,n):
result = int(n ** .5)
new = n/result
i = i + 1
myList.append(new)
return myList
</code></pre>
|
python
|
[7]
|
1,991,410 | 1,991,411 |
PHP and Excel sheet
|
<p>this is code to retrive data and insert it in to excel sheet</p>
<pre><code>header( "Content-Type: application/vnd.ms-excel" );
header( "Content-Type: text/html; charset=ISO-8859-1" );
header('Content-Type:text/html; charset=UTF-8');
header( "Content-disposition: attachment; filename=spreadsheet.xls" );
$rs = mysql_query("select * from organizations");
while ($row = mysql_fetch_object($rs)) {
echo $row->name1 . "\t" . $row->name2 . "\t" . $row->name3 ."\t" . $row->email . "\n";
}
</code></pre>
<p>($row->name1) is in arabic format</p>
<p>the problem is in excel sheet Arabic language is unreadable</p>
<p>any solution please</p>
|
php
|
[2]
|
2,197,722 | 2,197,723 |
Get timestamp and convert it to string
|
<p>I'm using this to get current timestamp in seconds and add it to a string <code>Double.toString((System.currentTimeMillis()/1000))</code>
However instead of decimal notation I get "1.23213E9". How do I switch to the decimal notation ?</p>
|
java
|
[1]
|
3,153,752 | 3,153,753 |
Java: How to add static text to file using ObjectOutputStream
|
<p>i am developing a small application in Java. At certain point i need to save the object of my custom class to a text file for this i override <code>toString()</code> method in my custom class and then use <code>ObjectOutputStream</code> class to save object of my custom class to text file. Now everything works fine i.e the text file contains the text as expected. Following three lines contain major code for that</p>
<pre><code>ObjectOutputStream outputStream = null;
outputStream = new ObjectOutputStream(new FileOutputStream(filename));
outputStream.writeObject(person);//person is the instance of my custom class
</code></pre>
<p>Now, how do i add some static data to my file along with the object data</p>
<pre><code>outputStream = new ObjectOutputStream(new FileOutputStream(filename));
outputStream.WhatFunctoinToUse("some static text");//What function i use to add static text??
outputStream.writeObject(person);//person is the instance of my custom class
</code></pre>
|
java
|
[1]
|
1,999,899 | 1,999,900 |
WebView problem - on click open new Activity
|
<p>I have image ( building cross layout and need to put that on background, always same dimensions ) and I have list of air conditioners with x_coord and y_coord on image ( that list is changeable and I need dynamically to add air conditioners on layout). I need to enabled zoom layout with air conditioners on and on click on some air conditioner to open new activity. I thought to use WebView and create page ( background to be layout, and every air conditioner be and to on click to do something - javascrit), but how to implement that on click I change to new activity from WebView ( I know JavScript, but how to connect that with Android ) ? Any suggestion or advice ? Is possible at any way that from onclick javascript somehow opet new activity in android app ?</p>
|
android
|
[4]
|
2,582,313 | 2,582,314 |
why no replace() method defined on the Set interface?
|
<p>Currently I have to write the following to update an element already contained in a Set:</p>
<pre><code>Set mySet= ...
Element e1 = new Element (...);
....
....
Element e2 = new Element (...);
\\e1 and e2 are different instances, but equals.
\\update the element contained into the Set
if (mySet.contains(e2)){
mySet.remove(e2);
myset.add(e2);
}
</code></pre>
<p>That doesnt look nice. Is there an alternative ?</p>
|
java
|
[1]
|
2,958,338 | 2,958,339 |
How to identify whether a variable is a class or an object
|
<p>I am working at a bit lower level writing a small framework for creating test fixtures for my project in Python. In this I want to find out whether a particular variable is an instance of a certain class or a class itself and if it is a class, I want to know if it is a subclass of a certain class defined by my framework. How do I do it?</p>
<pre><code>class MyBase(object):
pass
class A(MyBase):
a1 = 'Val1'
a2 = 'Val2'
class B(MyBase):
a1 = 'Val3'
a2 = A
</code></pre>
<p>I want to find out if the properties a1 and a2 are instances of a class/type (a1 is a string type in B) or a class object itself (i.e a2 is A in B). Can you please help me how do I find this out?</p>
|
python
|
[7]
|
2,865,204 | 2,865,205 |
button back navigation bar crash
|
<p>I have a crash when i click in the back bar in the navigation bar, the crash log is :</p>
<pre><code>-[__NSCFType hidesBottomBarWhenPushed]: unrecognized selector sent to instance 0x2f2480
</code></pre>
<p>what can be the reason of my crash ?</p>
<p>thanks for your answers</p>
|
iphone
|
[8]
|
2,771,429 | 2,771,430 |
Why can't you assign an int to an Integer in a loop without curly braces?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1974641/why-this-is-not-compiling-in-java">Why this is not compiling in Java?</a> </p>
</blockquote>
<p>In java, curly braces are optional for one line for loops, but I've found a case where it isn't allowed. For instance, this code:</p>
<pre><code>for(int i = 0; i < 10; i++)
Integer a = i;
</code></pre>
<p>won't compile, but if you add curly braces, like so:</p>
<pre><code>for(int i = 0; i < 10; i++){
Integer a = i;
}
</code></pre>
<p>it will. Why won't this code compile?</p>
|
java
|
[1]
|
5,452,893 | 5,452,894 |
Jquery get image
|
<p>I am using a form to submit details to a page which create an image, the form is submitted using Jquery so that the user does not have to leave the page. The send() function calls on the refresh() function to update the div where the image is placed into...</p>
<p>I am having an issue with one of the lines of code of my code and I don't know what to put to get it to work:</p>
<pre><code> function refresh()
{
$(function () {
var img = new Image();
$(img).load(function () {
//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
$(this).hide();
$('#loader').removeClass('loading').append(this);
$(this).fadeIn();
}).error(function () {
// notify the user that the image could not be loaded
// The next line causes the error
}).attr('src', "signatures/" +$("#username") "png");
});
}
</code></pre>
<p>Any help would be appreciated.</p>
|
jquery
|
[5]
|
3,155,465 | 3,155,466 |
python syntax error output
|
<p>Please could you help me by fixing the error with my code. When I print last line I get a syntax error message:</p>
<pre><code>import math
m_ = 900 # identifier for normal distribution mean [mm]
s_d = 1 # identifier for normal distribution standard deviation [mm]
print "DISTRIBUTION OF A PLATE WIDTH:" " MEAN", "=",m_,"," "STD DEV", "=", s_d
print ""
print "Using functions from the math library ..."
# The probability density function(pdf) for a normal distribution with mean m_ and
standard deviation s_d
ftotal = 0
term = 0.0
count = 0
while abs(term) > 911:
ftotal += term
count += 1
term = term * xx / float(count)
print "x" " " " f(x)" " " " F(x)"
print "890" "" (1 / ((s_d * (2 * math.pi) ** -0.5)) * math.exp((- (x - m_) ** 2) / (2 * (s_d) ** 2), 0.5 * (1 + math.erf((x - m_) / s_d * m.sqrt(2))
</code></pre>
|
python
|
[7]
|
2,956,388 | 2,956,389 |
Measure column width in TableLayout
|
<p>I have a TableLayout with 4 columns. In order to stretch column 1 I do:</p>
<pre><code>android:stretchColumns="1"
</code></pre>
<p>This works well. Now I need to measure the width of this column 1 once it's displayed on the screen. I need to do this because I want to fit a custom view into this column. This custom view is just a rectangle which shall fill into the complete width of this column 1. I draw the rectangle by:</p>
<pre><code>public class TaskRectangleView extends View {
private ShapeDrawable mDrawable;
private Paint textPaint;
private String task;
public TaskRectangleView(Context context, String task, int width, int height) {
super(context);
this.task = task;
int x = 10;
int y = 10;
mDrawable = new ShapeDrawable(new RectShape());
int color = DbSettingsManager.getInstance(context).getColorByName(task);
mDrawable.getPaint().setColor(color);
mDrawable.setBounds(x, y, x + width, y + height);
textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(Color.WHITE);
textPaint.setTextSize(10);
}
protected void onDraw(Canvas canvas) {
mDrawable.draw(canvas);
canvas.drawText(this.task, 10, 20, textPaint);
}
</code></pre>
<p>}</p>
<p>So this custom drawn rectangle should fit into column 1 of my TableView. For this (so I believe) I need to measure the width of the column at display-time. How to do this? Thanks!</p>
|
android
|
[4]
|
5,208,602 | 5,208,603 |
Console application becomes ghost and does not show on task manager processes tab
|
<p>My program uses MSSQL database and has been working fine. However, after making some changes including converting from VS2008 to VS2010, generating 32bit application. It starts having the following strange problem:
When I try to shutdown the console by clicking the system menu(X button), it does not shutdown, you can move the console around, you can also click on the left hand system menu such as properties, etc, but the program does not show up on the taskmanger's processes tab, therefore, there is no way to shut it down, but to restart box.</p>
<p>Also, while the program is in this ghost mode, I can actually start another instance. That means the ghost application already release most of the resources such as file handle, db etc.</p>
<p>The problem seems to occur after we have some issues with ms-sql server, such as time out exception. I simulate the situation by throwing an exception in the same db function call, but that does create the ghost situation. box is Windows Server Standard without Hyper-V, SP2, 32bit.</p>
|
c#
|
[0]
|
1,679,694 | 1,679,695 |
How do i close shut down my application from another Form?
|
<p>I have this event in a new Form:</p>
<pre><code>private void CrawlLocaly_FormClosed(object sender, FormClosedEventArgs e)
{
}
</code></pre>
<p>Im not sure if to use Closed or Closing.
The reason is that i want to check if the user shut down the program for example by just closing the application from the taskbar.</p>
<p>If he did close it from the taskbar mouse right click then close then i want it to close all the program and not only this Form.</p>
<p>How can i do it ?</p>
|
c#
|
[0]
|
3,392,917 | 3,392,918 |
API to export your voicemails in iphone
|
<p>I am currently limited to a certain amount of space for voicemails on my mobile phone. Once that space is full I can no longer have the ability to receive voicemails or have voicemails left for me. That is until I delete them or some of them. </p>
<p>So I would like to know is it possible to export your voicemails to some external device, if yes is there an API for doing this. </p>
<p>Thanks
Abhishek</p>
|
iphone
|
[8]
|
1,532,954 | 1,532,955 |
How to implement a paint-update loop?
|
<p>I want to create a paint and update loop in android for game animation on a canvas but I am having trouble as I can't seem to get the threading to work appropriately. It seems to crash almost immediately. Here is what I have tried:</p>
<pre><code> // Create the thread supplying it with the runnable object
Thread thread = new Thread(runnable);
// Start the thread in oncreate()
thread.start();
class runner implements Runnable {
// This method is called when the thread runs
long wait = 1000;
public void run() {
update();
}
public void update()
{
try{
Thread.currentThread();
//do what you want to do before sleeping
Thread.sleep(wait);//sleep for 1000 ms
//do what you want to do after sleeping
}
catch(InterruptedException ie){
//If this thread was interrupted by another thread
}
run();
}
}
</code></pre>
<p>Also when I drop the wait down lower it crashes faster.</p>
<p>Is there a more appropriate way to approach this?</p>
<p>Changed to this:</p>
<pre><code>class runner implements Runnable {
// This method is called when the thread runs
long wait = 10;
boolean blocked = false;
public void run() {
if(!blocked){
blocked = true;
paint();
}
}
public void paint()
{
update();
}
public void update()
{
try{
Thread.currentThread();
//do what you want to do before sleeping
Thread.sleep(wait);//sleep for 1000 ms
//do what you want to do after sleeping
}
catch(InterruptedException ie){
//If this thread was interrupted by another thread
}
paint();
}
</code></pre>
<p>}</p>
<p>This results in the same error... :/</p>
|
android
|
[4]
|
295,688 | 295,689 |
How can I Violate Encapsulation property?
|
<p>How can I Violate Encapsulation property without having a compile time error? (in C++)</p>
<p>just so curious..</p>
<p>This was actually a question asked by one of my professor.. Please don't misunderstand.
This was asked when we had a discussion over compiler error's</p>
|
c++
|
[6]
|
780,662 | 780,663 |
accessing dictionary with classes
|
<p>I am learning OOP with python.
I want to implement something like to display:
<code>firstName</code>, <code>lastName</code> of a person with address as dictionary like, <code>'state': someState, 'city': someCity</code></p>
<p>I've done:</p>
<pre><code>class data:
def __init__(self, firstName, lastName, **address):
self.firstName = firstName
self.lastName = lastName
self.address = {
"state": self.state,
"city" : self.city
}
</code></pre>
<p>When I did:</p>
<pre><code>>>> d = data("a", "b", 'state' : "stat", 'city' : "ci")
SyntaxError: invalid syntax
>>> d = data("a", "b", 'state'="stat", 'city'="ci")
SyntaxError: keyword can't be an expression
</code></pre>
<p>Is there mistake with my code or the syntax of accessing dictionary is mistake. I can not figure it out.</p>
|
python
|
[7]
|
4,905,668 | 4,905,669 |
What could cause ASP.NET's executionTimeout to not be enforced running under IIS?
|
<p>I'm trying to troubleshoot a problem, but I'm unable to reproduce it locally under IIS because no matter how low I set executionTimeout, the requests never time out.</p>
<p>I've tried setting this via the web.config (, via code (Page.Server.ScriptTimeout = 5;).</p>
<p>I'm running with binaries that were compiled in release mode, and debug=false is set in the compilation element.</p>
<p>FWIW, under Cassini (the standalone development webserver), everything works as expected, running out of the same directory off of the exact same assemblies/config files.</p>
<p>Any ideas on what could be causing this?</p>
<p>EDIT: If it's relevant, the development workstation in question is running Win7/IIS7.</p>
<p>EDIT 2: I'm using reflection to write out HttpContext.Current.Timeout, and in both Cassini and IIS, it's writing out the value I expect, so it seems that it's a matter of the limit being enforced as opposed to being set incorrectly.</p>
|
asp.net
|
[9]
|
5,787,429 | 5,787,430 |
How to insert 18,6 decimal number value into database field using java
|
<p>How to insert 18,6 decimal number value into database field using java?</p>
|
java
|
[1]
|
614,442 | 614,443 |
How do I find the source code for Java SE 6 update 10?
|
<p>At <a href="http://java.sun.com/javase/downloads/index.jsp" rel="nofollow">Java SE Downloads</a> I may for example download:</p>
<ul>
<li>Java SE Runtime Environment (JRE) 6 Update 10</li>
<li>Java SE Development Kit (JDK) 6 Update 10</li>
</ul>
<p>But I can't find any source code for update 10. If I click <a href="http://download.java.net/jdk6/6u3/promoted/b05/index.html" rel="nofollow">Java SE 6 JDK Source Code</a> on the Java SE Downloads page it seems I can only download source for "JDK 6u3 Source". Where can I find the source for update 10? If there isn't any and I use update 10 for development, won't there be serious sync problems if I choose to debug and "step into" the source of a JDK method? (It seems like it should.)</p>
|
java
|
[1]
|
3,960,447 | 3,960,448 |
List of keys and values, where the order is set based on order of insertion for both keys and values
|
<p>I basically want a list of lists.</p>
<p>They key will be a GUID, and the Value will be a list of Guids.</p>
<p>The order of inserting the Key, and when I insert the List of Guids in the value should keep the order of when I inserted them.</p>
<p>I want this to use generics.</p>
<p>How can I do this?</p>
<p>e.g.</p>
<pre><code>foreach(var guid in SomeList)
{
foreach(var subGuid in SomeList.Values)
}
</code></pre>
<p><strong>And again, order is important, based on how I inserted them (both key and list of values).</strong></p>
|
c#
|
[0]
|
2,675,978 | 2,675,979 |
How to scroll programatically a ScrollView?
|
<p>I have a little problem with a ScrollView.</p>
<p>I have a layout for an activity which is made with a ScrollView. This scrollview contains two ListViews.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
</code></pre>
<p>
</p>
<pre><code> <ListView android:id="@+id/accountsListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="none" />
<ListView android:id="@+id/cardsListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="none" />
</LinearLayout>
</code></pre>
<p>In onCreate method of my activity I compute ListViews height according there contents.</p>
<p>During execution, on activity launch, ScrollView is already scrolled a bit.</p>
<p>So I tried, at the end of onCreate to call method scrollTo(0, 0), but it does not change anything.</p>
<p>Any idea ?</p>
<p>Regards,
Quentin</p>
|
android
|
[4]
|
3,151,920 | 3,151,921 |
Select All Checkboxes By ID/Class
|
<p>I'm really bad at Javascript and I'm struggling to get my head round it.</p>
<p>What I'm trying to do is get something to select all checkboxes. However everything I have found tries to do it by name, I want to do it by ID or class. Select all by name is just inpractical isn't it?</p>
|
javascript
|
[3]
|
4,941,944 | 4,941,945 |
Why does zip() drop the values of my generator?
|
<p>I was writing an answer to <a href="http://stackoverflow.com/questions/11205037/detect-period-of-unknown-source">this question</a> when noticed that my simple implementation didn't produce correct results. While hunting down the bug, I noticed the following:</p>
<pre><code>In [1]: import itertools
In [2]: gen = itertools.cycle((0,1,2))
In [3]: zip(gen, range(3))
Out[3]: [(0, 0), (1, 1), (2, 2)]
In [4]: zip(gen, range(3))
Out[4]: [(1, 0), (2, 1), (0, 2)]
</code></pre>
<p>For whatever reason, <code>gen</code>'s <code>next()</code> method is called one additioinal time.
To illustrate this, I used the following:</p>
<pre><code>class loudCycle(itertools.cycle):
def next(self):
n = super(loudCycle, self).next()
print n
return n
In [6]: gen = loudCycle((0,1,2))
In [7]: zip(gen, range(3))
0
1
2
0
Out[7]: [(0, 0), (1, 1), (2, 2)]
</code></pre>
|
python
|
[7]
|
731,463 | 731,464 |
Size of Alert Dialog or Custom Alert Dialog
|
<p>I am creating my application for all tablets of 10.1 and now i am trying this on samsung galaxy tab.
I have done all the parts of that but alert dialog is too small regarding tablet size.
I have also created custom alert dialog but it does not look good.
<strong>So tell me can i change the size of default alert dialog if yes then how.</strong></p>
<p>OR</p>
<p><strong>how to create custom alert dialog that looks like default alert dialog.</strong></p>
<p>Thanks.</p>
|
android
|
[4]
|
5,561,953 | 5,561,954 |
Can't get value of preference in the same application, in BroadcastReceiver
|
<p>In my application, the package preferences, I have a class that records and retrieves preferences (<code>SharedPreferences</code>). In another package, have a class called <code>BootReceiver</code> that extends from <code>BroadcastReceiver</code>. </p>
<p>In this class, I have read the application's preferences during the boot ... Turns out, the Eclipse debugger disconnects during boot and I can not debug to see where the error and can not get the value of preference! even in <code>MODE_WORLD_READABLE</code></p>
|
android
|
[4]
|
3,417,135 | 3,417,136 |
why is my indexOf statement creating an error
|
<p>I am trying to use .indexOf to find out if an array contains a string. Something is causing an error, but I don't know what. I'm sure this is a <strong>really</strong> simple thing, but I don't know the language and so don't see it. What's wrong?</p>
<pre><code>//this code creates an error in IE
var myMines=new Array();
var newMine="22";
var myVar = myMines.indexOf(newMine); //when I comment out this line, the page does not generate an error
</code></pre>
|
javascript
|
[3]
|
5,138,337 | 5,138,338 |
need help with infinite scrolling
|
<p>i am trying to debug why when i use this <a href="http://www.infinite-scroll.com/infinite-scroll-jquery-plugin" rel="nofollow">infinite scrolling plugin</a>, nothing happens ... </p>
<pre><code>$(function() {
$(".posts").infinitescroll({
navSelector: "#pageNav",
nextSelector: ".next",
itemSelector: ".posts .post"
});
});
<div class="posts">
<div class="post">1. ...</div>
<div class="post">2. ...</div>
<div class="post">3. ...</div>
<div class="post">4. ...</div>
<div class="post">5. ...</div>
<div class="post">6. ...</div>
<div class="post">7. ...</div>
<div class="post">8. ...</div>
<div class="post">9. ...</div>
<div class="post">10 ...</div>
</div>
<ul id="pageNav" class="clearfix">
<li><a href="page1.html" class="active">1</a></li>
<li><a href="page2.html" class="next">2</a></li>
<li><a href="page3.html">3</a></li>
<li><a href="page4.html">4</a></li>
<li><a href="page5.html">5</a></li>
</ul>
</code></pre>
|
jquery
|
[5]
|
642,729 | 642,730 |
Dictionary - Object referenced not set to an instance of an object
|
<p>I'm trying to hold a lobby system inside of a dictionary.</p>
<pre><code>private Dictionary<string, Dictionary<string, string>> lobbys;
</code></pre>
<p>The first string being the Lobby ID, and the dictionary within the dictionary holding the clients usernames in the lobby.</p>
<p>When I try to create a new 'lobby' in the dictionary like so:</p>
<pre><code>lobbys.Add("dSd244SfasdD", null);
</code></pre>
<p>( the "dSd244SfasdD" being the unique lobby ID, and null being the null dictionary I've yet to create (since theres no users in it yet))</p>
<p>I get this error: "Object referenced not set to an instance of an object."</p>
<p>I'm unsure as to what I'm doing wrong, and I'm fairly new to C#. Please help. Thanks :)</p>
|
c#
|
[0]
|
1,582,693 | 1,582,694 |
'+' or parseInt() - which one is efficient to convert string to integer in javascript
|
<p>In JavaScript codes, I have seen people using '+' character to convert string to integer as in - </p>
<pre><code>var i = +"2";
</code></pre>
<p>another way is just using parseInt() method as following - </p>
<pre><code>var i = parseInt("2");
</code></pre>
<p>I want to know which one is efficient? </p>
<p>Sorry I should also add that, I am dealing with integers only and the data is huge so even a little difference in performance would be good for me.</p>
|
javascript
|
[3]
|
2,560,689 | 2,560,690 |
How to create custom search box
|
<p>I am doing search_bar in my android application, for that i created edit text and button. it will search data whatever we edited in edit text.But giving more attraction to my search_bar i have a idea to include android default search box to my application. i am not sure about the possibility of including default search bar to my application. I searched in google, but i cant get any proper guidance. if any of you guys having idea about this issue please guide me.. </p>
|
android
|
[4]
|
2,552,912 | 2,552,913 |
How to implement a simple prioritized listener pattern in JavaScript
|
<p>I have an event/listener manager that has this function:</p>
<pre><code> var addListener = function(event, listener) {
myListeners[event].push(listener); //assume this code works
}
</code></pre>
<p>But now I need to change it so that it looks like this:</p>
<pre><code> var addListener = function(event, listener, fireFirst) {
if(fireFirst) {
myListenersToFireFirst[event].push(listener);
} else {
myListenersToFireSecond[event].push(listener);
}
}
</code></pre>
<p>This is so that when the <code>fireEvent</code> function is called, it will fire the listeners in the <code>myListenersToFireFirst</code> array first, then the listeners in the second array.</p>
<p>So it will look something like this:</p>
<pre><code> var fireEvent = function(event) {
var firstListeners = myListenersToFireFirst[event];
//for each listener in firstListeners, call `apply` on it
var secondListeners = myListenersToFireSecond[event];
//for each listener in secondListeners, call `apply` on it
}
</code></pre>
<p>Is this the best way to accomplish this in JavaScript? Is there a more elegant way of achieving this priority list of listener-event firing?</p>
|
javascript
|
[3]
|
1,653,298 | 1,653,299 |
Mapping numbers to letters
|
<p>I had an interview question asking this:</p>
<blockquote>
<p>text file has following lines> </p>
<pre><code> 1: A C D
4: A B
5: D F
7: A E
9: B C
</code></pre>
<p>*Every line has a unique integer followed by a colon and one or
more letters. These letters are
delimited spaces (one or more)> </p>
<pre><code> #2 Write a short program in the language
</code></pre>
<p>of your choice that outputs a sorted
list like</p>
<pre><code> A: 1 4 7
B: 4 9
C: 1 9
D: 1 5
E: 7
F: 5
</code></pre>
</blockquote>
<p>I'm not looking for someone to solve it, but I always get confused with problems like this. I'd like to do it in C# and was wondering should I store each line in a 2d array? What is the best way to handle this. After storing it how do I relist each line with letters rather then numbers? </p>
<p>Just looking for pointers here.</p>
|
c#
|
[0]
|
833,748 | 833,749 |
problem attaching text files to email Intent object
|
<p>I have a requirement that I need to attach text files generated by my app to the email composer.</p>
<p>I have created my files at my applications private area (getFilesDirectory()).</p>
<p>I am attaching URI of that file path to the email Intent object. I am able to see the attachments in email composer but I am unable to receive the attachments.</p>
<p>I am using this statement attach the files to the intent object</p>
<pre><code>intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(context.getFilesDirectory()+"abc.txt"));
</code></pre>
<p>after doing some search in google I got to know "getFilesDirectory()" is only private to my application and other app's can't access my files (my case its E-mail).</p>
<p>As many of devices may not have SD-card ,I can't kept my files in SD-Card.</p>
<p>Please let me know where I can store my files so that I can attach my files to the email application.
thanks.</p>
|
android
|
[4]
|
4,408,188 | 4,408,189 |
help with ajax only working once
|
<p>Been trying to put this into a function to make live calls, but can't figure it out.</p>
<p>this works but only once:</p>
<pre><code><script>
$(document).ready(function(){
$(".addFavorite").click(function(){
var row = $(this);
$.ajax({
type: "POST",
url: "/app/Favs/jsoncreate?id=<%= @place.ven_id %>&name=<%= @place.name %>",
success: function(data){
$(row).replaceWith('<div id="' + data + '" class="vFav vBtn deleteFavorite"><img src="/public/images/icons/favorite-.png" alt="Favorite -"></div>');
}
});
});
$('.deleteFavorite').click(function(){
var id = $(this).attr('id');
var row = $(this);
$.ajax({
type: "POST",
url: "/app/Favs/jsondelete?id=" + id,
async: true,
data: id,
success: function(data){
if (data == "1"){
$(row).replaceWith('<div class="vFav vBtn addFavorite"><img src="/public/images/icons/favorite.png" alt="Favorite"></div>');
}
if (data == "0"){
alert("Delete Failed!")
}
},
error: function(response){
alert('Favorite Delete FAILED!');
}
});
});
});
</script>
</code></pre>
|
jquery
|
[5]
|
909,188 | 909,189 |
C++ Self Assessment - Online
|
<p>I am an experienced C++ programmer, but I see there are many gaps in my understanding. I would like to know what are my strong areas and the ones I am weak at. This will help me to choose the topics I want to further concentrate. Is anybody aware of any such service (paid or free) which is reliable available online?</p>
|
c++
|
[6]
|
2,620,040 | 2,620,041 |
PDO response to json
|
<p>Im new to PHP and trying to make a very simple api (good way too learn i think), why doesnt this work?
When loading this page the output is: <strong><em>{"queryString":"SELECT id, Name FROM Food WHERE userID=1 ORDER BY Name"}</em></strong> and not the JSON-string that I want</p>
<pre><code>$dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);
$response = $dbh->query("SELECT id, Name FROM Food WHERE userID=1 ORDER BY Name");
$responseJSON = json_encode($response);
header('Content-type: application/json');
echo "$responseJSON";
$dbh = null;
</code></pre>
<p>Nothing is wrong with the query because i get what i want when trying this:</p>
<pre><code>$dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);
$response = $dbh->query("SELECT id, Name FROM Food WHERE userID=1 ORDER BY Name");
foreach ($response as $row)
{
print $row['Name'] . ' ';
}
$dbh = null;
</code></pre>
<p>outputs:
<em>Bacon
Cheese
chips</em></p>
|
php
|
[2]
|
2,616,669 | 2,616,670 |
minSdkVersion breaking program
|
<p>So whenever I add </p>
<pre><code><uses-sdk android:minSdkVersion = "7"></uses-sdk>
</code></pre>
<p>my application refuses to work properly. The UI is miniature (the font is small and the buttons are smaller than usual). I tried changing the minversion from 7-15 and none of them worked. My phone is on 4.0.4 and whenever I take out </p>
<pre><code><uses-sdk android:minSdkVersion>
</code></pre>
<p>it works perfectly. Sadly google market requires this, and I can't upload the application not working. Any ideas? If I need to give more information just ask, thank you so much!</p>
<p>The application is mainly an XML app, such that there is no graphical interface, just native buttons, and such. I am using the <code>Theme.Holo.Light</code> theme though. Thank you!</p>
|
android
|
[4]
|
5,938,439 | 5,938,440 |
How to handle touch events in order?
|
<p>I want to make a program what in I need to handle touch events in order within 1 activity. For example: The user need to click on a picture first If he doesn't click on it I will show an another activity, but if he click on the requested picture I want him to click on the second, third etc. But I don't know how I can handle multiple touch events. I know that I need an on touch event method and in it I need an if -else statement for the first click but I don't know how I can monitor the second, third etc. Touch events.</p>
<p>Thanks for any helps!</p>
|
android
|
[4]
|
889,493 | 889,494 |
How to delete the last character from a TextBox?
|
<p>I'm trying to write a copy of MS Windows Calculator - just to exercise the knowledge I have acquired in the course I'm doing - and I'm having problems to write the <kbd>Backspace</kbd> key, but I have no idea about how to delete the last character on <code>TxtResult.Text</code> (Text Box). So, can some one teach me how to do that?</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ZigndSuperCalc
{
public partial class FrmZigndSC : Form
{
Int64 aux, result;
Int16 cont = 0;
bool sucess;
public FrmZigndSC()
{
InitializeComponent();
}
private void BtnSoma_Click(object sender, EventArgs e)
{
sucess = Int64.TryParse(TxtInput.Text, out aux);
result += aux;
TxtInput.Text = Convert.ToString(result);
TxtInput.Focus();
}
private void BtnCE_Click(object sender, EventArgs e)
{
TxtInput.Text = "0";
}
private void BtnC_Click(object sender, EventArgs e)
{
result = 0;
TxtInput.Text = "0";
}
private void BtnBackspace_Click(object sender, EventArgs e)
{
// write here a method to delete the last character from
}
}
}
</code></pre>
|
c#
|
[0]
|
5,914,871 | 5,914,872 |
How to display current date and time as toast message in Android
|
<p>How to display current date and time as toast message</p>
|
android
|
[4]
|
3,856,587 | 3,856,588 |
Upgrading to PHP 5.3 - solutions for legacy sites
|
<p>I am about to upgrade a couple of servers from PHP 5.1.6 to PHP 5.3.x, however, we host a number of old websites that would be time-consuming to fix in application code.</p>
<p>As I see it there are 2 solutions: </p>
<ul>
<li>stick the old sites on a separate, compatible server</li>
<li>make minimal (backwards-incompatible) fixes and turn off error reporting</li>
<li>fix all backwards-incompatible and deprecated features in application code</li>
</ul>
<p>The latter 2 options are not preferable given this would be very time-consuming -- bear in mind that there are no unit tests and such. The former will be at additional expense given we'd have to pay for and manage an additional box.</p>
<p>Are there any other options you might suggest trying, or <strong>what in your experience has been the best solution to managing legacy sites?</strong></p>
<p>Cheers </p>
|
php
|
[2]
|
5,590,984 | 5,590,985 |
Is the following function ok to validate an email?
|
<p>Just tested this function to validate an email..However,it does not validate the presence or absence of the dot in the email..Why this is happening and how can I fix this?</p>
<pre><code><script type="text/javascript">
function isEmail(textbox){
var reg4 =/^(\w+)@(\w+).(\w+)$/;
if(reg4.test(textbox.value)){
return true;
}
return false;
}
</script>
</code></pre>
|
javascript
|
[3]
|
2,709,542 | 2,709,543 |
Handling orientation changes yourself
|
<p>From the documentation regarding the <code>android:configChanges='orientation'</code> attribute of the activity tag in the manifest:</p>
<blockquote>
<p>Note: Using this attribute should be avoided and used only as a last-resort. Please read Handling Runtime Changes for more information about how to properly handle a restart due to a configuration change.</p>
</blockquote>
<p>Why does it say this? </p>
<p>In the case of threads and networking requests via a service API library, a request could be made with a reference to the original Activity, and then an orientation change could occur, leaving the thread pointing to the old Activity.</p>
<p>While this can be fixed, it's tedious and ugly compared to just handling the configuration changes yourself.</p>
<p>Why should it be avoided?</p>
<p>Edit: I guess I should also ask: would this be an acceptable reason for doing the orientation configuration changes yourself?</p>
|
android
|
[4]
|
2,783,229 | 2,783,230 |
I want to load second view with given frame size
|
<p><img src="http://i.stack.imgur.com/1QQ9t.png" alt="enter image description here"></p>
<p>I try to load Second view in MainView with define frame size but don't need to see component of second view. I set size till it weel be appear.</p>
<pre><code>-(IBAction)displayNewView:(id)sender {
[mrView setFrame:CGRectMake(0,150,320,50)];
[self.view addSubview:mrView];
}
</code></pre>
<p><img src="http://i.stack.imgur.com/kLDaB.png" alt="enter image description here"></p>
<p>i dont want to see second button.</p>
|
iphone
|
[8]
|
4,906,714 | 4,906,715 |
Whats the use of sealed class?
|
<p>Is it possible to declare the stored proc name as sealed class?\</p>
<pre><code>public sealed class DataSQLConstants
{
#region "Storedproc Names"
public const string SCREENPRIVILIGES_BYROLE = "dbo.RoleScreenPriviliges";
public const string GETCLIENTROLEBY_USERID = "dbo.GetClientRoleScrnbyUserId";
public const string GETUSERBY_USERNAME = "dbo.GetUserByUserName";
public const string GETUSERPWDBY_USERNAME = "dbo.AuthenticateUser";
public const string SAVEFILESETDETAILS = "dbo.SaveFileSetDetails";
public const string SAVESOURCEFILEDETAILS = "dbo.SaveSourceFileDetails";
#endregion
}
</code></pre>
|
asp.net
|
[9]
|
5,360,414 | 5,360,415 |
Facebook Error after xcode upgrade
|
<p>I have been using xcode 4.1 till yesterday and my facebook integration using FBConnect was also working fine . But when i update my xcode to xcode 4.2 , i am getting error on facebook after successful login like "This endpoint has been deprecated. To temporarily reenable it, you may disable the "august_2012" platform migration.</p>
<p>need to fix this issue. </p>
<p>Plz help</p>
<p>Thanks</p>
|
iphone
|
[8]
|
5,029,830 | 5,029,831 |
Intialization of static variables in a class of utility functions
|
<p>For my Android application, I have written a class which is composed of utility functions which are needed at various activites in the application.In this class, I need a context variable(for working with files) and an instance of preference manager and preference editor.Also, a long integer represnting the current date as a timestamp is needed:</p>
<pre><code>private static long today;
private static Context myContext;
private static SharedPreferences sharedPrefs;
private static Editor editor;
</code></pre>
<p>Which is correct way to initialize these variables. I have tried doing it via a private constructor as shown below, but I am getting errrors.</p>
<pre><code>private NetworkController()
{
//Getting the Unix timestamp for today
GregorianCalendar aDate = new GregorianCalendar();
GregorianCalendar tDate = new
GregorianCalendar(aDate.get(Calendar.YEAR),aDate.get(Calendar.MONTH),
aDate.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
today = (tDate.getTimeInMillis())/1000;
//The preferences manager for reading in the preferences
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(myContext);
//The preferences editor for modifying the preferences values
editor = sharedPrefs.edit();
}
</code></pre>
<p>One approach would be to create an instance of this class in every activity where its used but I don,t want to do that.Any other approach is possible?</p>
|
android
|
[4]
|
4,355,487 | 4,355,488 |
Best reverse compatible approach to nullifying value in hidden field using JQuery
|
<p>I would like to know the best reverse compatible approach to nullifying the value property in a hidden field using JQuery.</p>
<p>Thanks!</p>
<p>Note:</p>
<pre><code>$('#MyHiddenField').val('');
</code></pre>
<p>is not good enough.</p>
<p>I need a good old fasioned null.</p>
|
jquery
|
[5]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.