Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
4,220,291 | 4,220,292 | Initiate a pairing with a BT device like BluetoothSettings does | <p>i searched and searched, is there any generic way to initiate the paring sequence just like BluetoothSettings does ?</p>
<p>i've looked at android platform source code and most flows are set to "hide". for example, createBond() function in bluetooth device..</p>
<p>please help ... </p>
<p>btw, any trick to remove the 'hide' and just use the code </p>
<p>android : 2.3.3</p>
| android | [4] |
4,951,874 | 4,951,875 | How to find the name of the parent class, within a base class in C#? | <p>I inherit a class from a base class "MyLog". </p>
<p>If I call "Write" within the inherited class, I want it to prefix any messages with the name of the inherited class.</p>
<p>As this application needs to be fast, I need some way of avoiding reflection during normal program operation (reflection during startup is fine).</p>
<p>Here is some code to illustrate the point:</p>
<pre><code>class MyClassA : MyLog
{
w("MyMessage"); // Prints "MyClassA: MyMessage"
}
class MyClassB : MyLog
{
w("MyMessage"); // Prints "MyClassB: MyMessage"
}
class MyLog
{
string nameOfInheritedClass;
MyLog()
{
nameOfInheritedClass = ?????????????
}
w(string message)
{
Console.Write(nameOfInheritedClass, message);
}
}
</code></pre>
| c# | [0] |
2,864,645 | 2,864,646 | Download and save a file using Java | <p>Let's say I have an URL, like something.domain/myfile.txt then I want to save this file, with that "Save File" dialog.</p>
<p>I tried my best to do it, but everytime I save the file using the dialog the file is not there.</p>
<p>An example or somewhere I can find information on this would help a lot!</p>
<pre><code> URL website = null;
try {
website = new URL(<insert url here>);
} catch (MalformedURLException e) {
e.printStackTrace();
}
ReadableByteChannel rbc = null;
try {
rbc = Channels.newChannel(website.openStream());
} catch (IOException e2) {
e2.printStackTrace();
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File("minecraft.jar"));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
try {
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
} catch (IOException e) {
e.printStackTrace();
}
JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showSaveDialog(fileChooser) == JFileChooser.APPROVE_OPTION) {
File dir = fileChooser.getCurrentDirectory();
dir.mkdir();
//After this point is where I need help.
</code></pre>
| java | [1] |
3,508,501 | 3,508,502 | XML string/array Comparison | <p>I'm trying to match the indexes from "filename" and "filesize" with the ones from "xml". They contain filesize and names. I need to match them up in an if statment. I'm stuck though, and have no idea how to proceed.</p>
<pre><code> public static void APB()
{
ArrayList filename = new ArrayList();
ArrayList filesize = new ArrayList();
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
var files= directory.GetFiles("*", SearchOption.AllDirectories);
long fnd = 0;
foreach (var file in files)
{
filename.Add(file.FullName);
filesize.Add(fnd += file.Length);
}
ArrayList xml = new ArrayList();
XmlTextReader reader = new XmlTextReader(dictonary.launcher);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
xml.Add(reader.Name);
while (reader.MoveToNextAttribute())
xml.Add(reader.Name + "=" + reader.Value);
break;
}
}
}
</code></pre>
| c# | [0] |
2,818,628 | 2,818,629 | How can I support airview for Note II users in my application? | <p>I want to support the airview feature in my application for Note II users, and I have no idea how from where should I start.</p>
<p>I already did a google search, but I found nothing.</p>
| android | [4] |
457,753 | 457,754 | In Javascript does a recursive function release it's resources once it has hit the base case and starts moving back down the stack? | <p>That is, should you care about returning objects inside of a recursive function if you don't even reference the object until the very bottom of the stack?</p>
| javascript | [3] |
2,778,748 | 2,778,749 | Capturing console output from proc_open | <p>I'm using proc_open to launch a telnet session connecting to a server program.
Connection is ok but when I get the reply, I can't store the whole string on a file as it is cut after some chars.</p>
<p>Here is my snippet: </p>
<pre><code>$descriptorSpec = array( 0 => array( "pipe", "r" ),
1.=> array( "file", $logPath, "w" ) );
$process = proc_open( "telnet localhost 2323", $descriptorSpec, $pipes );
fwrite( $pipes[0], "helo" . PHP_EOL );
fwrite( $pipes[0], "quit" . PHP_EOL );
</code></pre>
<p>I've also tried using netcat and exec: </p>
<pre><code>exec( "echo \"helo quit\" | netcat localhost 2323 >> $logPath" );
</code></pre>
<p>but I had the same result.</p>
<p>If I run the telnet/netcat command from the console, I get the whole string on stdout but if I try to redirect it to another file I get the same prob as above.</p>
| php | [2] |
5,779,715 | 5,779,716 | why my asp.net application design can be vary with system to system ?how to acheive this? | <p>i developed one asp.net application.i published the application in iis server.then by using that url i am testing the application in my system the design is coming fine.But in other systems the design is vary.both the systems are having IE8 Browser and both are same versions.</p>
<p>why the designing is vary can u pls let me know.</p>
<p>and also button styles all are different changing in system to system.</p>
| asp.net | [9] |
864,977 | 864,978 | Make subcategories in template script | <p>I really need help with a script i have bought, the script has some categories, but i also need sub categories, so i added an extra field in the table traffic_categories. The original traffic_categories has id and category, but i have added sub_id also, so if the category is a main category it has 0 in sub_id, but if the category is a sub category it has the main category id in the sub_id field.. Simple..</p>
<p>The problem is the script hava an advanced template system i can´t figure out how works.
Here is the script that gets the categories from mysql:</p>
<pre><code>$result = mysql_query('SELECT category FROM traffic_categories WHERE sub_id = 0 ORDER BY category ASC;');
$iCat=2;
$CONF['categories'] = array(); $TMPL['cats'] = '';
while(list($TMPL['cat']) = mysql_fetch_row($result)) {
$TMPL['cath'] = str_replace(' ', '+', $TMPL['cat']);
$TMPL['cats'] .= base::do_skin('menu/cats');
$CONF['categories'][] = $TMPL['cat'];
$TMPL['last'] = $iCat++ % 4 === 0 ? ' last' : '';
}
</code></pre>
<p>and here is cats.html:</p>
<pre><code><div class="one-fourth{$last}">
<h5><a href="/cat/{$cath}">{$cat}</a></h5>
<ul class="categoryList">
Here i want the subcategories--><li> - <a href=""></a></li>
</ul>
</div>
</code></pre>
<p>and in my frontpage.html where the categories will be showed is just {$cats}.</p>
<p>So if someone please can help me show the subcategories inside the list in cats.html where is have written "Here i want the subcategories-->", then i will be really glad, thanks.</p>
| php | [2] |
2,382,505 | 2,382,506 | Anything similar to LINQ in Java? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/50135/linq-to-java">LINQ to Java?</a> </p>
</blockquote>
<p>coming from .Net world, so ask. particularly to operate on collections.</p>
| java | [1] |
353,214 | 353,215 | UserControl Property Changing | <p>I have created a User Control(Popupcontrol) and in that control i have created a property(PageType) and when i am using the Popupcontrol on the page then i set the property(pagetype) according to the page.
but now there is some problem i have to two button on the page and on the second button click i want to change the pagetype property .So is there any solution for the same.</p>
| asp.net | [9] |
5,573,576 | 5,573,577 | converting a ssh command to python | <p>I am trying to convert the below ssh command to python code,I was able to convert to python but the python code doesnt give any output,so i think i did not convert it properly especially the boolean "AND" logic..can anyone point what is wrong here?</p>
<pre><code>ssh -p 29418 company.com gerrit query --current-patch-set --commit-message --files 'status:open project:platform/code branch:master label:Developer-Verified=1 AND label:Code-Review>=1'
</code></pre>
<p>Python code:-</p>
<pre><code>with open(timedir + "/ids.txt", "wb") as file:
check_call("ssh -p 29418 company.com "
"gerrit query --commit-message --files --current-patch-set "
"status:open project:platform/code branch:master label:Developer-Verified=1 AND label:Code-Review>=1 |"
"grep refs |"
"cut -f4 -d'/'",
shell=True, # need shell due to the pipes
stdout=file) # redirect to a file
</code></pre>
| python | [7] |
5,998,028 | 5,998,029 | Parameter losing value when passed | <p>I'm sure this is something simple but I've been staring at it for a bit now and I think all I need is a fresh pair of eyes to look at it, and since my cat doesn't have a whole lot of experience with iPhone programming I've turned to you.</p>
<p>I am passing a variable of type float from a class (UIView) to another class (UIViewController) right before the variable is passed it's value is correct but when it reaches the function it loses it's value, it's shown to be 0 or -2 and I'm not sure why. Like I said I'm sure it's something simple but I just need a fresh pair of eyes to look at it</p>
<p>Code is below</p>
<pre><code> //inside UIView
-(void)UpdateFloat
{
myFloat = myFloat + 0.01;
}
-(void)RemoveView
{
//Function Call
[viewController myFunction:myFloat];
}
//Function
-(void)myFunction:(float)myFloat
{
[myView removeFromSuperview];
[self.view addSubview:myOtherView];
[myOtherView anotherFunction:myFloat];
</code></pre>
<p>}</p>
<p>the float gets updated by a timer and when the UIView makes the function call the value of the float is correct (usually about 15.67)</p>
<p>any help would be appreciated</p>
<p>Thank you in advance,
BWC</p>
| iphone | [8] |
4,257,539 | 4,257,540 | Memory Leak Problems with UIImagePickerController in iPhone | <p>I am using the following code for UIImagePicker,</p>
<pre><code>UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
</code></pre>
<p>When I run instrument, I see a memory leak on the first line of the code. Though I am releasing it, still its showing memory leak, does anyone have any idea where am I going wrong.</p>
<p>I installed the iPhoneCoreDataRecipes Application from iPhone Developers Sample Code help and it is having the same problem.</p>
| iphone | [8] |
264,134 | 264,135 | School Assignment. C++ Book Example seems to have issues | <p>The following code is part of a slide in my C++ Class. IntelliSence is giving me errors and I don't know why. Not sure why it doesnt like the Constructor and Destructor. Can Someone please Help?</p>
<pre><code>class Vehicle {
friend void guest();
private:
string make;
string model;
int year;
public:
void Vehicle();
void Vehicle(string, string, int);
void ~Vehicle();
string getMake();
}
void guest() {
cout << make;
}
1) IntelliSense: member function with the same name as its class must be a constructor
2) IntelliSense: member function with the same name as its class must be a constructor
3) IntelliSense: return type may not be specified on a destructor
</code></pre>
| c++ | [6] |
5,686,669 | 5,686,670 | BaseAdapter not allow INTENT action | <p>An extended class with <code>BaseAdapter</code> will not allow me to jump from one activity to the second ::
it give me syntax error :: </p>
<pre><code>holder.capture.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
intent_request = new Intent(this, SaxParser2.class);
}
</code></pre>
<p><strong>Screen</strong> </p>
<p><img src="http://i.stack.imgur.com/tmXmp.png" alt="enter image description here"></p>
| android | [4] |
3,555,349 | 3,555,350 | What is the use of Public Key in Android developer console? | <p>I have signed my android application with keytool but don't know what to do with public key in my android developer console..</p>
| android | [4] |
1,119,590 | 1,119,591 | Is this the right way to set this up for selection in jquery | <p>Is this the right way to select an element, it seems to work but looks really ugly code wise</p>
<pre><code>$(this).parent().parent().siblings('.photoWrap');
</code></pre>
| jquery | [5] |
3,774,050 | 3,774,051 | Android - How to add a View progamatically to an Activity's Absolute Layoute setting it's possition? | <p>I have a form with several Views on it, the last one is a Spinner that is bound to an adapter to get it's data from a Web Server via a POST request, at the end I append an additional entry for "Other...". If this option is selected on the spinner, a new EditText View at the bottom where the user enters a custom value, I've managed to get the EditText View to show on the screen, but it's positioned at the very top, over my other Views and I can't seem to find the way to make it appear at the bottom, below the Spinner as I want it to, here is the code I have so far:</p>
<pre><code>EditText suggestCarrierField = new EditText(getBaseContext());
suggestCarrierField.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
suggestCarrierField.setHint("Suggest your carrier");
((AbsoluteLayout) findViewById(R.id.createAccountView)).addView(suggestCarrierField);
((AbsoluteLayout) findViewById(R.id.createAccountView)).invalidate();
</code></pre>
| android | [4] |
1,150,862 | 1,150,863 | jQuery how to use .find | <pre><code><table id="myTable">
<tr id="myRow1">
<td>hi</td>
<td>hello</td>
<td>comeon</td>
</tr>
</table>
</code></pre>
<ol>
<li><p>In the above scenario, what's the difference between</p>
<p><code>$("#myTable").find('tr')</code></p>
<p>and</p>
<p><code>$("#myTable").find('tr')[0]</code> or <code>$("#myTable").find('tr').get(0)</code>?</p></li>
<li><p>Also given <code>$("#myTable").find('tr')[0]</code>, how do I get the number of <code>td</code>s under it?</p></li>
</ol>
<p>Thanks.</p>
| jquery | [5] |
2,990,557 | 2,990,558 | How do i get the full path of the file in Firefox | <p>How do i get the full path of the file in Firefox with JavaScript?</p>
<p>Thanks in advance!</p>
| javascript | [3] |
2,093,198 | 2,093,199 | asp.net form submitted twice | <p>I have a web page with a form and a submit button, and in the server side I used a session value to prevent the form submit twice, which is like the initial value of the session is 0 and turn it to 1 after user click submit button, every time submit button will check the session value first. </p>
<p>But, when our project published, I found there were two records for the same person (which means they submit twice I guess, and it didn't happen very often maybe on one or two persons), and the time interval between these two records is very small, like 0.3 second, so first I thought they might double click the submit button, but after I tried on my computer, it still only insert one record into the database</p>
<p>I am confused how does this happen, and how to prevent it?</p>
<p>Here is the code:</p>
<pre><code> protected void Page_Init(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["IsBackForwordPayment"] = 0;
}
}
protected void submit_Click(object sender, EventArgs e)
{
if (Session["IsBackForwordPayment"] != null && Session["IsBackForwordPayment"].ToString() != "0")
Response.Redirect("~/pages/renewal/duplicaterenewal.aspx");
.......
}
</code></pre>
<p>Is it possible because that after checking the session value the program just redirect to another page but not terminate the submit process ??</p>
| asp.net | [9] |
935,855 | 935,856 | Filesize checks for integrity checks | <p>Hey I'm wanting to have an integrity check on a software that will be distributed to many different types of servers. Can I use PHP's filesize() comparisons safely... for example will a filesize that is 745 on my server be 745 across all other servers?</p>
| php | [2] |
2,799,661 | 2,799,662 | Changing Style Sheet javascript | <p>I got this HTML code:</p>
<pre><code><head>
<script type="application/javascript" src="javascript.js">
<link id="pagestyle" href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<button id="stylesheet1" > Default Style Sheet </button>
<button id="stylesheet2" > Dark Style Sheet </button>
</body>
</code></pre>
<p>And in javascript.js I got this:</p>
<pre><code>function swapStyleSheet(sheet) {
document.getElementById("pagestyle").setAttribute("href", sheet);
}
function initate()
{
var style1 = document.getElementById("stylesheet1");
var style2 = document.getElementById("stylesheet2");
style1.onclick = swapStyleSheet("default".css);
style2.onclick = swapStyleSheet("dark".css);
}
window.onload = initate;
</code></pre>
<p>I want to the style sheets to change while pressing this buttons. I can't figure out why it is not working. </p>
| javascript | [3] |
1,331,148 | 1,331,149 | Find out if checkbox is checked using jQuery | <p>I've read lots of other posts on SO from people with the same problem, everything I have tried so far has not worked.</p>
<p>I have HTML like so:</p>
<pre><code><ul>
<li class="templateList">
<input id="ctl00_MainContent_newCollection_wzd_lstSiteTypes_ctr10_chkSite" type="checkbox" checked="checked" name="ctl00$MainContent$newCollection$wzd$SiteTypes$ctrl0$chkSite">
<div></div>
</li>
<li>
...
</li>
</ul>
</code></pre>
<p>Using jQuery I need to find all the checkboxes in the UL that are checked, then add a CSS class to the LI parent element called "selected". This is what I have so far:</p>
<pre><code> $(".templateList input:checkbox").each(function () {
var chk = $(this);
alert($(chk).attr("checked"));
if (chk.attr("checked")) {
... do something ...
}
});
</code></pre>
<p>The alert satement is for debug - it always says "undefined".</p>
<p>This is so simple but is driving me nuts!</p>
| jquery | [5] |
446,119 | 446,120 | How to create Yahoo Messenger Client in Android? | <p>Hi
I am trying to create Yahoo messenger client in Android, and i got Openymsg api to implement that.This is small snippet of my code</p>
<pre><code> Session session=new Session();
session.login("Email Id", "password");
</code></pre>
<p>But this code is throwing UnknownHost Exception in "scs.msg.yahoo.com".I dont know how to fix this.If any body knows it please help me.</p>
| android | [4] |
708,186 | 708,187 | What is the difference between object keys with quotes and without quotes? | <p>Is there any difference between</p>
<pre><code>obj = {'foo':'bar'}
</code></pre>
<p>and</p>
<pre><code>obj = {foo: 'bar'}
</code></pre>
<p>I have noticed that you can't use <code>-</code> in the key when you don't use the quotes. But does it actually make a difference? If yes, what is it?</p>
| javascript | [3] |
4,709,072 | 4,709,073 | Bypassing a requiredfieldvalidator | <p>I have a webform which has validators on it that work well when the user presses the submit button. But when the user presses the logout button the validators stop that button from working.</p>
<p>Any suggestions as to how remedy this?</p>
| asp.net | [9] |
214,515 | 214,516 | Can one make Python constructors more concise? | <p>My python code has a class from which instantiates objects representing countries. The class has a constructor.</p>
<pre><code>class Country:
def __init__(self, population, literacy, firms, area, populationDensity):
self.population = population
self.literacy = literacy
self.firms = firms
self.area = area
self.populationDensity = populationDensity
</code></pre>
<p>Is there a way to make this code more concise? Here is the pseudocode for what I am seeking.</p>
<pre><code>class Country:
def __init__(self, population, literacy, firms, area, populationDensity):
# assign object these properties in one line
</code></pre>
<p>Thank you.</p>
| python | [7] |
1,423,965 | 1,423,966 | Increment current Date by two days | <p>i want to increment todays date (Present date) by 2 days because I need to use it to be sending reminders two days before an appointment.</p>
| java | [1] |
4,392,600 | 4,392,601 | PHP Blank Values Inserted In Database | <p>I'm using PHP and Mysql</p>
<p>Here I have used simple form to insert the Name, Email, Phone Number.</p>
<p>I have validated all the data's: (PHP code after submit...)</p>
<pre><code>$error = array();
if(isset($_POST['Name']) && $_POST['Name']=='') {
$error[] = "Please enter the Name";
}
if(isset($_POST['Email']) && $_POST['Email']=='') {
$error[] = "Please enter the Email";
}
if(isset($_POST['Phone']) && $_POST['Phone']=='') {
$error[] = "Please enter the Phone";
}
</code></pre>
<p>Finally Insert the data using the below query..</p>
<pre><code>if(count($error)==0) {
$error= "";
And the query is
insert into mytab ('Name','Email','Phone') Values (mysql_escape_string($_POST['Name']),mysql_escape_string($_POST['Email']),mysql_escape_string($_POST['Phone']));
redircet to success..
}
</code></pre>
<p>It's Works fine, But Some time i am geting Insert $error log like the below..</p>
<p>error Log : </p>
<pre><code> Time File name:myfile.php Insert $error: insert into mytab ('Name','Email','Phone') Values('','','');#~#
</code></pre>
<p>The log i was write using my db wrapper class (using mysql_$error())</p>
| php | [2] |
1,959,845 | 1,959,846 | What method is the easiest/fastest way for developing Android Apps | <p>Which one of these is the easiest/fastest choice for developing simple Android apps/games? I'm familiar with all this technologies.</p>
<pre><code> • Android SDK or NDK
• C# on MonoDroid platform
• Adobe Flash & Adobe AIR
• Corona SDK
• Converting tools like PhoneGap
</code></pre>
<p>Fundamentally, Could you explain adventages and disadventages of this methods.</p>
| android | [4] |
3,068,429 | 3,068,430 | image change or disable on click | <p>i have a image on my site that work as like button when some one click on it page will be refresh and add 1 in like box.now i want that after click on it once after adding 1 in like count box and page refresh image will be hide or link will remove.please help any one?
here is the button code</p>
<pre><code> <div class="code_large" style="margin-top:10px;">
<img src="images/more_img_large.jpg" hspace="5" align="absmiddle" />
<span>
<?php echo $value['love_it']; ?></span><span style=" line-height:30px; margin-left:55px;">
<a href="index.php?option=com_shopsearch&task=loveit&shop_id=<?php echo $value['shop_id']; ?>">
<img src="images/love_it.jpg" alt="Love it" width="106" name="loveit" id="Image9" height="28" onClick="multiclick();" />
</a>
</code></pre>
| php | [2] |
4,827,794 | 4,827,795 | ListViewItem in WPF ListView | <p>I'm attempting to get the ListViewItem object from the currently selected row of a data bound ListView, like so:</p>
<pre><code>ListViewItem selectedItem = new ListViewItem();
selectedItem = (ListViewItem)listView1.Items[index];
</code></pre>
<p>what this does however, is returns the object type the ListView is bound to, in this instance, its a company class object for a database. What I would like it to return is the actual ListViewItem object itself (so that I can access its properties).</p>
<p>is there anyway to do this?</p>
<p>thanks</p>
| c# | [0] |
1,117,707 | 1,117,708 | how to access label control in repeater for perticular row | <p>i have to set label visibility true or false in repeater. I have to access that label on onclick event of linkbutton. both label and linkbutton are in repeater. so when i click on hide link button i have to hide label and when click on show i have to display.but i didn't get label control of that perticular. onclick event of linkbutton only perticular row should change. </p>
<pre><code> protected void lnkshow_onclick(object sender, EventArgs e)
{
LinkButton lnkshow = (LinkButton)sender;
//RepeaterItemCollection rc = rList.Items;
int intSOid=Convert.ToInt32(lnkshow.CommandArgument);
// update flag into database as hide or show
string flag = ARIData.updateIntoInvoiceItemsTable(intSOid);
if (flag == "Y")
{
lnkshow.Text = "Show";
}
else
{
lnkshow.Text = "Hide";
}
RepeaterItemCollection rc = rList.Items;
Label lbreakdown = default(Label);
foreach (RepeaterItem Item in rc)
{
lbreakdown = (Label)Item.FindControl("lBreakdown");
if (flag == "Y")
{
lbreakdown.Visible = false;
}
else
{
lbreakdown.Visible = true;
}
}
}
</code></pre>
<p>this code changes whole rows.</p>
| c# | [0] |
1,655,684 | 1,655,685 | How to achieve autoFit on columns which are merged for an excel sheet generated by POI? | <p>I am novice developer, i am using POI 3.6 for generating ExcelSheet. How to achieve autofit for the columns which are merged - sheet.autoSizeColumn(columnNumber) is not working on columns which are merged?</p>
| java | [1] |
4,039,347 | 4,039,348 | Repeat Python function call on exception? | <p>Hey everybody I'm working on a data scraping project and I'm looking for a clean way to repeat a function call if an exception is raised.</p>
<p>Pseudo-code:</p>
<pre><code>try:
myfunc(x)
except myError:
###try to call myfunc(x) again Y number of times,
until success(no exceptions raised) otherwise raise myError2
</code></pre>
<p>I realize this isn't best practice at all but I'm working through a number of different code/network layers that aren't reliable and I can't realistically debug them.</p>
<p>Right now I'm accomplishing this with a huge set of try\except blocks and it's making my eyes bleed.</p>
<p>Elegant ideas anyone?</p>
| python | [7] |
3,732,921 | 3,732,922 | Alternative to PHP deprecated function session_is_registered() for logout.php file | <p>I'm trying to create a simple member login site, and I was following along with a tutorial online. However, a deprecated function is used. Here is the code.</p>
<pre><code><?php
session_start();
session_destroy();
if(isset($_COOKIE['id']))
{
//remove cookie
setcookie("$id_cookie", '', time() - 50000);
setcookie("$pass_cookie", '', time() - 50000);
}
if(!session_is_registered('username'))
{
header("Location: index.php");
}
else
{
exit('Sorry we could not log you out');
}
?>
</code></pre>
<p>I also tried <code>!isset($_SESSION['username'])</code>, but every time I try to log out, I just receive the 'Sorry we could not log you out' text.</p>
<p>Here is the part of my login.php file code where I set the sessions:</p>
<pre><code>//member does exist, start sessions
$_SESSION['password'] = $password;
while($row = mysql_fetch_array($query))
{
$username = $row['username'];
$id = $row['id'];
}
$_SESSION['username'] = $username;
$_SESSION['id'] = $id;
</code></pre>
<p>Any help would be great! </p>
| php | [2] |
4,313,344 | 4,313,345 | Extract IFrame source using JavaScript | <p>I have a simple HTML/PHP web page and one IFrame in it. The IFrame contains links to external web sites.</p>
<p>I need some JavaScript that will extract the exact URL of the web page that is currently displayed inside the IFrame (not just the base URL of the external site). How can this be done?</p>
| javascript | [3] |
1,194,836 | 1,194,837 | JavaScript loop running indefinately | <p>so, i am trying to get my script to figure out the relevant last day of the school term. it needs to run until the current date is less than (as in before) the last day of the quarter. it just keeps on running no matter what. ps, i think the problem might be that it isnt resetting the "lastDayofQuarter" (at least outside of the loop). How can i circumvent this? thanks a ton!</p>
<pre><code>var today = new Date();
var lastDayofQuarter=new Date();
var lastDaysofQuarter=new Array();
lastDaysofQuarter[0]=(2009,11,3);
lastDaysofQuarter[1]=(2010,11,10);
lastDaysofQuarter[2]=(2011,4,18);
lastDaysofQuarter[3]=(2011,5,10);
lastDayofQuarter.setFullYear(lastDaysofQuarter[0]);
i=0;
while (lastDayofQuarter<today) {
lastDayofQuarter.setFullYear(lastDaysofQuarter[i]);
i++;
}
</code></pre>
| javascript | [3] |
1,007,372 | 1,007,373 | Can we have only Finally block with out Try and Catch? | <blockquote>
<p><strong>Can we have only Finally block with out adding Try and Catch block?</strong></p>
</blockquote>
| java | [1] |
31,252 | 31,253 | Get the child controls with type T of a control | <p>I have the following function to get all the child controls of type.</p>
<pre><code> private IEnumerable<Control> GetControlsOfType(Control control, Type type)
{
var controls = control.Controls.Cast<Control>();
return controls.SelectMany(ctrl => GetControlsOfType(ctrl, type))
.Concat(controls)
.Where(c => c.GetType() == type);
}
</code></pre>
<p>I am trying to convert it using generic type parameter.</p>
<pre><code> private IEnumerable<T> GetControlsOfType<T>(Control control) where T: Control
{
var controls = control.Controls.Cast<Control>();
return controls.SelectMany(ctrl => GetControlsOfType<T>(ctrl))
.Concat(controls)
.Where(c => c.GetType() == T);
}
</code></pre>
<p>The code has the error on <code>.Concat</code>.</p>
<blockquote>
<p>Error 6 'System.Collections.Generic.IEnumerable<code><T</code>>' does not contain a
definition for 'Concat' and the best extension method overload
'System.Linq.Queryable.Concat<code><TSource</code>>(System.Linq.IQueryable<code><TSource</code>>,
System.Collections.Generic.IEnumerable<code><TSource</code>>)' has some invalid
arguments</p>
</blockquote>
<p>How to fix the issue?</p>
| c# | [0] |
1,537,924 | 1,537,925 | No Output? PHP foreach doesn't seem to work | <p>I am trying to form an acronym from a given text. The Idea here is that the first Letter in $text ($text[0]) will be taken and placed inside the array $storage using array_push(). Now, if there is a space inside the array, the letter of the next index should be a part of the Acronym. I am currently not getting an ouput, what am I missing?</p>
<pre><code>public function Acronym($text)
{
$text = str_split($text);
$count = strlen($text);
$storage = array();
for($i=0; $i<$count; $i++)
{
array_push($storage, $text[0]);
if($text[$i]==' ')
{
array_push($storage, $text[$i+1]);
}
foreach($storage as $clean)
{
echo $clean;
}
}
}
</code></pre>
| php | [2] |
2,292,707 | 2,292,708 | Why is it recommended to save viewstate values in the PreRender event call? | <p>I am trying to persist member variables by saving them in the ViewState (only a few small variables) however I read up and I gather its better to save them into the ViewState at the PreRender stage than PageLoad? </p>
<p>I can see that the ViewState can be saved to anytime before Page rendering, but does it make any difference in PreRender or PageLoad?</p>
| asp.net | [9] |
5,067,545 | 5,067,546 | Why Does Python Script Jump Over Some Entries And Not Others? | <p>In a Python list, an entry I expected to be removed remained, and another entry was removed. Why is that?</p>
<p>Here's the problematic code:</p>
<pre><code>def getAdjacent(pos, bounds):
posibles = [
[pos[0]-1, pos[1]],
[pos[0]+1, pos[1]],
[pos[0], pos[1]-1],
[pos[0], pos[1]+1]]
for p in posibles:
if isOutside(p,bounds):
posibles.remove(p)
return posibles
def isOutside(pos, bounds):
if pos[0] > bounds[0]-1 or pos[0] < 0 or pos[1] < 0 or pos[1] > bounds[1]-1:
return True
else:
return False
</code></pre>
<p>Here's some Inputs and outputs that reflect the problem:</p>
<pre><code>In [13]: bounds = [10, 10]
In [14]: p = [9,0]
In [15]: getAdjacent(p, bounds)
Out[15]: [[8, 0], [9, -1], [9, 1]]
In [16]: isOutside([9, -1], bounds)
Out[16]: True
In [17]: isOutside([9, 1], bounds)
Out[17]: False
</code></pre>
<p>Now why is [9, -1] still in getAdjacent() when getAdjacent() removes all elements that cause isOutside() to retrun True? And why isn't [10, 0] still in there? Is it a magnitude thing?</p>
| python | [7] |
4,065,377 | 4,065,378 | what does ~ mean in the java code? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4887876/what-does-this-tilde-mean">What does this tilde mean?</a> </p>
</blockquote>
<p>I am using IntelliJ and found that it can re-factor my code of the following</p>
<pre><code>Handle<String> handle = new Handler<String>() {}
</code></pre>
<p>to <code>Handler<String> handler = new Handler<~>() {}</code></p>
<p>what's the meaning of ~ in the above?</p>
| java | [1] |
1,345,210 | 1,345,211 | Html Parser using java | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/904293/is-there-a-validating-html-parser-implemented-in-java">Is there a validating HTML parser implemented in Java?</a> </p>
</blockquote>
<p>Hi,</p>
<p>Is there is any API which parse the HTML text using java.</p>
<p>All the function should in the format of Objects</p>
<p>e.g. In the following text i want to Parse the HTML file
and parser should return me the list of tags , attribute ..</p>
<pre><code><HTML>
<BODY>
<INPUT TYPE="text" value="100">
</BODY>
</HTML>
</code></pre>
<p>Thanks</p>
| java | [1] |
2,520,782 | 2,520,783 | Not able to understand func<Type> code | <p>I know what a func is, but not able to understand the following piece of code:</p>
<p>There's a simple property :</p>
<pre><code> public Func<DomainFacade> BusinessFacadeFactory { get; set; }
</code></pre>
<p>And this is how the property is set:</p>
<pre><code> this.BusinessFacadeFactory = () => new DomainFacade();
</code></pre>
<p>Now this way of setting the property, is it a Anonymous method or something else?</p>
| c# | [0] |
1,702,576 | 1,702,577 | C# Convert Hex string to byte | <p>Little bit stuck on this, I have a var called PORTBhex holding a value in the range 0x00 to 0x3F which is written to an external device via USB. The problem I am having is getting the value into this bit of code:</p>
<pre><code>public bool PORTBwrite()
{
Byte[] outputBuffer = new Byte[65];
outputBuffer[0] = 0;
outputBuffer[1] = 0x00; //Command tells PIC18F4550 we want to write a byte
outputBuffer[0] = 0;
//Must be set to 0
outputBuffer[2] = IO.PORTBhex;
//Hex value 0x00 - 0x3F to write to PORTB
//above line gives the error cannot implicity convert string - byte
//IO.PORTBhex is returned from the code in second snippet
if (writeRawReportToDevice(outputBuffer))
{
return true; //command completed OK
}else{
return false; //command failed .... error stuff goes here
}
}
</code></pre>
<p>Now the problem is the value i have is an integer that is converted to hex using:</p>
<pre><code> public static string ToHex(this int value)
{
return string.Format("0x{0:X}", value);
}
</code></pre>
<p>The value starts off as an integer and is converted to hex however I cannot use the converted value as its of the wrong type I am getting Cannot implicitly convert type 'string' to 'byte'.</p>
<p>Any idea what I can do to get around this please?</p>
<p>Thanks</p>
<p>EDIT:</p>
<p>I think I might have poorly described what I'm trying to achieve, I have an int variable holding a value in the range 0-255 which I have to convert to Hex which must be formatted to be in the range 0x00 to 0xFF and then set outputBuffer[2] to that value to send to the microcontroller.</p>
<p>The integer var has some maths performed on it before it needs to be converted so i cannot solely use byte vars and has to be converted to a hex byte afterwards.
Thanks</p>
| c# | [0] |
970,010 | 970,011 | Check whether app updates work without submitting to App Store | <p>I have an application already on the store and would like to release an update. Since my app deals with databases and I've had to change some parts of it, I would like to ensure that the update does not affect the existing functionality in any way once the user updates from the App Store.</p>
<p>What I did was this - install the first version of my app on my device. Changed the update's version in info.plist to 1.1 and run it via xcode (and install on my device). But what happens by doing this is some of the changes I made to the XIBs do not show up. It looks as if the app was only half-updated (if you know what I mean)</p>
<p>Is there any way to update an existing app programmatically without having to go through the app store and then find out it could lead to a disaster?!</p>
<p>Thanks for any help!</p>
| iphone | [8] |
5,290,149 | 5,290,150 | I don't want to select hidden element, How can I do that? | <p>I am using a JQuery Plugin, which uses following line</p>
<pre><code>var inputSelector = 'input[class]:not(:button|:submit|:reset), textarea[class], select[class]';
</code></pre>
<p>It select some element.</p>
<p>It also selects the hidden element, how can I achieve that without giving any class to hidden element?</p>
<p>And It must work in IE.</p>
| jquery | [5] |
2,105,707 | 2,105,708 | Learning Python regular expression | <p>Which is the best website for learning python regular expression?
please recommend me the best one.</p>
| python | [7] |
4,763,728 | 4,763,729 | php str_replace and \b word boundary | <p>I am trying to use str_replace, but can't figure out how to use \b for word boundary:</p>
<pre><code><?php
$str = "East Northeast winds 20 knots";
$search = array("North", "North Northeast", "Northeast", "East Northeast", "East", "East Southeast", "SouthEast", "South Southeast", "South", "South Southwest", "Southwest", "West Southwest", "West", "West Northwest", "Northwest", "North Northwest");
$replace = array("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");
$abbr = str_replace($search, $replace, $str);
echo $abbr;
// this example echoes "E Neast winds 20 knots" since \b word boundary is not used
// how to apply word boundary so that is seeks the exact words to replace?
// the text to replace could be anywhere (start, middle, end) of string
// this example should output "ENE winds 20 knots"
?>
</code></pre>
| php | [2] |
1,743,916 | 1,743,917 | How do I show things directly to the screen in Android? | <p>I'm new to android and I was wandering is there a way to show a stream or a pic to the screen directly even without the manifest?</p>
<p>Or how do I load resources files without using the manifest on the Android platform?</p>
| android | [4] |
5,775,298 | 5,775,299 | How to format dates in javascript | <p>I pick this date from a textbox and i would like to format to this format: yyyy-MM-dd
So from dd/MM/yyyy to yyyy-MM-dd</p>
<pre><code> var startDate = document.getElementById('ctl00_PlaceHolderMain_ctl00_Date').value;
var s = new Date(startDate);
alert(startDate); //which prints out 7/03/2012
//when i use the below to try and format it to : yyyy-MM-dd which is what i want
var scurr_date = s.getDate();
var scurr_month = s.getMonth();
scurr_month++;
var scurr_year = s.getFullYear();
</code></pre>
<p>For some reason i get:</p>
<pre><code>var fstartdate = scurr_year + "-" + scurr_month + "-" + scurr_date;
//Output:2012-7-3
instead of : 2012-3-7
also fi i pick a date like 31/12/2011
i get : 2013-7-12
</code></pre>
<p>Any ideas what to do.I kind of notice if i use US like 03/07/2012 it kind os works ok.
Thank in advance</p>
| javascript | [3] |
3,387,276 | 3,387,277 | Environment.GetResourceString | <p>I had to reverse engineering other vendor code .Since i have to hack his code.I jumped few problem but still can understand c# code(** I'm a php oop developer full time).The only last part was Enviroment.GetResourceString was not found.Some said it was in .net framework 2.0.I have install .net framework 2.0 sdk and also compact edition.But still visual web developer cannot find the function.Any idea to change Enviroment.GetResouceString to other function ?
Operating System : Windows 2008 r2 Web Edition 64 bit</p>
<p>throw new ArgumentOutOfRangeException("maxValue", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_MustBePositive"), new object[] { "maxValue" }));</p>
| c# | [0] |
3,245,404 | 3,245,405 | Adding items to a navigation toolbar | <p>I have a navigation toolbar in which I am adding toolbar items programatically, as below. The toolbar displays properly, and the toolbar style is set to black opaque. but the button on the toolbar does not display. Why? </p>
<pre><code> //Set up the toolbar
[[[self navigationController] toolbar] setBarStyle:UIBarStyleBlackOpaque];
UIBarButtonItem *myButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(handleMyButton)];
NSArray *myItems = [NSArray arrayWithObjects: myButtonItem,nil];
[[self navigationController] setToolbarItems:myItems animated:NO];
[myButtonItem release];
</code></pre>
| iphone | [8] |
4,982,891 | 4,982,892 | DeviceAdmin policies PASSWORD_QUALITY_NUMERIC not working | <p>I am working on DeviceAdmin policies implementation, followed below link for implementation <a href="http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#PASSWORD_QUALITY_NUMERIC" rel="nofollow">http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#PASSWORD_QUALITY_NUMERIC</a> , In that if we selected PASSWORD_QUALITY_NUMERIC password Quality from spinner, while setting password, it should ask for at least one digit but not showing any information to input digit, simply accepting ALPHABETIC, not asking for at least 1 number.I hope this is not expected behaviour,may be i am wrong Please let me know Am i misunderstand PASSWORD_QUALITY_NUMERIC?.If i selected PASSWORD_QUALITY_ALPHABETIC, i tried to give only digits, this time asking for at least 1 letter. Thanks in advance :D</p>
| android | [4] |
4,605,432 | 4,605,433 | What does the keyword this refer to when used as a function parameter/agrument? | <p>Hello I'm somewhat past the newbie stage of javascript and am looking at how a certain widget library works. (All printed out code, can't copy and paste) I condensed it so I hope it's enough for you guys to understand. </p>
<pre><code>Page.prototype.createForm= function (){
....
this.form1 = new Form();
....
this.form1.clickEvent(this,"clickedDelete");
};
Page.prototype.clickedDelete= function (){
....
};
</code></pre>
<p>So my question is what the this inside ClickEvent mean?
this.Form.clickEvent(this,"clickedDelete")</p>
<p>I hope this is enough information, but anyways, what is this inside </p>
<pre><code> (this,"clickedDelete")
</code></pre>
<p>referring to? </p>
<p>is it the page object or page.form1 (thus called this.form1?) </p>
<p>If this is too little information, can you provide any links or examples of your own that's somewhat close to this example. Thank you. </p>
| javascript | [3] |
1,872,772 | 1,872,773 | Make a TextView and a Button the same size | <p>I have a TextView and Button in my program and I cannot get the size of the Button and the TextView to be the same. How can I do this? </p>
<pre><code> <LinearLayout
android:layout_width="match_parent"
android:layout_height="67dp"
android:background="#999999"
android:gravity="center"
>
<Button
android:id="@+id/button1"
android:layout_width="130dp"
android:layout_height="60dp"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_width="130dp"
android:layout_height="60dp"
android:background="#ffffff" android:textColor="#000000"
android:textSize="24dp" android:textStyle="bold"
android:gravity="center"
android:text="0.0" />
</LinearLayout>
</code></pre>
| android | [4] |
1,343,210 | 1,343,211 | String to Integer array conversion | <p>I need to add values into an int array. </p>
<pre><code> int[] placeHolders[];
</code></pre>
<p>Now i do not know the size of the elements to add into this array. I add it while i have input. I want to know how can i convert my string output values into int array repeatedly. </p>
<p>Input: 23.45.1.34</p>
<p>I am using string tokenize on . to get tokens </p>
<pre><code>Value = Integer.parseInt(strtokObject.nextElement().toString());
</code></pre>
<p>I am using above line to add int to single int value but if i need to add int elements to array just like push in vector (C++ STL) i am unable to do. </p>
| java | [1] |
965,248 | 965,249 | Overridden Class Only Offers Static Methods | <p>I have a class that overrides TextView however if I try to use any of the member functions of either my class or TextView I get an error message in Eclipse stating "Cannot make a static reference to the non-static method ##MEMBER FUNCTION## from the type View". Where ##MEMBER FUNCTION## is the method I am calling i.e. setLayoutParams(ViewGroup.LayoutParams). If I look in the suggestions dialog only the static methods are offered.</p>
<p>I have tried cutting my class down too;</p>
<pre><code>import android.widget.TextView;
public class MyClass extends TextView {
public MyClass(Context context) {
super(context);
}
}
</code></pre>
<p>But I still get the same errors.</p>
<p>Thanks in advance,<br>
Mark</p>
| android | [4] |
1,704,222 | 1,704,223 | Skill points menu not working | <p>Basically, the user chose a class earlier. IN this menu, it checks, and if the user chose Wizard, then they an choose to spend up to 4 skill points. </p>
<pre><code>if Class == ("wizard") or Class == ("Wizard"):
print("You have four spell points. You can learn up to four level- one spells, or one level-four spell, or any combination thereof.")
Spellpoints = 4
FireballLvl = 0
IceBlastLvl = 0
TelekeniticSheildLvl = 0
ElectricShockLvl = 0
WindLvl = 0
while True:
Spellmenu = input("Press 1 to spend a point on Fireball. Press 2 to spend a point on Ice Blast. Press 3 to spend a point on Telekenitic Sheild. Press 4 to spend a point on Electric Shock. Press 5 to spend a point on Wind.")
if Spellpoints == 0:
print ("You have no more spell points")
break
if Spellmenu == ("1"):
Spellpoints - 1
FireballLvl + 1
elif Spellmenu == ("2"):
Spellpoints - 1
IceBlastLvl + 1
elif Spellmenu ==("3"):
Spellpoints - 1
TelekeniticSheildLvl + 1
elif Spellmenu ==("4"):
Spellpoints - 1
ElectricShockLvl + 1
elif Spellmenu ==("5"):
Spellpoints - 1
WindLvl + 1
</code></pre>
<p>My problem is that the loop never ends. It is supposed to when there are no more spell points, but it doesn't end. Many thanks in advance. </p>
| python | [7] |
422,271 | 422,272 | Why does overloaded assignment operator return reference to class? | <pre><code>class item {
public:
item& operator=(const item &rh) {
...
...
return *this;
}
};
</code></pre>
<p>Is the following signature wrong?</p>
<pre><code>void operator=(const item &rh);
</code></pre>
<p></p>
<pre><code>item a, b;
a = b; // equivalent to a.operator=(b); so there is no need to return this.
</code></pre>
| c++ | [6] |
3,642,070 | 3,642,071 | PHP snippet to match wildcarded IPv4 strings | <p>I'm finding an hard time in figuring out how to create a snippet that can tell me if an ip is matching with a database of blacklisted ips, also containing wildcards.
Example:</p>
<pre><code>$global_blacklistedips = Array ( '10.10.*.*', '192.168.1.*' );
function checkBlacklistedIp ( $ip ) {
// some kind of regular expression
// match? return true;
// else return false;
}
</code></pre>
<p>Anyone can help? The only approach I've figured out is to code a very very ugly "state machine" that switches between 1, 2, or 3 wildcards ( 4 wildcards would lead to blacklist everything ), but this kind of coding is really a mess</p>
| php | [2] |
3,074,892 | 3,074,893 | Why is it not possible to access elements via JS on this site? | <p>The website I'm talking about: <a href="https://sephir.ch/vfi/user/lernendenportal/index.cfm" rel="nofollow">https://sephir.ch/vfi/user/lernendenportal/index.cfm</a></p>
<p>I wanted to make a simple bookmarklet which fills my email and password into those two textboxes. My JS code works on any other site, but not on this one. </p>
<p>HTML:</p>
<pre><code> <input type="text" name="email" size="40" maxlength="60" class="tdschwarz" autocomplete="off">
</code></pre>
<p>JS:</p>
<pre><code> javascript:function fill() {alert(document.getElementsByName("email")[0].value);} fill();
</code></pre>
<p>Error:</p>
<pre><code> Uncaught TypeError: Cannot read property 'value' of undefined
</code></pre>
<p>Do you guys have any ideas why it doesn't work? Thanks in advance.</p>
| javascript | [3] |
1,658,872 | 1,658,873 | How does asort work? | <p>I was having a look over some of my old work and saw that the asort function would have worked perfectly for some of the uses I needed, although I attempted an extremely different and longwinded way. </p>
<p>So my question is exactly, how does asort maintain association when sorting? I thought an array can be sorted by key, or by value, is there a third sorting pivot?</p>
| php | [2] |
1,748,264 | 1,748,265 | Increase the grid spacing in android | <p>I have a gridview in which i have a lot of items in three colums. I want to increase the spacing between them. How can I do that in android?</p>
| android | [4] |
4,343,216 | 4,343,217 | javascript open parent window | <p>The following is in the NewForm.aspx which gets executed from a parent page (surveys/lists/testsurvey/allitems.aspx). The javascript works and open google. However, it opens the google in the pop up window (newform.aspx) but i need to close the popup window and show google.com on the parent window (or whatever the parent window link is)</p>
<pre><code><script type="text/javascript">
function redirect()
{
var inputcCtrls = document.getElementsByTagName("input");
for(m=0; m<inputcCtrls.length; m++)
{
if(inputcCtrls[m].type == 'button' && inputcCtrls[m].value == 'Finish')
{
var funcOnClick = inputcCtrls[m].onclick;
inputcCtrls[m].onclick = function () { window.location = "http://www.google.com/" }; }
}
}
redirect();
</script>
</code></pre>
| javascript | [3] |
2,857,216 | 2,857,217 | How to replace part of href= value from a javascript variable similer to phps str_replace(..)? | <p>i got javascript variable(code2) that holds the following data:</p>
<pre><code><div class="pages"><center><a class="selected" href="/Episodes-1234_power1" title="power album page 1" >1</a><a class="normal" href="/Episodes-1234_power2" title="power album page 2"> 2</a>
</code></pre>
<p>and i want to change it to this:</p>
<pre><code><div class="pages"><center><a class="selected" href="./doit.php?title=<?php echo $_GET['title'];?>&Num=/Episodes-1234_power1" title="power album page 1" >1</a><a class="normal" href="./doit.php?title=<?php echo $_GET['title'];?>&Num=/Episodes-1234_power2" title="power album page 2"> 2</a>
</code></pre>
<p>I have doen similer thing in php like this example :</p>
<pre><code>$code2=str_replace('href="', 'href="./doit.php?title='.$title.'&Num=', $code1);
echo $code2;
</code></pre>
<p>I tried to do same thing in javascript but my following code doesnt work! could you guys help me fix it? Thanks</p>
<pre><code><script>
.....
.....
alert ('' + code2);
//document.write(code2);
var myString = code2;
var myString2 = myString.replace(href=, 'href="./doit.php?title=<?php echo $_GET['title'];?>&Num=');
document.write (myString2);
</script>
</code></pre>
| javascript | [3] |
1,425,493 | 1,425,494 | Can I open UNIX POSIX ports from Python? | <p>Can I open UNIX POSIX ports from Python 2.7 ( I don't need IP port, just UNIX POSIX) ? Does anybody have experience with this ?</p>
| python | [7] |
5,861,137 | 5,861,138 | How to disable maximize,mimimize and close button for a new window open | <p>I am using window.open() method to open a page as a pop-up window
for a link button click event.
But the poup-up window is having minimize,maximize,close(x) button.
I dont want those buttons.How can remove these buttons?
this is the method i am using,</p>
<pre><code>window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,titlebar=no,scrollbars=1,resizable=0,width=450,height=310,left=500,top=350");
</code></pre>
<p>Tell me how can do this
Regards,
Chirag Jain.</p>
| javascript | [3] |
3,397,904 | 3,397,905 | An Exception occur in Tablayout | <p>I wanna add three layout in a TabActivity, but it was force closed when I ran it.</p>
<h2>Here is the code:</h2>
<p>import android.app.TabActivity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;</p>
<p>public class Test1 extends TabActivity {</p>
<pre><code>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("egcquery").setIndicator("EGCQuery").setContent(R.layout.main1));
tabHost.addTab(tabHost.newTabSpec("PatientInfo").setIndicator("PatientInfo").setContent(R.layout.main2));
tabHost.addTab(tabHost.newTabSpec("Comp_Interp").setIndicator("Comp_Interp").setContent(R.layout.main3));
}
</code></pre>
<p>}</p>
| android | [4] |
3,320,943 | 3,320,944 | How can I update the title of the tab in the same way GMail/Facebook does? | <p>Every time you receive a new email, or something happens on your Facebook profile, your browser tab's name changes. For example, on gmail, if you receive a new mail, it will change to something like <code>GMail (1)</code>. How can I get the same effect in my application? I think it's a Javascript thing, but I'm not sure.</p>
| javascript | [3] |
4,564,037 | 4,564,038 | java and website redirection detection | <p>I have java related question...</p>
<p>Website www.stationv3.com gets updated daily (most of the time at least, it's kinda irregular). Every time I connect to a site using address www.stationv3.com (using a browser), it redirects me to it's subpage www.stationv3.com/date_of_latest_update.html</p>
<p>I'm trying to make a program that will pull latest comic from the site, but I am not sure how to find out it's exact address. But I know I'd be able to find out if I could somehow find out where where am I being redirected on every connect. Is that possible with java? I know it can do all sorts of quirky things, but I'm still new to internet related stuff...</p>
<p>I used exact site name just to make it easy for you to check outwhat's going on...
And also, I'm creating a generic code, one which could (with some tinkering) be applyed to any site that functions in that manner.</p>
| java | [1] |
4,579,157 | 4,579,158 | How read Doctype of XML file | <p>I have
file config.xml</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE app SYSTEM "text.dtd">
<app>
<appname>NTTDK</appname>
<version>1</version>
</app>
</code></pre>
<p>file text.dtd</p>
<pre><code><!ELEMENT app(appname,version)>
<!ELEMENT appname(#PCDATA)>
<!ELEMENT version(#PCDATA)>
</code></pre>
<p>I want to read info of file text.dtd in android.
Can you help me this problem?
Thanks!</p>
| android | [4] |
3,838,644 | 3,838,645 | Need to pass a String array to a Set | <p>Hello guys I need to pass a string array over to a setter that takes a Set. Not sure how to pass it over. Thanks</p>
<p>THis is my form:</p>
<pre><code> public String[] getFields() { return fields; }
public void setFields(String[] s)
{
fields = s;
//System.out.println("form Array length " + s.length);
}
</code></pre>
<p>and here is the bean:</p>
<pre><code>private Set<FieldBean> fields;
public void setFields( Collection<FieldBean> val )
{
t
if( fields == null ) fields = new HashSet<FieldBean>();
fields.addAll( val );
}
</code></pre>
<p>Action code:</p>
<pre><code>ParameterBean paramBean = new ParameterBean();
form.getFields() y
paramBean.setFields(Arrays.asList(form.getFields())); //Need bean set here
</code></pre>
<p>got a message that stated: The method setFields(Collection) in the type ParameterBean is not applicable for the arguments (List)</p>
| java | [1] |
5,800,258 | 5,800,259 | Is it possible to have an array of elements as a property of a PHP class? | <p>As this does not seam to work?</p>
<pre><code>class Site {
private $PROPERTIES = array(
"NAME",'STACKOVERFLOW',
"URL",'http:/stackoverflow.com'
);
function __construct() {
$this->props = $PROPERTIES;
}
function dumpData() {
var_dump($this->props)
}
}
</code></pre>
| php | [2] |
2,921,805 | 2,921,806 | Can i inherit the operator>>? | <p>I have the following problem: let's say class <code>Item</code> holds the serial number of a product,
and class <code>Book</code> is an <code>Item</code> which inherits class <code>Item</code>'s serial number. I have to create and use <code>operator>></code> for every class. I thought about creating <code>operator>></code> to <code>Item</code>, and then just call it in the implementation of the <code>istream</code> of the book, but I don't know how.</p>
<p>The code goes like this:</p>
<pre><code>class Item
{
protected:
int _sn;
public:
Item();
~Item();
...
const istream& operator>>(const istream& in,const Item& x)
{
int temp;
in>>temp;
x._sn=temp;
return in;
}
};
class Book
{
private:
char _book_name[20];
public:
Book();
~Book();
...
const istream& operator>>(const istream& in,const Book& x)
{
char temp[20];
////**here i want to use the operator>> of Item**////
in>>temp;
strcpy(x._book_name,temp);
return in;
}
};
int main()
{
Book book;
in>>book; //here i want to get both _sn and _book_name
}
</code></pre>
<p>Is this even possible?</p>
| c++ | [6] |
4,769,677 | 4,769,678 | Unknown Asp.net syntax | <p>Can some one explain the significance of the $ in the following line of aspnet code? Not sure what to look for since I've never seen the syntax but FormView2 is the name of the formview this input sits inside. </p>
<p>Why is this necessary (if it is at all)?</p>
<pre><code><pre>
<code>
<!---test-->
<input type="text" class="grid_2" id="FormView2_TextBoxName" value="0" name="FormView2$TextBox4">
<blockquote>
</pre>
</code>
</code></pre>
| asp.net | [9] |
530,947 | 530,948 | Activity not losing its state when I rotate the emulator screen | <p>I have created one layout with two edit boxes. After I launch my application, I enter some text in both of the edit boxes, and I press the 7 and 9 buttons to rotate the emulator screen, and the text I have entered still remains. But I have read from the docs that upon screen orientation change, the activity will be restarted and the data will be gone if I don't save the state.</p>
<p>Am I doing something wrong to change the screen orientation? I welcome any suggestions, as I am new with Android.</p>
| android | [4] |
1,303,606 | 1,303,607 | C# multiple custom controls types recognizing | <p>My question is based on an example from WPF, but, I think, it's more about C# in general.</p>
<p>Suppose I have a WPF app where I use several types of Custom Controls, let it be <code>CustControl1</code>, <code>CustControl2</code>, <code>CustControl3</code>. The page can dynamically load the XAML with controls of either of the types.<br>
This very page has a code-behind where some manipulations are made with the Custom Controls, like:</p>
<pre><code>List<CustControl1> MyCustControls = this.Descendents().OfType<CustControl1>().ToList();
foreach (CustControl1 cntr in MyCustControls)
{
...
</code></pre>
<p>In the above code the <code>CustControl1</code> type is explicitly defined, and if other types of Custom Controls are loaded on the page (of <code>CustControl2</code> or <code>CustControl3</code> type), the code will not recognize it.</p>
<p>My level of C# knowledge is insufficient to find out how to solve such a problem of multiple type recognizing. Or is it possible in C# at all?</p>
| c# | [0] |
1,969,447 | 1,969,448 | What does it really mean by 'this' in java? | <pre><code>class A {
void methodA {
B b= new B();
b.methodB();
//point 1
}
private class B {
void methodB(){
//point 2
}
}
}
</code></pre>
<p>if I use a system out to print <code>this.toString()</code> at both point 1 and point 2, it gives the same value. Can anyone please tell me why ? Shouldn't those two give different values ?</p>
| java | [1] |
5,519,119 | 5,519,120 | parent().filter(":first") doesn't work | <p>I have:</p>
<pre><code><td>firstTD</td>
<td>secondTD</td>
<td>thirdTD</td>
<td>
<img src="img/cross.png" onclick="alert($(this).parent().parent().filter('td:first').val());">
</td>
</code></pre>
<p>Why I didn't get an alert: "firstTD" ?</p>
| jquery | [5] |
5,793,670 | 5,793,671 | list with infinite elments | <p>I need to operate on two separate <strong>infinite list</strong> of numbers, but could not find a way to generate, store and operate on it in python.</p>
<p>Can any one please suggest me a way to handle infinite Arithmetic Progession or any series and how to operate on them considering the fact the minimal use of memory and time.</p>
<p>Thanks every one for their suggestions in advance.</p>
| python | [7] |
3,774,773 | 3,774,774 | Pass variables through Quoted Javascript String | <p>I have a function which returns a string which contains a javascript call. Since it is quoted I cannot pass variables through it. </p>
<p>How can I change the return string which would enable me to pass javascript object values. </p>
<p>Ex: How can I pass <code>var i</code> through the return statement.</p>
<pre><code>var i = 'iaa';
</code></pre>
<p><code>return '<a href="javascript:abccd(\'i\');" ><img src="../images/btnsave2.png" style="margin:6px 0 0 6px;" height="13" width="13" /></a> ';</code></p>
| javascript | [3] |
1,124,578 | 1,124,579 | Android - Enter button with finger detection? | <p>I'm working on a soundboard, however I've got a problem when it come to drag the finger over the screen to play the sounds for the buttons I drag the finger over.</p>
<pre><code>Button Button3 = (Button)findViewById(R.id.button03);
Button3.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN){
mp.playSound(3);
}
return false;
}
});
</code></pre>
<p>Do anyone know how I can detect when a finger enter a button and not click the button?
Thanks :)</p>
| android | [4] |
2,101,955 | 2,101,956 | Feature detection - Lion scrollbar | <p>I have some css code that mimics Lion/iOS style scrollbars (like Twitter website). However, I would like to prevent the styles to be used for browsers that supports new scrollbars and are running Lion. Is there a better way than checking the user agent for WebKit+Lion ?</p>
| javascript | [3] |
1,197,846 | 1,197,847 | Is there any offline multilingual dictionaries which I could use in my own application via API? | <p>The idea is to use any possible ready to use <em>multilingual dictionary</em> available on the market in my own android app. </p>
<p>What am I looking for is like this <a href="http://www.abbyy.com/lingvo_android/api/" rel="nofollow">http://www.abbyy.com/lingvo_android/api/</a></p>
<p>Does anybody know dictionary apps like mentioned? Or is it maybe better to look for some ready to use third parties dictionary database? The problem is such DBs are big in size (150-300MBs compressed) so it couldn't be included into assets folder of android application.</p>
| android | [4] |
5,201,077 | 5,201,078 | Why doesn't this email-address-submitting code work with Opera and Internet Explorer? | <p>I've just discovered the <a href="http://www.yoomoot.com" rel="nofollow">email-address-saving form on my website</a> does not work on Opera and Internet Explorer (7 at any rate), and possibly other browsers. Works fine with Firefox. Unfortunately I'm not a developer and no longer have any contact with the guy who wrote the code for the form so I've no idea how to fix it. I assume the problem has something to do with the code below:</p>
<pre><code><?php
$str = '';
if (isset($_POST['submit']))
{
if(!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $_POST['email'])) {
$str = "<span style='color: red'>Not a valid email address</span>";
} else {
$file = 'emails.txt';
$text = "$_POST[email]\n";
if (is_writable($file)) {
if (!$fh = fopen($file, 'a')) {
exit;
}
if (fwrite($fh, $text) === FALSE) {
exit;
}
fclose($fh);
}
header('Location: thankyou.html');
}
}
?>
</code></pre>
<p>and then the body bit:</p>
<pre><code><form action="index.php" method="post">
<input type="text" name="email" style="width: 250px;" />
<input type="image" src="img/button-submit.png" name="submit" value="Submit" style="position: relative; top: 5px; left: 10px" />
</form>
<?php echo $str ?>
</code></pre>
<p>Anybody feeling pity for a helpless non-dev and have an idea what's not working here?</p>
| php | [2] |
4,081,958 | 4,081,959 | Access Point Location | <p>Is there any way I can know the distance between android device and the access point it is connected too?</p>
<p>let us say if the device is connected to another mobile device via hot spot feature.</p>
| android | [4] |
3,558,645 | 3,558,646 | Make javascript run onclick instead of pageload | <p>I have the the following script that runs when the page is loaded:</p>
<pre><code><script language="JavaScript">
j=parseInt(Math.random()*ranobjList.length);
j=(isNaN(j))?0:j;
document.write(unescape(ranobjList[j]));
</script>
</code></pre>
<p>How can I execute it when a button is clicked rather then when it loads?</p>
| javascript | [3] |
777,773 | 777,774 | Is there a better way to write a unit test to ensure an object has been set with a newly instantiated value? | <p>say I have a class:</p>
<pre><code>public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public int Height { get; set; }
}
</code></pre>
<p>and in a method I instantiate it:</p>
<pre><code>public void SomeMethod(Person person)
{
person = new Person()
}
</code></pre>
<p>so before the person was passed in it had values.</p>
<p>What is the best way to test SomeMethod set it to a newly instantiated value?</p>
<p>All I can think of is to check all the nullable properties are empty and the non nullable values have default values.</p>
<p>Is there a better way than this?</p>
| c# | [0] |
3,756,979 | 3,756,980 | how to change a function in existing 3rd party library in python | <p>This was an interview question which was asked to me. Please do not penalize me if it doesn't make sense. She asked:</p>
<p>"I have an existing 3rd party lib in python and there is a function foo() in it. How do I modify that function after importing in my existing module?"</p>
| python | [7] |
1,456,778 | 1,456,779 | Can't get session.gc.lifetime | <p>I am trying to find out the maxtime for my php session (I don't have access to the cpanel or php.ini file). I am trying to use this code but its not printing out anything (except 'hello'). Whats wrong?</p>
<pre><code> <?php
session_start();
error_reporting(E_ALL);
ini_set("error_reporting",1);
// Get the current Session Timeout Value
$currentTimeoutInSecs = ini_get(’session.gc_maxlifetime’);
print "hello " . $currentTimeoutInSecs;
?>
</code></pre>
| php | [2] |
5,681,050 | 5,681,051 | Time alert problem - Android | <p>I develop app for time alerting ( for example when you need to drink medicine - it repeats at time intervals ). How can I implement that service runs forever in background ? Is that possible at all ?</p>
| android | [4] |
1,562,894 | 1,562,895 | PHP Script Parsing Files Incorrectly | <p>I am not exactly sure what the problem is, but I have a PHP script which should be downloading and displaying specified web pages. However, certain pages create a download dialog in the browser rather than displaying the page (but the downloaded file is still the correct HTML). This only happens for some websites but I am not sure what makes the difference.</p>
<p>I have messed around with the content type headers and I do not think this is the problem, but could this be a client-side problem somehow? I do not know where to look to figure out how to debug this, so I would appreciate any help that points me in the right direction.</p>
<p>Thank you for your time.</p>
| php | [2] |
2,830,298 | 2,830,299 | Activator.CreateInstance failing | <p>I have am creating an Instance dynamically using Activator.CreateInstance. However, it is saying object cannot be null on every attempt. Pasting the code below. Am I doing anything wrong?</p>
<p>Is there any problem if </p>
<blockquote>
<p>Activator.CreateInstance</p>
</blockquote>
<p>replaces the conventional switch/case statements for determining the object type in the run-time? Thanks.</p>
<pre><code>public abstract class Base
{
public abstract void Func();
}
public class Derived:Base
{
public override void Func()
{
MessageBox.Show("Derived First");
}
}
public class Derived2 : Base
{
public override void Func()
{
MessageBox.Show("Derived Second");
}
}
private void button1_Click(object sender, EventArgs e)
{
// I was trying to make use of the overladed version
// where it takes the Type as parameter.
BaseClass report =
(BaseClass) Activator.CreateInstance(Type.GetType("Derived"));
report.Func();
}
</code></pre>
| c# | [0] |
468,253 | 468,254 | Returning searched results in an array in Java without ArrayList | <p>I started down this path of implementing a simple search in an array for a hw assignment without knowing we could use ArrayList. I realized it had some bugs in it and figured I'd still try to know what my bug is before using ArrayList. I basically have a class where I can add, remove, or search from an array. </p>
<pre><code>public class AcmeLoanManager
{
public void addLoan(Loan h)
{
int loanId = h.getLoanId();
loanArray[loanId - 1] = h;
}
public Loan[] getAllLoans()
{
return loanArray;
}
public Loan[] findLoans(Person p)
{
//Loan[] searchedLoanArray = new Loan[10]; // create new array to hold searched values
searchedLoanArray = this.getAllLoans(); // fill new array with all values
// Looks through only valid array values, and if Person p does not match using Person.equals()
// sets that value to null.
for (int i = 0; i < searchedLoanArray.length; i++) {
if (searchedLoanArray[i] != null) {
if (!(searchedLoanArray[i].getClient().equals(p))) {
searchedLoanArray[i] = null;
}
}
}
return searchedLoanArray;
}
public void removeLoan(int loanId)
{
loanArray[loanId - 1] = null;
}
private Loan[] loanArray = new Loan[10];
private Loan[] searchedLoanArray = new Loan[10]; // separate array to hold values returned from search
}
</code></pre>
<p>When testing this, I thought it worked, but I think I am overwriting my member variable after I do a search. I initially thought that I could create a new Loan[] in the method and return that, but that didn't seem to work. Then I thought I could have two arrays. One that would not change, and the other just for the searched values. But I think I am not understanding something, like shallow vs deep copying???....</p>
| java | [1] |
2,401,573 | 2,401,574 | Event Handler Not Working | <p>I have this jQuery code:</p>
<pre><code>$('#SomeLink').onclick =
function(event)
{
alert('test');
};
</code></pre>
<p>And this is my markup:</p>
<pre><code><a href='#' id='SomeLink'>
Some Link
</a>
</code></pre>
<p>Obviously very simple. <a href="http://jsfiddle.net/Surfer/fspSJ/" rel="nofollow">Here is the jsFiddle for the above code</a>.</p>
<p>What is the <code>onclick</code> event not firing with a simple dialog? I'm new to jQuery, and I'm sure it's a very simple thing but I can't seem to figure it out.</p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.