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,411,470 | 5,411,471 | How to strip dashes out of file basename and display using php? | <p>I'm trying to list links to all the files in a folder on my web site by including the code below in the index page in that folder. </p>
<p>Using this code outputs file names that look like this <code>name-of-file</code> which are linked to <code>name-of-file.html</code>.</p>
<p>Now how do I modify the code below to strip out the slashes and display the file names as <code>name of file</code>? </p>
<p>I'm a php noob so any help will be greatly appreciated. Thanks. </p>
<pre><code><ul>
<?php
$files = glob("*.html");
foreach($files as $file)
{
echo '<li><a href="'.basename($file).'">'.basename($file, ".html").'</a></li>';
}
?>
</ul>
</code></pre>
| php | [2] |
1,277,635 | 1,277,636 | C++: Declare a global class and access it from other classes? | <p>I have a class which should be declared globally from main() and accessed from other declared classes in the program, how do I do that?</p>
<pre><code>class A{
int i;
int value(){ return i;}
};
class B{
global A a; //or extern??
int calc(){
return a.value()+10;
}
}
main(){
global A a;
B b;
cout<<b.calc();
}
</code></pre>
| c++ | [6] |
2,614,568 | 2,614,569 | How to create a modal popup window with external file in Javascript? | <p>I am currently working on a website and I want to create a modal popup window in JavaScript. The problem is, I want to pull the contents of the window from a separate .html file and not from a hidden div on the page (this is how most of the examples I have seen show you how to do it).</p>
<p>I would really appreciate if someone could point me in the right direction on how to implement this.</p>
<p>Thanks in advance</p>
<p>Matt D</p>
| javascript | [3] |
2,980,207 | 2,980,208 | Finding specific string within a string, and recombining them | <p>Trying to figure this out and am just getting lost. What I am trying to do...</p>
<p>I have a program that takes a tarot card and gives the user the meaning. So the code passes the card selected as "One of Cups" but the image files names are formatted as "1ofCup" - so I am trying to get the program to check for the Number and card suite and then combine it into the proper image name format so I can use that variable to call the image.</p>
| php | [2] |
4,906,364 | 4,906,365 | I am getting HTML response through web service | <p>I am getting HTML response through web service and i want xml from web method,i am using TBXML xml purser, its occur occasionally.like as</p>
<p>The resource cannot be found.body{font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}b{font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}..............................................................
pls help me.</p>
| iphone | [8] |
3,603,261 | 3,603,262 | Memory allocation/reference comparison for ints and Integers | <p>With the following:</p>
<pre><code>String a = new String("test");
String b = "test";
System.out.println(a == b); //false
</code></pre>
<p>We get false, since <code>String a</code> is an object, so <code>a</code> points to a different location in memory than the string literal, <code>b</code>. I wanted to see how this worked for <code>int</code> and <code>Integer</code>:</p>
<pre><code>Integer x = new Integer(5);
int y =5;
System.out.println(x == y); //true
</code></pre>
<p>I though that <code>x.equals(y)</code> would be true, but <code>x == y</code> would be false as it is in the case with <code>Strings</code>. I understand that we compare <code>ints</code> with <code>==</code>, but I figured that comparing an <code>int</code> to an <code>Integer</code> would be different. Why is this not the case?</p>
<p>I assume that in this case using <code>==</code> won't work for comparing references, so how would we do it (not sure if this is practical, but I'd like to know)?</p>
| java | [1] |
4,880,780 | 4,880,781 | How to access a variable in an object from a member object's function | <p>Ok, I have a class:</p>
<pre><code>class class1
{
public:
class2 object2;
int a;
};
</code></pre>
<p>where:</p>
<pre><code>class class2
{
public:
void function2();
};
</code></pre>
<p>Basically, I need function2 in object2 to be able to access "a." How would I go about doing this? Thanks.</p>
| c++ | [6] |
1,968,376 | 1,968,377 | How to Force close all Applications Running in the Backgroung of the phone Programatically? | <p>I want to force close all applications running in the background of the phone after Every 2 seconds.How to do that?I found a lot here on SO as well as on Google Still not got the right Solution yet.So Please someone help me for my this issue.</p>
<pre><code>activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> Runningtasks = activityManager
.getRunningTasks(Integer.MAX_VALUE);
for (int i = 0; i < Runningtasks.size(); i++) {
ComponentName comName = Runningtasks.get(i).topActivity;
Packname = comName.getPackageName();
String Classname = comName.getClassName();
marray_adapter.add(Packname);
lst_list.setAdapter(marray_adapter);
}
activityManager.killBackgroundProcesses(Packname);
</code></pre>
| android | [4] |
4,057,267 | 4,057,268 | Horizontal view switching like in the official Google plus app | <p>Anyone have a code sample of horizontal view switching like in the official Google plus app. Im mean were you switch between Nearby - Circles - Incomming in the Stream view.</p>
| android | [4] |
5,951,469 | 5,951,470 | Enum internationalization exception | <p>I have an enum and I tried to internationalize it like:</p>
<pre><code>public enum ActivityEnum {
PROJECT_CREATED, PROJECT_EDITED, PROJECT_DONATION;
@Override
public String toString() {
switch (this) {
case PROJECT_CREATED:
return Messages.get("activity.project.created");
case PROJECT_EDITED:
return Messages.get("activity.project.edited");
case PROJECT_DONATION:
return Messages.get("activity.project.donation");
default: return super.toString();
}
}
private ActivityEnum activityEnum;
public ActivityEnum getActivityEnum() {
return activityEnum;
}
public void setActivityEnum(ActivityEnum activityEnum) {
this.activityEnum = activityEnum;
}
</code></pre>
<p>}</p>
<p>Now, please note that the keys defined in my messages.properties contains string formatters like:</p>
<pre><code>activity.project.created = User <%s> created project <%s>
</code></pre>
<p>Well, the issue is that when I do something with this enum in other places in the code, it throws an exception like:</p>
<pre><code>MissingFormatArgumentException occured : Format specifier 's'
</code></pre>
<p>so basically it wants that when I get the key in <code>toString</code> enum class, to apply also the args for formatting but this I only do later where I use that enum...</p>
<pre><code>activity.summary = String.format(activityEnum.toString(), args);
</code></pre>
<p>Can you please give me a suggestion of how to handle this?</p>
<p><strong>UPDATE</strong>:</p>
<p>If I use the classic way, all works nice:</p>
<pre><code>PROJECT_CREATED("User <%s> created project <%s>"), PROJECT_EDITED(
"User <%s> edited project <%s>"), PROJECT_DONATION(
"User <%s> made a donation of <%d> to project <%s>");
</code></pre>
<p>but this is without internationalization.</p>
| java | [1] |
160,011 | 160,012 | Automatically increment filename | <p>Right now, this is my code</p>
<pre><code>int number = 0;
DirectoryInfo di = new DirectoryInfo(scpath + @"Screenshots\");
if (di.Exists) {
} else {
di.Create();
}
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
bmpScreenShot.Save(di + "Screenshot_" + number, ImageFormat.Jpeg);
</code></pre>
<p>Program takes a screenshot (which works) and then saves the shot. What i wanna do, is have the program check and see if a screenshot exists "Screenshot_*" and if not create it. If it does, increment till it hits a number that hasn't been used at the end of "Screenshot_"
Not sure how to go about this given that it's more with files and incrementing. I'm thinking a for loop but I'm playing with it now.</p>
| c# | [0] |
3,659,187 | 3,659,188 | iPhone:Streaming feed URL sample? | <p>I have a media streaming code like below for playing streaming video. I want to test it with some working streaming url feed on iOS 4 devices. Could someone provide me the exact sample streaming video feed if anything is available for iPhone supported? So that, i can test this code and make sure it works well, though it could be correct. I want a real streaming video url link.</p>
<pre><code>NSString *strUrl = @"http://????????????"
</code></pre>
<p>NSURL *url = [NSURL URLWithString:strUrl];</p>
<p>MPMoviePlayerController *mPlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
mPlayer.view.frame = self.view.frame;</p>
<p>[self.view addSubview:mPlayer.view];</p>
<p>[mPlayer setFullscreen:YES animated:YES];</p>
<p>[mPlayer play];</p>
<p>Thanks.</p>
| iphone | [8] |
80,545 | 80,546 | Cannot create test condition after using nextLine() | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/767372/java-string-equals-versus">Java String.equals versus ==</a> </p>
</blockquote>
<p>I have been having difficulties using nextLine() to get a string, and then use it as a test condition (either in an if statement or a while loop). Looking at the println(), it seems as if the String is correctly assigned to the variable 'repeat' but then the test condition fails for some reason. Banging my head on the wall, bleeding from my forehead. Please help.</p>
<pre><code>import java.util.Scanner;
public class potpie {
public static void main(String args[]){
Scanner input = new Scanner(System.in);
String repeat = "yes";
System.out.println("Type in yes");
repeat = input.nextLine();
System.out.println("If repeat is now yes, print yes: " +repeat);
if(repeat == "yes"){
System.out.println("It worked");
} else
System.out.println("it failed");
}
}
</code></pre>
| java | [1] |
5,008,463 | 5,008,464 | Set multiple textview android in single listview | <p>I am able to send and receive message xmpp client and display them in listview in corresponding layouts. When i send or receive message. I get both the sent and received message combined in a single textview on different layouts.I need to display them in different layouts's textview. i want to display received message in 1 layout's textview and sent message in another layouts textview correspondingly. </p>
<p>Kindly guide me in this issue..</p>
<p>Thanks in advance.</p>
| android | [4] |
3,134,764 | 3,134,765 | Double PopUP Onclick IE8 | <p>I have the following code</p>
<pre><code><script>
function Results()
{
document.report_form.action = "index.php?p=report_view";
document.report_form.target = "_blank";
document.report_form.submit();
return true;
}
function CSV()
{
document.report_form.action = "csv.php";
document.report_form.target = "_blank";
document.report_form.submit();
return true;
}
</script>
<form name='report_form' method='post'>
<input type='submit' name='view_table' value='Display' onclick="return Results();">
<input type='submit' name='view_csv' value='Export CSV' onclick="return CSV();">
</form>
</code></pre>
<p>When using Firefox or Chrome, it doesn't trigger a double popup, when using IE8 , users click once on the button and either 2 windows popup or 2 download requests appear.</p>
<p>I couldn't find a solution to this, can you please show me where I am wrong?</p>
<p>Thank you</p>
| javascript | [3] |
1,310,200 | 1,310,201 | File Layout Exception | <p>I'm writing a java Application that can open and edit files. But I want it to give me an error if the layout of the file isnt as it should be.
My file looks like this:</p>
<pre><code>Title
X Y
Name
X times line
</code></pre>
<p>If looked into try and catch but that doesnt give me the right solution to give an error like:</p>
<pre><code>"There is no X or Y specified"
</code></pre>
<p>or</p>
<pre><code>"There is nog Title in this file"
</code></pre>
<p>Whats the option to do this?</p>
| java | [1] |
2,261,030 | 2,261,031 | PHP have syntax like this: $expr= $a || $b | <p>In javascript I can do:</p>
<pre><code>$a= $b || $c
</code></pre>
<p>if $b is null or empty then $a=$c, else $a=$b.</p>
<p>there is somthing like that in php?</p>
<p>i tried:</p>
<pre><code>$a=$b && $c
</code></pre>
<p>but I get $a=true or false, not the value of $b or $c.</p>
| php | [2] |
2,660,691 | 2,660,692 | How can I found a specific data in jpg image file by PHP | <p>I have a very much of jpg images, these images are copy of contract. and i need PHP script that can check these images if it had a fingerprint and stamp and barcode and image of person. Thanks in advance.</p>
| php | [2] |
1,166,226 | 1,166,227 | asp.net After a Server.Transfer how do you get the path of the current page? | <p>To get the url of the current page, I usually do something like this:</p>
<pre><code>string path = Request.Path;
</code></pre>
<p>If I do this after a Server.Transfer then I get the path of the page where the transfer was done. How can I get it for the current page?</p>
<p>For example:</p>
<p>On Page1.aspx I do Server.Transfer ("Page2.aspx")<br>
On Page2.aspx Request.Path returns /Page1.aspx and not /Page2.aspx</p>
<p>I would like to get /Page2.aspx. How can I get it?</p>
| asp.net | [9] |
2,460,645 | 2,460,646 | Passing Parameters via URI in Android | <p>Is it possible (or recommended) to pass parameters to content providers via URIs in Android, similar to how web addresses use them? That is to say, can I use name/value pairs in content:// URIs?</p>
<p>For example, I have a search provider that can search based on names. I pass it a URI like this:</p>
<p>content://com.example.app/name/john</p>
<p>That would return anyone with "john" in their names, including John, Johnathon, Johnson, etc.</p>
<p>I want to have the option (but not requirement) to search by exact names and not find partial matches. I was thinking of doing something like this:</p>
<p>content://com.example.app/name/john?exact=true</p>
<p>That would tell the search provider to only return names that exactly match "John." But I haven't seen any other examples of parameters used like this within Android. Is there a better way? What am I missing here?</p>
<p>Thanks!</p>
| android | [4] |
935,356 | 935,357 | click admob ad and forbid push up window | <p>I have an app which has an admob ad. When users click the ad, it will push up a window.
Is it possible to go to the web page directly rather than push up a window?</p>
<p>Welcome any comment</p>
| iphone | [8] |
3,387,297 | 3,387,298 | How can I find last <td> in table with PHP | <p>I wonder how can i find out last in table with PHP, aka if that is last then i want to apply different style and content to it.</p>
<p>This is part of my code generating table content.</p>
<pre><code> $content .= '</tr>';
$totalcols = count ($columns);
if (is_array ($tabledata))
{
foreach ($tabledata as $tablevalues)
{
if ($tablevalues[0] == 'dividingline')
{
$content .= '<tr><td colspan="' . $totalcols . '" style="background-color:#efefef;"><div align="left"><b>' . $tablevalues[1] . '</b></div></td></tr>';
continue;
}
else
{
$content .= '<tr>';
foreach ($tablevalues as $tablevalue)
{
$content .= '<td>' . $tablevalue . '</td>';
}
$content .= '</tr>';
continue;
}
}
}
else
{
$content .= '<tr><td align="center" style="border-bottom: none;" colspan="' . $totalcols . '">No Records Found</td></tr>';
}
</code></pre>
<p>I know there is option to do something like that with jQuery later on, but I don't want to complicate it and just solve it with php at time when i generate table.</p>
| php | [2] |
794,336 | 794,337 | How do I pass the value of a variable to an specific page element with solely javascript? | <p>Let's say I have:</p>
<p>var url="http://www.google.html";</p>
<p>how do I put the url variable value as the href value of an specific anchor tag in the page?
I know about str.link() but how I can use that with an specific element? and can I use link*( to build anchors of images? That didn't seem to work for me. Thanks for the help</p>
| javascript | [3] |
3,365,980 | 3,365,981 | Jquery - .click() is not launched after first attempt | <p>I have a div containing 3 input fields and a button. When the button is clicked, my js launched. My JS checks for input that have empty values and puts them with a red background. Everything working fine. My problem is as follows. Lets imagine the following situation: I just input the the 2 first input fields and click on the button. What will happen is that the third input will become red. Normal. But when I then put some text into that third input and reclick the button it is not switching to red. I don't get it. Hope someone can help. Thank you in advance for youe replies. Cheers. Marc.</p>
<p><a href="http://jsfiddle.net/g3b9S/" rel="nofollow">http://jsfiddle.net/g3b9S/</a></p>
<p>My html:</p>
<pre><code><div id="userList">
<input type="text" id="user1" class="verif" /><br>
<input type="text" id="user2" class="verif" /><br>
<input type="text" id="user3" class="verif" /><br>
<input type="submit" id="btn" />
</div>
</code></pre>
<p>My js:</p>
<pre><code>$('#btn').click(function() {
var myArray = [];
var userList = $('#userList .verif');
userList.each(function() {
var userID = $(this).attr('id');
var userName = $(this).val();
if (!userName) {
myArray.push({
'id': userID,
'name': userName
});
}
});
$.each(myArray, function(i, v) {
$('#userList .verif[id=' + v.id + ']').css('background-color', 'red');
});
});
</code></pre>
| jquery | [5] |
985,723 | 985,724 | Java-String is never read error! | <p>This is driving me insane! Here's the code:</p>
<pre><code>public static void main(String[] strings) {
int input;
String source;
TextIO.putln("Please enter the shift value (between -25..-1 and 1..25)");
input=TextIO.getInt();
while ((input < 1 || input > 25) && (input <-25 || input >-1) && (input != 999 && input !=-999))
{
TextIO.putln(input + " is not a valid shift value.");
TextIO.putln("Please enter the shift value (between -25..-1 and 1..25)");
input=TextIO.getInt();
}
TextIO.putln("Please enter the source text (empty line to quit)");
//TextIO.putln(source);
source = TextIO.getln();
TextIO.putln("Source :" + source);?");
}
}
</code></pre>
<p>However, its telling me that 'source' is never read! It's not allowing me to get input! Can anyone see what the problem may be?</p>
| java | [1] |
3,988,225 | 3,988,226 | Why can't you declare a static struct in C#, but they can have static methods? | <pre><code>// OK
struct MyStruct
{
static void Foo() { }
}
// Error
static struct MyStruct
{
}
</code></pre>
| c# | [0] |
3,905,090 | 3,905,091 | How to write the codes of LFU for Simplescalar? | <p>I am still new in Simplescalar and also in programming. Do anyone know how to write the codes to implement Least frequently used policy in Simplescalar? </p>
<p>It is a urgent!</p>
| c++ | [6] |
4,181,835 | 4,181,836 | Application Is stop if i pressed Back Button In Android | <p>i have created one application it contains
Progress bar with maximum limit.if i press start for starting my progress bar progress bar starts in background and got message box in application only. But if i press BACK button then my application get stop..
i want my application running in background though i press BACK button..So please tell me how to achieve this..if want code of my application then let me know...</p>
| android | [4] |
2,959,255 | 2,959,256 | Why isn't there a getContentView() method for Activity? | <p>The Activity class has a setContentView() method. The PopupWindow Class has a getContentView() method but nothing else does. Is there another way to get the main content view for an activity?</p>
| android | [4] |
2,339,519 | 2,339,520 | How to specialize a given template for a template | <p>Is it possible to specialize this template for any basic_string's?</p>
<pre><code>template<class T> struct X {};
</code></pre>
<p>Since basic_string is a template itself, I know this would be a solution:</p>
<pre><code>template <template <class, class, class> class T> struct X {}; template <> struct X<basic_string> {};
</code></pre>
<p>However, I would like to know if the language allows to preserve the first template definition, by specializing it somehow for basic_string's only.</p>
| c++ | [6] |
5,946,548 | 5,946,549 | Insert several chars instead of one into string | <p>I have a string with expression. For example the string is "a + b". I need insert float variables instead of that characters. "a" = 2.4494 and "b" = 5.545466. I convert variables to string and then make from strings with expression and with values char arrays.</p>
<pre><code>expr = expressions.get(i)[0]; // string with expression
for (int j = 0; j < valsListArray.length; j++) {//find characters and values
//they should have
String selection = (String) valsListArray[j].getSelectedItem(); //get
//chosen character
Float valueFloat = segmentAreas.get(j); //get value
String valueString = "" + valueFloat;
char[] charexpr = expr.toCharArray(); //
char[] valueChar = valueString.toCharArray();
char[] ch = selection.toCharArray();
for (int jj = 0; jj < charexpr.length; jj++) {
if (charexpr[jj] == ch[0]) {
charexpr[jj] = valueChar[0]; //here is the problem
}
}
String s =new String(charexpr);
expr = s;
</code></pre>
<p>but I cant understand how insert the whole charArray instead one character...</p>
| java | [1] |
928,114 | 928,115 | Finding all classes that implement C# interface - Similar to Java | <blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/26733/getting-all-types-that-implement-an-interface-with-c-3-5">Getting all types that implement an interface with C# 3.5</a><br>
<a href="http://stackoverflow.com/questions/927861/how-to-find-what-classes-implements-an-interface-net">How to find what class(es) implements an interface (.Net)</a> </p>
</blockquote>
<p>Is this possible in C# like it is Java?</p>
<p>If I have an interface name (IDataReader for arguments sake), how do I get a list of all classes that implement this?</p>
<p>In java this is listed in the API - Is this available in C#</p>
| c# | [0] |
1,193,999 | 1,194,000 | jQuery - Traversing the DOM | <p>Here is my HTML:</p>
<pre><code> <li>
<div class="menu_inner">
<a href="#">
<div class="button"><img class="486" src="images/portalbutton.png" /></div>
<div class="prod_description">&nbsp;</div>
</a>
</div>
</li>
</code></pre>
<p>I want to add a .click() function to .prod_description, the click event should take the background colour applied in CSS from the li element.</p>
<p>Using this code:</p>
<pre><code>$(".prod_description").mousedown(function() {
$('#toolbar').css('background-color', $(this).parent().css('background-color'))
})
</code></pre>
<p>I dont seem to be able to get the correct <code>$(this).parent()</code> combination....</p>
| jquery | [5] |
4,283,258 | 4,283,259 | Animate Jquery addClass on hover | <p>I'm new to Jquery so unsure how i would go about editing the code below to create a fade in when the class element is hovered over.</p>
<pre><code> <script type="text/javascript">
<!--//--><![CDATA[//><!--
$(function() {
$('div.work-item').hover(function() {
}).hover(function() {
$(this).addClass("hover");
}, function(){
$(this).removeClass("hover");
});
});
//--><!]]>
</code></pre>
<p>Any pointers would be greatly appreciated.</p>
<p>Thanks!
</p>
| jquery | [5] |
2,364,836 | 2,364,837 | rebuild a code from a decompiled java code | <p>how to rebuild a code from a decompiled java code and how to modify the classes whose name contains $ to suit the application</p>
| java | [1] |
2,231,336 | 2,231,337 | C# how to populate a string, IList, or Array through if statement | <p>I have the following code:</p>
<pre><code>foreach (string file in FleName)
if (!ActualFiles.Any(x => Path.GetFileName(x).Equals(file)))
{
IList<string> MissingFiles = file;
}
</code></pre>
<p>I have 3 if statements that access this method. At the end of the if statements I need to show the entire IList. </p>
<p>So heres what I want. First if statment goes into the method and returns every file with the word "EqpFle -" before each value</p>
<p>The second if statemenet I want it to return all those items with "DPFle-" in front of all the names, and simialr for the third.</p>
<p>At the end of all the if statements (this is in a for each) I want it to read the entire list.</p>
<p>how owuld I do this?</p>
<p>the ifs basically look as follows:</p>
<pre><code> foreach (string file in files)
{
if
{
Check <----thats the method
}
if
{
Check <----thats the method
}
if
{
Check <----thats the method
}
}
</code></pre>
| c# | [0] |
2,348,049 | 2,348,050 | how does compareTo and compare work? | <p>I know that compare and <code>compareTo</code> returns an <code>int</code> value.</p>
<p>For example:</p>
<pre><code>Returns
0 if a equal b
-1 if a < b
+1 if a > b
</code></pre>
<p><code>sort</code> method makes a call to either <code>compareTo</code> or <code>compare()</code> methods. But how does <code>sort</code> method arranges the <code>list</code> when compare or <code>compareTo</code> returns a <code>int</code> value. What is background scenario running after a <code>compare</code> or <code>compareTo</code> returns an int value to sort?how does <code>sort</code> method makes use of int values(<code>-1</code> or <code>0</code> or <code>1</code>) returned to it from <code>compare</code> and <code>compareTo</code></p>
| java | [1] |
5,241,993 | 5,241,994 | running a compiled java program on linux | <p>I use eclipse for developing my applications.</p>
<p>I have 2 java files, one is main and one is class that is used by main.
In eclipse, I just execute as java program and it works. (default package).</p>
<p>Now I just want to run this program on linux and other windows.
How do I run it? if you can point to me a tutorial that also is fine.</p>
<p>I am not looking at jar file/mainfest at this point of time . all I am looking for is to run thr program </p>
| java | [1] |
2,093,668 | 2,093,669 | C# Product Calculation Tool | <p>I am looking to implement a product calculation tool into my web site and I am looking for advise on possible tutorials/web links people may have to help with this. The tool will be used for a joinery website. What I am wanting the form to do is add values from different drop down lists and produce a quote price.</p>
<p>The form would have several drop down lists for example: item, size, finish, wood type etc. Obviously each item would have different sizes, finishes etc so these would need to be dependant on what item the user selected. The user would be able to select different values for each drop down box and then they would hit a calculate button. this would then produce a quote for the dimensions etc that they have selected.</p>
<p>Any help would be appreciated. </p>
<p>Framework is .Net Framework 4</p>
| c# | [0] |
3,749,818 | 3,749,819 | How to implement two queries within one MySQL statement? | <p>how to implement two queries within one MySQL statement? </p>
<p>for example coding</p>
<pre><code><?php var query=mysql_query("INSERT INTO adminDetails (user_name) VALUES ('uma');SELECT * FROM adminDetails");
?>
</code></pre>
<p>The above sql is giving result.but i used the same concept in below statement but it is not working </p>
<pre><code><?php
mysql_query("INSERT INTO adminDetails (user_name) VALUES ('uma');UPDATE domainname SET email='[email protected]' where id='18'")
?>
</code></pre>
| php | [2] |
3,528,139 | 3,528,140 | is jquery a problem for large scale sites? | <p>can jquery be a problem for large scale sites in relation to something like facebook, where a huge number of visits hit the site or the site containing a great amount of content?</p>
| jquery | [5] |
4,203,255 | 4,203,256 | php shipping charges api | <p>I want to use one api that will calculate shipping charge automatically & return me the price.
please give me solution with one example of api which you will give because i dont know how to use it.</p>
<p>thank you </p>
| php | [2] |
3,409,525 | 3,409,526 | Async methods in C# | <p>I have several process that need to run in the background of a Windows Forms application, because they take too much time and I do not want to freeze the user interface until they completely finish, I would like to have an indicator to show the process of each operation, so far I have a form to show the progress of each operation but my operations run synchronously.</p>
<p>So my question is what is the easiest way to run these operation (that access the database) async??</p>
<p>I forgot one important feature that the application requires, the user will have the option to cancel any operation at any time. I think this requirement complicates the application a lot, at least with my current skills, so basically I would like to enphatize that I need a solution easy to understand, and easy to implement. i am aware there will be good practices to follow but at this point I would like some code working later I with more time I would refactor the code</p>
| c# | [0] |
1,749,816 | 1,749,817 | Caching problem with a web view activity | <p>The activity launched is a webview activity.when i login first time then shows the login page but when logged on second time then the web view cache the pervious login and shows me the homepage instead it should be showing a login page again.i don't have a logout button in my web view.</p>
<pre><code>switch (v.getId()) {
case R.id.myaccount:
// intent = new Intent(getApplicationContext(), UIBMainView.class);
intent = new Intent(getApplicationContext(), MyAccount.class);
//intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
break;
</code></pre>
| android | [4] |
2,713,565 | 2,713,566 | Want to check if my banner was clicked - admob | <p>i've a added a banner using AdMob,</p>
<p>I want to check if it was clicked.</p>
<p>this is my code:</p>
<pre><code>public class CalcActivity extends Activity {
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calc);
adView = new AdView(this, AdSize.BANNER, "a150b2362fba949");
LinearLayout layout = (LinearLayout)findViewById(R.id.calcL);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
</code></pre>
<p>I've tried the adView.SetAdListener method, but it doesn't seem to have an "OnClick" method.</p>
<p>any idea?</p>
<p>Thanks!</p>
| android | [4] |
3,413,586 | 3,413,587 | Is device deployment enough to simulate application update? | <p>The application update process via app store (on the device by a lambda user) is not very well documented. I've sum up all this to these questions :</p>
<ul>
<li>what happens when the user updates his app? Is everything erased, or just some part of the app?</li>
<li>so what is kept, what is not kept?</li>
<li>how to test the application update in a development environment ?</li>
</ul>
| iphone | [8] |
346,202 | 346,203 | What does x(); refer to? | <pre><code>var y = new w();
var x = y.z;
y.z= function() {
doOneThing();
x();
}
</code></pre>
<p><em>where <code>w</code> does not contain a <code>z</code> object but contains other objects (e.g, <code>a</code>, <code>b</code>, <code>c</code>)</em></p>
<p>What is <code>x();</code> possibly referring too? (Again, this is JavaScript)<br />
Is the function calling itself?</p>
| javascript | [3] |
1,307,351 | 1,307,352 | SQLiteOpenHelper won't fire onCreate | <p>I am using this code</p>
<pre><code>public class PeopleDBHelper extends SQLiteOpenHelper {
public static final String TABLE_NAME = "Person";
public static final String DB_PATH = "/data/data/com.machinarius.labs.preloadedsql/databases/";
public static final String DB_NAME = "preload-test.sqlite";
private static final String DB_PREFS = "whyDoIHaveToDoThisAgain?";
private Context parent;
public PeopleDBHelper(Context context) {
super(context, DB_NAME, null, 1);
parent = context;
SharedPreferences prefs = context.getSharedPreferences(DB_PREFS, 0);
if(prefs.getBoolean("firstRun", true)) {
prefs.edit().putBoolean("firstRun", false).commit();
onCreate(null);
}
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
Log.i(getClass().getSimpleName(), "onCreate()");
InputStream source;
OutputStream destination;
byte[] buffer;
try {
source = parent.getAssets().open(DB_NAME);
destination = new BufferedOutputStream(new FileOutputStream(DB_PATH + DB_NAME));
buffer = new byte[512];
while(source.read(buffer) > 0) {
destination.write(buffer);
}
source.close();
destination.flush();
destination.close();
} catch(IOException ex) {
Log.e(getClass().getSimpleName(), "IOException", ex);
}
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i2) {
}
}
</code></pre>
<p>And i have been wondering... why do i have to implement that silly hack with SharedPreferences in order for onCreate to fire? Even after wiping application data from the Settings menu and calling getWritableDatabase() onCreate would not fire, leading to crashes coming from the persistence layer. What did i do wrong?</p>
| android | [4] |
4,277,353 | 4,277,354 | polymorphism in java | <p>is method overloading is a example of run time polymorphism?
is method overloading example of compile time polymorphism?</p>
| java | [1] |
3,741,059 | 3,741,060 | Filter Array Duplicates On Associative Value | <p>I've got an array:</p>
<pre><code>(
[0]
(
[room_num] => 1
[is_event] => true
[date] => '01/01/2013'
)
[1]
(
[room_num] => 2
[is_event] => false
[date] => ''
)
[2]
(
[room_num] => 3
[is_event] => false
[date] => ''
)
[3]
(
[room_num] => 1
[is_event] => false
[date] => ''
)
)
</code></pre>
<p>What I'd like to do is filter the results so that where <code>is_event = true</code> supersedes <code>is_event = false</code>. My returned array would look like:</p>
<pre><code>(
[0]
(
[room_num] => 1
[is_event] => true
[date] => '01/01/2013'
)
[1]
(
[room_num] => 2
[is_event] => false
[date] => ''
)
[2]
(
[room_num] => 3
[is_event] => false
[date] => ''
)
)
</code></pre>
<p>Sort of like array_unique except ON a certain value. </p>
<p>Is there a built in function for this? </p>
| php | [2] |
2,920,901 | 2,920,902 | Jquery if checkbox is checked add a class | <p>I am trying to add a class when a checkbox is checked.</p>
<p>My jquery:</p>
<pre><code>$('input').attr("checked").change(function(){
$('div.menuitem').addClass("menuitemshow");
})
</code></pre>
| jquery | [5] |
5,876,652 | 5,876,653 | Android Frame Animation | <p>I would like to know if it is possible to remove one of the frames I added using addFrame in Android?</p>
<p>Thanks</p>
<p>Kelvin</p>
| android | [4] |
2,249,015 | 2,249,016 | PHP Undefined variable in Apache error_log | <p>I'm getting a series of:</p>
<p>"Undefined variable: loginError in /Library/WebServer/Documents/clients . . ."</p>
<p>entries in my Apache error_log which I would like to prevent. I have a simple login.php page which, if there's an error logging in sets the $loginError variable as such:</p>
<pre><code>$loginError = '<p class="text-error">Login Error: '. $layouts->getMessage(). ' (' . $layouts->code . ')</p>';
</code></pre>
<p>If there's no error logging in it does this:</p>
<pre><code>$loginError = '';
</code></pre>
<p>I then output any errors as such:</p>
<pre><code>if ($loginError !== '') { //line 112
echo $loginError; /line 113
}
</code></pre>
<p>I'm getting the entries for the line 112 and 113 noted in my comments above. Anyone tell me how I can prevent the entries appearing? I'm using PHP Version 5.3.6.</p>
<p>thanks</p>
| php | [2] |
5,947,258 | 5,947,259 | How to change the url though php? | <p><Br>
i want to change the url though php. <br>
as we have </p>
<pre><code>window.location.href = "http://www.something.com";
</code></pre>
<p>in javascript. <br>
I want to same thing but in php.<br>
how to do that?<br>
Thanks in advance.</p>
| php | [2] |
1,023,717 | 1,023,718 | what are the steps need to consider to migrate Windows based applicaotin from 1.1 to .net 3.5 | <p>can anyone tell me main steps to consider while migrating 1.1 to 3.5 windows based applicatoin?</p>
<p>what are the steps need to consider at initially while planing for migration?
as per i know this applicatin i need to migrate like wsf and wpf and soo on.</p>
<p>thanks</p>
| asp.net | [9] |
3,257,149 | 3,257,150 | Add/remove characters in python? | <p>I have two things I need this for, these should explain what I mean:</p>
<ol>
<li>To have a 'shell popup' of sorts, like <code>man</code> does, that can be removed when done</li>
<li>To have a blinking ellipsis (...) for visual effect</li>
</ol>
<p>Is there any standard Python way to do this? Could I 'unprint' the last line and reprint it?</p>
| python | [7] |
3,730,696 | 3,730,697 | What does it mean global namespace would be polluted? | <p><strong>What does it mean global namespace would be polluted?</strong></p>
<p>I don't really understand this that global namespace getting polluted. Is this something related to garbage collection.</p>
| javascript | [3] |
1,815,033 | 1,815,034 | Interface class with getter and setter in c# | <p>As I read here <a href="http://msdn.microsoft.com/en-us/library/75e8y5dd%28v=VS.100%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/75e8y5dd%28v=VS.100%29.aspx</a></p>
<p>It is possible to put get in an Interface class BUT NOT set ?</p>
<p>So if I want getter and setter in Interface I have to create the old syntax getVar setVar just because new syntax doesn't fit Interface Class syntax ?</p>
<p>Update: If I must omit set in Interface class, does this means I cannot enforce class to have setter which defeats the purpose of having an Interface class in this case as I can only partially enforce ?</p>
| c# | [0] |
1,123,366 | 1,123,367 | isset($_COOKIE) is not working | <p>I am using the function set cookie to set (id) cookie like so:</p>
<pre><code>$cookie_id = $insert_userid;
setcookie("id", $cookie_id, time() + 31556926, '/', 'www.example.com');
</code></pre>
<p>The code above is working fine. I am checking the setting with firefox and the correct cookie is there.
Now on my other pages on my webiste I want to check if the cookie is set.
I am using this code to redirect if the cookie is not set.
I am getting redirected in both ways weather the cookie is set or not.</p>
<pre><code><?php
if(isset($_COOKIE['id'])){
//do something.
}else{
header('Location: login.php');
}
?>
</code></pre>
<p>how do I fix this problem ?</p>
<p>Var dump result is :</p>
<pre><code>array(4) { ["link"]=> string(43) "http://www.zzz.com/zzz" ["__unam"]=> string(30) "a5caeed-1385397a335-7fca86ad-2" ["PHPSESSID"]=> string(26) "6khzzzzzzzzjd51i6hamm0" ["id"]=> string(10) "zzzzzzzzzz" }
</code></pre>
<p>Update: I am not checking the cookie from the same page I crated it.</p>
| php | [2] |
1,222,481 | 1,222,482 | best way to make base uiviewcontroller iphone | <p>I an making an app which has many different uiviewcontrollers but they share the same functionality. I am going to make a basecontroller so the other classes extend this. However there are about 5-7 variables that I need to provide to the basecontroller. What is the proffered way to do this? Making a constructor that takes 7 parameters or is there better ways doing this?</p>
<p>Thanks in advance.</p>
| iphone | [8] |
4,149,725 | 4,149,726 | Asynchronous task | <p>I have created an asynchronous task like this:</p>
<pre><code>private class LongOperationcheckall extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
String result="Start";
try
{
Looper.myLooper().prepare();
// Looper.loop();
// TODO Auto-generated method stub
for(int k=0;k<13;k++)
{
checkall();
this.publishProgress("Show the dialog");
//count++;
}
result="Success";
checkallcomp++;
OnscanComplete();
}
catch(Exception ex)
{
checkallcomp++;
OnscanComplete();
}
return result;
}
@Override
protected void onProgressUpdate(String... values) {
super.onProgressUpdate(values);
Log.i("Progress", "Progressincheck");
}
protected void onPostExecute(String params ) {
Log.w("all Check",params);
// Execution of result of Long time consuming operation
}
}
</code></pre>
<p>I have added code,</p>
<pre><code>Looper.myLooper().prepare();
</code></pre>
<p>to call to this task as</p>
<pre><code>taskAllcheck = new LongOperationcheckall();
taskAllcheck.execute();
</code></pre>
<p>The fourth time when I click on start button the fourth time, it gives the exception </p>
<blockquote>
<p>Can't create handler inside the thread inside thread which not called looper.prepare </p>
</blockquote>
<p>Only, when I run in the device it executes OK in the emulator, but after add this line, the error comes as only one looper may be created per thread when I click on the start button for the fourth time and call <code>taskAllcheck.execute();</code>.</p>
| android | [4] |
5,931,045 | 5,931,046 | a basic Text to speech app not working | <p>i tried the following on the emulator but the as the app starts it gives a runtime error . could someone please help me on this . Heres' the code i tried </p>
<pre><code>package com.example.TextSpeaker;
import java.util.Locale;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
public class TextSpeaker extends Activity {
/** Called when the activity is first created. */
int MY_DATA_CHECK_CODE = 0;
private TextToSpeech mtts;
String test1="hello world";
String test2="hi i am working fine";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent myintent = new Intent();
myintent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(myintent, MY_DATA_CHECK_CODE);
}
protected void onActivityResult(int requestcode,int resultcode,Intent data)
{
if(requestcode == MY_DATA_CHECK_CODE)
{
if(resultcode==TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
{
// success so create the TTS engine
mtts = new TextToSpeech(this,(OnInitListener) this);
mtts.setLanguage(Locale.ENGLISH);
mtts.speak(test1, TextToSpeech.QUEUE_FLUSH, null);
mtts.speak(test2, TextToSpeech.QUEUE_FLUSH, null);
}
else
{
//install the Engine
Intent install = new Intent();
install.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(install);
}
}
}
}
</code></pre>
| android | [4] |
923,991 | 923,992 | BufferedReader reads only 61 bytes | <p>i wanna read a 90kb file (which apparently equals approximately 90,000 bytes) using Java's BufferedReader, but it stops after only 61 bytes. The file's alright, I've checked it using an HexEditor.</p>
<pre><code>private ArrayList<byte[]> readAsBytes(String dir, String filename, int lineCount) {
/** Read file as byte*/
ArrayList<byte[]> outputArr = new ArrayList<byte[]>();
try {
InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream (dir+filename));
BufferedReader reader = new BufferedReader(inputStreamReader);
if (lineCount == -1) {
String buf = "";
buf = reader.readLine();
if (buf != null) {
outputArr.add(buf.getBytes());
}
}
else {
for (int i = 0; i < lineCount; i++) {
String buf = reader.readLine();
if (buf != null) {
outputArr.add(buf.getBytes());
}
else continue;
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
</code></pre>
<p>Can anyone help? Probably kinda simple mistakes, but it I'm starting to get tired...</p>
| java | [1] |
1,213,284 | 1,213,285 | How to do Gridview Datakey value at @nd page of gridview? | <p>The Problem is:</p>
<p>i have a gridview to bind with 20 records & its allowpaging is true,but pageindexchanging event is not fired & pagesize is10</p>
<p>& on rowdatabound of gridview i get datakey value for first 10 records but not get the datakey value for next 10 records(i.e. 2nd page)</p>
<p>& the gridview is binding for 20 records</p>
| asp.net | [9] |
1,565,989 | 1,565,990 | how to downgrade project from android2.2 to android 2.1 ? | <p>I have my android project running on android 2.2 . I want it to work on android 2.1 .
How do I do that ??
Changing the target sdk in manifest file did not help .
I tried to clean the project but it deleted my R.java file. Plz suggest urgently.</p>
| android | [4] |
3,293,734 | 3,293,735 | ASP.NET getting viewstate in global.asax | <p>Is it possible to get at the viewstate in the global.asax file? I am having a problem with viewstate on some clients and I want to log what the viewstate is in the Application_Error event.</p>
| asp.net | [9] |
359,104 | 359,105 | How to send text area content to next page via post method? | <p>I got a textarea that has some html code in it. I want to send the content of this textarea without any change to next page via post method. </p>
<pre><code><html>
<form id="myform" name="myform" action="./getdata.php" method="post">
<td><textarea rows="7" cols="15" name="outputtext" style="width: 99%;"></textarea></td>
<input type="submit">
</form>
</html>
</code></pre>
<p>and my php code :</p>
<pre><code><?
$file_contents = $_POST['outputtext'];
?>
<textarea rows="30" cols="150"><?PHP print_r($file_contents); ?></textarea>
</code></pre>
<p>The problem with my code is that the orginal content of my first textarea gets changed when it sends to next page! For example:</p>
<pre><code><a href="/season/episodes.php?name=ok&id=1">
</code></pre>
<p>becomes:</p>
<pre><code><a href=\"/season/episodes.php?name=ok&id=1\">
</code></pre>
<p>could you guys how i can preserve the original html content without it changes in next page ?(Note all my html content changes in second pages which i dont want to change).My second textarea in second page is for testing purpose and i actually want to parse orginal value of $file_contents but for some reason it changes!</p>
| php | [2] |
4,358,438 | 4,358,439 | Android - Simplifying Radicals | <p>I am trying to make a calculator that performs the quadratic formula. </p>
<p>Currently if my result would be a decimal it returns NaN. (EDIT: Resolved)</p>
<p>Preferably I would like the result to be in an simplified radical form (i.e. √(99) = 3√(11) ).</p>
<p>How would I go about achieving this?</p>
<p>This is what I have so far.</p>
<pre><code>// Do the math
private double mathCalcPlus(double varA,double varB,double varC) {
return ((-varB + Math.sqrt(varB * varB - 4 * varA * varC)) / 2 * varA);
}
private double mathCalcMinus(double varA,double varB,double varC) {
return ((-varB - Math.sqrt(varB * varB - 4 * varA * varC)) / 2 * varA);
}
</code></pre>
<p>Any help will be greatly appreciated.</p>
| java | [1] |
2,632,372 | 2,632,373 | Passing form name and form object names to functions | <p>I'm having trouble understanding the workings of Javascript...I want to pass a form name and the submit button name so that the function can evaluate a passed value and either enable or disable the submit button. </p>
<p>It works if I explicitly use the names but I'd like it to work dynamically. Unfortunately I just am not understanding how to correctly use these arguments.</p>
<p>Right now the first document statement works (form name and button name are used), why doesn't the second, where arguments are used? I know from the alert that the form name isn't correct and can't be used as is but this won't work even if I explicitly name the form but use the passed button name which does appear correct.</p>
<p>I know this must be javascript 101 but I run into this time and again and am just not getting what's what. Anyone willing to explain this to me?</p>
<pre><code><script type="text/javascript">
function aTest(formName,objName,val){
if (val<5){
document.aForm.aBtn.disabled=false;
alert(formName+" - "+objName);
}
else {
document.formName.objName.disabled=true;
}
}//end function aTest(formName,objName)
</script>
<form name="aForm">
<input name="testFld" type="text" onBlur="aTest(this.form,'aBtn',this.value)">
<input name="aBtn" type="submit" value='submit'></form>
</code></pre>
<p>Thank you for your kind attention!</p>
| javascript | [3] |
2,573,224 | 2,573,225 | Android: how to make a ListView that looks similar to Preferences? | <p>I do not want to use the framework provided Preferences, rather I would like to create a ListView that looks similar. In particular, I would like it to use the same font size and style for the TextViews.</p>
| android | [4] |
8,906 | 8,907 | How to reduce this code? | <p>Is there any way to shorten this code:</p>
<pre><code>$resultCategoryName = mysql_query("SELECT ecname FROM electioncategorymaster WHERE ecid=".$Category);
$rowCategoryName = mysql_fetch_row($resultCategoryName);
$CategoryName = $rowCategoryName[0];
</code></pre>
| php | [2] |
4,464,338 | 4,464,339 | Working with Excel ? In Asp.net? | <p>In web application, i write the code for displaying the data in excel sheet to gridview. it is working fine but, can i track the sheet name of that particular excel sheet. For example i have sample.xls in that how can i find the sheet name. i write the query like this</p>
<pre><code> OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
</code></pre>
<p>How can i find the sheet name of the particular excel and if the excel sheet having more than one sheet then how can i display the data. can you help me.</p>
| asp.net | [9] |
2,502,220 | 2,502,221 | embedding php pchart on page | <p>How can I get a pchart in a specific location on my html page? right now when I follow the example and use </p>
<blockquote>
<p>$myPicture->autoOutput();</p>
</blockquote>
<p>It just overwrites my entire page and just shows the graph.</p>
<h2>edit. 4:32pm</h2>
<p>Looking at the pChart source I found inside pImage.class.php a relevant function</p>
<pre><code> function stroke()
{
if ( $this->TransparentBackground ) { imagealphablending($this->Picture,false); imagesavealpha($this->Picture,true); }
header('Content-type: image/png');
imagepng($this->Picture);
}
</code></pre>
<p>I tried to change it to this but it seems to return null and I'm getting a bunch of errors about
<strong>Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename in</strong></p>
<pre><code> function stroke()
{
ob_start(NULL,4096);
$this->Picture;
header('Content-type: text/html');
return base64_encode(ob_get_clean();
}
</code></pre>
| php | [2] |
596,798 | 596,799 | How to tell java.lang.String.split to skip the delimiter? | <p>as input my program gets a String containing IP Addresses are separated by a line delimiter, i.e. one IP Address per line. To validate each of the addresses I do:</p>
<pre><code>String[] temp;
temp = address.split(System.getProperty("line.separator"));
</code></pre>
<p>and then I loop though the array of Strings.</p>
<p>I was wondering why all but the last IP Address were always invalid. I've found out, that they look like 10.1.1.1^M</p>
<p>Is there a way to tell the java.lang.String.split to drop the delimiter before putting the token into the array? Or what other options do I have here? Sorry, I'm not a Java Ninja, so I thought I'll ask you guys before I start googling for hours.</p>
<p>Thanks
Thomas</p>
| java | [1] |
5,170,699 | 5,170,700 | is this valid javascript? | <p>I am new to javascript, but is this valid?</p>
<pre><code><script type="text/javascript">
if (condition()) {
location = "http://example.com/foo/bar/baz";
}
function condition()
{
if(something)
return true
else
return false
</script>
</code></pre>
<p>I am trying to write a javascript that goes insdie of content editer web part inside of SharePoint.
Thanks.</p>
| javascript | [3] |
3,803,038 | 3,803,039 | System hang while using Apache-POI java library for reading an excel file | <p>I used Apache-POI java library for reading excel files, it worked well. I read about 100 cells of every excel file, then I close the excel file.</p>
<p>The strange is when the excel file has large data, it will read the data successfully and then into another function system would crash. </p>
<p>I would appreciated any idea to solve this problem.</p>
<p>I am using this code for reading the excel file:</p>
<pre><code>public void ExcelReader(String path,int range1, int range2)
{
try
{
// Read from original Excel file.
FileInputStream file = new FileInputStream(path);
Workbook workbook = WorkbookFactory.create(file);
// Get the first sheet.
Sheet sheet = workbook.getSheetAt(0);
int allocated = range2 - range1 +1;
BarcodeList = new int [allocated];
int count = 0;
for(int i=range1-1; i<allocated; i++)
{
Row row = sheet.getRow(i);
Cell cell = row.getCell(0);
double x = Double.parseDouble(cell.toString());
int y = (int) x;
BarcodeList[count] = y;
count++;
}
file.close();
}
catch(NullPointerException e)
{
System.out.println(e);
}
catch(FileNotFoundException e)
{
System.out.println(e);
}
catch(IOException e)
{
System.out.println(e);
}
catch(InvalidFormatException e)
{
System.out.println(e);
}
}
</code></pre>
| java | [1] |
4,437,181 | 4,437,182 | Passing variable between functions in JavaScript | <p>How can I pass the variable <code>word1</code> in the first function to the second function in pure JavaScript?</p>
<pre><code>function functionOne()
{
var word1 = "dog" ;
}
function functionTwo()
{
var word2= word1;
}
</code></pre>
<p>I've checked the other questions in stackoverflow on this subject but I didn't get a simple answer.</p>
| javascript | [3] |
559,209 | 559,210 | jQuery Find Element Using Property | <p>I am using jquery to locate some elements from a table. The problem is that I might not know all the time the type of the element. That means an element can be a simple TD or a SELECT. But since both have text associated with it I want to retrieve the element if that has the text property. </p>
<pre><code>$($(rows[i]).find("element that has property text")[0]).text();
</code></pre>
<p>UPDATE 1: I updated the code and the td text node has a value but the currentRow.triggerType is returned empty.</p>
<pre><code>currentRow.triggerType = $($(rows[i]).find('td')[0]).filter(function() {
return this.nodeType == 3;
}).text();
</code></pre>
| jquery | [5] |
5,342,758 | 5,342,759 | how to identify whether X and y coordinates of touch lie with in range of bitmap image or not | <p>here is the code snippet to get bitmap and i am using Touch Event to get the coordinates</p>
<pre><code>`BitmapDrawable drawable = (BitmapDrawable) view.getDrawable();
Bitmap bitmap = drawable.getBitmap();
float x=event.getX();
float y=event.getY();`
</code></pre>
<p>Now i want to know whether these x and y lie in the bitmap region or not
i found a condition but its in pseudo code Kindly guide me that how can i find this xOfBitmap and yOfBitmap </p>
<pre><code> if (x >= xOfYourBitmap && x < (xOfYourBitmap + yourBitmap.getWidth())
&& y >= yOfYourBitmap && y < (yOfYourBitmap + yourBitmap.getHeight()))
{
// if this is true, you've started your click inside your bitmap
}
</code></pre>
<p>thanks in advance</p>
| android | [4] |
4,114,611 | 4,114,612 | Count a certain file type in a zip file using php | <p>I want to be able to count a certain file type in a zip file with PHP.</p>
<p>I have zip files with files that have a .ppml extension contained in them and need to find out how many are in each file without unzipping them.</p>
<p>Thanks in advance for your help.</p>
| php | [2] |
1,662,592 | 1,662,593 | Why do we include jQuery in the header? | <p>I was told not to mess with the core files. Also, I don't want jQuery to load on every single page.</p>
| jquery | [5] |
4,183,176 | 4,183,177 | Which view touch event will get called + iPhone | <p><strong>First Scenario</strong> :
Suppose we have a first view as FirstView. in this view(FirstView) we add another view(SecondView) having exactly same frame as FirstView as</p>
<pre><code>[FirstView addSubView:SecondView];
</code></pre>
<p>Now touch event of which view(FirstView or SecondView) will get called?</p>
<p><strong>Second Scenario</strong> :</p>
<p>suppose after adding SecondView(frame exactly same as FirstView) to FirstView I write
[FirstView:sendSubView];</p>
<p>Now touch event of which view will get invoked?</p>
| iphone | [8] |
5,028,591 | 5,028,592 | Recommended way to "load" javascript file dependencies? | <p>I have a priorityQueue class that depends on a set of heap functions being loaded.
Currently they're in separate files, priorityQueue.js and fheap.js.
I would like to do</p>
<pre><code><script src="priorityQueue.js"></script>
</code></pre>
<p>and have the fheap.js file automatically loaded (order doesn't matter). Furthermore, I'd like a method that cascades (ie dijkstra.js loads priorityQueue loads fheap).</p>
<p>Currently each file just loads its dependencies by injecting elements at end of . Is there a better way to achieve the same result, and what should I watch out for with the current method?</p>
| javascript | [3] |
5,494,919 | 5,494,920 | searching inside an array for a value | <p>Morning Guys</p>
<p>im currently playing with javascript and am creating a simple black jack game, i want to keep track of cards which have already been pulled from the pack. heres my function</p>
<pre><code>function usedCards(value,suit)
{
var exists = false;
for(i = 0; i< usedCardNo.length;i++)
{
if (value === usedCardNo[i] && suit === usedCardSuit[i])
{
exists = true;
console.log(i);
}
}
console.log("exists = " + exists);
if (exists===false)
{
usedCardNo.push(value);
usedCardSuit.push(suit);
console.log(value + " and " + suit +" added to array");
}
}
</code></pre>
<p>i pass the function 2 id numbers one realting to card number ie ace, 7, 9 aswell as suit.</p>
<p>i then check if it already exists in the array, if not add it. but its not currently working?? it just doesnt recognise a duplicate value.</p>
| javascript | [3] |
2,733,889 | 2,733,890 | What's the difference when initializing an array declaration with a string literal and a list of distinct characters? | <pre><code>char short_string[] = "abc"
char short_string[] = {'a', 'b', 'c'}
</code></pre>
<p>what I think is the difference is that the 2nd line is a switch statement and that it requires input from user (either a b or c as the 1st line is more of a statement.... is this right ?</p>
| c++ | [6] |
122,180 | 122,181 | JavaScript - Iterate through object properties | <p><strong>Beginners JavaScript</strong></p>
<p><strong>Code</strong></p>
<pre><code>var obj = {
name: "Simon",
age: "20",
clothing: {
style: "simple",
isDouche: false
}
}
for(var propt in obj){
alert(propt + ': ' + obj[propt]);
}
</code></pre>
<p><strong>Question</strong></p>
<p>How does the variable 'propt' represents the properties of the object? It's not a built-in method, or property. Then why does it comes up with every property in the object?</p>
<p>I hope I'm not asking stupid questions, I couldn't find any answers.</p>
| javascript | [3] |
1,522,150 | 1,522,151 | "JNI WARNING: illegal start byte 0xff" why? | <p>I'm using reflection to get access to the native properties. However, the following code results in :</p>
<pre><code>W/dalvikvm( 1714): JNI WARNING: illegal start byte 0xff
W/dalvikvm( 1714): string: 'ÿÿÿÿÿÿÿÿ'
W/dalvikvm( 1714): in Landroid/os/SystemProperties;.native_get (Ljava/lang/String;)Ljava/lang/String; (NewStringUTF)
</code></pre>
<p>Why? What does it mean ?</p>
<pre><code> @SuppressWarnings("rawtypes")
Class SystemProperties=null;
@SuppressWarnings("rawtypes")
Class[] paramTypes;
Method getprop=null;
try
{
SystemProperties = Class.forName("android.os.SystemProperties");
paramTypes = new Class[1];
paramTypes[0] = String.class;
getprop = SystemProperties.getMethod("get", paramTypes);
}
catch(Exception e)
{
SystemProperties=null;
}
if (SystemProperties != null)
{
try
{
Object[] params = new Object[1];
params[0] = new String("hw.type");
strKey = (String) getprop.invoke(SystemProperties, params);
}
catch(Exception e)
{
}
}
</code></pre>
| android | [4] |
3,235,350 | 3,235,351 | Multiple 'endings' to a function - return an object, return a string, raise an exception? | <p>This one's a structure design problem, I guess. Back for some advice.</p>
<p>To start: I'm writing a module. Hence the effort of making it as usable to potential developers as possible.</p>
<p>Inside an object (let's call it <code>Swoosh</code>) I have a method which, when called, may result in either success (a new object is returned -- for insight: it's an <code>httplib.HTTPResponse</code>) or failure (surprising, isn't it?).</p>
<p>I'm having trouble deciding how to handle failures. There are two main cases here:</p>
<ol>
<li>user supplied data that was incorrect</li>
<li>data was okay, but user interaction will be needed () - I need to pass back to the user a string that he or she will need to use in some way.</li>
</ol>
<p>In (1) I decided to <code>raise ValueError()</code> with an appropriate description.
In (2), as I need to actually pass a <code>str</code> back to the user.. I'm not sure about whether it would be best to just <code>return</code> a string and leave it to the user to check what the function returned (<code>httplib.HTTPResponse</code> or <code>str</code>) or <code>raise</code> a custom exception? Is passing data through raising exceptions a good idea? I don't think I've seen this done anywhere, but on the other hand - I haven't seen much.</p>
<p>What would you, as a developer, expect from an object/function like this?</p>
<p>Or perhaps you find the whole design ridiculous - let me know, I'll happily learn.</p>
| python | [7] |
816,997 | 816,998 | Why the IEnumerable.Except method doesn't return any elements? | <p>I'm generating two <code>IEnumerable<int></code> objects:</p>
<pre><code>var listA = model.SelectedFormats.Select(a => a.ID); //values: 1,2,4
var listB = basket.OrderPosition.Select(x => x.BookFormatTypeID); //values: 1,4
var result = listA.Except(listB);
</code></pre>
<p>but I can't see any results from the <code>Except</code> method (the compiler doesn't show even that the
<code>result</code> is)</p>
| c# | [0] |
3,596,835 | 3,596,836 | C++ Why is it calling the function with reference | <p>say i have the following C++ class.</p>
<pre><code>class C
{
int foo() const;
int & foo();
};
</code></pre>
<p>and i just call <code>myC.foo()</code>, i can see using the debugger that it calls the one with the reference.</p>
<p>why?</p>
<p>thanks!</p>
| c++ | [6] |
5,632,120 | 5,632,121 | asp.net division followed by formatting | <p>I have the following code:</p>
<pre><code><tr>
<td class="add_border_bold" nowrap="nowrap">Schedule Saved (days)</td>
<td width="100%" class="add_border">
<%# Eval("schedule_saved_days", "{0:0,0}")%>
&nbsp;
</td>
</tr>
<tr>
<td class="add_border_bold" nowrap="nowrap">Scheduled Saved in Months</td>
<td width="100%" class="add_border">
<%# Eval("schedule_saved_days", "{0:0,0}")%>
&nbsp;
</td>
</tr>
</code></pre>
<p>What the requirement is, is to display the second 'schedule saved' in months, rather than days (for some reason they can't figure it out based on days). previously in coldfusion i had just been dividing the number by 30. i had tried a couple different things like <code><%# Eval("schedule_saved_days"/30, "{0:0,0.00}")%></code> and <code><%# Eval("schedule_saved_days/30)%></code> just to get something to work. i'm sure this is a quick fix and my google-fu is failing me. Thanks in advance.</p>
| asp.net | [9] |
501,940 | 501,941 | how to add, edit, delete and queries since other computer (with internet) | <p>this is my connection class, i know i am going to put the ip, or i am in a error ? the direction of internet? what do i go to put? can i do it with web service? what is the form easy for to do it? here my connection class...</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace MisNotas.Conexiones
{
class Conexion
{
public SqlConnection conectar()
{
SqlConnection con = new SqlConnection(@"Data Source=.\sqlexpress;Initial Catalog=misnotas;Integrated Security=True");
return con;
}
public void EjecutarConsulta(SqlCommand comando)
{
comando.Connection.Open(); // open connection
comando.ExecuteNonQuery(); // execute the query
comando.Connection.Close(); // close the connection
}
}
}
</code></pre>
<p>The idea is since another place, i can to start session and to do queries and edits... how to do it?</p>
<p>it is in windows application not in asp.net.. thanks </p>
<p>i will put diferents tags for the import is how to do it... thanks</p>
| c# | [0] |
4,123,327 | 4,123,328 | how to invoke media scanner on button click in android | <p>Actually problem is that when i insert server images into Sdcard its gone and also display in sdcard but when i open phone Gallery it is not showing .
I also use this code for invoke media scanner on button click .... </p>
<pre><code>sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+Environment.getExternalStoragePublicDirectory(Environment.MEDIA_MOUNTED))));
</code></pre>
<p>but its not working.</p>
<p>in case when i mount and unmount sdcard in device then after all images are shown.
but i want when app is run images stored into sdcard and also show in device gallery.</p>
<p>pls help it much appreciate ..</p>
<p>Thanks ...</p>
| android | [4] |
3,648,937 | 3,648,938 | Concurrency Problem in Java | <p>I am designing a client-server chat application in Java. This is a secure application where the messages are exchanged using cryptographic algorithms. I have one server and it can support many clients. My problem is that when one client logs on the server it works fine, but when another user logs into the system, the server starts giving me bad padding exceptions for the encrypted text. </p>
<p>I am not able to figure out the problem, according to my logic, when new connection request to server is made, the server creates a thread for listening to the client. Is it possible that once the instance of thread class is created, it does all the processing correctly for the first client, but not for the second client because the variables in server listener thread class already have some previous value, and thus the encrypted text is not decrypted properly?</p>
<p>Please advise how I can make this process more robust so that the number of clients does not affect how well the server functions.</p>
<p>Hi, The code is like this :</p>
<p>When Server Starts:</p>
<pre><code>Socket in= serverSocket.accept();
Receive rlt = new Receive(in);
Thread receiveReq = new Thread(rlt);
receiveLoginReq.start();
</code></pre>
<p>now the Receive Thread waits for the incoming message and do the process according to message type. When more than one client is invoked, Server works fine, problem starts when one client terminates and then again tries to reconnect. Server always gives the Error in following pattern:</p>
<ol>
<li>First time the HAsh not matched error for second client</li>
<li>Second time javax.crypto.BadPaddingException: Given final block not properly padded error</li>
</ol>
<p>When this happens, I need to restart server and restart both clients, only then both clients works. but again if one client terminates connection and again tries to reconnects, the same 2 errors occurs in the same manner. and then again restart Server. </p>
<p>Any Advise will be highly appreciated.
Thanks</p>
| java | [1] |
601,595 | 601,596 | Put data between foreach() in PHP | <p>How can I put data between specific results in the foreach() function?, I have an array like this:</p>
<pre><code>array('01:data1:data2:data3', '01:data4:data5:data6', '02:data1:data2:data3')
</code></pre>
<p>When I print the array with <code>foreach()</code> I want to put html code between each number, like:</p>
<pre><code><ul>
<li>01:data1:data2:data3</li>
<li>01:data4:data5:data6</li>
</li>Image</li>
<li>02:data1:data2:data3</li>
<li>Image</li>
</ul>
</code></pre>
<p>Is it possible?</p>
| php | [2] |
1,429,466 | 1,429,467 | Version of python to learn, revisited | <blockquote>
<p><strong>Possible Duplicate:</strong><br />
<a href="http://stackoverflow.com/questions/170921/to-learn-python-2-then-3-or-3-from-the-start">To learn python 2 then 3, or 3 from the start?</a> </p>
</blockquote>
<p>I started learning python in 2.6 but didn't get as far as I would have liked before getting overloaded with projects at work. Now, I'd like to start fresh again, but should I go back to 2.6 or 3 now that it's been out for a little while.</p>
<p>I searched and found this question had been asked, answered and closed (here <a href="http://stackoverflow.com/questions/170921/to-learn-python-2-then-3-or-3-from-the-start">http://stackoverflow.com/questions/170921/to-learn-python-2-then-3-or-3-from-the-start</a>) but most the comments were based on the fact that v3 was too new. If this question has been asked again recently, my apologies, I couldn't find it. </p>
<p>Thanks!</p>
| python | [7] |
782,103 | 782,104 | Use markitup or masked input plugin (for example) on several elements, created after page loading? | <p>Here is a small example with the masked input plugin :</p>
<pre><code>//apply the mask to an input
$('.st').live('click', function() {
$(this).mask("99:99");
});
</code></pre>
<p><code>.st</code> is a text input with a td, the use can clone the td. However, when you clone this td, and try to click in the <code>.st</code> of the new element, your gain the focus of the first <code>.st</code> and it's not working.</p>
<p>I have tried several things, <code>bind()</code>, <code>live()</code>, and <code>each()</code> with no results.</p>
| jquery | [5] |
1,669,187 | 1,669,188 | compare and select classes by member function - a neat way | <p><strong>Given:</strong> </p>
<ol>
<li>a set of class instances (CL) and a reference instance (r)</li>
<li>the class has several getters, such as 'getA', 'getB', ...</li>
</ol>
<p><strong>Todo:</strong> Find those instances from CL that match 'r' by comparing 'getA', 'getB', ... For good code, only one selection function should be written, and you called by giving different getters as the comparison and selection criteria.</p>
<p>My code looks like this:</p>
<pre><code>def selector(r, cl, cmp_function_name):
return [i for i in CL if getattr(r, cmp_function_name)() == getattr(i, cmp_function_name)()]
# call it like this:
selector(r, cl, 'getA')
selector(r, cl, 'getB')
...
</code></pre>
<p>But I am not sure this is neat or pythonic. What do you think about it and How would you code it?</p>
<p>Thanks!</p>
| python | [7] |
119,582 | 119,583 | Convert 40px to sp | <p>What is the sp value for 40px? Please also tell the formula of conversion.</p>
<p>I am trying to convert my font sizes present in psd into sp units for mdpi density i.e. 320*480 with 160 dpi</p>
| android | [4] |
769,656 | 769,657 | Dynamic VariableFromString in objective C | <p>I want to dynamically create variable from string in objective C.</p>
<p>Like <code>NSClassFromString</code> thats way. In that I want to access variable.</p>
<p>Any idea about this?</p>
| iphone | [8] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.