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 |
|---|---|---|---|---|---|
5,757,038 | 5,757,039 | Android Market - Number of Installs | <p>What if somebody installs one app and from the market and then removes it and then installs it again, then will the number of installs still increase?</p>
| android | [4] |
4,216,910 | 4,216,911 | JavaScript syntax | <p>I keep finding some JavaScript that looks like the example below. Can someone explain this as I have not seen JavaScript written like this before.</p>
<p>What is "SomethingHere" and the colon represent? I'm used to seeing function myFunction() but not what is shown below.</p>
<pre><code> SomethingHere: function () {
There is code here that I understand.
}
</code></pre>
| javascript | [3] |
5,311,492 | 5,311,493 | Removing URL Extensions | <p>Looking to remove .php from my URL's</p>
<p>For example;</p>
<p><a href="http://www.websitesbylewis.co.uk/about.php" rel="nofollow">http://www.websitesbylewis.co.uk/about.php</a></p>
<p>to</p>
<p><a href="http://www.websitesbylewis.co.uk/about" rel="nofollow">http://www.websitesbylewis.co.uk/about</a></p>
<p>Thanks again.</p>
| php | [2] |
3,167,362 | 3,167,363 | class forward declaration fails | <p>I have 2 header files and a source file,</p>
<p>food.h:</p>
<pre><code>#ifndef _FOOD_H
#define _FOOD_H
struct food {
char name[10];
};
#endif
</code></pre>
<p>dog.h:</p>
<pre><code>#ifndef _DOG_H
#define _DOG_H
class food; //forward declaration
class Dog {
public:
Dog(food f);
private:
food _f;
};
#endif
</code></pre>
<p>And here is the source file of <code>class dog</code>,</p>
<pre><code>//dog.cpp
#include "dog.h"
#include "food.h"
Dog::Dog(food f) : _f(f)
{}
</code></pre>
<p>The problem is I can compile the above code, I got an error saying <code>_f has incomplete type</code>.</p>
<p>I thought I can put a forward declaration in <code>dog.h</code> and include <code>food.h</code> in <code>dog.cpp</code>, but it doesn't work, why? And I shouldn't put user defined header file in <code>.h</code> files, right? It's deprecated, isn't it?</p>
| c++ | [6] |
2,910,949 | 2,910,950 | Datagridview information load very slow with multiple records | <p>I have a DataGridView where I show some information on the Web, everything works fine when I have few records but the problem is when the DataGridView tries to load more than 300 records or so, because the page takes a long time loading information.</p>
<p>The question is there a way to optimize such queries with a Datagridview?</p>
| asp.net | [9] |
1,326,478 | 1,326,479 | How to use ajax Nobot control in Asp.net mvc | <p>I have no idea how to use Ajax Nobot control in Asp.net MVC.Please help me.</p>
<p>Regards,
Tejveer</p>
| asp.net | [9] |
2,101,977 | 2,101,978 | Know when network connectivity returns | <p>I have an application that tries to be a good samaritan, basically when any services starts that needs to interact with the network. I am checking to see if the device has connectivity:</p>
<p><strong>hasConnectivity Method</strong></p>
<pre><code>private boolean hasConnectivity() {
NetworkInfo info = mConnectivity.getActiveNetworkInfo();
boolean connected = false;
int netType = -1;
int netSubtype = -1;
if (info == null) {
Log.w(sTag, "network info is null");
notifyUser(MyIntent.ACTION_VIEW_ALL, "There is no network connectivity.", false);
} else if (!mConnectivity.getBackgroundDataSetting()) {
Log.w(sTag, "background data setting is not enabled");
notifyUser(MyIntent.ACTION_VIEW_ALL, "background data setting is disabled", false);
} else {
netType = info.getType();
netSubtype = info.getSubtype();
if (netType == ConnectivityManager.TYPE_WIFI) {
connected = info.isConnected();
} else if (netType == ConnectivityManager.TYPE_MOBILE
&& netSubtype == TelephonyManager.NETWORK_TYPE_UMTS
&& !mTelephonyManager.isNetworkRoaming()
) {
connected = info.isConnected();
} else if (info.isRoaming()) {
notifyUser(MyIntent.ACTION_VIEW_ALL, "Currently Roaming skipping check.", false);
} else if (info.isAvailable()) {
connected = info.isConnected();
} else {
notifyUser(MyIntent.ACTION_VIEW_ALL, "..There is no network connectivity.", false);
}
}
return connected;
}
</code></pre>
<p>When this method returns false I know that I don't have a connection because the user is on the phone or 3g and wifi is not available</p>
<p>What is the best way to know when Connectivity is available with out pulling the network stats with a timer periodically?</p>
<p>Is there an Intent action that I can observe with a broadcast receiver that will announce a change with connectivity?</p>
<p>Thanks for any help, I will keep searching the docs for some clue on what to do next.</p>
| android | [4] |
698,182 | 698,183 | Change input values from select list. | <p>I have two text input boxes that will need to be populated from the same selection list but each text box may have different values. What happens is that the code I have written allows you to click and change on value but when you try to do change the second value it changes both values rather than just the second value. I have looked at bind, text with no luck. </p>
<p>Input Boxes:
<code><input type="text" id="lensStyle" size="35" class="orderinput" tabindex="12"/>
<input type="text" id="lensStyleLeft" size="35" class="orderinput" tabindex="12"/></code></p>
<p>grabs the values in from:</p>
<pre><code><select class="longbox" size="14" id="lensStyleBox"></select>
</code></pre>
<p>using this Jquery</p>
<pre><code> $("#lensStyle").focus(function(){
$("#lensStyleBox").click(function(){
$("#lensStyle").val($("#lensStyleBox").val());
});
});
$("#lensStyleLeft").focus(function(){
$("#lensStyleBox").click(function(){
$("#lensStyleLeft").val($("#lensStyleBox").val());
});
});
</code></pre>
| jquery | [5] |
4,154,296 | 4,154,297 | TabHost , TabSpec - onclick implementation | <p>i am working with TabHost , TabSpec .i want to do some actions(like onClick) when TabSpec is clicked. has anyone tried this i am able to go to another activity with "home.setIndicator("Home")...." is it possible</p>
| android | [4] |
2,748,071 | 2,748,072 | javascript storing global variables in DOM | <p>I have a fairly large script that contains about 60 global variables. I'm thinking about using the namespace pattern to encapsulate my script and have only one global variable that references one object.</p>
<p>Even though this pattern is considered best practice, I'm also thinking about an alternative: storing the global variables inside the DOM, in hidden divs, and accessing them with <code>$('#MyGlobalVar1').text()</code>. Is this a good idea or not?</p>
<p>Thanks for your suggestions.</p>
| javascript | [3] |
2,527,068 | 2,527,069 | error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' | <p>Getting this error and I'm pretty sure it's in the operator<< function. Both prints are public.</p>
<pre><code>void CRational::print() const
{
print(cout);
}
void CRational::print(ostream & sout) const
{
if(m_denominator == 1)
cout << m_numerator;
else
cout << m_numerator << "/" << m_denominator;
}
ostream operator<<(ostream & sout,const CRational a)
{
a.print();
return sout;
}
CRational operator++() // prefix ++x
{
m_numerator += m_denominator;
return *this;
}
in main:
cout << "e before: " << e << ", \"cout << ++e\" : " << ++e << " after: " << e << endl;
</code></pre>
| c++ | [6] |
698,597 | 698,598 | Easily scale android application for smaller screen sizes | <p>Right now I have an application I built that is built for android 10.1 inch screens (tablet) and I would like to to be able to be scaled so that it work on the kindle fire (7 inch screen). What would the easiest way to do this be?</p>
<p>Edit:
So I've taken the advise that the majority of the people in this tread have given and replaced all of the absolute layouts with relative layouts and I am using margins left,right,top,bottom, to place them, but still the button images are too large and they are misplaced, how can i do this so it works correctly?</p>
| android | [4] |
1,898,028 | 1,898,029 | How to check package class method in android through cmd? | <p>How to check package class method in android through cmd</p>
<p>just like this type </p>
<pre><code>C:\herong>javap java.lang.String | find "byte"
public java.lang.String(byte[], int, int, int);
public java.lang.String(byte[], int);
public java.lang.String(byte[], int, int, java.lang.String)
throws java.io.UnsupportedEncodingException;
public java.lang.String(byte[], java.lang.String)
throws java.io.UnsupportedEncodingException;
public java.lang.String(byte[], int, int);
public java.lang.String(byte[]);
public void getBytes(int, int, byte[], int);
public byte[] getBytes(java.lang.String)
throws java.io.UnsupportedEncodingException;
public byte[] getBytes();
</code></pre>
| android | [4] |
4,665,134 | 4,665,135 | Android Inject event to browser | <p>I have developed an application in Android (Android1), which performs user action to my app installed on another Android over the LAN (Android2). The scope of action is completely inside my webview application. Now from my application installed on Android2 I open a browser , I want to know is there any event that I can fire to close the browser, so that it takes the user back to my application.</p>
<p>Any pointers is appreciated. </p>
| android | [4] |
1,776,408 | 1,776,409 | Directory.CreateDirectory strange behaviour | <p>I have a windows service which runs a separate thread with a function which may do</p>
<pre><code>if (!Directory.Exists(TempUpdateDir))
{
DirectoryInfo di = Directory.CreateDirectory(TempUpdateDir);
di.Refresh();
EventLog.WriteEntry("Downloader", string.Format("DEBUG: Trying to create temp dir:{0}. Exists?{1},{2}",TempUpdateDir, Directory.Exists(TempUpdateDir), di.Exists));
}
</code></pre>
<p>which does not throw exceptions, Directory.Exists says true (inside if block) and yet there is no such directory on the disk, when you look with explorer. I've seen directory created a couple of times, but most of the time directory isn't created, no exceptions thrown either.</p>
<p>(This service runs under Local System)
Later on this service starts program using Process class and exits. That program is also suppose to work with files, copy them to created directory, but it doesn't do it either.</p>
<p>Code has problems on Windows 2003 server.</p>
<p>What the....?????????????</p>
| c# | [0] |
1,653,061 | 1,653,062 | How to split a string based on every third character regardless of what the character is in c# | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/105770/net-string-format-to-add-commas-in-thousands-place-for-a-number">.NET String.Format() to add commas in thousands place for a number</a> </p>
</blockquote>
<p>I am trying to add commas to a number for the presentation layer and need to cast and then split the number on every third character in order to join on a ','. </p>
<p>So if i have a string like this </p>
<pre><code>546546555
</code></pre>
<p>desired output:</p>
<pre><code>546,546,555
</code></pre>
<p>Other times, the number could be longer or shorter:</p>
<pre><code>254654
</code></pre>
<p>desired output:</p>
<pre><code>254,654
</code></pre>
<p>Is it possible to split in this manner then join with a comma?</p>
<p>tahnks!</p>
<p>EDIT:</p>
<p>Hi Everyone,</p>
<p>Thanks very much for your help.</p>
<p>To add to this post I also found a way to do this in SQL:</p>
<p>SUBSTRING(CONVERT(varchar, CAST(NumItems AS money), 1), 0, LEN(CONVERT(varchar, CAST(NumDocs AS money), 1)) - 2) as [NumDocs]</p>
| c# | [0] |
1,964,975 | 1,964,976 | Problem with input in c++ | <p>I have a very basic question i want to take integer input in certain range from user. if the user gives some string or char instead of integer. then my program goes to infinite loop.</p>
<p>my code is some what like that</p>
<pre><code>cin >> intInput;
while(intInput > 4 || intInput < 1 ){
cout << "WrongInput "<< endl;
cin >> intInput;
}
</code></pre>
<p>I am only allowed to use c++ libraries not the c libraries.</p>
| c++ | [6] |
5,236,144 | 5,236,145 | doc file created in iPhone documents encoding issue | <p>I'm trying to write a MSword file in document directory by the following code:</p>
<pre><code>NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString* path;
NSString* gradeDoc = [self fetchCommentsDesc];
NSString* str = [self.objStudent.strName stringByAppendingFormat:@".doc"];
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:str];
[gradeDoc writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
[self fetchCommentsDesc] returns NSString.
self.student.strName is a String
</code></pre>
<p>Issue:
When i Open the doc file created in document directory of iphone, all the special characters in the doc appears as boxes or some arabic chars.</p>
<p>Please help!</p>
| iphone | [8] |
2,922,998 | 2,922,999 | Create array with all unique combinations | <p>Can't figure out how to create an array with all matches. I suppose I need a recursive function for this. </p>
<p>I like to get all values from the JSON below and create an array with all value combinations.
There may be more or less models (Name4) and more or less values.
Any help?</p>
<pre><code>var models = [
{
name: 'Name1',
values: [
'Title1Value1',
'Title1Value2',
'Title1Value3'
]
},
{
name: 'Name2',
values: [
'Title2Value1',
'Title2Value2'
]
},
{
name: 'Name3',
values: [
'Title3Value1',
'Title3Value2'
]
}
];
// Output array
var matches = [
[ 'Title1Value1', 'Title2Value1', 'Title3Value1' ],
[ 'Title1Value1', 'Title2Value1', 'Title3Value2' ],
[ 'Title1Value1', 'Title2Value2', 'Title3Value1' ],
[ 'Title1Value1', 'Title2Value2', 'Title3Value2' ],
[ 'Title2Value2', 'Title2Value1', 'Title3Value1' ],
[ 'Title1Value2', 'Title2Value1', 'Title3Value2' ],
[ 'Title1Value2', 'Title2Value2', 'Title3Value1' ],
[ 'Title1Value2', 'Title2Value2', 'Title3Value2' ],
[ 'Title1Value3', 'Title2Value1', 'Title3Value1' ],
[ 'Title1Value3', 'Title2Value1', 'Title3Value2' ],
[ 'Title1Value3', 'Title2Value2', 'Title3Value1' ],
[ 'Title1Value3', 'Title2Value2', 'Title3Value2' ]
];
</code></pre>
| javascript | [3] |
4,567,511 | 4,567,512 | Why is this code generating extra commas? | <p>I am using javascript </p>
<pre><code>function chkout_pp(i) {
var myarray = new Array();
var li = 1;
myarray[0] = ""
for(j = 1; j < 13; j++)
{
if ($('#chkpp'+j).is(':checked') == true) {
myarray[li] = $('#chkpp'+j).val()+"<br>";
li++;
}
}
$("#ownerarray").val(myarray);
$("#edmt_pp").html(myarray+"");
}
</code></pre>
<p>This code is generating commas. I want to remove the commas. Is there anyone that can answer my question?</p>
| javascript | [3] |
1,916,233 | 1,916,234 | how to assigning values for child window? | <pre><code>var selwindow = window.open('child1.html','_blank','resizable=yes,width='+(screen.width-500)+',height='+(screen.height-500)+'');
selwindow.document.selectform.childText.value=document.getElementById('pdetails1').value;
</code></pre>
<p>I am using this code to assign a value for textbox in the child window. It works well in Internet Explorer, but it shows an error when run in Firefox. It shows: <code>selwindow.document.selectform is undefined</code>.</p>
<p>Here, <code>childText</code> is the current window textbox id, and <code>pdetails1</code> is the child window text box id</p>
| javascript | [3] |
3,302,020 | 3,302,021 | How to format number to a currency format using String.localeFormat() using jquery? | <p>Number <code>56675.456</code></p>
<p>I want to format this number with Format : <code>{0:$###.##}</code></p>
<p>using <code>String.localeFormat()</code> in JQuery</p>
<p>Expected Result: <code>$56675.46</code></p>
| jquery | [5] |
3,802,806 | 3,802,807 | How to change the value of the Button using jquery | <pre><code><input type="button" id="badd" value="Add"/>
</code></pre>
<p>I have one more button on the page called Edit when I click on Edit button I need to Change the Add Button value to SAVE...using jquery..</p>
<p>thanks</p>
| jquery | [5] |
102,782 | 102,783 | declaring more than 10 objects | <p>as we know we can declare an array like this </p>
<pre><code>for (int i=0;i<array.length;i++)
{ d[i]=new array();}
</code></pre>
<p>What about an object I want to declare more than 10 objects and I think it's not efficient to
write a declare statements for 10 times !!like this </p>
<pre><code>car c1 = new car();
car c2= new Car();
</code></pre>
<p>..etc</p>
<p>what can I do ?</p>
| javascript | [3] |
1,082,229 | 1,082,230 | my live() method goes crazy | <p>first some code:</p>
<p>I have many elements like that:</p>
<pre><code><section class="item>
<div class="caption">
</div>
</section>
</code></pre>
<p>the "caption" is hidden, when you go on the "item" the "caption" came in.</p>
<p>I did this before with hover() and worked fine, but now I need to have it live(), because I'm adding some more "item"s with an ajax() call.</p>
<p>What's happening now is that when "caption" is showed, it takes precedence over item, because it is styled as absolute. Here some other code:</p>
<pre><code>.caption {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 5;
display: none;
}
</code></pre>
<p>I like this style because sometimes my "item" can have any size, and "caption" just follows it. But let's go on.</p>
<p>Symptoms: when I mouse-enter on my "item" the caption shows, then instantly goes away, then goes in, then goes out. Like mad. I know why, I suppose it's because my "caption" even if lives into "item" takes precedence, so "item" is no more in mouse-enter event. So "caption" leaves, and "item" fires another mouse-enter. And so on, until the end of time.</p>
<p>Here is my javascript, how can I say to live() to behave like it did before with hover()?</p>
<pre><code>$('.item').live({
mouseenter : function() {
$(this)
.find('.caption')
.animate({
opacity: 1,
height: 'toggle'
}, 'fast');
},
mouseout : function() {
$(this)
.find('.caption')
.animate({
opacity: 0,
height: 'toggle'
}, 'fast');
}
})
</code></pre>
<p>thank you!</p>
| jquery | [5] |
3,433,879 | 3,433,880 | Creditcard payment in android using creditcard interface | <p>I want to make a credit card payment in android.</p>
<p>I used credit card interface from this link:</p>
<p><a href="http://www.innerfence.com/apps/credit-card-terminal/developer-api" rel="nofollow">http://www.innerfence.com/apps/credit-card-terminal/developer-api</a></p>
<p>But when I try to run, clicking charge button, makes it ask me to install <code>CCTerminal</code> & move to playstore & says as <code>This isn't available in your country</code></p>
<p>Can't I download it or is there any other option?</p>
<p><strong>Editor's Note:</strong> English is not his first langauge</p>
| android | [4] |
3,142,317 | 3,142,318 | jquery 2 plugins breaking each other... which, and why? | <p>I am new to jQuery and am using 2 plugins together.</p>
<p><a href="http://www.drewgreenwell.com/projects/metrojs" rel="nofollow">http://www.drewgreenwell.com/projects/metrojs</a>
^ For a flip effect when the page loads and mouseover flip effect.</p>
<p>And rcarousel, which I can't post a link to because I'm new.</p>
<p>Basically, the effect is this:</p>
<ul>
<li>Page loads, all of the tiles should flip/animate.</li>
<li>Any mouseover should cause the tile to flip again (currently for testing purpose, they all flip at the same time, twice, then stop, and then flip on mouesover).</li>
<li>Carousel will be sitting in a header and requires user interaction to scroll through the rest of the tiles.</li>
</ul>
<p>They work fine together when the page first loads ... but once you press Left or Right arrow on the carousel, the animation no longer functions, neither if I change the repeat back to infinite nor on mouseover.</p>
<p><a href="http://www.elevation24.com/newtiles" rel="nofollow">http://www.elevation24.com/newtiles</a></p>
<p>Thanks for any assistance, please be gentle :) I realize everything is likely quite convoluted and messy... I have no idea what I am doing and am amazed I have gotten this far :D</p>
| jquery | [5] |
2,665,759 | 2,665,760 | How to c# function using javascript | <p>I have input HTML button(Not ASP.NET Button) click event in c#</p>
<p>Is there any way i can call c# function using javascript</p>
<p>Thank you very much....</p>
| javascript | [3] |
3,967,356 | 3,967,357 | How to add a select all button to a custom Listview | <p>I have a custom listView in my app I would like to implement my select all button I have created.</p>
<p>My ListView looks like.</p>
<p>[(Image)(Text)(CheckBox)]</p>
<p>I have looked at some similar questions, the most common answer was with the user of the <code>notifyDataSetChanged ()</code> method, iv'e tried researching and implementing without any luck, I was wondering can you think of a way round it or give me an example of how I can implement the method</p>
| android | [4] |
2,523,745 | 2,523,746 | How to Call an activity method from a BroadcastReceiver? | <p>I am currently developing an app, I need to call an activity method from BroadcastReceiver.</p>
<p>My app is to when the user getting a call Broadcast receiver find that and send a message to that particular number. </p>
<p>I am able to get that no, but I want to send a message to that number, for this sending sms I created an activity in side sending sms method is there..</p>
<p>How do I call that particular method from my BroadcastReceiver.</p>
| android | [4] |
5,796,636 | 5,796,637 | PHP $_POST array for unchecked checkboxes | <p>If I have a form with two checkboxes that have have the same array as name attribute </p>
<blockquote>
<p>name="1_1[]"</p>
</blockquote>
<p>and neither of those checkboxes is ticked, is there any way I can know they were present in the form? These fields are not being sent through the $_POST array if they are unchecked.</p>
<p>I'm asking this cause these name values are being generated dynamically, I don't always know what they are and I have to validate them (make sure at least one of the two is checked).</p>
<p>Do I have to start using hidden fields to send the name attribute values through, or is there a better way?</p>
| php | [2] |
3,157,300 | 3,157,301 | PHP code with alternating row color | <p>Hello Im new in programing. I want to create a table using the alternate row color. But dont know how to do it. Here is my code. Please help me!</p>
<pre><code>while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td>' . $row['a.ServiceID'] . '</td>';
echo '<td>' . $row['a.Title'] . '</td>';
echo '<td>' . $row['a.Description'] . '</td>';
echo '<td>' . $row['a.Notes'] . '</td>';
echo '<td>' . $row['a.SubmitBy'] . '</td>';
echo '<td>' . $row['a.AssignedEmp'] . '</td>';
echo '<td>' . $row['c.GroupName'] . '</td>';
echo '<td>' . $row['d.NameCategory'] . '</td>';
echo '<td>' . $row['e.TipoStatus'] . '</td>';
echo '<td>' . $row['f.TiposUrgencia'] . '</td>';
echo '<td>' . $row['g.CustomerName'] . '</td>';
echo '<td>' . $row['a.DayCreation'] . '</td>';
echo '<td>' . $row['a.ModifyBy'] . '</td>';
echo '<td>' . $row['a.ModifyTime'] . '</td>';
echo '</tr>';
}
mysqli_free_result($result);
echo '</table>';
</code></pre>
| php | [2] |
5,961,957 | 5,961,958 | Why does this compile | <p>I have trouble understanding what the following code <em>means</em> (and partly, why it even compiles).</p>
<p>We have the following snippet:</p>
<pre><code>if (true) return;
{
... // Unreachable code detected
}
</code></pre>
<p>Why does this even compile? </p>
<p><strong>Am I correct in thinking that the compiler <em>assumes an <code>else</code> in this construct</em>?</strong> If not, how does it work?</p>
<p>I think it must be logically equivalent to </p>
<pre><code>if (true)
return;
else
{
...; // Unreachable code detected.
}
</code></pre>
<p>I'm in doubt, because the compiler doesn't seem to interpret the following as an if-else</p>
<pre><code>if (condition)
{
...
}
{
...
}
</code></pre>
<p>It does compile, but the second block gets executed no matter what.</p>
<p>Is this behavior explicitly stated in the C# specs?</p>
| c# | [0] |
860,973 | 860,974 | How to add subitems in a ListView | <p>I'm trying to add subItems in my ListView.
My listView should be organized with emails for items and their institution for the subitems, but with the following code I just added items, how can I add my subitems on it? I've tried so many things but it doesn't work.</p>
<pre><code> List<Login> listEmails = JsonUtil.getAllEmails(json);
ArrayList<String> emails = new ArrayList<String>();
ArrayList<String> institutions = new ArrayList<String>();
for (Login loginObj : listEmails) {
emails.add(loginObj.getEmailAndress());
}
for (Login loginObj : listEmails) {
institutions.add(loginObj.getInstitution());
}
ArrayAdapter<String> adapter;
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, emails);
emailListView.setAdapter(adapter);
</code></pre>
| android | [4] |
886,680 | 886,681 | Assigning NSArray Issues on Simulator Versus Device | <pre><code> NSArray *favoriteSharers=[NSArray arrayWithObjects:@"SHKMail", @"SHKTWitter", @"SHKFacebook", nil];
</code></pre>
<p>On Simulator, I step through the code and favoriteSharers array contains three strings of SHKMail, SHKTWitter, and SHKFAcebook.</p>
<p>However, on device, after I step through this line code, the favoriteSharers contains 3 items but all junk, undefined strings.. How odd. </p>
<p>How odd! How can on device this would happen?? it wouldn't assign the 3 literal strings to the NSArray?</p>
| iphone | [8] |
3,529,173 | 3,529,174 | How do I set the defaults (Language & Keyboard) for an Android AVD (SDK 2.1 & 2.2) | <p>I recently upgraded to Android SDK 2.1 and 2.2 but the AVD always displays with Chinese and Japanese characters active. I can go to Settings to uncheck these options but it's becoming a pain. How can I set the Language & Keyboard defaults to avoid this hassle?</p>
<p>Thanks ...</p>
| android | [4] |
5,302,326 | 5,302,327 | How to detect if an attribute contains a certain value in jQuery? | <p>I have elements with various values for an attribute (ids="32, 56, 21"). How can I get the elements that contain 21?</p>
| jquery | [5] |
2,133,067 | 2,133,068 | Count for datetime object | <p>I'm trying to iterate over DateTime properties on objects in a List collection... </p>
<p>Ex. a tree view that lists the a Name with all its Courses underneath works fine:</p>
<pre><code> // Sorting on name with the courses beneath it:
// *list* is a List<ClsStandholder>;
private void ShowNameWithCourses()
{
treeViewList.Nodes.Clear();
for (int i=0; i < list.Count; i++) {
treeViewList.Nodes.Add(list[i].name);
for (int j=0; j < list[i].courses.Count; j++) {
treeViewList.Nodes[i].Nodes.Add(list[i].courses[j]);
}
treeviewList.ExpandAll();
}
}
</code></pre>
<p>That works perfect... where I am having trouble is trying to sort on date and iterate through a count of the dates.</p>
<pre><code>for (int j=0; j < list[i].SubscriptionDate. // how do i put some sort of count for this?
</code></pre>
<p>There seems to be no property to loop over all the dates entered.</p>
| c# | [0] |
5,455,740 | 5,455,741 | Pass arguments to console.log as first class arguments via proxy function | <p><code>console.log</code> takes an unspecified number of arguments and dumps their content in a single line.</p>
<p>Is there a way I can write a function that passes arguments passed to it directly to <code>console.log</code> to maintain that behaviour? For example:</p>
<pre><code>function log(){
if(console){
/* code here */
}
}
</code></pre>
<p>This would not be the same as:</p>
<pre><code>function log(){
if(console){
console.log(arguments);
}
}
</code></pre>
<p>Since <code>arguments</code> is an array and <code>console.log</code> will dump the contents of that array. Nor will it be the same as:</p>
<pre><code>function log(){
if(console){
for(i=0;i<arguments.length;console.log(arguments[i]),i++);
}
}
</code></pre>
<p>Since that will print everything in different lines. The point is to maintain <code>console.log</code>'s behaviour, but through a proxy function <code>log</code>.</p>
<p>+---</p>
<p>I was looking for a solution I could apply to all functions in the future (create a proxy for a function keeping the handling of arguments intact). If that can't be done however, I'll accept a <code>console.log</code> specific answer.</p>
| javascript | [3] |
1,198,003 | 1,198,004 | get username from Webservice | <p>How can i get the username from the webservice my Webservice is configured under Enterprise sign on authentication.</p>
<p>I am using the below code for webapplication Re<code>quest.ServerVariables("HTTP_CT_REMOTE_USER")</code>
and i need a equavelent for webservices</p>
<pre><code>Context.Request.ServerVariables["HTTP_CT_REMOTE_USER"]
</code></pre>
<p>returns null for me</p>
| c# | [0] |
3,506,676 | 3,506,677 | Why does jQuery use the prototype property for plugins? | <p>One assigns a plugin to the jQuery prototype property. What's the point of doing this when one doesn't use 'new' with jQuery? There's only ever one instance of jQuery isn't there? So couldn't plugins be assigned directly to the singleton jQuery object?</p>
| jquery | [5] |
3,688,938 | 3,688,939 | Fixed - Adding parameter to link, then redirect results in amp; in $_GET | <p>// Edit
FIXED: I fixed it by moving the code to the HTML head, removing it from the Smart html template file. Seems smarty messed it up in some way. Thx for your help :]
// Edit</p>
<p>How do I correctly add a parameter to a link with jquery? I've now read various threads here about that, but I can't get it to work right. </p>
<p>In detail, if the user clicks a certain link on click I want to get the value of an input, afterwards add it to the clicked link and redirect the user with the new url with the added parameter.</p>
<p>Everything works just fine, but when I dump the $_GET with Php on the target URL I always end up with amp;parameter_name instead of parameter_name. What I do:</p>
<pre><code>$('#add-item-wishlist').bind('click', function(e) {
// get quantity from input
var current_qty = $('.inp-qty').val();
//redirect user
e.preventDefault();
window.location.href = $(this).attr("href") + '&qty=' + current_qty;
});
</code></pre>
<p>&qty always results in amp;qty if I dump with php, so does the check inside the php script fail.</p>
<p>// edit
may I mention that i use this snippet in en enviroment with Smarty Template Engine?</p>
| jquery | [5] |
5,577,144 | 5,577,145 | Show or hide content based on the date with jQuery? | <p>I want to have some content on my page (some images) change based on the date. With jQuery, how would this be possible?</p>
<p>Basically, I am leaving on vacation and my client needs something to change while I'm unavailable.</p>
<p>I've been able to do it with ColdFusion for another client, but I don't know how to do it with jQuery. Any help is GREATLY appreciated.</p>
| jquery | [5] |
2,534,986 | 2,534,987 | Android AlarmManager effect immediately, why? | <p>I'm learning to use AlarmManager in Android. I was looking for example in google and I found <a href="http://stackoverflow.com/questions/4459058/alarm-manager-example">stackoverflow.com</a>
I have a class </p>
<pre><code>public class Alarm extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TESTTEST");
wl.acquire();
// Put here YOUR code.
Toast.makeText(context, "Alarm !!!!!!!!!!", Toast.LENGTH_LONG).show(); // For example
wl.release();
}
public void SetAlarm(Context context)
{
AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, Alarm.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
am.set(AlarmManager.RTC, 1000 * 10 , pi); // Millisec * Second * Minute
}
public void CancelAlarm(Context context)
{
Intent intent = new Intent(context, Alarm.class);
PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(sender);
}
}
</code></pre>
<p>And my activity</p>
<pre><code>protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
alarm = new Alarm();
alarm.SetAlarm(getApplicationContext());
}
</code></pre>
<p>I get this exapmle code from other post on stackoverflow.com
Why Toask ALARM!!! shows immediately ???</p>
| android | [4] |
1,024,110 | 1,024,111 | Database documentation | <p>Can anyone suggest me the format of how to make and analyse database documentation.</p>
| asp.net | [9] |
4,870,318 | 4,870,319 | Upload image and mp3 in same form, but mp3 did not get uploaded | <p>i'm trying upload image and mp3 in the same form but image is uploaded and mp3 is not.
this is my form</p>
<pre><code> <form action="upload.php"
enctype="multipart/form-data" method="post">
<p>
Please select image<br>
<input type="file" name="image" size="40">
</p>
<p>
Please select audio<br>
<input type="file" name="audio" size="40">
</p>
</code></pre>
<p>and this is my upload.php</p>
<pre><code>// checking image
if (($_FILES["image"]["type"] == "image/gif")
or ($_FILES["image"]["type"] == "image/jpeg")
or ($_FILES["image"]["type"] == "image/pjpeg")
or ($_FILES["image"]["type"] == "image/png"))
{
if ($_FILES["image"]["error"] == 0)
{
move_uploaded_file($_FILES["image"]["tmp_name"],
"upload/".$_FILES["image"]["name"]);
}
else
{
echo "image upload failed";
}
}
else
{
echo "file is not supported image";
}
// checking mp3
if (substr($_FILES["audio"]["name"],-3) == "mp3")
{
if ($_FILES["audio"]["error"] == 0)
{
move_uploaded_file($_FILES["audio"]["tmp_name"],
"upload/".$_FILES["audio"]["name"]);
}
else
{
echo "audio upload failed";
}
}
else
{
echo "file is not supported audio";
}
</code></pre>
<p>now, image get's uploaded and moved to ./upload but on mp3 it echoes "audio upload failed".
Don't get it</p>
| php | [2] |
481,145 | 481,146 | Learning Java the "right way": any book that goes over DI, loosely coupling, writing testable code? | <p>I'm comfing from the .net world, and want a book that goes over the 'right' way of coding.</p>
<p>Things like dependancy injection, loosely coupling of objects, how to layout your web application properly, unit-testing etc.</p>
| java | [1] |
5,232,081 | 5,232,082 | How to call a python function from an another file | <p>I have this class in my parser.py file</p>
<pre><code>class HostInfo(object):
def __init__(self, host_id):
self.osclass = []
self.osmatch = []
self.osfingerprint = []
self.portused = []
self.ports = []
self.extraports = []
self.tcpsequence = {}
self.hostnames = []
self.tcptssequence = {}
self.ipidsequence = {}
self.trace = {'port': '', 'proto': '', 'hop': []}
self.status = {}
self.address = []
self.hostscript = []
# Umit extension
self.id = host_id
self.comment = ''
# XXX this structure it not being used yet.
self.nmap_host = {
'status': {'state': '', 'reason': ''},
'smurf': {'responses': ''},
'times': {'to': '', 'srtt': '', 'rttvar': ''},
'hostscript': [],
'distance': {'value': ''},
'trace': {'port': '', 'proto': '', 'hop': []},
'address': [],
'hostnames': [],
'ports': [],
'uptime': {'seconds': '', 'lastboot': ''},
'tcpsequence': {'index': '', 'values': '', 'class': ''},
'tcptssequence': {'values': '', 'class': ''},
'ipidsequence': {'values': '', 'class': ''},
'os': {}
}
</code></pre>
<p>after that it defined a function which trying to find an host id from a xml file </p>
<pre><code>def get_id(self):
try:
return self._id
except AttributeError:
raise Exception("Id is not set yet.")
def set_id(self, host_id):
try:
self._id = int(host_id)
except (TypeError, ValueError):
raise Exception("Invalid id! It must represent an integer, "
"received %r" % host_id)
</code></pre>
<p>Now i want to use call this <code>get_id</code> function from an another file.I tried so many time but it shows an error i.e. module can't be import</p>
| python | [7] |
3,143,387 | 3,143,388 | Getting error in starting Emulator | <p>When I run my application, I am getting an error. The error is:</p>
<blockquote>
<p>invalid command-line parameter:
sw\android-sdk-windows\tools/emulator-arm.exe. Hint: use '@foo' to
launch a virtual device named 'foo'. Please use -help for more
information</p>
</blockquote>
<p>What can I do to fix this?</p>
| android | [4] |
48,695 | 48,696 | Python split list at zeros | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/13633901/remove-leading-and-trailing-zeros-from-multidimensional-list-in-python">Remove leading and trailing zeros from multidimensional list in Python</a> </p>
</blockquote>
<p>if I have a list such as:</p>
<pre><code>my_list = [[1,2,0,1], [1,0,0,1]]
</code></pre>
<p>I want to split this at the zeros and throw them away, so that I end up with something like:</p>
<pre><code>my_list = [[[1, 2], [1]], [[1],[1]]]
</code></pre>
<p>Any help much appreciated.</p>
| python | [7] |
3,877,739 | 3,877,740 | Change div text if Select contains option with specific text | <p>I have a CMS that multiple people administer. We enable/disable some of our shipping methods depending on the time of year. I want to setup our checkout page to display a different message in our pickup info TD if someone enables the "Text Reserv. Pick-up" shipping option, but leave it as the default if not.</p>
<p>I've found plenty of examples to change a div or something else if an option is selected, but I just want to see if an option is in the list and then change the content of a TD based on that. I've tried modified of those examples to see if it will work for my situation, but haven't got it to work.</p>
<p>I already have the code to change the TD, but can't figure out how to check to see if the select contains a certain option first. Here's the code I have to change the text and input button of the TD:</p>
<pre><code>// Change description from "To pick up at the bookstore" on Step 2 of checkout to Reserve Your Textbooks
$('td[id$=PickupAtStoreColumn] div.multipleship').each(function() { $(this).html($(this).html().replace("To pick up at the bookstore","Reserve Your Textbooks")); });
// Change "Pick Up At Store" button text on Step 2 of checkout to Reservation Pickup
$('td[id$=PickupAtStoreColumn] input[id$=btnPickupAtStore]').attr('value','Reservation Pick-up');
</code></pre>
<p>How can I check to see if select[id$=drpShipType] has "Text Reserv. Pick-up" enabled as an option first? Thanks!</p>
| jquery | [5] |
5,614,054 | 5,614,055 | Does jQuery or a jQuery plugin have a function that does what this function does? | <p>I would like to know if jQuery or a jQuery plugin has a function that does what the following function does:</p>
<pre><code>function $array(a /* an ARRAY */, f /* a function */) {
var $res = $();
for (var i = 0; i < a.length; ++i)
/* Notice: The result of evaluating f(a[i])
* shall always be a jQuery selector
*/
$res.add(f(a[i]));
return $res;
}
</code></pre>
<p>I find this function very useful, but I don't want to reimplement it if it already exists.</p>
<hr>
<p><strong>EDIT 1:</strong></p>
<p>I admit the question was not particularly clear. I want to be able to do something like:</p>
<pre><code>$('<select>')
.append($array([
{ value: 0, name: 'Item 0' },
{ value: 1, name: 'Item 1' },
{ value: 2, name: 'Item 2' }
], function(option) {
return $('<option>')
.val(option.value)
.html(option.name);
}))
.appendTo('body');
</code></pre>
| jquery | [5] |
1,906,083 | 1,906,084 | Python won't print after smtplib.SMTP | <p>I was trying to write a python sendmail class, I like to print sent mail info, but after smtplib.SMTP it won't print anything, even an error, here is my code: </p>
<p>main.py:</p>
<pre><code>import MailServer
from Mailler import Mailler
mail_server = MailServer.Server()
mailler = Mailler( mail_server )
mailler.sender = 'test@gmail.com'
mailler.receiver = 'test@ymail.com'
mailler.subject = 'test'
mailler.send_text( 'test' )
</code></pre>
<p>Mailler.py:</p>
<pre><code>import email
import smtplib
class Mailler():
sender = ''
receiver = ''
def __init__( self, target_server ):
self.target_server = target_server
print 'host:' + target_server.host + ' port:' + str( target_server.port )
self.server = smtplib.SMTP( target_server.host, target_server.port )
self.server.set_debuglevel( 1 )
print 'test 2'
def __enter__( self ):
return self
def send_text( self, subject, message ):
mail = email.mime.text.MIMEText( message )
mail[ 'Subject' ] = subject
mail[ 'From' ] = self.sender
mail[ 'To' ] = self.receiver
self.server.sendmail( self.sender, [self.receiver], mail.as_string )
print 'Mail sent:' + subject + ' sender:' + self.sender + ' receiver:' + self.receiver
def __exit__( self, type, value, traceback ):
self.server.quit()
</code></pre>
<p>the output:</p>
<pre><code>host:127.0.0.1 port:22223
</code></pre>
| python | [7] |
4,605,465 | 4,605,466 | When did C# get explicit interface implementation? | <p>When did C# get explicit interface implementation? Was this in version 1 or was it added later?</p>
| c# | [0] |
11,039 | 11,040 | How to avoid .prev().prev().prev() OR how to look up an item with a class before the current one | <p>I looked up the whole jQuery Docs, but i doesn't found anything:
Is it possible to search an element before the current one with a specific class?
I thought this will work, but it doesn't:</p>
<pre><code>$(this).prev('.bar');
</code></pre>
<p><a href="http://jsfiddle.net/Ejh5G/" rel="nofollow">http://jsfiddle.net/Ejh5G/</a></p>
| jquery | [5] |
2,419,487 | 2,419,488 | I am looking for an example of DataColumnsWithJoins usage? | <p>I am looking for an example of <a href="http://d.android.com/reference/android/provider/ContactsContract.DataColumnsWithJoins.html" rel="nofollow">DataColumnsWithJoins</a> usage? Do you know any?</p>
| android | [4] |
2,600,756 | 2,600,757 | jQuery Slide Panel on Mouseover | <p>How can I make this sliding panel example to slide down on mouseover and slide back in on mouseout instead of using the click function?</p>
<p>See the example here: <a href="http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html" rel="nofollow">http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html</a></p>
<pre><code>$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active"); return false;
});
</code></pre>
| jquery | [5] |
2,913,787 | 2,913,788 | error in using BtnSubmit.Attributes("onclick") in asp.net | <p>can anybody tell me what is problem in</p>
<p>BtnSubmit.Attributes("onclick") = string.Format("document.getElementById(\'{0}\').value= document.getElementById(\'{1}\').value;", this.HiddenField1.ClientID, this.FileUpload1.ClientID);</p>
<p>it is giving me error 'Non invocable memberusing System.Web.UI.WebControls.Attributes cannot be used like method.'</p>
| asp.net | [9] |
5,655,426 | 5,655,427 | Readonly toolbar item - valid or invalid - iPhone Human Interface Guideline? | <p>The toolbar of our iPhone app contains an icon to indicate online/offline status. Since the icon is just an indication of online/offline status, it is readonly or say 'not-clickable'.</p>
<p>My question is - Does an item in toolbar has to perform some action or can it be readonly icon ? </p>
<p>Will it create any problem in future while submitting app to appstore ?</p>
<p>Thanks in advance,
--Prem</p>
| iphone | [8] |
4,743,369 | 4,743,370 | override $(element) expression to achieve the same functionality as $(element).length | <p>Is it possible what I have mentioned in the title?</p>
<p>I would like to use this for checking existence of an element like so:</p>
<pre><code>if($('#item')){...}
</code></pre>
<p>Any ideas?</p>
<p>That's the code where I use it:</p>
<pre><code>if($('#auto_redirect_in_3_s').length)//I "wished" $('#auto_redirect_in_3_s')
{
var timer = setTimeout("document.location.href = index_url;",3000);
}
</code></pre>
<p>description:
If I put in php code it means that the page have to redirect in 3 s.</p>
| jquery | [5] |
57,555 | 57,556 | Javascript function making the Iframe display in the whole browser after an action in iframe | <p>I display an IFrame in a div in a webpage.Inside the IFrame I have a hyperlink. On click of this link, a JS function will be invoked and all the check boxes present in that page will be unchecked.</p>
<p>The thing is when I click the Link named 'Clear All', all the check boxes are getting cleared but the DIV containing the IFrame is spreading over the entire page or simply put the whole webpage is showinf only the iframe.</p>
<p>The JS function is as follows</p>
<p>function clearAll() {</p>
<pre><code>try{
var secNamesTable = document.getElementById('securityNamesTable');
var docTypesTable = document.getElementById('docTypesTable');
var rowCount = secNamesTable.rows.length;
for ( var i = 0; i < rowCount; i++) {
var row = secNamesTable.rows[i];
var checkBox = row.cells[0].childNodes[0];
checkBox.checked=false;
}
rowCount = docTypesTable.rows.length;
for ( var i = 0; i < rowCount; i++) {
var row = docTypesTable.rows[i];
var checkBox = row.cells[0].childNodes[0];
checkBox.checked=false;
}
var object = (document.getElementById('peLibraryTreeDiv')==null)?parent.document.getElementById('peLibraryTreeDiv'):document.getElementById('peLibraryTreeDiv');
try{
var messageDiv = (document.getElementById('messageDiv')==null)?parent.document.getElementById('messageDiv'):document.getElementById('messageDiv');
messageDiv.innerHTML='Please select from the choices on the left';
}
catch(e){
object.innerHTML='<p style="color:206A7F; text-Align:center; position:relative; top:50px;" id="messageDiv">Please select from the choices on the left.</p>';
}
}
catch(e)
{
alert('error occured-'+e.message);
}
return false;
</code></pre>
<p>} </p>
<p>Please help me out of this.</p>
<p>Thanks,
kartheek</p>
| javascript | [3] |
1,467,999 | 1,468,000 | Problem in getting the expected output by starting an activity from another activity | <p>I have developed a simple application in which i have called an activity from another activity using Intent.It works fine.. but what is the problem is, When i made changes in the called activity it doesn't reflected in the output. I don't know how to solve this problem... please help me....</p>
| android | [4] |
208,907 | 208,908 | jquery - $.map - returning element not appending properly | <p>using $.map function i am looping a object and appending the element i make. but my case, i am getting the console info properly, but finally returning object only appending, what is the issue in my code?</p>
<p>my code :</p>
<pre><code> $('body').append(
$.map(val.fields, function (val, i) {
var element;
if (val.label) {
element = $('<label />', {
text: val.label
});
console.log(element); //properly consoles 3 lables but not appending why?
}
if (val.type) {
element = val.type === 'text' || val.type === 'submit' ? $('<input />', {
type: val.type,
name: val.name,
value: val.value,
id: val.vlaue
}) : val.type === 'select' ? $('<select />', {
name: val.name
}) : '';
console.log(element); // properly console 3 element and only this is appending
}
return element;
}))
</code></pre>
| jquery | [5] |
4,505,633 | 4,505,634 | File.separator vs Slash in Paths | <p>What is the difference between using <code>File.separator</code> and a normal <code>/</code> in a Java Path-String?</p>
<p>In contrast to double backslash <code>\\</code> platform independence seems not to be the reason, since both versions work under Windows and Unix (please correct me if I am wrong here).</p>
<pre><code>public class SlashTest {
@Test
public void slash() throws Exception {
File file = new File("src/trials/SlashTest.java");
assertThat(file.exists(), is(true));
}
@Test
public void separator() throws Exception {
File file = new File("src" + File.separator + "trials" + File.separator + "SlashTest.java");
assertThat(file.exists(), is(true));
}
}
</code></pre>
<p>To rephrase the question, if <code>/</code> works on Unix and Windows, why should one ever use want to use <code>File.separator</code>.</p>
<p>Thank you.</p>
| java | [1] |
5,358,621 | 5,358,622 | Converting from list of tuples to list of lists of tuples | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python">How do you split a list into evenly sized chunks in Python?</a> </p>
</blockquote>
<p>I have list of tuples, each tuple has two items (the amount of tuples may vary).</p>
<pre><code>[(a, b), (c, d)...)]
</code></pre>
<p>I want to convert the list to a nested list of tuples so that each nested list contains 4 tuples, if the original list of tuples has quantity not divisible by 4 e.g. 13 then the final list should contain the leftover amount in the case of 13, 1 tuple.</p>
<pre><code>[[(a, b), (c, d), (e, f), (g, h)], [(a, b), (c, d), (e, f), (g, h)]...]
</code></pre>
<p>One of the things about python I love is the methods and constructs for converting between different data structures, I was hoping there might be such a method or construct for this problem that would be more pythonic then what Iv come up with.</p>
<pre><code> image_thumb_pairs = [(a, b), (c, d), (e, f), (g, h), (i, j)]
row = []
rows = []
for i, image in enumerate(image_thumb_pairs):
row.append(image)
if(i+1) % 4 == 0:
rows.append(row)
row = []
if row:
rows.append(row)
</code></pre>
| python | [7] |
4,066,724 | 4,066,725 | print the first sentence of each paragraph in Java | <p>I have a text file and wish to print the <strong><em>first</em></strong> sentence of each paragraph. Paragraphs are separated by a line break, i.e. "\n".</p>
<p>From the BreakIterator, I thought I could use the getLineInstance() for this but it seems it is iterator over each word:</p>
<pre><code>public String[] extractFirstSentences() {
BreakIterator boundary = BreakIterator.getLineInstance(Locale.US);
boundary.setText(getText());
List<String> sentences = new ArrayList<String>();
int start = boundary.first();
int end = boundary.next();
while (end != BreakIterator.DONE) {
String sentence = getText().substring(start, end).trim();
if (!sentence.isEmpty()) {
sentences.add(sentence);
}
start = end;
end = boundary.next();
}
return sentences.toArray(new String[sentences.size()]);
</code></pre>
<p>Am I using getLineInstance() incorrectly or is there another method to do what I want?</p>
| java | [1] |
1,403,069 | 1,403,070 | Setting the path of an image view | <p>I have an ImageView in my android application, and I have a picture on my desktop.
I would like to relate this imageView to the path of the desktop image, so that when I run my application the image is shown . Can any one help me with the code? Thanks !</p>
| android | [4] |
4,880,183 | 4,880,184 | Validate zip and display error with onBlur event | <p>Check if zip is 5 digit number, if not then display 'zip is invalid'. I want to use onBlur event to trigger the display. But it's not working. </p>
<pre><code><script>
$(function(){
function valid_zip()
{
var pat=/^[0-9]{5}$/;
if ( !pat.test( $('#zip').val() ) )
{$('#zip').after('<p>zip is invalid</p>');}
}
})
</script>
zip (US only) <input type="text" name='zip' id='zip' maxlength="5" onblur="valid_zip()">
</code></pre>
| jquery | [5] |
4,878,613 | 4,878,614 | Refresh Activity using onResume() | <p>I have a Flashlight Activity. Normally it works fine but When I go to any other activity, it stop working!</p>
<p>So I want to refresh the code when I back to the Flashlight Activity.</p>
<p>I think refreshing using <code>onResume()</code> would help me best, But how to do it?</p>
<pre><code>public class FlashLightActivity extends Activity {
//flag to detect flash is on or off
private boolean isLighOn = false;
private Camera camera;
private Button next1, next2;
@Override
protected void onStop() {
super.onStop();
if (camera != null) {
camera.release();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
next1 = (Button) findViewById(R.id.ebtn28_answer);
next1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), FullScreen.class);
startActivityForResult(myIntent, 0);
}
});
next2 = (Button) findViewById(R.id.buttonFlashlight);
Context context = this;
PackageManager pm = context.getPackageManager();
// if device support camera?
if (!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
Log.e("err", "Device has no camera!");
return;
}
camera = Camera.open();
final Parameters p = camera.getParameters();
next2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if (isLighOn) {
Log.i("info", "torch is turn off!");
p.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(p);
camera.stopPreview();
isLighOn = false;
} else {
Log.i("info", "torch is turn on!");
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(p);
camera.startPreview();
isLighOn = true;
}
}
});
}
}
</code></pre>
| android | [4] |
5,957,453 | 5,957,454 | not giving sum of the row | <p>I am getting undefined as the resulting sum of the row.</p>
<pre><code>var myArray = new Array(3);
for (var i = 0; i < 3; i++) {
myArray[i] = new Array(3);
for (var j = 0; j < 3; j++) {
myArray[i][j]=prompt("element"," ");
}
}
for(i=0;i<4;i++)
{
sum=0;
for(j=0;j<4;j++)
{
document.write(myArray[i][j]);
sum+=myArray[i][j];
}
document.write("sum of"+ i+ "row"+sum);
}
</code></pre>
| javascript | [3] |
836,748 | 836,749 | Weird javascript output | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/850341/workarounds-for-javascript-parseint-octal-bug">Workarounds for JavaScript parseInt octal bug</a> </p>
</blockquote>
<p>I was learning the parseInt() function of javascript and was just trying out, and out of nowhere</p>
<pre><code>parseInt('08') returns 0
</code></pre>
<p>moreover,</p>
<pre><code>parseInt('07') returns 7 //which is correct
</code></pre>
<p>but again</p>
<pre><code>parseInt('09') returns 0 // really, are you kidding me.?
</code></pre>
<p>Either I am crazy or I am missing something?</p>
| javascript | [3] |
1,606,112 | 1,606,113 | Multiple widgets: Launching configuration activity on widget click | <p>following scenario:
I have 3 of the same widgets on my home screen. If one gets clicked, the widget configuration activity gets launched. </p>
<p>This was implemented by following code:</p>
<pre><code>Intent intent = new Intent(context, WidgetConfigurator.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent pendIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteView.setOnClickPendingIntent(R.id.widget_linearlayout, pendIntent);
</code></pre>
<p>The launching is working, but there is one problem:<br>
1. Widget A gets clicked, configuration activity of Widget A is opened<br>
2. User hits "back" key, configuration activity disappears<br>
3. Widget B gets clicked, configuration activity of Widget B is opened<br>
4. User hits "back" key<br>
=> Now the configuration activity of Widget A is shown<br></p>
<p>I always only want the "actual" configuration activity (fitting to the widget that was clicked) to be shown. Which settings do i have to use for the Intent / PendingIntent?</p>
<p>thx for any help</p>
| android | [4] |
3,548,154 | 3,548,155 | Does ASP.net use MVP pattern through code-behind code? | <p>I read somewhere on the internet that ASP.net automatically implements MVP pattern with its code-behind page technique. Can anybody tell me why it is considered as implementing MVP pattern when I cannot see any Presenter class?</p>
| asp.net | [9] |
5,294,049 | 5,294,050 | How can I erase a printed output line? | <p>What code would I have to add, replacing the comment, to print 1 & 3 only?</p>
<pre><code>main()
{
cout<<" 1 "<<endl;
cout<<" 2 "<<endl;
/* Code here to remove above " 2" line on output screen */
cout<<" 3 "<<endl;
}
expected output:
1
3
</code></pre>
<p>If you know the answer, please let me know.</p>
| c++ | [6] |
1,606,772 | 1,606,773 | Why is the listdir() function part of os module and not os.path? | <p><code>os.path</code> module seems to be the default module for all path related functions. Yet, the <code>listdir()</code> function is part of the <code>os</code> module and not <code>os.path</code> module, even though it accepts a path as its input. Why has this design decision been made ?</p>
| python | [7] |
5,127,717 | 5,127,718 | Python path help | <p>how can i run my program using test files on my desktop without typing in the specific pathname. I just want to be able to type the file name and continue on with my program. Since i want to be able to send it to a friend and not needing for him to change the path rather just read the exact same file that he has on his desktop.</p>
| python | [7] |
5,841,938 | 5,841,939 | Write values while runnig program | <p>i want to write some data to a .txt file.</p>
<pre><code> public void writeToFile(String filename) {
try {
//Construct the BufferedWriter object
bufferedWriter = new BufferedWriter(new FileWriter(filename));
//Start writing to the output stream
bufferedWriter.write("first value : " + firstValue);
bufferedWriter.newLine();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
//Close the BufferedWriter
try {
if (bufferedWriter != null) {
bufferedWriter.flush();
bufferedWriter.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
</code></pre>
<p>i use this code, buth the problem is, that it overwrites the first line constantly (i think).
Does anyone have a idea how i can fix this?
i read everey 50ms a value from the serial port, and wan't to write this. (every value on a separate line)</p>
<p>it should write the values until i close the progam.</p>
<p>best regards</p>
| java | [1] |
5,304,199 | 5,304,200 | Speed up web UI development in Java by redeploying only UI code? | <p>I'm really pissed when I'm developing UI and have to redeploy the whole application to see my changes which can take up to a minute. Most of the time when starting up is spent in starting up the service and dao layer(=hibernate). I already have the application divided into multiple modules and the UI code is one separate module. All of the modules are packaged inside war and deployed on Tomcat. The software uses Spring for IOC. The code in the UI layer uses Spring MVC and more recently Vaadin. Maven is used to build the projet.</p>
<p>Is there any tips to speed things up when changing code in the UI layer? Like is there a way to redeploy only one jar? I've read about OSGI and EJB that could help with this? Would you recommend using one of those or is there other solutions? I've no problems using a real application server like glassfish or jboss. The end result doesn't have to be a war-file either.</p>
<p>EDIT: I'm trying to get rid of JSP so replacing JSP files on server is not enough anymore. Vaadin is plain Java code. Even in Spring MVC the controllers are Java code.</p>
| java | [1] |
4,474,120 | 4,474,121 | Initializing final variables in Java | <p>I have a class with lots of final members which can be instantiated using one of two constructors. The constructors share some code, which is stored in a third constructor.</p>
<pre><code>// SubTypeOne and SubTypeTwo both extend SuperType
public class MyClass {
private final SomeType one;
private final SuperType two;
private MyClass(SomeType commonArg) {
one = commonArg;
}
public MyClass(SomeType commonArg, int intIn) {
this(commonArg);
two = new SubTypeOne(intIn);
}
public MyClass(SomeType commonArg, String stringIn) {
this(commonArg);
two = new SubTypeTwo(stringIn);
}
</code></pre>
<p>The problem is that this code doesn't compile: <code>Variable 'two' might not have been initialized.</code> Someone could possibly call the first constructor from inside MyClass, and then the new object would have no "two" field set.</p>
<p>So what is the preferred way to share code between constructors in this case? Normally I would use a helper method, but the shared code has to be able to set final variables, which can only be done from a constructor.</p>
| java | [1] |
4,763,274 | 4,763,275 | How to rollback actions through javaScript? | <p>I am having a JSP page where the user will be displayed with a table consisting rows.
If the user wishes, he may add a new row and press the save button, which will insert the data into the table, which is done through JavaScript.</p>
<p>My request is that, user adds a new row and enters the details in that. If he clicks the reset button, it clears the data entered inside the new row but not removes the entire giving the original data which was displayed when user started.</p>
<p>Please help me.</p>
| javascript | [3] |
2,827,068 | 2,827,069 | pass starting variables to php | <p>i am trying to have it so that when a page opens, it shows the current month and year in a div named display. there are 3 links, previous...reset...next. One click I want to reload the content in the display div with the appropriate data...being next month...last month..etc.</p>
<p>I have the reset link working but I cannot figure out how to pass the month and year variables so the script knows where to go next. I also need it so that you can continually press the next or previous links to continue counting down or up. I know i need to add logic for months 1 and 12 to affect the years...but i need to figure out this part first as the year changes would be easy enough for me.
heres a link to the code on a page
<a href="http://www.intarsiaplans.com/thepage.php" rel="nofollow">http://www.intarsiaplans.com/thepage.php</a></p>
| jquery | [5] |
2,896,046 | 2,896,047 | Force default reevaluation on function call | <p>AFAIK, Python evaluates the defaults of a function only once, at declaration time. So calling the following function <code>printRandom</code></p>
<pre><code>import random
def printRandom(randomNumber = random.randint(0, 10)):
print randomNumber
</code></pre>
<p>will print the <em>same</em> number each time called without arguments. Is there a way to force reevaluation of the default <code>randomNumber</code> at each function call without doing it manually? Below is what I mean by "manually":</p>
<pre><code>import random
def printRandom(randomNumber):
if not randomNumber:
randomNumber = random.randint(0, 10)
print randomNumber
</code></pre>
| python | [7] |
3,298,524 | 3,298,525 | move up/down in jquery | <p>I Have 5 spans i am trying to move them up/down (swap positions) in jquery</p>
<pre><code><a href="#" id="up">Up!</a>
<a href="#" id="down">Down!</a>
<span id='1'>Test1</span><br>
<span id='2'>Test2</span><br>
<span id='3'>Test3</span><br>
<span id='4'>Test4</span><br>
<span id='5'>Test5</span>
</code></pre>
<p>i have tryed but nothing is happening.</p>
<pre><code> $("#"+LinkID).insertBefore($("#"+LinkID).next('span'));
</code></pre>
| jquery | [5] |
1,173,222 | 1,173,223 | How to create menu item & subitem using jquery in asp.net? | <p>How to create menu item & subitem using jquery in asp.net?</p>
| asp.net | [9] |
5,166,282 | 5,166,283 | Form content changes identifier using jquery? | <p>Is there is any jquery plugin or utility which identify
the changes happen in form / document. ?</p>
<p>i.e. Preious content and after contents</p>
<p>Please help</p>
| jquery | [5] |
3,188,343 | 3,188,344 | Which one is best scenario to parse data from server (net) in android | <p>In my app i have to parse data from server.I have seen in some sites,some of examples using <code>AsyncTask</code>, some of examples using some callback methods,some of examples using threads and handlers.</p>
<p>which one is best to parse data from server.</p>
| android | [4] |
4,331,761 | 4,331,762 | find specific index position in string in php? | <p>can someone help me finding the position of the in string?</p>
<pre><code>$data="e0ab71ab9ed24e627a24e7d65367936393cb3b39db9a9e84d65cd7a9254a4665";
</code></pre>
<p>here data contain length 64.</p>
<p>just I need if string index position is 30 break the line and print next line remaining numbers.</p>
| php | [2] |
444,872 | 444,873 | jQuery - Can I combine object reference with other selectors? | <p>Occasionally I pass an 'object' to jQuery rather than an id or other selectors. For example</p>
<pre><code><input type="text" onclick="doit(this)" />
<script type="text/javascript">
function doit(e) {
var a = $(e).val();
}
</code></pre>
<p>It is useful when ids are not convenient such as long lists of elements or dynamically created input fields. I actually have seen any examples of passing the object. I just tried it and it works.</p>
<p>My question is: can I combine object selector with other selectors such as I would with ids. so instead of:</p>
<pre><code>$("#myDiv .myClass").something()
</code></pre>
<p>I wouldn't know how to code it - something like this maybe:</p>
<pre><code>$(e + " .myclass").something
</code></pre>
<p>thanks</p>
| jquery | [5] |
4,360,946 | 4,360,947 | How to get screen DPI | <p>I'm trying to get the screen's dpi but so far it isn't working. I tried:</p>
<pre><code> DisplayMetrics dm = new DisplayMetrics();
mainContext.getWindowManager().getDefaultDisplay().getMetrics(dm);
SCREEN_DPI = dm.densityDpi;
</code></pre>
<p>But both on Samsung Galaxy Tab 10.1 and on Samsung Galaxy S I9000 the SCREEN_DPI is equal to 160. I also tried <code>SCREEN_DPI = dm.density</code>, but I get the value <code>1.0</code> to both cases.</p>
<p>Any help would be greatly appreciated.</p>
| android | [4] |
2,306,995 | 2,306,996 | In C# what is perception? | <p>In one of the job interview some one asked me, In C# what is perception? And i don't know what he mean to say until now. Can some one brief it ?</p>
| c# | [0] |
3,801,689 | 3,801,690 | Filling array with integer values | <p>I have the following code:</p>
<pre><code>public static <T extends Comparable<T>> T[] getRandomPermutationOfIntegers(int size) {
T[] data = (T[])new Comparable[size];
for (int i = 0; i < size; i++) {
data[i] = i;
}
// shuffle the array
for (int i = 0; i < size; i++) {
int temp;
int swap = i + (int) ((size - i) * Math.random());
temp = data[i];
data[i] = data[swap];
data[swap] = temp;
}
return data;
}
</code></pre>
<p>which permutes an array of integers and return them. I want to fill the array with int values but am getting error in the two for() loops since T is different from int.</p>
<p>How do i fix them to make them work?</p>
| java | [1] |
3,263,433 | 3,263,434 | how to get checked value from radiobutton represented as variable? | <p>I would like to get checked value of some radiubutton.
That is not a problem when you using expression:</p>
<pre><code> $("input[name='radioname']:checked").val();
</code></pre>
<p>but I have a situation when I need to use DOM object from variable as below:</p>
<pre><code>var obj = $("[name=myradio1]");
</code></pre>
<p>and now I'm operating with variable obj.</p>
<p>Please explain how to get a checked value from <strong>obj</strong> variable</p>
<p>this is html code:</p>
<pre><code><input id="answer_21" type="radio" value="21" name="answer[1]">
<input id="answer_22" type="radio" value="22" name="answer[1]">
</code></pre>
| jquery | [5] |
5,895,726 | 5,895,727 | "#orderedlist > li" selector | <p>I'm studying jQuery with <a href="http://docs.jquery.com/Tutorials%3AGetting%5FStarted%5Fwith%5FjQuery" rel="nofollow">this</a> tutorial, but one of examples doesn't work.</p>
<pre><code><html>
<head>
<style type="text/css">
a.test { font-weight: bold; background: #fc0 }
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#ol > li").addClass("test");
$("#some").addClass("test");
});
</script>
</head>
<body>
<a href="http://jquery.com/" id="some">Some</a>
<ul id="ol">
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
</body>
</html>
</code></pre>
<p>This example apply the "test" style to hyperlink (#some), but doesn't apply this style to the ordered list (#ol). Why?</p>
| jquery | [5] |
2,524,176 | 2,524,177 | What does the << operator do in C++? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/10588748/what-is-the-operator-in-c">What is the “<<” operator in C++?</a> </p>
</blockquote>
<p>In a piece of code I am looking at, the following takes place:</p>
<pre><code>... (header[4] << 8) + header[5] ...
</code></pre>
<p>I'm fairly new to programming and have never seen the << operator before. Googling didn't provide any results. Any quick pointers would be appreciated!</p>
| c++ | [6] |
2,074,708 | 2,074,709 | Creating a copy of the object for multiple comparison is a good practice? | <p>Suppose multiple comparations are required at once:</p>
<pre><code>enum usermode
{
active,
standingby,
inactive,
dead,
// many other modes....
};
class A
{
public:
usermode mode;
};
</code></pre>
<p>function inherited pointer to class A (ptr points to A)</p>
<p>Method A:</p>
<pre><code>if( ptr->mode == active || ptr->mode == standingby || ptr->mode == inactive || ptr->mode == dead ...//etc )
{
//do something
}
</code></pre>
<p>Method B: </p>
<pre><code>usermode cmpmode = ptr->mode;
if( cmpmode == active || cmpmode == standingby || cmpmode == inactive || cmpmode == dead ...//etc )
{
//do something
}
</code></pre>
<p>Is it a good practice to do so?</p>
| c++ | [6] |
4,178,489 | 4,178,490 | Caching in dll for asp.net site? | <p>I have a .NET DLL on my site. I'd like to use Cache() like you can on ASP.net websites, but it's just a class library project.</p>
<p>I'm guessing I'm missing a reference but I don't know what it is.</p>
| asp.net | [9] |
1,522,052 | 1,522,053 | How do I create a resource dll | <p>How do I create a resource dll ? The dll will be having a set of .png files. In a way these .png files should be exposed from the dll. My application would need to refer this dll to get a .png file. </p>
| c++ | [6] |
4,577,940 | 4,577,941 | "No data received" error when I have a mysql query in while loop | <p>I have this PHP code:</p>
<pre><code><?php
include_once("connect_to_mysql.php");
$max=300;
while($max--)
{
sleep(1);
doMyThings();
}
?>
</code></pre>
<p>it is supposed to repeat a mysql query 300 times with gap of 1 second between each. But the problem is after a minute or so in the browser i get this message: No Data Received. Unable to load the webpage because the server sent no data. </p>
| php | [2] |
199,326 | 199,327 | How do we create a custom drop down list in android which is different than spinner? Please help me with the code | <p>The drop down list should have a fixed predefined name unlike spinner.
When its elements are clicked, they should pass an Intent to go to their corresponding activity.
Hoping for a good code.
Thank You.</p>
| android | [4] |
3,546,194 | 3,546,195 | How do I add an onclick function to all matched elements | <p>This function only works once, when I click an anchor element again, nothign happens. I thought the selector would apply the .click function to all matched elements? </p>
<pre><code> $('#welcome-nav li a').click(function (e) {
// prevent anchor from firing
e.preventDefault();
var chosenElement = $(this).parent().attr('class');
var index = articles.indexOf('.' + chosenElement) + 1;
//remove all classes of active on articles
$.each(articles, function (index, value) {
$(value).removeClass('active');
})
$('.' + chosenElement).addClass('active');
$('#sharpContainer').bgStretcher.sliderDestroy();
startBgStretcher(returnImageArray(index));
})
</code></pre>
<p>Below is the plugin that I think is breaking the onclick function</p>
<pre><code> $('#sharpContainer').bgStretcher({
images: imageContainer,
anchoring: 'left top', //Anchoring bgStrtcher area regarding window
anchoringImg: 'left top', //Anchoring images regarding window
nextSlideDelay: 8000, //Numeric value in milliseconds. The parameter sets delay until next slide should start.
slideShowSpeed: 2000, //Numeric value in milliseconds or(’fast’, ‘normal’, ’slow’). The parameter sets the speed of transition between images
transitionEffect: 'superSlide',
slideDirection: 'W',
callbackfunction: homepageSlide
});
function homepageSlide() {
//homepage slide is called after a slide has loaded
var index = $('li.bgs-current').index();
//hide current article
$.each(articles, function (index, value) {
$(value).removeClass('active');
})
//show next article
$(articles[index]).addClass('active');
}
</code></pre>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.