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,323,414 | 5,323,415 | Loop in java until the users pushes enter | <p>How do I loop in java until the user pushes enter, then stop?</p>
<p>Something like</p>
<pre><code>while(System.in != ""){
do x;
}
</code></pre>
| java | [1] |
3,763,936 | 3,763,937 | Determining if an input is a number | <p>How do I find out if my user's input is a number?</p>
<pre><code>input = raw_input()
if input = "NUMBER":
do this
else:
do this
</code></pre>
<p>What is "NUMBER" in this case?</p>
| python | [7] |
4,641,206 | 4,641,207 | How to remove unnecessary tags? | <p>I have field "body" in my table (mysql) and there a lot of entries like:</p>
<pre><code></p><p> &nbsp;</p><p>
</p><p>
</p><p>
</code></pre>
<p>A lot of spaces, new line, &nbsp, etc. How to remove it?</p>
<p>This not work:</p>
<pre><code>text.replace('</p><p>&nbsp;</p><p>', '</p><p>')
text.replace('</p><p>\n</p><p>', '</p><p>')
</code></pre>
| python | [7] |
573,774 | 573,775 | ValueError: invalid literal for int() with base 10: '107.24' | <p>i am new in python, i just try to play a video in avg player through python. All the videos are played successfully, but one video has through this value error. i am not sure why this error was happened . if you know describe me.</p>
| python | [7] |
229,206 | 229,207 | want to find all possible values for given number.(in C language) | <p>my output should appear as (ex- input is 4)
[(1,1,1,1),(1,2,1),(2,2),(1,3),4]</p>
| python | [7] |
3,152,011 | 3,152,012 | Download files from server php | <p>I have a URL where I save some projects from my work, they are mostly MDB files, but some JPG and PDF are there too.</p>
<p>What I need to do is to list every file from that directory (already done) and give the user the option to download it.</p>
<p>How is that achieved using PHP?</p>
| php | [2] |
1,091,724 | 1,091,725 | Extract numbers from a string | <p>I want to extract the numbers from a string that contains numbers and letters like:</p>
<pre><code>"In My Cart : 11 items"
</code></pre>
<p>I want here to get the number 11 or any other number...</p>
<p>Thanks</p>
| php | [2] |
14,275 | 14,276 | Object reference not set to an instance of an object. exception at string assignment | <p>This is my code to generate an autogenerating jobcode and fill it in a text box</p>
<pre><code> public void newjobecodenoget(){
String jobcodeno = null;
OleDbConnection oleDbConnection1 = new System.Data.OleDb.OleDbConnection(connString);
oleDbConnection1.Open();
String query = "SELECT TOP 1 jobpk FROM jobcodemastertable ORDER BY jobpk DESC";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
DataSet ds = new DataSet();
dAdapter.Fill(ds, "tbljobrdataview");
Int32 S = int.Parse(ds.Tables[0].Rows[0][0].ToString());
S++;
jobcodeno = "NFT" + S.ToString();
MessageBox.Show( jobcodeno);
txtjobcode.Text = "NFT" + S.ToString();
}
</code></pre>
<p>but Iam getting exception at the last line ie txtjobcode.Text = "NFT" + S.ToString();
Object reference not set to an instance of an object.
all other things are fine and jobcode is generated and shown in message box
can anyone help pls</p>
<p>my txtjobecode was declared as</p>
<pre><code>private void InitializeComponent()
{
this.txtjobcode = new System.Windows.Forms.TextBox();
//
// txtjobcode
//
this.txtjobcode.Location = new System.Drawing.Point(98, 23);
this.txtjobcode.Name = "txtjobcode";
this.txtjobcode.Size = new System.Drawing.Size(91, 20);
this.txtjobcode.TabIndex = 0;
//
}
</code></pre>
| c# | [0] |
2,216,252 | 2,216,253 | computing RTT problem with javascript | <p>I want to measure how long an RTT is to the server...
Here is the problem, when I have the following work it works perfectly:</p>
<pre><code>var start = new Date();
var startTime=start.getMilliseconds();
document.write('<img src="http://mysite.com/myfile.gif" onload="getEndTime()">');
function getEndTime()
{
var stop= new Date();
var t=stop.getMilliseconds()-startTime;
console.log(t);
}
</code></pre>
<p>But if i want to store t in a variable and print it out of the function, it most of the time doesn't work! </p>
<p>For example:</p>
<pre><code>var start = new Date();
var startTime=start.getMilliseconds();
document.write('<img src="http://mysite.com/myfile.gif" width="1" height="1" onload="getEndTime()">');
var rtt;
function getEndTime()
{
var stop= new Date();
var t=stop.getMilliseconds()-startTime;
rtt=t;
}
console.log(rtt);
</code></pre>
<p>rtt will be 0 most of the time!!... Can anyone help? it is so frustrating!....</p>
| javascript | [3] |
3,716,725 | 3,716,726 | Trouble using reflection with setOverScrollMode | <p>I want to be able to turn off overscroll (the glowing effect when reaching the top or bottom of a page in 2.3+) however I also want my code to run in older versions of android that don't even have overscroll functionality. As per the documentation here: <a href="http://developer.android.com/resources/articles/backward-compatibility.html" rel="nofollow">Android Backwards Compatibility</a> I am using reflection in my custom webview class to call setOverScrollMode however everytime I call this on a device running 2.3.4, I get a NoSuchMethodException. Any idea why I can't retrieve this method?</p>
<p>Strangely, if I just call setOverScrollMode without any reflection, it works, so the method is definitely there.</p>
<pre><code>public class MyWebView extends WebView{
public void compatibilitySetOverScroll(){
try {
Method mWebview_SetOverScroll = WebView.class.getMethod("setOverScrollMode", new Class[] { Integer.class } );
/* success, this is a 2.3+ */
if (mWebview_SetOverScroll != null) {
try {
mWebview_SetOverScroll.invoke(this, 2);
} catch (InvocationTargetException ite) {
throw new RuntimeException(ite.getCause());
} catch (IllegalAccessException ie) {
System.err.println("unexpected " + ie);
}
}
} catch (NoSuchMethodException nsme) {
/* failure, must be older device */
}
}
}
</code></pre>
| android | [4] |
5,541,620 | 5,541,621 | Building and maintaining an options array/object in JavaScript | <p>I'm building a faceted/filtering search for a project I'm currently working on and I'm looking for a function (or jquery plugin) to help me do this. Let's say I have an object like the following:</p>
<pre><code>var options = {
"country": 2,
"Gender": 1
}
</code></pre>
<p>I then have a function called filter(). I pass filter the key and value of the option I want to toggle/add/update. My current function is causing me nothing but trouble and I'm too far down the debugging rabbit hole to make it worth posting. Essentially I have this:</p>
<pre><code>filter('country', 3);
</code></pre>
<p>would update the 'country' key to have '3' as its new value.</p>
<pre><code>filter('Age Group', 4);
</code></pre>
<p>would add that key/value pair to the options object.</p>
<pre><code>filter('Gender', 1);
</code></pre>
<p>would remove the 'Gender' key from the object completely.</p>
<p>Any point in the right direction would be appreciated.</p>
| javascript | [3] |
372,292 | 372,293 | Security issue in device adminstrator app in android | <p>I was using the google's device administator feature in order to build an android app which is related to security and antitheft. So I used the sample code provided by google. The main purpose is that if the mobile is stolen, the thief should not be able to remove our security app, thus we could track our phone.</p>
<p>In normal situations,when we make our app a device adminstrator, we wont be able to install that app directly. We need to disable the device admin for which we would need a password.</p>
<p>But recently I have found out that we could set the phone to refactory mode whose completion would erase all installed apps from our mobile and thus our seurity app will also get erased.</p>
<p>So what I would like to know is: Is not this a security treat to android users if theifs could take away our android mobile and convert the phone into refactory mode that getting rid of every security apps installed in our mobile, thus limiting our chance to tracking our phone?</p>
<p>Also, what's the purpose of using google's adminstator feature if people can use this way of booting etc to get into someone else mobile?</p>
| android | [4] |
643,921 | 643,922 | [PHP]: Error -> Too few arguments in sprintf(); | <p>This line is giving error: "Too few arguments". What is the problem?</p>
<pre><code>$InsertQuery = sprintf("INSERT INTO listing (ldate, places, company, designation, projectdetails, desiredcandidate, hrname, hrcontact, email) VALUES (DATE_FORMAT(%s,'%Y %m %d),%s,%s,%s,%s,%s,%s,%s,%s)", $ldate,$places,$company,$designation, htmlentities($projectdetails), htmlentities($desiredcandidate),$hrname,$hrcontact,$email);
</code></pre>
| php | [2] |
4,847,987 | 4,847,988 | access animated elements via their queue key? | <p>Can I stop an animation in a custom-named queue without access to the animated elements?</p>
<pre><code>$(complictedSelector).animate(
{opacity: .5},
{duration: 10000, queue: 'hover'} );
</code></pre>
<p>My naive attempt at using <code>$stop( 'hover' )</code> doesn't work :-)</p>
<p>It seems I <strong>do</strong> need the elements. So... is there a way to access animated elements via their queue key/name?</p>
<p>By queue key I mean a string passed into the options (in this example, 'hover').</p>
<p><em><a href="http://api.jquery.com/animate/" rel="nofollow">( As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. )</a></em></p>
| jquery | [5] |
4,941,242 | 4,941,243 | Miller Rabin Primality test | <p>I have wrote a Miller Rabin primality test in C sharp, but it return false on every input.</p>
<p>Here's the code:</p>
<pre><code> static Boolean MilRab(UInt64 n)
{
UInt64[] ar = new UInt64[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 };
for (int i = 0; i < 10; i++)
{
if (Tanu(ar[i], n) == true) return false;
}
return true;
}//MilRab
static Boolean Tanu(UInt64 a, UInt64 n)
{
UInt64 b = n - 1;
UInt64 d = 1;
UInt64 x;
Int16 i;
for (i = 63; i >= 0; i--) if (((b >> i) & 1) == 1) break;
for (;i>=0;i--)
{
x = d;
d = ((d * d) % n);
if (d == 1 && x != 1 && x != n - 1) return true;
if (b>>i == 1) d = (d * a) % n;
}
if (d != 1) return true;
return false;
}//Tanu
</code></pre>
<p>What do you think the problem can be? I spent a hole day debugging and its driving me crazy. Thank you.</p>
| c# | [0] |
1,937,088 | 1,937,089 | Capitalizaing a string in JavaScript | <p>Is there any method to captitalize a string in JavaScript? I want a JS equivalent of following Java:</p>
<pre><code>String st = "aks";
String st1 = st.toUpperCase();
</code></pre>
| javascript | [3] |
2,549,717 | 2,549,718 | Android : how to chose between background Thread with looper and Service | <p>by my understand about looper that it's can be a central for running by any request pass through
handler in message and Service can do that too. So what is adventage of each(priority of thread,reliable,resource,...) to decided to use.Any suggestion?</p>
| android | [4] |
1,431,736 | 1,431,737 | passing value from one text box to another in php | <p>I have two text boxes and one button. I want when i will type any value in 1st textbox and click on a button the value which i'll type in 1st text box should be the value of 2nd text box. And i was using this code. Can some one help me on this?</p>
<pre><code><?php
if(isset($_POST['sum']))
{
$v1=$_POST['abc'];
if($v1=="vivek")
{
echo "welcome Mr.".$v1;
}
else
{
echo "Unauthorised User Mr. ".$v1;
}
}
?>
<html>
<body>
<form method="post" action="">
<p>Name:&nbsp&nbsp&nbsp&nbsp&nbsp
<input type="text" name="abc" value=""/>&nbsp&nbsp
</br></br>
Passed Value: <input type="text" name="xyz" value="<?php echo $v1;?>"/>
</p>
<p>
<input type="submit" name="sum" value=" Submit "/>
</p>
</form>
</body>
</html>
</code></pre>
| php | [2] |
1,518,596 | 1,518,597 | Tcp/udp client/server Programs over Ipv6 in java | <p>i am struggling with</p>
<p>IPV6 programing</p>
<p>please help me or guide to me to ipv6</p>
<p>if it is posible please send reference site for following programs</p>
<p>Tcp/upd client /server examples over ipv6 </p>
<p>Advanced Thanks</p>
| java | [1] |
3,660,161 | 3,660,162 | Speech Recognition, ListView ArrayAdapter: What is the best way to use if("certain word spoken"){ } is there methods i can use? | <p>The Speech Recognition puts all the possibilities into the list view, im just wondering how i can use the values in ListView to use an if("word was spoken"){ "do something" }, do i have to make my own search or is there already methods, proper syntax</p>
| android | [4] |
3,693,900 | 3,693,901 | Simple Question about NSObject class / Retain Count | <p>If I create an NSObject class with a method that returns an NSMutableArray do I need to release the array inside the class or does the Class never retain? </p>
<p>Not sure on how to explain so here is some code:</p>
<pre><code>@implementation PointsClass
- (NSMutableArray *)pointsForLevel
{
NSMutableArray *_points = [NSMutableArray new];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(521, 279)]];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(321, 491)]];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(419, 477)]];
return _points;
}
@end
</code></pre>
<p>If i call this method from a ViewController like this:</p>
<pre><code>PointsClass *pointsClass = [PointsClass new];
NSMutableArray *points = [pointsClass pointsForLevel];
[pointsClass release];
</code></pre>
<p>Do I only need to release the pointers Array?
Has the _points array been retained at all?</p>
| iphone | [8] |
1,789,869 | 1,789,870 | viewflipper not calling onCreate of page | <p>I am new to Android development. I would like to use the viewflipper to bring in pages of my application. It would go to the next or previous page depending on the recieved gesture event. I have the gesture working and pages scroll in and out. Cool! Problem: the onCreate of each page doesn't fire and hence I have no click events defined. Here's what I got:</p>
<pre><code>private void BuildViewFlipper(ViewFlipper flipper)
{
views = new View[2];
views[0] = GetView(R.layout.ivdosage);
flipper.addView(views[0], 0);
views[0].setOnClickListener(CalculationViewer.this);
views[0].setOnTouchListener(gestureListener);
views[1] = GetView(R.layout.ivrate);
flipper.addView(views[1], 1);
views[1].setOnClickListener(CalculationViewer.this);
views[1].setOnTouchListener(gestureListener);
flipper.setDisplayedChild(viewIndex);
}
private View GetView(int id){
LayoutInflater inflater = this.getLayoutInflater();
View view = inflater.inflate(id, null);
return view;
}
</code></pre>
<p>The views in the above code were Activities. What am I missing? Any help would be greatly appreciated!</p>
<ul>
<li>Craig</li>
</ul>
<p>PS: The fixed array for the views was to just get me going and will be updated later. :)</p>
| android | [4] |
2,046,918 | 2,046,919 | Where to put snarfer.php? | <p>I followed these instructions: <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates" rel="nofollow">http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates</a></p>
<p>My understanding of those instructions was that the file snarfer.php needed to be in the folder 'themes', so it appears in the same list as the following folders and file:</p>
<p>twentyeleven (folder)
twentyeleven-child (folder)
twentyten (folder)
index.php</p>
<p>…but when I put it there, and went to create a Page, the new template didn't appear as an option in the list Default Template / Showcase Template / Sidebar Template.</p>
<p>So I tried putting snarfer.php in the folder 'twentyeleven-child' -- which is the active theme.</p>
<p>And the new template now appears in the Template list when I create a Page.</p>
<p>Do I have snarfer.php in the right place?</p>
| php | [2] |
5,098,193 | 5,098,194 | How to compare date and year? | <p>i am implementing one graph related app.</p>
<p>In that when application start i am getting present month,present year from calende and display on the screen with graph. like April 2012 and graph</p>
<p>ok that is fine.</p>
<p>In my screen i have two buttons like preview,next.</p>
<p>when user clicks preview ,i want to change April 2012 to March 2012,Fib 2012 ..........</p>
<p>And when user clicks next button,i want to change April 2012 to May 2012.....</p>
<p>How i will do these type of comparigens.</p>
<p>If any one know please help me.</p>
<p>Thanks in advance</p>
| android | [4] |
4,953,915 | 4,953,916 | Encoding non-English characters | <p>I'm having a bit of trouble here and I was hoping someone throws me a hint :)</p>
<p>I'm getting some GET VARS with JS but I have trouble with non-latin charsets: cyrillic for example. The cyrillic var appears correct in the url but when I retrieve it with JS I get some dummy string.</p>
<p>I was wondering of a function similar to "unescape" for such a case.</p>
<p>Alternatively, if someone knows a way I could convert a cyrillic string to the same dummy string I get from the URL, it will still do me the trick, since all I need is compare.</p>
<p>:)
Thanks!
Martin</p>
| javascript | [3] |
1,934,785 | 1,934,786 | javascript function indexOf() not working in chrome with white space in string | <p>I want to search the string in anchor tag, When I simply search the "Happy" without space it works fine however when I search it with some space like "Happy " it does not work.</p>
<p>Below is the code sample:</p>
<pre><code><html>
<body>
<a style="color:#555555" href="Happy coding!!">test</a>
<br/>
<script type="text/javascript">
var hrefTags = document.getElementsByTagName("a");
var bDayId = "";
var stringToSearch = "Happy coding!!";
for(var hrefIndex=0; hrefIndex < hrefTags.length; hrefIndex ++){
bDayId = hrefTags.item(hrefIndex).href.toString();
document.write(bDayId+"<br/>");
document.write( bDayId.indexOf("Happy "));
}
</script>
</body>
</html>
</code></pre>
| javascript | [3] |
3,710,298 | 3,710,299 | Trying to have an array with 2 values in side by side | <p>I need to create an array where i can use 1,2,3 but have 1v1, 2v2, Clubs associated with them.</p>
<p>I am going to use 1,2,3 for option value and 1v1,2v2 and clubs to display to the user.</p>
<p>How can I store this in an array and then use foreach to extract?
Thanks</p>
| php | [2] |
346,539 | 346,540 | buffer size changed | <p>I am doing a simple communication between sockets and here is my C++ code</p>
<pre><code>while(1)
{
string buffer = "23,45\n";
const char* foo = buffer.c_str();
cout << "size of buffer is " << sizeof(buffer)<<endl;
send (s, foo, sizeof(buffer), 0);
}
</code></pre>
<p>weird thing is the fist iteration, the size of the buffer is 5 as expected, but since the second iteration and so on, the size dramatically jumped to 32. any idea why? Thank you very much. By the way, the added size comes from leading while spaces.</p>
| c++ | [6] |
2,214,724 | 2,214,725 | < is not working in a string with email | <p>I am making a script that sends some individual emails to specific users, since I need authentication, I am using PEAR mail function and its working great, but when I a try to put in the from address the name and email of my enterprise, I get an error, so I was testing and testing and went back to baby steps where a very simple script showed me that something is wrong, but I don´t know if it is with PHP configuration, my script, my structure or what is happening. I the following code, I have in one variable the name, the second one is the email, and the third one appends both and adds the < > for the email, when I echo it, only the name appears, the is not echoed and that same is what is happening in my pear script.</p>
<pre><code> <?php
$var1 = "John";
$var2 = "john@domain.com";
echo $var12 = "$var1 $var2<br>"; // This one outputs name and email without the < >
echo $var122 = "$var1 <$var2> <br>"; // This one only outputs the data of $var1
?>
</code></pre>
<p>I appreciate your help.</p>
| php | [2] |
111,770 | 111,771 | Session value expires too quickly in hosting environment.How to fix this in asp.nen | <p>Session value expires too quickly in hosting environment.How to fix this in asp.net</p>
| asp.net | [9] |
3,980,670 | 3,980,671 | how to go to next Activity in androd | <p>I have three views main1.xml, main2.xml , main3.xml
In main.xml I am putting three buttons when user click on first button I want it to show main1.xml, if second button then main2.xml etc.. I am done with the main.xml files how to do that view change </p>
| android | [4] |
5,973,673 | 5,973,674 | Server-side Application to registration ID for Android device | <p>I am working on an application for android to get the Device Id from the respective devices of client.</p>
<p>I am following <a href="http://developer.android.com/google/gcm/gs.html" rel="nofollow">this tutorial</a>.</p>
<p>Here I am struck at the point where I need to make the server-side application to get device Id from GCM.</p>
<p>Actually, I am not an Android programmer and I have no knowledge of this platform, I just want to generate device id that is further required in the push notification.</p>
| android | [4] |
1,917,684 | 1,917,685 | CALayer w/ Animation as UIViews layer | <p>I have a UIView & I want that view's layer to be a continuously looping animation but I'm having some trouble getting started. I have the following in my view subclass:</p>
<pre><code>+ (Class)layerClass {
return [CALayer class];
}
</code></pre>
<p>Then in my viewController I have:</p>
<pre><code>CAGradientLayer *gradient = [CAGradientLayer layer];
[gradient setColors:[NSArray arrayWithObjects:[UIColor redColor],[UIColor blueColor],nil]];
[[[self view] layer] addSublayer:gradient];
</code></pre>
<p>This crashes my app. What exactly am I doing wrong? The app crashes w/ EXC_BAD_ACCESS.</p>
| iphone | [8] |
4,134,742 | 4,134,743 | why echo does not show anything while php is busy | <p>PHP Echo or Print functions does not show anything when php is busy with something (like when surfing the web with curl or something like that).</p>
<p>Later i discovered php does show the output when you execute your php on the command line:</p>
<pre><code>php myscript.php
</code></pre>
<p>But right now i don't get any outputs from command line too!
Is there any kind of tricks or setting should be done to make php show the outputs?</p>
| php | [2] |
4,950,717 | 4,950,718 | Counting repeated characters in a string in Python | <p>I want to count the number of times each character is repeated in a string. Is there any particular way to do it apart from comparing each character of the string from A-Z
and incrementing a counter?</p>
<p><strong>Update</strong> (in reference to <a href="http://stackoverflow.com/questions/991350/counting-repeated-characters-in-a-string-in-python/991372#991372">Anthony's answer</a>): Whatever you have suggested till now I have to write 26 times. Is there an easier way?</p>
| python | [7] |
3,741,862 | 3,741,863 | Skype Script For Contacting Me On Skype | <p>I would like a link on my website that when somebody clicks on it, it either starts a chat with me on skype, or if I'm offline, it starts a chat with my friend and when he's offline, it sends a pop-up saying "Sorry, nobody is availible." The status has to be online, otherwise go to the next person. </p>
<p>I found this, which outputs a number that corresponds to the status. If the number is anything else then 2, go to the next person or if it was the last person, pop-up.</p>
<p><a href="http://mystatus.skype.com/username.num" rel="nofollow">http://mystatus.skype.com/username.num</a></p>
<p>This is the code that has to be performed in order to start the chat:</p>
<p>"skype:username?chat"</p>
| javascript | [3] |
3,020,150 | 3,020,151 | Url rewriting in asp.net 3.5 | <p>I am developing an asp.net 3.5 application.I need to rewrite the url.My current url is,</p>
<p><a href="http://app.evetos.com/Areas/UserV1/Controllers/Order1.aspx?EventID=JRQlVFOQDYs=&status1=true" rel="nofollow">http://app.evetos.com/Areas/UserV1/Controllers/Order1.aspx?EventID=JRQlVFOQDYs=&status1=true</a> </p>
<p>This url will be very long and not user freindly.So i need to reduce this url to following url,</p>
<p><a href="http://app.evetos.com/Order/G8Oh9WHyAKA=/true" rel="nofollow">http://app.evetos.com/Order/G8Oh9WHyAKA=/true</a> </p>
<p>Here,querystrings like EventID and status are dynamically generating.So we need to pass these querystrings dynamically.so we can't hardcode these values.</p>
<p>We tried tag in web.config.but it is not useful.because here we cant pass the dynamic values in web.config.</p>
<p>So please tell me,how to do this.is there any application in internet please give me the url.</p>
<p>Thanks in advance.</p>
| asp.net | [9] |
2,951,688 | 2,951,689 | How do you organize resource dependent code? | <p>The code can be dependent upon other libraries or DOM content.</p>
| javascript | [3] |
2,714,883 | 2,714,884 | my program doesn't accept time print out sentence | <p>Here's the code that what I have. I also have in my class file: <code>import java.util.*;</code> and <code>long time;</code> and two formulas to calculate time before and after my calculations, and there is no error.</p>
<pre><code>import java.io.*;
public class RhoMain
{
public static void main(String arg[])throws IOException
{
int n, c;//To get number and Coefficient
// BufferedReader Object to get Runtime Inputs
BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
// Getting number and Coefficient at Runtime
System.out.println("Enter a Number to be factorize : ");
n = Integer.parseInt(BR.readLine());
System.out.println("Enter a Number for coefficient : ");
c = Integer.parseInt(BR.readLine());
// Creating an Object for RhoFact Class
RhoFac1 PolFac = new RhoFac1(n,c);
int compnum = n;// Temporarily used for n
if(PolFac.succeeded() == true)
{
// Displaying the calculation Steps
System.out.println("\ty(i)\ty(2i)\td\n\n");
for (int i = 0; i != PolFac.sizeof(PolFac.aList); i++)
System.out.println("\t" + PolFac.aList.elementAt(i) + "\t"
+ PolFac.bList.elementAt(i) + "\t"
+ PolFac.dList.elementAt(i) + "\n");
System.out.println("\nfound non-trivial factor:\t" + PolFac.result
+ "\nanother non-trivial factor is:\t"
+ (compnum / PolFac.result));
System.out.println("Factorization succeeded");
System.out.println(time/1000) + " seconds");
}
else{
System.out.println("no RHO-FACTORIZATION possible with "
+ "polynom x²+" + c);
System.out.println(n + " is no valid number");
}
}
}
</code></pre>
| java | [1] |
2,949,318 | 2,949,319 | How does variable assignment work in JavaScript? | <p>So I was playing around the other day just to see exactly how mass assignment works in JavaScript.</p>
<p>First I tried this example in the console:</p>
<pre><code>a = b = {};
a.foo = 'bar';
alert(b.foo);
</code></pre>
<p>The result was "bar" being displayed in an alert. That is fair enough, <code>a</code> and <code>b</code> are really just aliases to the same object. Then I thought, how could I make this example simpler.</p>
<pre><code>a = b = 'foo';
a = 'bar';
alert(b);
</code></pre>
<p>That is pretty much the same thing, isn't it? Well this time, it returns <code>foo</code> not <code>bar</code> as I would expect from the behaviour of the first example.</p>
<p>Why does this happen?</p>
<p><strong>N.B.</strong> This example could be simplified even more with the following code:</p>
<pre><code>a = {};
b = a;
a.foo = 'bar';
alert(b.foo);
a = 'foo';
b = a;
a = 'bar';
alert(b);
</code></pre>
<p>(I suspect that JavaScript treats primitives such as strings and integers differently to hashes. Hashes return a pointer while "core" primitives return a copy of themselves)</p>
| javascript | [3] |
1,160,361 | 1,160,362 | Unable to download Android 2.3.3 in Android SDK Manager | <p>I've tried to install Android 2.3.3 so I can then install OpenSense for HTC phones.</p>
<p>When I start the procedure to download Android 2.3.3 in the Android SDK Manager I get the followin messages:</p>
<blockquote>
<p>Preparing to install archives Downloading SDK Platform Android 2.3.3,
API 10, revision 2 </p>
<p>File not found: C:\Program Files
(x86)\Android\android-sdk\temp\android-2.3.3_r02-linux.zip (Access is
denied) Done. Nothing was installed.</p>
</blockquote>
<p>Any ideas?</p>
| android | [4] |
57,143 | 57,144 | Image Caching Problem in iPhone | <p>I have briefly described the working of my application to under stand my Question.</p>
<p>I have an application, in which more than 1600 images are stored with in iPhone-Application-Document Directory.
I have a tableView on Main Screen as follows.
=>First Category
=>Second Category
=>Third Category</p>
<p>=>if user selects First category, Images are loaded in my ScrollView<br>
Like <br>
|--------------------Page View Controller-----------------|<br>
| First Image | Second Image | Third Image | Fourth Image |<br>
|--------------------Page View Controller-----------------|<br></p>
<p>After selecting Category, User can see - First Image From Page view Controller & others are already loaded in page View Control, user has to just scroll left - right to see the other images, but at a time user can see only one image.(that is the task of page view control)</p>
<p><strong>Now Each Page has an Image View Placed in Scroll View (so user can zoom in out)</strong></p>
<p>All this things work Perfectly,</p>
<p>Problem occurs in following situation.<br>
=><strong>After watching first category</strong>'s images<br>
=>User presses <strong>Back</strong><br>
=>Now user <strong>selects second category</strong> to view all images of second category are loaded in page view controll.<br></p>
<p>iPhone terminates the application in the given situation. (as it can't load all images to page view control)
(<strong>each image</strong> is of at-least <strong>4 MB approximately</strong>.)</p>
<p>iPhone <strong>simulator works perfectly</strong> in described situation but <strong>iPhone doesn't</strong>.
<strong>iPhone terminates</strong> the application in given situation.</p>
<p>I think there might be memory caching problem in iPhone.</p>
<p>Question is how to resolve this problem?</p>
<p>Thanks in advance for helping me.</p>
| iphone | [8] |
176,374 | 176,375 | Android game development - Java or flash development or flash animation? | <p>I'm trying to make an android game here, but I'm not sure what is it that I need to learn - J2ME or flash development?
Also, if flash then is there a difference between flash development (coding) & flash animation?
I'd really appreciate any help here. </p>
| android | [4] |
1,015,367 | 1,015,368 | How to increase hit area of Android button without scaling background? | <p>I have a button with a custom drawable.</p>
<pre><code><Button
android:layout_width="22dip"
android:layout_height="23dip"
android:background="@drawable/triangle" />
</code></pre>
<p>The drawable is a triangle with transparent background. </p>
<pre><code>|\
| \
|__\
</code></pre>
<p>I find this button hard to tap. First, it's relatively small. Second, the transparent pixels are not tappable. I would like to keep the drawable the same size, but make the hit area a square shape twice the size of the triangle.</p>
<pre><code>_____________
| |
| |\ |
| | \ |
| |__\ |
|____________|
</code></pre>
| android | [4] |
627,701 | 627,702 | Accessing data from another class Java | <p>Okay, this is total noob stuff, and this is a simple concept I just cannot grasp from everything I've looked at.</p>
<p>Currently I have some a GUI with a JList, when you select the 1st, 2nd, 3rd or whatever thing in the list it gets the respective value from a list. However, I want to move this list to a 'data' class (or all my values are elsewhere, for easier maintainence - and yes I want them hard coded into the software).</p>
<pre><code>new DefaultComboBoxModel(
new String[] { "A", "B", "C", "D", "E" });
final Double[] letterCost = { 2.5, 1, 1, 1, 2.5 };
</code></pre>
<p>so when someone clicks E, for example, in the JList letterCost is set to 2.5
I want to move this bit</p>
<pre><code>final Double[] letterCost = { 2.5, 1, 1, 1, 2.5 };
</code></pre>
<p>into another class. I'm over simplifying what I'm actually doing. I just want to get my head around the concept. I've never worked with multiple classes before. </p>
<p>So how would I go about making a new class, having the data in that class, and have it accessed as it currently would be from my original class?</p>
<p>Thanks.. </p>
<p>oh, and if I had something that changed the values (say every time someone picked a letter the value increased by 1), would that continue to work the same?</p>
| java | [1] |
193,075 | 193,076 | Java ArrayList type issue | <p>I am new in Java.
Now I want to generate an ArrayList containing some values.</p>
<pre><code>"Circle","blue","red","yellow","1","2","3","4"
</code></pre>
<p>How can I code this. I found some tutorial from internet. Only int or string accepted? How about mix? Could someone should me the code that how to do this?
Thanks!</p>
| java | [1] |
5,569,870 | 5,569,871 | Open file dialog box | <p>I wanna use the open file dialog box to choose a folder.</p>
| c# | [0] |
5,630,756 | 5,630,757 | .trigger('blur') on collection of inputs? | <p>im trying to <code>trigger('blur');</code> on a collection of inputs but i does not seem to get this right.</p>
<p>example is avaible here <a href="http://jsfiddle.net/VUUme/1/" rel="nofollow">http://jsfiddle.net/VUUme/1/</a></p>
<p>im getting the collection and i got the blur method done but im not sure about the trigger part tho.</p>
<pre><code>var $inputs = $('#form').find('input');
alert('load');
$inputs.each(function(){
$(this).trigger('blur');
});
//i tried this to but with no success
//$inputs.trigger('blur');
alert('after the blur');
$inputs.blur(function(){
var $this = $(this);
if ($this.val() == ''){
alert('it works');
}
});
</code></pre>
| jquery | [5] |
2,417,335 | 2,417,336 | how to access serialPort1 in another form? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8566/best-way-to-access-a-control-on-another-form-in-winforms">Best way to access a control on another form in WinForms?</a> </p>
</blockquote>
<p>how can I access serialPort1 which is in form2 in the MainForm(Form1) ?
I want to use the methods which is related to the serialPort1 control ?</p>
| c# | [0] |
1,101,475 | 1,101,476 | can't get startActivity() to work | <p>So I was trying to get a chooser as it is shown <a href="http://developer.android.com/training/basics/intents/sending.html" rel="nofollow">here</a>...
but when I write <code>startActivity(chooser);</code></p>
<p>I get this error on Eclipse</p>
<p><code>The method startActivity(Intent) is undefined for the type myClass</code></p>
<p>What am I doing wrong?</p>
| android | [4] |
5,369,941 | 5,369,942 | Change class type at runtime | <p>I have two classes (let's call them <code>A</code> and <code>B</code>), both inheriting from a common superclass (<code>C</code>).</p>
<p>Let's say I need to build a <code>List</code> of <code>C</code>s. My problem is that, depending on the data received by <code>C</code>'s constructor I need to put an <code>A</code> or <code>B</code> object inside the list.</p>
<p>Is there a way to do this from inside <code>C</code>'s constructor? Or, alternatively, how can I solve this issue?</p>
| java | [1] |
802,975 | 802,976 | How to change startup layout from main.xml to another layout in Android | <p>I am new to android, is there any way to change this startup layout. actually application is already developed and later I implemented login layout for this, now how can I change startup layout to login layout?</p>
<p>Thanks</p>
| android | [4] |
4,137,169 | 4,137,170 | how to get current date time of the system in seconds | <p>how can I get current date time of the systems in seconds in C++?</p>
<p>I tried this one:</p>
<pre><code>struct tm mytm = { 0 };
time_t result;
result = mktime(&mytm);
printf("%lld\n", (long long) result);
</code></pre>
<p>but I got: -1?</p>
<p>Thanks in advance.</p>
| c++ | [6] |
137,840 | 137,841 | Change M.mysite.com to WWW.mysite.com in a URL | <p>I use a javascript function on mobile page to redirect users to main page(pc). So i want to change the url! Change M.MYSITE.COM/somepath/page.HTML to WWW.MYSITE.COM/somepath/page.HTML</p>
<p>Mobie URL</p>
<pre><code> m.mysite.com/pics/en/?wallpaper/super-man_w39.html
</code></pre>
<p>To main URL </p>
<pre><code> www.mysite.com/pics/en/?wallpaper/super-man_w39.html
</code></pre>
<p>Is there any way using PHP? I tried using parse url but i failed! help me? any way?</p>
| php | [2] |
76,810 | 76,811 | Base class usage in c #? | <p>Good day. I am just wondering how to create a base class and use it for my business objects. The base class would have some attributes like IsNew, IsDirty etc.</p>
<ol>
<li>What I want to know is how to
inherit this base class ?</li>
<li>Also what does the 'base' syntax
means ? Is it always required to use 'base' to access the base class ?</li>
<li>How many base classes can I have ?</li>
<li>Can you show me a little sample</li>
</ol>
<p>I did google but it was sort of confusing. Here I would get a quick answer. Thank you.</p>
| c# | [0] |
1,518,325 | 1,518,326 | Is there any selector to do a perfect match against text? | <p>On jQuery, I'm looking to a similar selector to <code>:contains</code> but I need to do a perfect match against an element text. Is there any?</p>
<pre><code><div>1</div>
<div>12</div>
<div>13</div>
<div>135</div>
</code></pre>
<p>so If I look for <code>text = 1</code> I would only get the first <code>div</code></p>
| jquery | [5] |
4,819,902 | 4,819,903 | Withing last 7 days | <p>Just can't get this to work. I want to check if this user bought a $45 or more bid pack in the last 7 days.</p>
<pre><code> $big_amount="45";
//check if the user has purchased bids
$strFind="SELECT * FROM `prepaypal` WHERE `memid`=\"$curmemid\" AND `success`='Y'
AND `pid`='0' AND `amount`>=\"$big_amount\" BETWEEN NOW() and DATE_SUB
(`date`, INTERVAL 7 DAY) ORDER BY `date` DESC LIMIT 1";
//echo $strFind;
$result=mysql_query($strFind) or die(mysql_error());
$row=mysql_fetch_array($result);
$bought_bids=$row['id'];
</code></pre>
| php | [2] |
4,701,156 | 4,701,157 | Can i Detect if .text() is called on a button? | <p>Suppose i have the following html:</p>
<pre><code><button class="inforTextButton" id"myButton">
<span class="leftSlice"></span>
<span class="centerSlice">Approved</span>
<span class="rightSlice"></span>
</button>
</code></pre>
<p>If i call the following command in jQuery: </p>
<pre><code>$("#myButton").text("New Text");
</code></pre>
<p>It will replace all the spans with the text. </p>
<p>Is there anyway to detect this event? What i would like to do at that time is prevent it from replacing all the contents and instead change the centerSlice. </p>
<p>Now I know i could call: <code>$("#myButton").find(".centerSlice").text("New Text")</code> but thats not what exactly the point of my question. In case in the future my button implementation changes and I am trying to see if this is possible in some way to detect which i am missing..</p>
<p>I tried textchange - seems like this does not fire on buttons.</p>
<p>Thanks</p>
| jquery | [5] |
3,953,912 | 3,953,913 | check for null with HtmlAgilityPack | <p>How do you check for null with HtmlAgilityPack? I'm getting "Property or indexer 'HtmlAgilityPack.HtmlNode.HasChildNodes' cannot be assigned to -- it is read only" with the following.</p>
<pre><code>if (Node.Element("TD").HasChildNodes = DBNull.Value)
</code></pre>
<p>I"m getting "Object reference not set to an instance of an object. " with </p>
<pre><code>if (Node.Element("TD").HasChildNodes)
</code></pre>
| asp.net | [9] |
939,088 | 939,089 | assign onclick event to function | <p>I want to call a function onclick and pass the event object to the function:</p>
<pre><code> progressBarOuter.onclick = function(e) {
var x; if (!e) {
x=window.event.clientX;
}
else {
x = e.clientX
}
yt.clickedOffset = x; yt.progressBarClicked
}
</code></pre>
<p>So i'm assigning clickedOffset to by enclosing object (yt) and then calling progressBarClicked which then uses the clickedOffset var. But what I actually would rather be doing is something like this:</p>
<pre><code>progressBarOuter.onclick = yt.progressBarClicked(e);
</code></pre>
<p>Because it's much more compact. Problem is that even if the user has clicked or not this bit of code is executed... yt.progressBarClicked(e). </p>
<p>Is there any way around this?</p>
| javascript | [3] |
5,872,789 | 5,872,790 | C++ cout fresh array gibberish | <p>When I "cout" an empty array, I get gibberish. Why?</p>
<pre><code>int main() { char test[10]; cout << test; return 0; }
</code></pre>
<p>...returns some unicode blather. An easy answer I'm sure.</p>
| c++ | [6] |
5,703,227 | 5,703,228 | How to use BCEL in java programming? | <p>Is BCEL(Byte code Engineering Library) directly usable in normal java 1.6 or we need to download something for using it?
Or is this an in built library in java1.6? </p>
| java | [1] |
5,929,527 | 5,929,528 | Android Http get request with json response | <p>I am getting json response with special characters and symbols. How can i encode to that symbol €. Please give me answer.</p>
<p>Thanks</p>
| android | [4] |
3,878,493 | 3,878,494 | Android merge two images | <p>I have these two images, which I basically merge on canvas. Now i want to save that canvas into an image. How should i do it or if there is any other way to merge two images.</p>
<p>My sample code is - </p>
<pre><code> Bitmap bmp1 = BitmapFactory.decodeResource(getResources(),
R.drawable.duckpic);
Bitmap bmp2 = BitmapFactory.decodeResource(getResources(),
R.drawable.img);
// canvas.drawColor(Color.BLACK);
// canvas.drawBitmap(_scratch, 10, 10, null);
Bitmap bmOverlay = Bitmap.createBitmap(bmp2.getWidth(), bmp2
.getHeight(), bmp2.getConfig());
// Canvas cs = new Canvas(bmp2);
canvas.scale((float) 0.5, (float) 0.5);
canvas.drawBitmap(bmp2, new Matrix(), null);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.save();
</code></pre>
<p>I got it working by doing this - </p>
<pre><code> cs = Bitmap.createBitmap(c.getWidth(), c.getHeight(), Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(s, new Matrix(), null);
comboImage.drawBitmap(c, new Matrix(), null);
comboImage.save();
// this is an extra bit I added, just incase you want to save the new
// image somewhere and then return the location
String tmpImg = String.valueOf(System.currentTimeMillis()) + ".png";
OutputStream os = null;
try {
os = new FileOutputStream("/sdcard/" + tmpImg);
cs.compress(CompressFormat.PNG, 100, os);
} catch (IOException e) {
Log.e("combineImages", "problem combining images", e);
}
</code></pre>
<p>Basically it is given here - <a href="http://www.jondev.net/articles/Combining_2_Images_in_Android_using_Canvas" rel="nofollow">http://www.jondev.net/articles/Combining_2_Images_in_Android_using_Canvas</a></p>
| android | [4] |
3,098,100 | 3,098,101 | Avoid using global variables and functions in Javascript | <p>How to alter the JavaScript code below so that it can avoid exposing the variables and functions to the global scope?</p>
<pre><code>var nMax = 10;
var i = 0;
var step = function(){
//do stuff
i += 1;
if(i < nMax){
step();
}else{
alert('finished');
}
}
step();
</code></pre>
<p>Ideally it would be grateful if the reason behind it could be provided.</p>
<p>Any idea would be very much appreciated!</p>
| javascript | [3] |
802,368 | 802,369 | Adding Map to collection of maps | <p>I have collection of maps.</p>
<pre><code>Collection<Map<String,Object>> xyz = (Collection<Map<String,Object>>) someMethod();
xyz.add(new HashMap<>());
</code></pre>
<p>If I try to add another map to this collection it gives me run time exception as</p>
<p>UnsupportedOperation.</p>
<p>What can be done?</p>
| java | [1] |
797,335 | 797,336 | jQuery: Finding an element | <p>I'm having trouble with this little thing. I have a code that looks like this:</p>
<pre><code><table>.........
<td>
<span class="editable" id="name"><?= $name ?></span>
<img class="edit_field" src="icons/edit.png"/>
</td>
.......
</table>
</code></pre>
<p>I want to obtain the id of the span, so that I can then change it (for example add an input box in it).</p>
<p>I have this:</p>
<pre><code>$('.edit_field').live('click', function() {
var td = $(this).parent();
var span = td.find(".editable");
alert(span.id)
});
</code></pre>
<p>But it's not working... Any ideas? (I'm trying to do it like this so it's reusable)</p>
| jquery | [5] |
604,668 | 604,669 | Is there possibility of sum of ArrayList without looping | <p>Is there possibility of sum of <code>ArrayList</code> without looping?</p>
<p>PHP provides <code>sum(array)</code> which will give the sum of array.</p>
<p>The PHP code is like</p>
<pre><code>$a = array(2, 4, 6, 8);
echo "sum(a) = " . array_sum($a) . "\n";
</code></pre>
<p>I wanted to do the same in Java:</p>
<pre><code>List tt = new ArrayList();
tt.add(1);
tt.add(2);
tt.add(3);
</code></pre>
| java | [1] |
4,168,404 | 4,168,405 | How do i hide the <h2> if the <h1> appears | <p>I'm working on a WordPress site that automatically displays an <code>h2</code> on the page as what the page/post is titled. I want to manually create <code>h1</code> for some pages and have the <code>h2</code> to be hidden if the <code>h1</code> appears. </p>
<p>Is there a way to do that?</p>
| php | [2] |
2,777,233 | 2,777,234 | How can I disable firebug in my webpage? | <p>How can I disable firebug using Javascript? I want to do this to hide the workings of my webpage from visitors. Is there any option to do this? </p>
| javascript | [3] |
4,011,940 | 4,011,941 | how to change time in the same line | <pre><code>int main()
{
time_t ltime;
time( &ltime );
tm * pTm = localtime(&ltime);
while(true)
{
for(int i=0;i<1000;i++)
{
if(i==999)
{
printf("Program time is: %02d:%02d:%02d \r", pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
i=0;
}
}
}
}
</code></pre>
<p>but it's not looping !!?</p>
| c++ | [6] |
3,589,293 | 3,589,294 | SSL Error on Https Request | <p>with Https request and using a DefaultHttpClient, i'm always getting an error :
NativeCrypto(20889): returned from sslSelect() with result 1, error code 2
What this means and how to fix it.
Thx.</p>
| android | [4] |
3,751,817 | 3,751,818 | Why is this consider bad practice? or is it? (ASP.Net) | <p>Would this code be considered bad practice:</p>
<pre><code><div id="sidebar">
<% =DisplayMeetings(12) %>
</div>
</code></pre>
<p>This is a snippet of code from the default.aspx of a small web app I have worked on. It works perfectly well, runs very fast, but as always, I am aware of the fact that just because it works, doesn't mean it is OK.</p>
<p>Basically, the DisplayMeetings subroutine outputs a bunch of formatted HTML (an unordered list actually), with no formatting, just the requisite html, and then my CSS performs all the necessary formatting.</p>
<p>The data for generating the list comes from an SQL server database (the parameter controls how many rows to return) and I am using stored procedures and datareader for fast access. This keeps my front-end extraordinary simple and clean, imho, and lets me do all the work in VB or C# in a separate module.</p>
<p>I could of course use a databound repeater (and probably 6 or more other methods) of accomplishing the same thing, but are they any better? Other than loosing the design-time features of VS2010?</p>
| asp.net | [9] |
196,959 | 196,960 | How can I use jQuery to get the value of a field and another field and send to ajax? | <p>How can I do an Ajax called based on a user updating a number in a text box?</p>
<p>I have something like the following. I removed surrounding code to make it easier to follow. I'm showing here two rows of a much larger grid.</p>
<pre><code> <div class="rep_tr0">
<div class="rep_td0" id="2">0001</div>
<div class="rep_td0"><input id="position_1" name="position_1" size="5" type="text" value="0" /></div>
</div>
<div class="rep_tr0">
<div class="rep_td0" id="2">0002</div>
<div class="rep_td0"><input id="position_2" name="position_2" size="5" type="text" value="0" /></div>
</div>
</code></pre>
<p>What I need is when the user makes a change to one of the input fields named "position_x" then I need to </p>
<pre><code>- get the value of the input field marked with "position_x"
- get the value that is stored in the div with id="x"
- make an ajax call passing the two parameters.
</code></pre>
<p>Note that x marks the row number. </p>
| jquery | [5] |
5,163,998 | 5,163,999 | How to find element type in JQuery | <p>I have an array with different elements inside it. Like array contain input elements and select elements. I want to check for particular type. I tried this but it didn't work</p>
<pre><code>var mandotaryElementsArray = $('.mandotary');
$.each(mandotaryElementsArray, function(index, element){
if (element == input) {
var $inputElement = $(this);
var test1;
} else if (element == select) {
var $selectElement = $(this);
var test2;
}
}); //end of .each()
</code></pre>
<p>Actually i want to check something that is similar to <strong>instance of</strong> in Java. Here i want to check if element is type of <strong>input</strong> then do this, if element is type of <strong>select</strong> then do this, if element is type of <strong>radiobutton</strong> then do this.. How can i make this check here?
Thanks </p>
| jquery | [5] |
498,012 | 498,013 | How to make a basic Forum Thread on my website? | <p>How to make a basic Forum Thread on my website ?
Like they click it shows the thread without going to a new page and what not.
EDIT*** Like the user he clicks something that says Thread or a Programming* and it shows all the posts and they may view that post as if it were on a whole new page without the Programming and thread just the post.</p>
| php | [2] |
190,436 | 190,437 | In php how to do session instances? | <p>I'm quite new on php and am trying to learn it.</p>
<p>My question is rather simple but I've been a bit lost while googling for it.</p>
<p>I just want to create an object to manage the database connection. I already did the object and now the problem I'm facing is:</p>
<p>How do i keep it instanced to a session? (So that i don't need to open/close the connection to the database on every page load) And how do I call it afterward?</p>
<p>Are there any way to declare a destroyer, so that when the instance is dying, the connection to the database gets closed?</p>
| php | [2] |
914,763 | 914,764 | Deriving time complexity of a function | <p>This following program is for searching two dimensional square array of positive integers with sorted rows and columns in non-decreasing order. The program returns true if target (value) element exist in array, false otherwise.
I need to design algorithm for this task which will be as efficient as possible.
I wrote this code, but i do not know how to derive the worst case run time complexity function using summations. I assume that the my solution is order O(n) in the worst case. but i do not know how to show it mathematically (using summations and etc). </p>
| java | [1] |
459,743 | 459,744 | How to use custom color for each textview in listview that extends SimpleAdapter in Android? | <p>I have a listview with custom rows and that extends SimpleAdapter.
Each row consist of two linear layouts : 1st having two textviews of which one is hidden in horizontal orientation, second having two textviews in horizontal orientation.
Now depending on the value in hidden textview , I want to setcolor for the remaining items for the row.
To put it as simple:
each listview item has some custom colors the value of which comes from the hidden field.</p>
<p>I have done this by overriding getview() for the simpleadapter and returning view for each, but this makes list very slow to render (and that I think is obvious as so much of work for each view before showing it). </p>
<p>Can I do this in some more efficient way ? like making views and then add up to list instead of using xml layout maybe one solution OR any other ? Any help ? Thanks.</p>
| android | [4] |
2,687,156 | 2,687,157 | Is there a way to assign an object property to an array? | <p>Pretty sure there is a way to do this but what I tried so far does not work</p>
<p>Consider we have an object $localDB with some properties, I was looking for a clean way to build the $connexionInfo array without casting $localDB or using a foreach loop.</p>
<pre><code>// This would be too easy if it worked
$connexionInfo = array( "UID" => $localDB->uid,
"PWD" => $localDB->pwd,
"Database" => $localDB->DB
);
// tried using {} a few different ways, also does not seem to work
$connexionInfo = array( "UID" => {$localDB->uid},
"PWD" => {$localDB->pwd},
"Database"=> {$localDB->DB}
);
</code></pre>
<p>I'm pretty sure there is a clean way to do this. Anyone?</p>
<p>UPdate:<br>
// Contrary to what I posted above ... this DOES actually do what it's supposed to!</p>
<pre><code> $connectionInfo = array("UID" => $localDB->uid, "PWD" =>$localDB->pwd, "Database"=> $localDB->DB);
</code></pre>
| php | [2] |
2,105,981 | 2,105,982 | Android List adapter with a button | <p>I need to implement a list with a custom list adapter view that contains a button.
Once I add the button the onClick is not triggered.</p>
<p>Is there a way to make this work?</p>
| android | [4] |
3,826,875 | 3,826,876 | PHP debugging + development tool? | <p>Is there a tool for PHP development that automatically displays helpful debugging information (maybe in a toolbar or something), such as $_POST data for form submission? I often find myself using error_log() or var_dump() to display information that I think would be handy to always have available without explicitly requesting it.</p>
| php | [2] |
2,425,591 | 2,425,592 | Javascript way to disable other script tags from executing? | <p>Is there a way to use JavaScript to "remove" a script tag from the DOM BEFORE the script tag gets a chance to execute.</p>
| javascript | [3] |
3,435,807 | 3,435,808 | Why does parseInt("014") come out to 12? | <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>It seems as though leading zeroes should just be ignored when parsing for an Int. What is the rationale behind this?</p>
| javascript | [3] |
4,063,311 | 4,063,312 | URL encoding problem | <p>I'm writing my first web application (still!), and have a problem activating user accounts.</p>
<p>The way I've got it set up is that the new user fills out a form with name, email address, and all that. They submit it, and my application sends a link to the email address they provide. They click that link, which passes (by way of a GET) a random code and their email address - activating their account.</p>
<p>In order to do some debugging, I thought I'd try this from different email services. Hotmail works, my own email works, but gmail doesn't. If you click on my 'activate' link in gmail, a 404 Not Found error pops up. So I've narrowed the problem down to how it encodes the link.</p>
<p>Here's the link in gmail (which doesn't work):</p>
<p>mywebsite.com/PHP+App+Files/App1/ln_activate.php?x=userx%40gmail.com&y=9c7b35bbdf1b0d24b0eda62f670c1456</p>
<p>When I change that one to this:</p>
<p>mywebsite.com/PHP%20App%20Files/App1/ln_activate.php?x=userx@gmail.com&y=9c7b35bbdf1b0d24b0eda62f670c1456</p>
<p>... it does work. I can see what the differences are, but why does gmail do that, and does anyone have any suggestions for a workaround?</p>
<p>Thanks!</p>
| php | [2] |
3,294,466 | 3,294,467 | Response.WriteFile | <p>There is one URL with specific syntax to download a file.<br>
<a href="http://www.hddownloader.com/?url=http://www.youtube.com/watch?v=N-HbxNtY1g8&feature=featured&dldtype=128" rel="nofollow">http://www.hddownloader.com/?url=http://www.youtube.com/watch?v=N-HbxNtY1g8&feature=featured&dldtype=128</a> </p>
<p>The user enters the file name in the textbox and presses the download button.In the click event the Response.WriteFile is called which sends the file to the client. </p>
<p>Now I want to create another website with a page, in which the user enters the filename and presses the download button to download that file. </p>
<p>Now I want to utilise the first URL for that. I dont want to use Response.Redirect, because by that way, the user will come to know that I am using mydownload.com. </p>
<p>How can I acheieve that. </p>
<p>One way is : When we download something from microsoft's website, a small popup window(with no close, maximise and minimise button) and then the save dialog box appears.</p>
<p>How to achieve this or another to achieve the same ?</p>
| asp.net | [9] |
2,526,978 | 2,526,979 | HTML tags in Content | <p>I'm implementing full text search on a table named as <code>tbljobs</code> on the cloumn named as <code>jobdescription</code>. In front end I'm getting html tags in the description. I'm showing the records in <code>GridView</code> and on <code>Gridview</code>'s <code>RowDataBound</code> enent I'm decoding the text. I'm using the following code on <code>Gridview</code>'s <code>RowDataBound</code> event:</p>
<pre><code>protected void GridNewlyPostedJobs_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string decodedText = HttpUtility.HtmlDecode(((Label)e.Row.FindControl("lblJobDescription")).Text);
((Label)e.Row.FindControl("lblJobDescription")).Text = decodedText;
}
}
</code></pre>
<p>But nothing works..!!</p>
| asp.net | [9] |
746,137 | 746,138 | Standard add-contact form | <p>Is there a standard add contact form available for someone to use in the sdk?</p>
| iphone | [8] |
1,905,968 | 1,905,969 | iPhone SDK: Avoid Blank screen while launching my application | <p>I am retrieving some data from server when launching my application itself. So whenever launch my application it shows a blank screen for few seconds(means it is downloading data from server) and then launches the first view. I don't want to show the blank screen to user. I want to add an image and activity indicator there.
Please route me into right direction to capture this task.</p>
<p>I appreciate your helps.</p>
<p>thanks.</p>
<p>Clave/</p>
| iphone | [8] |
1,939,493 | 1,939,494 | how to get method argument list from mangled name? | <p>I have following information in cobertura.xml </p>
<pre><code><method name="visitNode"
signature="(Lchs/cof/drawplus/IJoint;Lchs/cof/logical/schem/ISegment;Lchs/analysis/GraphServices$IGraphVisitor;I)Z"
</code></pre>
<p>The signature is java's mangled name for the method. (<a href="http://asm.ow2.org/doc/faq.html#Q7" rel="nofollow">http://asm.ow2.org/doc/faq.html#Q7</a>)</p>
<p>How can I construct the method argumentlist, which was like below.</p>
<pre><code> boolean visitNode(drawplus.IJoint root,
schem.ISegment segmentBefore,
IGraphVisitor visitor,
int branch)
</code></pre>
<p>Is there a library which can do this de-mangling? </p>
| java | [1] |
4,651,318 | 4,651,319 | Data reading and storing in c#, (Concept..no code) | <p>I want to translate my Matlab code (least squares plane fitting) into C#.
I have many problems in understanding c#.
Let me ask here.
Reading a text file and storing data in xyz format in matrix (e.g., xyzdata= xyz) in Matlab is quite easy.
Translating it into CSharp?
How can I read [x y z] without knowing length of file and how can I store it in Matrix form?
Thank you very much for your help and If someone has plane fitting code / link, please guide me.</p>
| c# | [0] |
668,616 | 668,617 | Multiple photo select uisng UIImagePickerController | <p>How to select multiple photos from photo album using <code>UIImagePickerController</code> ?</p>
| iphone | [8] |
3,903,333 | 3,903,334 | Image to byte array from a url | <p>I have a hyperlink which has a image, i need to read/load the image from that hyperlink & assign it to a byte array (byte[]) in C#</p>
<p>Thanks.</p>
| c# | [0] |
3,607,842 | 3,607,843 | By clicking on cancel in confirm box close my parent window . I want that on cancel it should be on same page | <p>Clicking on cancel in confirm box closes my parent window. I want that on cancel it should stay on same page. I have written the following code for it.</p>
<pre><code>function closeEditorWarning(){
var r=confirm("This will close all the opened windows of application.Do you want to continue.");
if (r==true)
{
for (var i=0;i<childWindow.length;i++) {
if (childWindow[i] && !childWindow[i].closed)
childWindow[i].close();
}
self.close();
}
else
{
}
}
window.onbeforeunload = closeEditorWarning;
</code></pre>
| javascript | [3] |
4,158,801 | 4,158,802 | Need a simple python script to divide a text file (based on the first row) | <p>OK, I should've learned python ages ago, but didn't. Now I need a script to divide a text file into multiple text files.</p>
<p>The output files have to be exactly the same as the input, except they should only contain subsets of the information, based on the values in the first row.</p>
<p>So, if I have a file specifying "Sample1" in the first row, all the columns marked Sample1 should become a new file, the same for "Sample2", "Sample3", etc.</p>
<p>Here's an example of what I mean...</p>
<p>Input file: <a href="https://docs.google.com/open?id=0B9o3EYTdM8lQT0oyZkVVM3RUVUk" rel="nofollow">https://docs.google.com/open?id=0B9o3EYTdM8lQT0oyZkVVM3RUVUk</a></p>
<p>Output: <a href="https://docs.google.com/file/d/0B9o3EYTdM8lQajNoU0JvR0dMSmc/edit?pli=1" rel="nofollow">https://docs.google.com/file/d/0B9o3EYTdM8lQajNoU0JvR0dMSmc/edit?pli=1</a></p>
<p>Any help would be great. Cheers</p>
| python | [7] |
1,157,315 | 1,157,316 | When dealing cards over the internet, is it better to distribute seed values or actual objects? | <p>I am working on a spades game that connects players over the internet, but I don't know how I should distribute the cards to players:</p>
<ul>
<li><p>If I send the seed values for the SecureRandom object used for shuffling to each player, they could theoretically sniff their own traffic for the values and look at the source code to create their own program that deals the cards similarly;</p></li>
<li><p>But if I use the dealer-player's machine to deal the cards and send them to the other players, the dealer could theoretically cheat.</p></li>
</ul>
<p>Sending seed values would decrease the amount of data sent over the internet, but sending the actual cards would seem to make it harder to cheat. I've thought about making my own trusted third-party server that the dealer-player would send their seed values to and would send the cards to the other players, but that would require setting up an EC2 instance and I have no idea how to even begin to do that.</p>
<p>Or am I overthinking this a bit?</p>
| java | [1] |
2,777,726 | 2,777,727 | {Object|Array|Anything} to string with respect to recursion limit in PHP? | <p>Is there a straightforward way in PHP to get an arbitrary complex value into a string without triggering recursion limits? For example, passing an hugely nested object and specifying I want only 2 levels deep. </p>
<p>What I want to avoid is getting an error on var_export or var_dump, even if that means that I get less accurate output.</p>
<p>Thanks!</p>
<p>Clarification: I want to use the string for logging usage, so debuggers are not applicable.</p>
| php | [2] |
259,793 | 259,794 | Pass href to jquery | <p>I use the following code to open external pages within a div on the current page:</p>
<pre><code>$(document).ready(function(){
$("#content").load("content.html");
});
(function($) {
$(function() {
$('.load_link').click(function() {
$("#content").load($(this).attr('href'));
var $row = $(this).closest("tr");
$row.removeClass("rownotselected").addClass("rowselected");
$row.siblings("tr").removeClass("rowselected").addClass("rownotselected");
return false;
});
</code></pre>
<p>Then for the actual link:</p>
<pre><code><a href="content2.html" class="load_link">Link text</a>
</code></pre>
<p>The links are displayed in a table and I like to be able to make the whole row clickable to open the link rather than just the text. Previosuly I only had one page to load so I hard coded the page name in the function and just opened it whenever the row was clicked with the following code:</p>
<pre><code><tr class="rownotselected load_link" style="cursor:pointer;">
</code></pre>
<p>However now there are multiple rows that need to be clickable which point to different pages, so I need to be able to pass the href value to the function via the above method in the same way as I do for a regular link. Is this possible? </p>
<p>I hope I've made the question clear, please do let me know if not.</p>
<p>Thanks in advance for any help!</p>
| jquery | [5] |
3,339,382 | 3,339,383 | Create a file from drawable | <p>I have a large number of resources in my drawable folder.All are having big size more than 500KB. I have to load all these 25 images all at once in a srollView. As usual I ran out of memory. Is there any way to reduce the size of the image programmatically.</p>
<p>I got this function but it's parameter is a File and I don't know how to create a File from a drawable.</p>
<pre>
private Bitmap decodeFile(File f){
Bitmap b = null;
try {
//Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
FileInputStream fis = new FileInputStream(f);
BitmapFactory.decodeStream(fis, null, o);
fis.close();
int scale = 1;
if (o.outHeight > IMAGE_MAX_SIZE || o.outWidth > IMAGE_MAX_SIZE) {
scale = Math.pow(2, (int) Math.round(Math.log(IMAGE_MAX_SIZE / (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5)));
}
//Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
fis = new FileInputStream(f);
b = BitmapFactory.decodeStream(fis, null, o2);
fis.close();
} catch (FileNotFoundException e) {
}
return b;
}
</pre>
<p>I have to go thorugh this screen cyclically many times after a number of traversal the system is showing Low memory and it is removing the other views in the back from the stack , but I actually need it.
Please help me.</p>
| android | [4] |
1,066,990 | 1,066,991 | Seeing a blank page on running Install.php? | <p>I am running on localhost the installation of a php based website. I got the following error</p>
<pre><code>Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\testweb\install\install.php on line 65
</code></pre>
<p>Line 65 has </p>
<pre><code>$Install =&new INSTALL();
</code></pre>
<p>I was told to remove the & have line 65 read <code>$Install =new INSTALL();</code> but then when I run install I just see a blank page and nothing more than that. Can somebody throw some light on this as to what is happening here and why I am seeing just a blank page. </p>
<p>My php version is 5.3.3 and I am running this on WAMP. </p>
| php | [2] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.