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 |
|---|---|---|---|---|---|
2,504,340 | 2,504,341 | How to split a string which is seperated by an Element in PHP | <p>I have a variable containing Date and Time Which has been seperated by the element " T "</p>
<pre><code>$date_time="2013-05-05T18:30:00";
</code></pre>
<p>Now i want the date in one variable and Time in another variable like below.</p>
<pre><code>$date="2013-05-05";
$time="18:30"
</code></pre>
<p>Thanks in advance,</p>
<p>Shoba.</p>
| php | [2] |
431,024 | 431,025 | Jquery problem with IE working fine in FF | <p>Hello i have this code that works perfect in Firefox but in IE 8 doesn't work and doesn't give me any error ?!</p>
<pre><code>$(".shp_div").change(function () {
var str = "";
$("select option:selected").each(function () {
var countprod =parseInt($("#countprod").val());
var str2 = $(this).val();
str2_array = str2.split('|');
var cost = parseInt(str2_array[0]);
var cost_extra = parseInt(str2_array[1]);
if ($("#countprod").val()>1) {
str = parseInt(((countprod-1)*cost_extra) + cost);
} else{
str = cost;
}});
$(".csq_item2").text(str);
var total =parseInt($("#subtotal").val());
var shipping=parseInt(str + total);
$(".price_total").text(shipping);
})
.change();
</code></pre>
<p>In order to get "full picture" please go at : <a href="http://poshsunglasses.net/21-Bottega_Veneta-B.V.88.html" rel="nofollow">http://poshsunglasses.net/21-Bottega_Veneta-B.V.88.html</a> and add to cart the prod and then in the cart page try to select the Shipping country in FF make the calculation in IE no.</p>
<p>thank you</p>
| jquery | [5] |
3,238,770 | 3,238,771 | jQuery offset error on Chrome & IE | <p>I'm getting this error on Chrome & IE "Cannot read property 'tagName' of null" when I try to get the offset position of an img tag width position:absolute. </p>
<p>html: </p>
<pre><code><img style="position: absolute;" src="1.jpg">
</code></pre>
<p>js:</p>
<pre><code>$('img').offset();
</code></pre>
<p>I search for reported bugs on jquery issues. I try jQuery 1.4.4 and 1.5.2.... but the error appear. Any ideas?</p>
| jquery | [5] |
2,552,458 | 2,552,459 | Post some values to Php and store in database using HTTP, stores empty values only | <p>I have tried to send some values to Php file in server using Http post...It store only empty values in Fields of my mysql database....please help me...</p>
<p><strong>My Android coding:</strong></p>
<pre><code>private void sendValues()
{
List<NameValuePair> data= new ArrayList<NameValuePair>(2);
data.add(new BasicNameValuePair("number", "123456789"));
data.add(new BasicNameValuePair("msg", "haiRam"));
try {
HttpClient httpclient=new DefaultHttpClient();
HttpPost httppost=new HttpPost("http://www.mywebsite.com/fasttrack/HttpTest.php");
httppost.setEntity(new UrlEncodedFormEntity(data));
HttpResponse rs=httpclient.execute(httppost);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
</code></pre>
<p><strong>my Php coding:</strong></p>
<pre><code><?php
// Gets data from URL parameters
$mobile=$_GET['number'];
$message = $_GET['msg'];
echo $message;
echo $mobile;
$connection=mysql_connect ("mysql", "user", "pass");
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db("gps", $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Insert new row with user data
$query = sprintf("INSERT INTO Http" .
" (mobile,mess) " .
" VALUES ('%s', '%s');",
mysql_real_escape_string($mobile),
mysql_real_escape_string($message));
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
</code></pre>
| android | [4] |
2,865,121 | 2,865,122 | Run service using Repeat alarm in between particular time of Day | <p>I have a service which runs on every 1 minute using repeat alarm. But I want to run this service in between 9.30 AM to 4 PM and 8 PM - 2.30 AM (timezone is Indian Standard Time-IST) only and run for every 1 minutes.</p>
<p>For example :</p>
<pre><code> UTC Time
StartTime EndTime
22:00 05:00
23:50 06:12
00:00 06:00
01:00 09:00
01:00 05:30
01:15 08:00
01:20 08:00
01:30 07:00
02:30 09:00
03:00 09:30
03:45 10:00
04:00 09:00
06:00 15:00
07:00 14:25
07:00 15:00
07:00 21:00
07:30 15:30
07:55 16:35
08:00 16:30
9:00 15:00
13:00 20:00
14:00 20:00
07:30 10:30
</code></pre>
<p>How to run a Service for every 1 min in between the above UTC timings only? Should I use a Service to run on 24 hours and inside the service check condition to do logic or can I manage using repeat alarm itself?</p>
| android | [4] |
17,676 | 17,677 | Android: Growing backstack problem, how to conserve memory? | <p>our app is designed using fragments and fragment transactions in a way where the user can keep going forward and "grow" our backstack indefinately. Now, besides the "dont design the app that way" answer, what options do I have to conserve memory. Eventually we run out and crash. Is there a way to onSaveInstanceState, save most of the state, release all the views (which hopefully releases memory associated with them), and then reload the views? Or is there a way to remove some transactions from the bottom of the stack? We are ok with loosing some of the user's backstack history if it comes from the bottom of the stack. Meaning: we would only keep the last 5 transactions in memory or something like that.</p>
| android | [4] |
5,608,829 | 5,608,830 | How to bring user further down the page using jQuery? | <p>When the user performs a certain action I want to bring them further down the page. Kind of like how an a-name link works. Except obviously it needs to happen without any additional parameters being added to the url or refreshing the page.</p>
<p>So what would be the jQuery way of doing this:</p>
<pre><code><a href="#person">Click Me</a>
<a name='person'>Tommy</a>
</code></pre>
<p>EDIT</p>
<p>a nice slide down effect to bring the user down the page would be nice too.</p>
| jquery | [5] |
1,272,807 | 1,272,808 | ASP.NET Refrence to my local PC in users event log, why? | <p>A customer has sent my a screen shot of their event log which shows an error from my ASP.Net app, the problem is it shows the line number where the error occurred but references my PC and the path into my files. Why? There's no references in my code.</p>
<p>Thanks
Lee</p>
| asp.net | [9] |
5,632,594 | 5,632,595 | trying to follow Bucky tutorials | <p>While following <a href="http://www.youtube.com/watch?v=OVfUq2DPKKg" rel="nofollow">this Youtube tutorial</a> (see the relevant code below) I get the following error:</p>
<blockquote>
<p>error line 6<br>
error: expected constructor destructor or type conversion before'('</p>
</blockquote>
<p>What might cause this error and how do I solve it?</p>
<pre><code>#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <time.h>
void myfun(int);//using own function
myfun(8);//pow(4.0,10.0)
using namespace std;
int main()
{
double num1;
srand(time(0));// to get a true random number
double num2;
num1 = pow(3.0, 9.0);//2 to the power of 4
cout << num1 <<endl;
num2 = rand() %100;//random number out of 100
cout << "\nrandom number = " << num2 << endl ;
return 0;
}
void myfun(int x)
{
using namespace std;
cout << "my favourite number is " << x << endl;
}
</code></pre>
| c++ | [6] |
5,135,090 | 5,135,091 | How can I change this with jquery? | <p>I want to change the text value in the search box to say, for example, "Awesome Search." I know it can be done with Jquery but I can`t get it to work. Can you assist?</p>
<p>Note, this is the default provided by Wordpress, and it would be difficult (for me) to go in and edit the files to separate the content from the behavior, so I need Jquery to override the default. The two answers provided thus far don`t seem to do that. </p>
<pre><code><input type="text"
onblur="if (this.value == '') {this.value = 'To search, type and hit enter';}"
onfocus="if (this.value == 'To search, type and hit enter') {this.value = '';}"
id="s"
name="s"
value="To search, type and hit enter"
class="text_input">
</code></pre>
| jquery | [5] |
1,750,115 | 1,750,116 | Add class to second instance of text | <p>Let's say my section contains the pages "Red", "Green" and "Blue". Each page has the title in a H1 tag as well as a shared #sidebar navigation showing all three links. How can I get jQuery to detect the text entered in the H1, find the same text in #sidebar, and add a class to the #sidebar link if a match is found?</p>
<p>HTML:</p>
<pre><code><h1>Red</h1>
<div id="sidebar">
<a href="#">Red</a><br>
<a href="#">Green</a><br>
<a href="#">Blue</a>
</div>
</code></pre>
<p>CSS:</p>
<pre><code>#sidebar { float: right; }
.current-section { background: red; }
</code></pre>
<p>Sorry - I'm a jQuery beginner at best. Here's a Fiddle: <a href="http://jsfiddle.net/BxCgT/" rel="nofollow">http://jsfiddle.net/BxCgT/</a></p>
| jquery | [5] |
4,977,679 | 4,977,680 | How to tell a View subclass to load its own layout | <p>I have a custom View subclass which I am calling <code>ListItem</code> which has a layout (<code>res/layout/list_item.xml</code>). I cannot get my <code>ListItem</code> class to load the layout xml file.</p>
<pre><code>public class ListItem extends View{
private TextView title, subtitle;
public ListItem(Context context) {
this(context, null);
}
public ListItem(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ListItem(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
//I want to load/inflate the view here so I can set title and subtitle.
}
}
</code></pre>
<p>I can get the view to load by doing this, but I don't like the fact that it happens outside of the scope of the <code>ListItem</code> class. It seems like <code>ListItem</code> should be responsible for loading its own view. From ListViewAdapter.java:</p>
<pre><code>public View getView(int position, View convertView, ViewGroup parent) {
ListItem entry = items.get(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_item, null);
}
TextView title = (TextView) convertView.findViewById(R.id.title);
title.setText(entry.getTitle());
TextView subtitle = (TextView) convertView.findViewById(R.id.subtitle);
subtitle.setText(entry.getSubtitle());
return convertView;
}
</code></pre>
<p>Again, I want to load the layout from within the <code>ListItem</code> class. Is it possible for a view to load its own layout?</p>
| android | [4] |
744,023 | 744,024 | How can we make a nested directory in resource folder to put the xmls with same name? | <p>How can we make a nested directory in resource folder to put the xmls with same name for different folders.And how we can read it using path in iphone app programatically?</p>
<p>Actually i want to make like resource>a>b>some.xml
again in resource like resource>f>g>some.xml</p>
<p>and so on...how ever both xml is containing different data in it.and also tell me the way how we can read it in iphone application.</p>
| iphone | [8] |
5,546,846 | 5,546,847 | Is it possible to prevent an app from being uninstalled? | <p>I want to write an app that a parent can use to disable phone functionality to prevent their child from using it. One way the child could circumvent this is by uninstalling the app. </p>
<p>Is there a way to prevent application uninstall on the Android?</p>
| android | [4] |
5,287,137 | 5,287,138 | XP app won't increase cpu utilization | <p>I am trying to fix a problem with a legacy Visual Studio win32 un-managed c++ app which is not keeping up with input. As a part of my solution, I am exploring bumping up the class and thread priorities.</p>
<p>My PC has 4 xeon processors, running 64 bit XP. I wrote a short win32 test app which creates 4 background looping threads, each one running on their own processor. Some code samples are shown following. The problem is that even when I bump the priorities to the extreme, the cpu utilization is still less than 1%.</p>
<p>My test app is 32 bit, running on WOW64. The same test app also utilizes less than 1% cpu utilization on a 32 bit xp machine. I am an administrator on both machines. What else do I need to do to get this to work?</p>
<pre><code>DWORD __stdcall ThreadProc4 (LPVOID)
{
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);
while (true)
{
for (int i = 0; i < 1000; i++)
{
int p = i;
int red = p *5;
theClassPrior4 = GetPriorityClass(theProcessHandle);
}
Sleep(1);
}
}
int APIENTRY _tWinMain(...)
{
...
theProcessHandle = GetCurrentProcess();
BOOL theAffinity = GetProcessAffinityMask(
theProcessHandle,&theProcessMask,&theSystemMask);
SetPriorityClass(theProcessHandle,REALTIME_PRIORITY_CLASS);
DWORD threadid4 = 0;
HANDLE thread4 = CreateThread((LPSECURITY_ATTRIBUTES)NULL,
0,
(LPTHREAD_START_ROUTINE)ThreadProc4,
NULL,
0,
&threadid4);
DWORD_PTR theAff4 = 8;
DWORD_PTR theAf4 = SetThreadAffinityMask(thread1,theAff4);
SetThreadPriority(thread4,THREAD_PRIORITY_TIME_CRITICAL);
ResumeThread(thread4);
</code></pre>
| c++ | [6] |
814,411 | 814,412 | Android gallery onItemClick show larger image | <p>I've just finished copying the android walkthrough for the gallery (http://developer.android.com/resources/tutorials/views/hello-gallery.html) and was wondering how I would go about having the thumbnail photo scale into a larger one within the onClickItem method.</p>
<pre><code> public void onItemClick(AdapterView parent, View v, int position, long id) {
Toast.makeText(ProjectPreview.this, "" + position, Toast.LENGTH_SHORT).show();
}
</code></pre>
<p>Currently it just shows the position as depicted in the Toast. Could someone point me in the right direction or show me a simple way?</p>
<p>Thanks in advance.</p>
<p>EDIT: Added this method and called it in the onItemClick sending it the position. And it works. </p>
<pre><code> public void showLarger(int position){
ImageView image = (ImageView) findViewById(R.id.iv1);
image.setLayoutParams(new Gallery.LayoutParams(200, 100));
image.setScaleType(ImageView.ScaleType.FIT_XY);
image.setImageResource(mImageIds[position]);
}
</code></pre>
| android | [4] |
2,935,887 | 2,935,888 | Get value of items from list using javascript | <p>I have this code :</p>
<pre><code><script>
function getgroup(){
var i=0;
var total=document.getElementById("selectedOptions").length;
while (i<total)
{
var group=document.getElementById("selectedOptions").value;
var group2=group.substring(2);
alert(group2);
i++;
}
}
</Script>
</code></pre>
<p>I want to loop inside the list and get the value of each item in the list.
By using this code I am getting only the value of the first item only.</p>
<p>Any help please?</p>
| javascript | [3] |
2,067,032 | 2,067,033 | Find all textfield using JQuery | <p>I have a jsp page in which i add dynamically more textfields
The id-s of those textfields are something like that textfield1, textfield2, ..., textfieldn
I have a button who save me all the values of textfields
But first i want to check if some of the textfields have values in it.
How can i check using JQuery all the textfields starting with 'textfield'
Thanks</p>
| jquery | [5] |
2,156,140 | 2,156,141 | What is a short-hand method for creating a of key/value pairs from a class instance variables? | <p>What should be a best way to create key/value pairs for all the string instance variables of a class? Is there any library exists doing such a task? </p>
<p>I am doing the same using a reflection based backward look-up. But it seems doing to much work.</p>
<p>For example:</p>
<p>I have a class</p>
<pre><code>public class Account implements ManagedEntity {
private String accountNumber;
public Account(String accountNumber) {
this.accountNumber = accountNumber;
}
}
</code></pre>
<p>If an instance of <code>Account</code> class is created like blelow,
Account ac = new Account("abc");</p>
<p>The output map should be like: [{"accountNumber", "abc"}].</p>
| java | [1] |
3,429,219 | 3,429,220 | android application in fixed size window | <p>is it possible to run an android application in a fixed size window? </p>
<p>for example , i want to run my application in a fixed size window and at the same time i should be able to control the remaining area of the device screen(read messages, play music, ect..). </p>
| android | [4] |
3,953,395 | 3,953,396 | query on calculating the Calendar day | <p>Can we use Calendar rule while getting Day of year in Gregorian calendar like we have for Week of year - GetWeekInYear(DateTime date, Calendar rule, DayOfweek firstDayOfWeek) ?</p>
| c# | [0] |
1,608,420 | 1,608,421 | SocketServer continue execution after serve_forever | <p>I'm using the SocketServer module in python to implement a simple embedded web server in my application. At the moment I'm calling the serve_forver method within a dedicated thread in order to continue the execution of my application.</p>
<p>I was wondering if there is there a more pythonic way to start my SocketServer and retun the execution to my application.</p>
| python | [7] |
3,857,295 | 3,857,296 | Dynamic Keyword Arguments in Python? | <p>Does python have the ability to create dynamic keywords?</p>
<p>For example:</p>
<pre><code>qset.filter(min_price__usd__range=(min_price, max_price))
</code></pre>
<p>I want to be able to change the <strong>usd</strong> part based on a selected currency.</p>
| python | [7] |
1,327,522 | 1,327,523 | Working with two projects- | <p>I have developed a basic desktop-app using Netbeans IDE, on the app I have a button called <code>Ok</code>. Now I have created another project, its a CRUD-app. Is there a way to make the ok-button in my 1st project to run the CRUD-app in another project- or how do I link tha ok-button to open/run the crud-app? In a different project..Project names are pro1 and CruD-test-
Below is a sample-code for my button:</p>
<pre><code>OK.addActionListener(new ActionListener(){
//please add a link to the CRUD-app contained in project Crud-test
</code></pre>
<p>@Max: I wanna run pro1 on the IDE and run the CruD-test as jar...how do I link mu OK-button to the CruD-test?</p>
| java | [1] |
1,128,333 | 1,128,334 | Accessing data from text box | <pre><code>function testTask06()
{
var cipherText = document.getElementById('cipherTextBox').value;
var indexCharacter = document.getElementById('indexCharacterTextBox').value;
document.getElementById('plainTextBox').value = (decryptMessage(cipherText, indexCharacter, plainArray, cipherArray));
}
</code></pre>
<p>I want to get values from textbox called 'cipherTextBox' and 'indexCharacterTextBox', then use those values in my function decryptMessage and then display result in textbox 'plainTextBox'. It doesnt work but i'm wondering if it's because my function decryptMessage is wrong.</p>
| javascript | [3] |
4,839,430 | 4,839,431 | How to insert data from multiple array to database PHP? | <p>How to insert data from multiple array to database PHP&MYSQL?</p>
<p>I have created one table name is student. There are 3 fields ID,Name and Sex.</p>
<p>Example: Array ( [0] => 1,Jam,M [1] => 2,Janny,F [2] => 3,Vary ).</p>
<p>Table students there 3 fields ID,NAME,SEX.</p>
<p>How to insert multiple array into Table students?</p>
| php | [2] |
902,547 | 902,548 | What is the purpose of a private class in c#? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3235283/is-it-possible-to-have-a-private-class">Is it possible to have a private class?</a> </p>
</blockquote>
<p>Please explain why a developer would create private class. What is the purpose of a private class?</p>
<p>Example:</p>
<pre><code>private class ClassB
{
public DoSomething()
{
}
}
</code></pre>
| c# | [0] |
239,292 | 239,293 | fmod() function for Android | <p>is there any equivalent function for fmod() in android?</p>
<p>--- in c++ : ----</p>
<pre><code>double fmod(double x, double y)
float fmodf(float x, float y)
</code></pre>
<p>The fmod functions compute the floating-point remainder of dividing x by y.</p>
<p>The return value is x - n y, where n is the quotient of x / y, rounded to the first integer towards zero.</p>
| android | [4] |
4,253,199 | 4,253,200 | How to get configured email username and password from iPhone | <p>I have created a sample iPhone application. In that application I have to fetch configured email username and password.</p>
<p>I have configured my GMail account in iPhone mail application.</p>
<p>How can i get my username and password using iPhone API.</p>
<p>Is this possible ?</p>
<p>Thanks in advance.</p>
| iphone | [8] |
2,297,401 | 2,297,402 | question about class | <blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/926752/why-should-i-prefer-to-use-member-initialization-list">Why should I prefer to use member initialization list?</a><br>
<a href="http://stackoverflow.com/questions/2785612/c-what-does-the-colon-after-a-constructor-mean">C++ - what does the colon after a constructor mean?</a> </p>
</blockquote>
<p>here is following code</p>
<pre><code>class vector2d {
public:
double x,y;
vector2d (double px,double py): x(px), y(py) {}
</code></pre>
<p>i dont understand this line</p>
<pre><code> vector2d (double px,double py): x(px), y(py) {}
</code></pre>
<p>is it same as
<code>vector2d(double px,double py){ x=px;y=py;}?</code> or?</p>
| c++ | [6] |
2,971,623 | 2,971,624 | how to fill Array Within the Start Date and End Date in android | <p>Suppose I want Array Of Dates i want Dates between</p>
<p>Start Date- 26/9/2012
End Date-3/10/2012</p>
<p>diffinDays=7;
What i am doing is </p>
<pre><code> for(int i=0;i<diffInDays;i++){
DateArray[i]=StartDate.toString();
SimpleDateFormat sdf= new SimpleDateFormat("dd/mm/yyyy");
Calendar c= Calendar.getInstance();
try {
c.setTime(sdf.parse(StartDate));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
c.add(Calendar.DATE, 1);
// number of days to add
StartDate= sdf.format(c.getTime()); // dt is now the new date
}
</code></pre>
<p>It Addes me Date but when the Date is 30/09/2012 how can i add Month? </p>
| android | [4] |
4,012,885 | 4,012,886 | Javascript to expand object at runtime? | <p>Hi is this possible? say you have the following:</p>
<pre><code>var settings = {
name : 'bilbo',
age : 63
}
</code></pre>
<p>Can you dynamically add another property at runtime so it becomes?</p>
<pre><code>var settings = {
name : 'bilbo',
age : 63,
eyecolor : 'blue'
}
</code></pre>
| javascript | [3] |
5,828,803 | 5,828,804 | Insert progress spinner into splashscreen android | <p>Hello
In my android application,i would like to place a progress bar such that it shows the user that the data is getting downloaded and gets dismissed once the data is loaded.</p>
<p>Is there any way that i can achieve this.</p>
<p>Thanks in advance:)</p>
| android | [4] |
1,769,896 | 1,769,897 | What are the replacements for javascript | <p>What are the replacements for javescript.
I think JQuery in one of the good replacement for jave scripts though it is developed using Java script.
I want to know any other like this ..
Please give me any link or information on this</p>
| javascript | [3] |
5,558,662 | 5,558,663 | jquery catch a first keypress only? | <p>I have this code:</p>
<pre><code> $j("#regfname").keypress(function () {
alert('Handler for .keypress() called.');
});
</code></pre>
<p>and want to execute only once... or only for the first keypress ..what's the most optimal way to do it? </p>
| jquery | [5] |
5,282,444 | 5,282,445 | What is the issue with this java singleton class implementation? | <p>I have come across another article in stackexchange on various ways to implement java singleton. One of the ways shown is the following example. It has been voted very low. Wanted to understand why.
<a href="http://stackoverflow.com/questions/70689/what-is-an-efficient-way-to-implement-a-singleton-pattern-in-java">What is an efficient way to implement a singleton pattern in Java?</a></p>
<pre><code>public class Singleton {
private static Singleton instance = null;
static {
instance = new Singleton();
// do some of your instantiation stuff here
}
private Singleton() {
if(instance!=null) {
throw new ErrorYouWant("Singleton double-instantiation, should never happen!");
}
}
public static getSingleton() {
return instance;
}
}
</code></pre>
| java | [1] |
5,615,369 | 5,615,370 | UIActivityIndicatorView is bugged in the iPhoneSDK? (crashes from UIKit) | <p>I got the following crash report from iTunesconnect. Is the UIActivityIndicatorView bugged? </p>
<pre><code>Date/Time: 2009-09-26 12:33:02.034 +1000
OS Version: iPhone OS 3.0 (7A341)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x31d54964 lstat + 8
1 Foundation 0x3055baf6 _NSFileExistsAtPath
2 Foundation 0x3055f6a2 -[NSFileManager fileExistsAtPath:]
3 WinterBoard.dylib 0x0019f034 0x19c000 + 12340
4 WinterBoard.dylib 0x001a032c 0x19c000 + 17196
5 UIKit 0x30972650 +[UIActivityIndicatorView _loadResourcesForStyle:]
6 UIKit 0x30972498 -[UIActivityIndicatorView setActivityIndicatorViewStyle:]
7 UIKit 0x309723bc -[UIActivityIndicatorView initWithFrame:]
8 UIKit 0x30a113f8 -[UIActivityIndicatorView initWithActivityIndicatorStyle:]
</code></pre>
<p>Below is how I created it:</p>
<pre><code>UIActivityIndicatorView *act = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
act.center = CGPointMake(160, 190);
[act startAnimating];
[self addSubview:act];
[act release];
</code></pre>
| iphone | [8] |
690,607 | 690,608 | Principle of java float number calculation error | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2100490/floating-point-inaccuracy-examples">Floating point inaccuracy examples</a> </p>
</blockquote>
<p>In the first, I apologize for my poor English.</p>
<p>We all know Java float number calculation error. Such as follows:</p>
<pre><code>System.out.println(0.0934 * 1000);
System.out.println(0.0935 * 1000);
System.out.println(0.0936 * 1000);
</code></pre>
<p>The result is</p>
<pre><code>93.39999999999999
93.5
93.60000000000001
</code></pre>
<p>And we can use <em>BigDecimal</em> to resolve this problem.</p>
<p><strong>I want to know the principle of the error. What reason caused the problem.</strong></p>
<p>Thanks.</p>
| java | [1] |
1,397,753 | 1,397,754 | how to pass last click item to another page using jquery | <p>how do i pass the last clicked item to another page using jquery? I have this toggle menu in my web app. what i want to happen is when i clicked a link in my toggle menu it will go to the another page but it will retain the selected toggle menu open. Is this possible?</p>
<p>here's my toggle menu code for jquery </p>
<pre><code><script>
$(document).ready(function(){
$(".product-contents").hide();
$("div.product-header").click(function(){
$(this).toggleClass("active").next().slideToggle("fast");
});
});
</script>
</code></pre>
| jquery | [5] |
3,620,566 | 3,620,567 | iPhone tabs issue | <p>I have made 5 tabs: <code>home</code>, <code>ask</code>, <code>tip of the day</code>, <code>inbox</code> and <code>disclaimer</code>. My problem is that the text <code>tip of the day</code> does not exactly fit inside the tab. I mean the <code>T</code> of tip and <code>Y</code> of day are getting out of the area of the tab. And it's looking absurd.</p>
| iphone | [8] |
3,079,118 | 3,079,119 | import module from another path cause IOERROR:NO such file or directory | <p>this is a visual representation of my directory :</p>
<p><img src="http://i.stack.imgur.com/tHtFX.png" alt="enter image description here"></p>
<p>here is the code snippet from test1.py </p>
<pre><code>....
def foo():
f=read("./test1.dat","r")
....
</code></pre>
<p>here is the code of test2.py </p>
<pre><code>import imp
TEST1 = imp.load_source('test1', '../test1.py')
def test2():
TEST1.foo()
</code></pre>
<p>running test2.py</p>
<pre><code>cd subdir
python test2.py
</code></pre>
<p>got IOERROR: No Such file or directory : "./test1.dat"</p>
<p>my question is :</p>
<p>if I don't change the structure of directory, for example move test2.py to its parent directory, is it possible to make module test1 find the correct file when calling it in module test2?</p>
| python | [7] |
4,659,322 | 4,659,323 | how to call an activity class in onBackPressed()-android | <pre><code>public void onBackPressed()
{
Intent setIntent = new Intent(this,xxxxx.class);
startActivity(setIntent);
return;
}
</code></pre>
<p>I call <code>onBackPressed()</code> to one activity the processing happen well.but it call same activity once again (ie) If we press back in android phone the previous onCreate() method can not call in normal action,if we overwrite 'onBackPressed()' onCreate() is called as per the code above. So how we start the activity without help of onCreate().</p>
| android | [4] |
56,368 | 56,369 | Android surface flinger | <p>I want to know whether the surface flinger knows anything about the clickable regions on the current screen or surface flinger just displays the final screen and it knows nothing about the clickable regions and the windowmanagerservice dispatches the input to the window which is on the top and it does whatever it has to do with the input?</p>
| android | [4] |
4,636,197 | 4,636,198 | web page not displaying special characters | <p>I have an ".HTML" file which is stored in the "res\raw" folder.
I used the following code to display the contents of my file:</p>
<pre><code>static String TAG="WebPageShowActivity";
WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webpagedisplay);
String summary = readRawTextFile(this,R.raw.spotlighterhelp);
//getResources().openRawResource(R.raw.spotlighterhelp).toString();
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadDataWithBaseURL (null,summary, "text/html","ASCII" ,null);
}
public static String readRawTextFile(Context ctx, int resId)
{
InputStream inputStream = ctx.getResources().openRawResource(resId);
InputStreamReader inputreader = new InputStreamReader(inputStream);
BufferedReader buffreader = new BufferedReader(inputreader);
String line;
StringBuilder text = new StringBuilder();
try {
while (( line = buffreader.readLine()) != null) {
text.append(line);
}
} catch (IOException e) {
return null;
}
Log.e(TAG, "file content: "+text.toString());
return text.toString();
}
</code></pre>
<p>now, my problem is: Whatever be the type of encoding, it is not displaying special characters like " or ' What do I do so that these characters are shown too?</p>
<p>Following is the output I am getting
<img src="http://i.stack.imgur.com/5MEC6.png" alt="enter image description here"></p>
| android | [4] |
2,022,924 | 2,022,925 | pass variable through hidden input php | <p>I am anew to php please help...
I am trying to collect a variable (in specific the counter I used in my loop) on a $_POST after I submit my form.</p>
<pre><code><form action="reportingTemplate.php" method="post">
<?php
function buildform() {
if (file_exists('textt.txt')){
$x = file_get_contents('textt.txt');
$y = explode("\r\n", $x);
$incr = 1;
foreach ($y as $value) {
$z = explode(",", $value);
writehtml($incr,$z[1],$z[2],$z[0]);
$incr++;
}
if ($incr < 15)
for ($incr = $incr; $incr<16; $incr++) {
writehtml($incr,"","","");
}
}
else
for ($increm = 1; $increm<16; $increm++) {
writehtml($increm,"","","");
}
}
?>
<input type="hidden" id="test" name"countt" value="<?php echo $incr; ?>"/> <!--error area -->
<input type="submit"/>
</form>
</code></pre>
<p>where I am getting my $_POST:</p>
<pre><code>$the = $_POST["countt"];
echo $the;
</code></pre>
| php | [2] |
5,473,017 | 5,473,018 | How to escape a pipe ( | ) symbol for url_encode in python | <p>I am facing a problem with urllib.url_encode in python. Bets explained with some code:</p>
<pre><code>>>> from urllib import urlencode
>>> params = {'p' : '1 2 3 4 5&6', 'l' : 'ab|cd|ef'}
>>> urlencode(params)
'p=1+2+3+4+5%266&l=ab%7Ccd%7Cef'
</code></pre>
<p>I want to keep the pipes ('|') in to l parameter. can you please tell me how?</p>
<p>The result should be</p>
<pre><code>'p=1+2+3+4+5%266&l=ab|cd|ef'
</code></pre>
<p>PS: I do not want to put together the URL manually, but use urlencode for that.</p>
<p>Thanks
-Pat</p>
| python | [7] |
2,246,858 | 2,246,859 | Session Logout in every two minutes | <p>I have Web Application in asp.net.
Where I am maintaining Session for every User. And every Time I got logout in Approx 2 min.
I tried to increase this time through web Config File upto 60 min but it is not working For me and I m getting same problem.</p>
<p>I have created A class file For maintaining session.I am Using This Code.</p>
<pre><code>public static void createSession(System.Web.SessionState.HttpSessionState session)
{
Session = session;
}
</code></pre>
<p>This is my class file code.</p>
<p>And I am calling this function in login Page load like this.</p>
<pre><code>BusinessClasses.SessionHandler.createSession(Page.Session);
</code></pre>
<p>Then After I am Checking In everyPage.</p>
<p>But this code is not working for me.
Please Give Suggest me correct solution for this problem.</p>
| asp.net | [9] |
2,926,172 | 2,926,173 | Add a Delete Button to my Gallery script | <p>I've made an image gallery to work with my instant image capture program I've made. I've got all the images from the directory to display correctly but I want to add a delete button which can delete the images. Here's my code so far (minus the HTML).</p>
<pre><code><?php
$ip = getenv(REMOTE_ADDR);
$folderName = md5($ip);
$dir = ''.$folderName.'';
$file_display = array('png', 'jpg', 'gif');
if (file_exists($dir) == false) {
echo "<b>Your Folder</b> ( $dir ) <b>cannot be found. Please contact the site developer.</b><br>";
} else {
$dir_contents = scandir($dir);
foreach ($dir_contents as $file) {
$file_type = strtolower(end(explode('.', $file)));
if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) {
echo '<div style="margin-bottom:15px;"><img src="', $dir, '/', $file, '" alt="', $file, '" /><br /><a class="button">Delete</a></div><br />';
}
}
}
?>
</code></pre>
<p>How would I got about making the link with the class "button" able to delete the image which is displayed? I'm not very experienced with PHP so a good explanation would be of great help and appreciation.</p>
| php | [2] |
4,588,596 | 4,588,597 | accordian + and - symbol help | <pre><code><script type='text/javascript'>
$(document).ready(function() {
$('div.Syb> div').hide();
$('div.Syb> h4').click(function() {
var span = $(this).children('span:first').attr('class');
// span.text(span.text()=='+'?'-':'+');
span = (span == 'plus')?'minus':'plus';
$(this).children('span:first').attr('class',span);
$(this).next('div').slideToggle('fast')
.siblings('div:visible').attr('css','plus').slideUp('fast');
// $(this).siblings('div.Syb>h4 >span:first').attr('css','plus');
});
});
</script>
</code></pre>
<p>when ever the div gets closed in need to put + symbol back...which i am not able to do ..any help on this?</p>
<pre><code><div class="Syb">
<h4><span class='plus'></span>Title 1</h4>
<div>Lorem...</div>
<h4><span class='plus'></span>Title 2</h4>
<div>Ipsum...</div>
<h4><span class='plus'></span>Title 3</h4>
<div>Dolor...</div>
</div>
</code></pre>
<p>is my html</p>
| jquery | [5] |
2,086,855 | 2,086,856 | Jquery counters & variables and square brackets | <p>A form with this hidden field is loaded</p>
<pre><code><input type = "hidden" class = "counter" value="6">
</code></pre>
<p>I use Jquery to do this</p>
<pre><code>var counter = $(".counter:last").val()
</code></pre>
<p>then a click event adds a row with this text field</p>
<pre><code>.append($('<input>').attr('type', 'text').attr('name', 'drugName["+counter+"]')
</code></pre>
<p>this returns</p>
<pre><code> <input size="40" type="text" name="drugName["+counter+"]">
</code></pre>
<p>Where am I going wrong. I tried multiple variations.</p>
<p>Any help/references?</p>
| jquery | [5] |
659,294 | 659,295 | jquery draggble has a problem on dragging? | <p>I wanted to restore the position of red block which is a draggble div on the green and gray block and not in blue block it is not worked on green block but it worked on gray block please help me ... For this purpose i am using jquery revert. The code and lnk are below please help me
<a href="http://galtech.org/testing/drag.php" rel="nofollow">http://galtech.org/testing/drag.php</a></p>
<pre><code><style type="text/css">
#draggable { width: 100px; height: 70px; background: red; }
#nodrag { width: 200px; height: 270px; background: #00CC66; }
</style>
</head>
<body >
<div style="background:#CCCCCC;">
<div id="droppble_blue" style="background:#99CCCC; height:500px; width:620px;">
<div id="draggable" >Drag</div>
<div id="nodrag" class="new">no Drag & drop here</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function() {
$("#draggable").draggable({ revert: "invalid" });
$("#droppble_blue").droppable({drop: function() { alert('dropped');}});
});
</script>
</code></pre>
| jquery | [5] |
2,129,380 | 2,129,381 | Access a C++ struct in C# | <p>I am having a <a href="http://en.wikipedia.org/wiki/Visual%5FC%2B%2B" rel="nofollow">VC++</a> stucture like </p>
<pre><code>struct VideoInputV20 {
int m_nBrightness;
int m_nSharpness;
int m_nSaturation;
int m_nContrast;
int m_nInputState;
CString m_sObjref;
};
</code></pre>
<p>Here in C# I'll receive this stucture in byte[]. Here I need to convert byte[] to stuct.</p>
<p>How can I achive this? Please provide sample code, if possible.</p>
| c# | [0] |
1,006,192 | 1,006,193 | android google map view | <p>i am using android Google map, the map is displayed in emulator but not in the device.. can any one help me to solve the problem.</p>
| android | [4] |
4,407,490 | 4,407,491 | TabBar rotation from protrait to landscape | <p>I am making a TabBar based universal app. I have added few extra tabs and changed the viewController to navigationController. Now when i am trying to rotate the view from protrait to landscape, its rotating the inside view but tabBar does not rotate and it stays at the same place ie at the bottom of the protrait mode where as every other UI are rotating properly.
Can any one help me out to solve this problem.
thanks in advance.
akash</p>
| iphone | [8] |
3,199,040 | 3,199,041 | missing argument in php function? | <p>Ok no i am calling a few variables from mysql database and they are not static i not that good but if i call a function like</p>
<pre><code>$var = 'hi';
function fun($var){
$var;
}
</code></pre>
<p>now it will be correct and display the result but if i call multiple variables from mysql database then it will show missing argument or variable not defined why so? I have define the result in more separate variables like </p>
<pre><code>$row_data['value'] = $var;
function fun($var){
$var;
}
</code></pre>
<p>now can anyone help me?</p>
| php | [2] |
1,846,411 | 1,846,412 | jQuery ui dialog wont work second time | <p>Hi I have an button and onClick i pop up a jQuery ui Dialog box with some form elements in it. the first time i click everything works perfectly but second time i click the box appears but my form elements are gone and its just an empty dialog box. Any ideas whats going wrong? The code im using is:</p>
<pre><code>var $dialog = $('<div id="saveDialog"></div>')
.html('Please choose the folder you wish to save the file in:')
.dialog(
{
autoOpen: false,
modal: true,
buttons: {Ok: function()
{
$( this ).dialog( "close" );
}},
show: "blind",
hide: "explode",
resizable: true,
minWidth: 500,
maxWidth: 800,
height: 400,
open: function()
{
var phpArray = <?php echo json_encode($directories); ?>;
$.each(phpArray, function (i, elem)
{
$('#saveDialog').append('<br> <img src="/app/webroot/css/jqueryFileTree/images/directory.png"/><a id="'+elem+'">'+elem+'</a>');
});
}
$dialog.dialog('open');
return false;
</code></pre>
<p>Thanks in advance!</p>
| jquery | [5] |
4,761,567 | 4,761,568 | How to get variable from one class to another? | <p>I am a newbie to PHP and have question which writen in Example_02 class.</p>
<pre><code><?php
class Entity
{
private $components = array();
public function add_component(Component $component)
{
if (in_array($component, $this->components) == false)
$this->components[] = $component;
}
public function get_component(Component $component)
{
if (in_array($component, $this->components) == true)
return $this->components[array_search($component, $this->components)];
}
}
class Component
{
}
class Example_01 extends Component
{
public $example_var;
public function __construct()
{
}
}
class Example_02 extends Component
{
public function __construct()
{
// how to get $example_var from Example_01 class?
}
}
$ent = new Entity();
$ent->add_component(new Example_01());
$ent->add_component(new Example_02());
var_dump($ent);
?>
</code></pre>
| php | [2] |
1,088,944 | 1,088,945 | Substring Comparison in python | <p>If i have List PhoneDirectory
Eg:</p>
<pre><code>['John:009878788677' , 'Jefrey:67654654645' , 'Maria:8787677766']
</code></pre>
<p>Which is the function that can be use to compare the Presence of Substring (Eg: Joh) in each entry in the List .</p>
<p>I have tried using </p>
<pre><code>if(PhoneDirectory.find(Joh) != -1)
</code></pre>
<p>but it doesnt work</p>
<p>kindly Help..</p>
| python | [7] |
4,188,856 | 4,188,857 | Make OS open directory in Python | <p>I am writing a program in Python, and want to get it to make the OS open the current working directory, making for instance Windows open explorer.exe and navigating to the wanted directory. Any ideas on how to do this? </p>
<p>The directory is already given by os.getcwd. </p>
<p>Cross platform methods preferred :)</p>
| python | [7] |
2,167,227 | 2,167,228 | How do i keep a php script active even if nobody opened the website? | <p>I have a project, i need to do this</p>
<ol>
<li>a desktop application sends a txt file with a number to the web server every 5 seconds</li>
<li>the web server opens that file and saves the number in a database</li>
</ol>
<p>the thing is that i need it to work 24/7 , even if the user hasn't logged in.</p>
<p>the desktop application already works, what can I do?</p>
| php | [2] |
875,784 | 875,785 | Method to record golf strokes | <p>The method is to record the number of strokes a player took when completing a hole. The method returns true when strokes are successfully recorded. There are 2 caveats: (1)the hole must be recorded in order and must start with 1. If a hole is received out of order, the score is not recorded and false is returned (2)The hole number must also be valid. You can't record a score for a hole that is less than 1 or greater than the number of holes on the course. When debugging my code give a java.lang.NullPointerException. What does that mean and how can i fix this.</p>
<p>Note: holesPlayed is an instance variable assigned the value of 0</p>
<p>Here is what i have:</p>
<pre><code>public boolean recordStrokes(int holeNumber, int strokes) {
if ((holeNumber >= 1) &&
(holeNumber <= this.holesPlayed) &&
(holeNumber == holesPlayed + 1
{
scores[holeNumber -1] = strokes;
holesPlayed = holesPlayed + 1;
return true;
}
else {
return false;
}
}
</code></pre>
| java | [1] |
5,282,714 | 5,282,715 | How can I write this shorter? | <pre><code>public static string GetUa(HttpRequest hr)
{
try
{
string visitorBrowser = hr.UserAgent.ToString();
string originalBrowser = hr.ServerVariables["X-OperaMini-Phone-UA"];
string anotherOriginalBrowser = hr.ServerVariables["X-Device-User-Agent"]; //novarra
if (!String.IsNullOrEmpty(originalBrowser))
{
return "OPERAMINI " + originalBrowser;
}
else
{
if (!String.IsNullOrEmpty(anotherOriginalBrowser))
{
return "NOVARRA " + anotherOriginalBrowser;
}
else
{
return visitorBrowser;
}
}
}
catch
{
return "No UA Found";
}
}
</code></pre>
| c# | [0] |
4,667,210 | 4,667,211 | How to copy Key Value Elements from one Hash Table to the other HT | <p>I am trying to copy first 5 key value pair from Hash Table 1 to Hash Table 2
and Then next 6 to 10th Key value pair from Hash Table 1 to Hash Table 3.</p>
<p>I am not able to get this going,, can any one has any hint please share it with me </p>
| java | [1] |
1,515,543 | 1,515,544 | How to search for words containg certain letters in a txt file with Python? | <p>Look at the code below. This finds the letter 'b' containing in the text file and prints all the words containing the letter 'b' right?</p>
<pre><code>x = open("text file", "r")
for line in x:
if "b" and in line: print line
searchfile.close()
</code></pre>
<p>Now here is my problem. I would like to search with not only one, but several letters.
Like, a and b both has to be in the same word.
And then print the list of words containing both letters.</p>
<p>And I'd like to have the user decide what the letters should be.</p>
<p>How do I do that?</p>
<hr>
<p>Now I've come up with something new. After reading an answer.</p>
<p>x = open("text file", "r")</p>
<p>for line in x:
if "b" in line and "c" in line and "r" in line: print line</p>
<p>Would this work instead?
And how do I make the user enter the letters?</p>
| python | [7] |
1,417,945 | 1,417,946 | jQuery form login issue | <p>Hey guys so basically I'm doing a normal jQuery login and I do some form validation. So basically the problem is I set a variable named no_errors = true and so when I do fill out all of the form I works fine until I add the if ( no_errors == true ) then when hit the submit button it refreshes the page which it isn't suppose to do. Anybody have any tips or ideas? Thanks </p>
<p>jQuery code</p>
<pre><code><script type='text/javascript' src='http://localhost/js/jquery.js'></script>
<script type="text/javascript">
$(function () {
var no_errors = true;
function trimInput(input) {
return $.trim(input);
}
function doError(div) {
$("#" + div).css("color", "red");
$("#" + div).css("background", "#F59FC1");
$("#" + div).css("border", "1px dotted #FF1C1C");
}
function doSuccess(div) {
$("#" + div).css("color", "green");
$("#" + div).css("background", "#94FFA8");
$("#" + div).css("border", "1px solid #00FF2F");
}
$("#signin").submit(function () {
if (!trimInput($("#username").val())) {
doError("username");
no_errors = false;
} else {
doSuccess("username");
}
if (!trimInput($("#password").val())) {
doError("password");
no_errors = false;
} else {
doSuccess("password");
}
if (no_error == true) {
$("#e_c").html("Were good here!");
}
return false; //Stops the page from refreshing.
});
});
</script>
</code></pre>
<p><em><strong>UPDATE</em></strong></p>
<p>I messed it up, instead of if (no_error == true) its if(no_errors == true) I missed an s :P common mistake I hope xD. </p>
| jquery | [5] |
70,354 | 70,355 | When to use Object[] and List<Object> | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1589813/when-to-use-a-list-over-an-array-in-java">When to use a List over an Array in Java?</a> </p>
</blockquote>
<p>As the title states, I am trying to figure out when to use certain types of lists. I just realized that I have no idea how these Object[]-lists are implemented, and thus when they are preferred over List. Perhaps they are only preferred when I know that the size of the list wont change? I hope I have made my question clear.</p>
<p>Cheers,</p>
| java | [1] |
5,659,009 | 5,659,010 | Click a button to go next tab in Android | <p>I have an Android application which is a tab layout and contains 3 tabs. There is a button in the first tab, which when clicked should go to the second tab. Also the second tab contains a back button which when clicked should go to the first tab. How to do this? Actually it should work like clicking on the tabs. Please help at the earliest.</p>
| android | [4] |
2,853,815 | 2,853,816 | How to distinguish between a SHA1 string and a date-time string? | <p>Basically I have two options:</p>
<pre><code>$one = "fdfeb16f096983ada02db49d46a8154475d700ae";
$two = "2011-12-28 05:20:01";
</code></pre>
<p>I need some sort of regex, so that I can detect wether the string follows the pattern in <code>$one</code>, or the pattern in <code>$two</code></p>
<p>Detect if the string is sha1 or datetime.</p>
<p>What would be the best way to determine this?</p>
<p>Thanks</p>
| php | [2] |
1,455,446 | 1,455,447 | Opening An sqlite database in android | <p>I have been trying to open my ready made sqlite data base</p>
<p>in my android application my question is:</p>
<p>how do I open an sqlite database with the function:</p>
<p>openOrCreateDatabase();</p>
<p>And where should i put the sqlite file</p>
<p>And if my approach is wrong please enlighten me</p>
| android | [4] |
5,170,354 | 5,170,355 | is it posible to check flash support on browser from code behind - C# asp.Net | <p>how can i check if a web browser was supported flash or not yet from code behind ?</p>
| asp.net | [9] |
3,428,084 | 3,428,085 | How to concatenate strings and integer in a variable | <p>I have a variable of <code>int</code> type.
I am running for loop on it and making a variable with adding some string info.</p>
<pre><code>a = 5 // variable with integer value
list = '' // empty variable
for x in range(a):
list.append('MA[' + x + '] |')
</code></pre>
<p>Expected output:</p>
<pre><code>MA[5] | MA[4] | MA[3] | MA[2] | MA[1] | MA[0]
</code></pre>
| python | [7] |
4,259,227 | 4,259,228 | Javascript Slide Out Panel without JQuery | <p>For example : <a href="http://www.building58.com/examples/tabSlideOut.html" rel="nofollow">http://www.building58.com/examples/tabSlideOut.html</a> (Click on the Contact button on the right)</p>
<p>I Live to have this function in my website, but I do not want to add a ton of javascript to mit. And so my question is: Is there any simple javascript to do that?</p>
<p>I found a tutorial that just uses CSS3 <a href="http://www.1stwebdesigner.com/tutorials/slide-out-panel-css3/" rel="nofollow">http://www.1stwebdesigner.com/tutorials/slide-out-panel-css3/</a> here but it shows the panel in the Top of the site, when I want it to the left or right :D</p>
<p>Thanks for your reply</p>
| javascript | [3] |
4,420,750 | 4,420,751 | Saving formatted timestring as file name problem in c# | <p>HI guys,
I only started c# recently so I'm not 100% familiar with it's syntax yet and I got into a problem. I'd like to write the current time into a filename. I'm using the following code:</p>
<pre><code>DateTime now = DateTime.now;
string dateString = string.Format(@"Z:\test\{0}.bmp",now.ToString("s"));
bitmap.Save(dateString);
</code></pre>
<p>Now this gives me a can't access filepath error. Apparently it has something to do with the ":" characters at the time part (at least when I give a now.ToString("d") ) it saves fine.
Any idea whats causing this? Thanks. </p>
| c# | [0] |
3,962,684 | 3,962,685 | How much time does it take to execute a loop? | <p>Is there any way to know how many seconds does it take a loop to execute in java? </p>
<p>For example:</p>
<pre><code>for(int i=0; i < 1000000; i++) {
//Do some difficult task goes in here
}
</code></pre>
<p>It does not have to be accurate 100%, but its just to have an idea of how long it could take. The algorithm inside is some kind of key generator that writes to a .txt file. I expect it to take even a few mins, so for my first test i want to count the seconds.</p>
| java | [1] |
5,609,689 | 5,609,690 | Object & Value context - Where did this come from? | <p>I was reading some random solutions on the train to work, and I came across one that was very well written and seemed to have some interesting information on arrays - and possibly more. From everything I know, the solution sounds perfect - but I've never heard it described this way before and I was wondering if anyone could provide me a reference or let me know where this came from so I could read more:</p>
<p>Excerpt from:</p>
<p><a href="http://stackoverflow.com/questions/2035066/type-of-an-array">Array Type - Rules for assignment/use as function parameter</a></p>
<blockquote>
<p>For understanding the difference, we need to understand two different contexts.
In value contexts, the name of an array of type T is equivalent to a
pointer to type T, and is equal to a pointer to the array's first
element. In object contexts, the name of an array of type T does not
reduce to a pointer.</p>
</blockquote>
<p>The solution goes on to talk about object & value contexts more, showing which situations use which contexts to describe how array types are treated. I'd love to understand this better and read a more thorough article on it. Can someone point me in the right direction?</p>
| c++ | [6] |
521,246 | 521,247 | static const in classes | <p>I think is an old question but I don't get it.</p>
<p>I have a header routines.h, its functions file routines.cpp and the main file main.cpp.</p>
<p>In the header there is:</p>
<pre><code>class myclass{
public:
static const double a;
void mymethod();
};
const double myclass::a=0.0;
</code></pre>
<p>The routines.cpp contains: <code>#include"routines.h"</code> and then define the methods.</p>
<p>main.cpp also has <code>#include"routines.h"</code>.</p>
<p>This setup gives a link error: a it's already defined. </p>
<pre><code>public: static double const myclass::a" (?a148@myclass@@2NB) already defined in DBFLOWPAR2.obj
</code></pre>
<p>DBFLOWPAR2 is my main file.</p>
<p>If I define the methods in routines.h it works fine, but I don't like that.
What else it's possible? I don't care how the variables are defined, I just want to be able to access myclass.a and find the right value in it.</p>
| c++ | [6] |
839,093 | 839,094 | How can i shows added person ? JQuery after inserting to db | <p>I basically insert person to my db and use below code.After inserting db if(response==ok)</p>
<p>it adds person to db. However, i have to show the added person. If i use reload it send the main page. What's your suggestion for that? </p>
<pre><code>function AddData(par){
var artistName = $("input[name='"+par+"']").attr('id') + '-'+$("input[name='"+par+"']").val();
$.post('/json/management/AddDataAjax2',
{
"artistName": artistName
},
function(response){
console.log(response);
if(response =='ok')
alert("Başarıyla eklendi");
else{
alert("Sanatçı bulunamadı, yönlendiriliyorsunuz");
window.location.replace("http://www.sinemalar.com/management/artistAddEditRemove/");
}
});
}
</code></pre>
| jquery | [5] |
1,289,328 | 1,289,329 | code restrict the user doing the task within the app based on device or ip | <p>I make an android login and register application, I want to try to prevent user unstop register which means they can only register once per hour( just an example), so how to set the time restriction in it? I know someone could create different account to do it, so may be it's even better to restrict the phone device. I had experience on the web that you could do it using cookie or ip, but I don't know how to achieve that in android since I am new to it, could anyone give me some idea or code even better, any help will be greatly appreciated!</p>
| android | [4] |
661,642 | 661,643 | C++ - 2 classes 1 file | <p>Suppose I want something of this sort, in one <code>.cpp</code> source file:</p>
<pre><code>class A {
public:
void doSomething(B *b) {};
};
class B {
public:
void doSomething(A *a) {};
};
</code></pre>
<p>Is there anyway of doing this without splitting it into two separate files, and without receiving a compiler error (syntax error on <code>doSomething(B *b)</code>)
<hr>
<strong>Thanks</strong>, all 5 of you. Who exactly am I supposed to mark as accepted? :)</p>
| c++ | [6] |
217,917 | 217,918 | Difference between * and *& | <p>When I have defined fnc in a following way: </p>
<pre><code>QDialog* get_dialog(Caller* caller);
</code></pre>
<p>then calling it with my class </p>
<pre><code>class Main_Dialog : public Base_Dialog<Ui::Main_Dialog>{};
</code></pre>
<p>works. </p>
<pre><code>//def of Base_Dialog
template< class Ui_Dialog >
class Base_Dialog : public QDialog, protected Ui_Dialog{};
</code></pre>
<p>but if I define this fnc as: </p>
<pre><code>QDialog* get_dialog(Caller*& caller); //note ref
</code></pre>
<p>then code doesn't compile, giving error: </p>
<pre><code>error: no matching function for call to 'Main_Dialog::get_dialog(Main_Dialog* const)'
</code></pre>
<p>candidate is: </p>
<pre><code>template<class Dialog, class Caller> QDialog* Main_Dialog::get_dialog(Caller*&)
</code></pre>
<p>Isn't that the fnc I'm trying to call? What's wrong?</p>
| c++ | [6] |
1,579,382 | 1,579,383 | Update a tabView from within another tab? | <p>I am having trouble with the tabBar:didSelectItem: in my app...
I have 4 tabs and 1 of them is a settings tab that updates a plist file with the settings on save. </p>
<p>What I want to do is to run an action, when another tabbar item is selected, so I can update the view with the appropriate settings. I just can't get this to work. Can anyone please show me an example on how to use the tabBar:didSelectItem: in this way, or maybe another way to do it? Thanks...</p>
| iphone | [8] |
4,980,186 | 4,980,187 | Account preferences crashes on ListPreference | <p>I have created an account type using the AccountAuthenticator stuff as done in the <code>SampleSyncAdapter</code> tutorial. I am now trying to get account preferences working.</p>
<p>I have added the line <code>android:accountPreferences="@xml/account_preferences"</code> to my <code>account-authenticator</code> and account_preferences.xml looks like so:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/alum_settings_title"/>
<CheckBoxPreference
android:key="sync_alum"
android:title="@string/sync_alum"
android:summaryOn="@string/sync_alum_check"
android:summaryOff="@string/sync_alum_nocheck"/>
<ListPreference
android:key="sync_alum_since"
android:title="@string/alum_years"
android:entries="@array/years"
android:entryValues="@array/years"
android:dependency="sync_alum"/>
</PreferenceScreen>
</code></pre>
<p>The checkbox preference works exactly like it should but the ListPreference crashes the entire system with the following message:</p>
<pre><code>05-14 22:32:16.794: ERROR/AndroidRuntime(63): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
</code></pre>
<p>I get the same error with EditTextPreference and with the custom subclass of DialogPreference I created.</p>
| android | [4] |
4,374,644 | 4,374,645 | Redirecting to the edited page in response to edit | <p>I am looking for a PHP Script that would redirect the user see his own page/record after he has saved his edits. e.g. client logs on finds his record clicks to edits his record and once he saves his record the page will redirect to view his changes. I am using PHPRunner. According to the instructions I would add a script to the After Edit Events: Redirect tab and add a script. The only problem I am having is that I don't know the script needed to fetch the records Key. Below is a sample of what I saw in a previous post. A little different for it is more of a button. But based on this script I figured I can make it work. Can anyone help? The TABLE: Teams Key: TID</p>
<p>I have an idea based on what I have seen.</p>
<pre><code>//********** Redirect to another page ************
header("Location: Teams_view.php?editid1=key1=".$keys["TID"]);
exit();
</code></pre>
<p>But this will not send the client to its own page. Then I have seen this but it does not fetch the record id(Key) either.</p>
<pre><code>header("Location: Teams.php?key1=".$keys["TID"]);
exit();
</code></pre>
| php | [2] |
1,809,954 | 1,809,955 | .NET now support trailing comma in array like python does | <p>Hi Everyone today i just noted that C# 3.5 have a interesting feature which is useful and available in python as well and may be other languages.</p>
<p>It is the trailing comma(,) in a array. Normally a compiler will give error on it but it need not to. And it seems that Microsoft add this feature and now compiler doest complaint for a trailing comma in array. It was unnecessary error which is now not treated as error any more.</p>
<p>Look at declaration of array i and s and see a trailing (comma), which compile and run correctly.</p>
<pre><code> static void Main(string[] args) {
var intarray = new[] { 1, 2, 3, 4, 5, };
var strarray = new[] { "Hello", ",", " ", "World", };
Console.WriteLine(string.Join("", strarray));
foreach (var i in intarray)
Console.WriteLine(i);
}
</code></pre>
<p>This for informative and not a question but comments are welcome. I am using VS2008.</p>
| c# | [0] |
1,711,314 | 1,711,315 | Page.IsPostBack or IsPostBack | <p>I just wanted to know that is there any performance difference between these two statements</p>
<pre><code>Page.IsPostBack
</code></pre>
<p>or</p>
<pre><code>IsPostBack
</code></pre>
| asp.net | [9] |
5,467,277 | 5,467,278 | Errors in form for php | <p>I have been working on this form for my php class. I can not believe I am getting errors left and right. Now I am getting this error:</p>
<p>No database selected
error on table connection </p>
<p>But i check and everything works on my table, here is my code:</p>
<pre><code>if ($_POST['submit']!=""){
if ($_POST['username']==""||$_POST['password1']==""||$_POST['password2']==""||$_POST['firstname']==""||$_POST['lastname']==""||$_POST['address']==""||$_POST['email']==""||$_POST['city']==""||$_POST['state']==""||$_POST['zip']==""||$_POST['phone']=="");
$error=1;
}
else if ($_POST['password1']!=$_POST['password2']){
$error=2;
}
else{
$hostname="localhost";
$database="Contacts";
$mysql_login="Web_User";
$mysql_password="my1230";
if (!($db = mysql_connect($hostname, $mysql_login , $mysql_password))){
echo "error on connect";
}
else{
if (!(mysql_select_db($databse,$db))){
echo mysql_error();
echo "<br>error on table connection";
}
else{
$SQL="Insert into tblUsers(username,password,firstname,lastname,email,address,city,state,zip, phone,signupDate)values)'".$_POST['username']."',PASSWORD('".$_POST['password1']."'),'".$_POST['firstname']."','".$_POST['lastname']."','".$_POST['address']."','".$_POST['city']."','".$_POST['state']."','".$_POST['zip']."','".$_POST['phone']."',NOW())";
mysql_query($SQL);
if (is_numeric(mysql_insert_id())){
header("Location:member-content.php?name=".$_POST['username']);
}
else{
echo "Sorry, there was an errot.Please try again ot contact the administrator";
}
mysql_close($db);//closeing out connection,done for now
}
}
</code></pre>
<p>}</p>
<p>?></p>
<p>I haven been sittin here and when I get one thing working the next thing don't work...</p>
| php | [2] |
2,788,883 | 2,788,884 | Python symbolic | <p>How can I create vector with symbolic e1,e2,e3..</p>
<p>[e1;e2;e3]</p>
| python | [7] |
327,003 | 327,004 | Can't find the bug in javascript | <p>Code:</p>
<pre><code>for(int j=0; j<virtualFields.length();j++)
{
finalOptions += '<option value="'+virtualFields[j]+'"><\/option>' ;
}
</code></pre>
<p>Firebug is giving this error: </p>
<blockquote>
<p>Missing ; after for loop initializer.</p>
</blockquote>
| javascript | [3] |
1,080,927 | 1,080,928 | getElementById problem | <p>I call the following function with a mouseover event but it's not working. My id's are all correct & I have properly linked all my external scripts.</p>
<pre><code>function new2() {
var prevWin = document.GetElementById("recentlyaddedtip");
prevWin.style.visibility = "visible";
}
</code></pre>
<p>recentlyaddedtip is set as hidden in the stylesheet (and it properly changes to visible when I change it manually.)</p>
| javascript | [3] |
4,869,448 | 4,869,449 | How to open android calculator buit-in-application | <p>Thanks to every on to support android development forum.
I want to make a application where when I click a button in my application then open android
built-in Calculator application.</p>
<p>That means I want to call calculator apk file from my application.
Is it possible?</p>
<p>Advanced thanks to reply</p>
| android | [4] |
3,651,288 | 3,651,289 | How to display floating-point numbers with a mantissa set to zero in C++? | <p>The following code displays floating-point numbers in scientific notation:</p>
<pre><code>float foo = 1.0;
::cout::setf(::std::ios::scientific);
::std::cout << foo;
</code></pre>
<p>It produces this output:</p>
<pre><code>1.000000e-000
</code></pre>
<p>What I would like to do is display floating-point numbers in a specific notation which resembles the scientific notation but with a mantissa set to zero. With the same floating-point number as above, it would produce:</p>
<pre><code>0.100000e+001
</code></pre>
<p>In C, I believe it would be written this way:</p>
<pre><code>printf("%.6E", foo);
</code></pre>
<p>Update: Well, actually I don't know how to do it in C as well.
Update2: The example using iostream formatting was incorrect. I modified it according to Michael Burr's comment.</p>
| c++ | [6] |
5,742,056 | 5,742,057 | Toggle a div closed if a #something is present in a URL | <p>How can i toggle a div closed using jquery ie hide the box below (close it) if #something is present in the URL <a href="http://www.mydomain.co.uk/index.php#something" rel="nofollow">http://www.mydomain.co.uk/index.php#something</a> </p>
<pre><code><div id="feature">content</div>
</code></pre>
| jquery | [5] |
5,175,708 | 5,175,709 | How to increase heap size of an android application? | <p>I am writing an Android application which uses several 3D models. Such a model with textures can take up a lot of memory. I found out the manufacturer sets a limit on the heap size an application can use. For example my tablet Samsung Galaxy Tab 8.9 P7310 can take up 64MB of memory.</p>
<p>Is there a way to increase this size of memory an application can use?</p>
| android | [4] |
271,483 | 271,484 | Android App crash when setting setOnFocusChangeListener to EditText | <p>My app keep crashing when i set OnFocusChangeListener to editText.. the app crashing and i logcat send me java.lang.nullPointerException..why?</p>
<pre><code>public class MainActivity extends FragmentActivity
implements HeadlinesFragment.OnHeadlineSelectedListener {
private int myYear, myMonth, myDay;
static final int ID_DATEPICKER = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.news_articles);
EditText txt1 = (EditText) findViewById(R.id.editText2);
txt1.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
final Calendar c = Calendar.getInstance();
myYear = c.get(Calendar.YEAR);
myMonth = c.get(Calendar.MONTH);
myDay = c.get(Calendar.DAY_OF_MONTH);
showDialog(ID_DATEPICKER);
}
});
</code></pre>
| android | [4] |
3,722,356 | 3,722,357 | Does UILabel have a horizontal padding? | <p>Does UILabel have a horizontal padding?</p>
| iphone | [8] |
2,965,131 | 2,965,132 | What exactly does this mean in C#? | <p>I'm browsing an open source .NET twain wrapper and saw this:</p>
<pre><code>[Flags]
internal enum TwDG : short
{ // DG_.....
Control = 0x0001,
Image = 0x0002,
Audio = 0x0004
}
</code></pre>
<p>What exactly does that 'Flag' decorator mean? (Is it called a 'decorator'?)</p>
<p>Also, what does the short mean at the end of the enum declaration?</p>
<p>Thanks!</p>
| c# | [0] |
6,005,454 | 6,005,455 | C# WebBrowser Button generated by Java Script | <p>How do I click a button generated by JavaScript? I'm loading the site via built-in WebBrowser, the button is showing, but I can't find it in the site source.</p>
<p>Generated button:</p>
<pre><code><a class="single_like_button" onclick="openFbLWin_xxxxxx();">Subscribe</a>
</code></pre>
<p><code>xxxxxx</code> are other every time, I don't have idea to search and click this button (or execute only <code>openFbLWin_xxxxxx()</code> )</p>
<p>Subscribe</p>
| c# | [0] |
2,041,399 | 2,041,400 | Will array_unique work also with array of objects? | <p>Is there a better way than using array-walk in combination with unserialize?</p>
<p>I have two arrays which contain objects. The objects can be same or can be different. I want to merge both arrays and keep only unique objects.</p>
<p>This seems to me like a very long solution for something so trivial. Is there any other way?</p>
<pre><code>class Dummy
{
private $name;
public function __construct($theName) {$this->name=$theName;}
}
$arr = array();
$arr[] = new Dummy('Dummy 1');
$arr[] = new Dummy('Dummy 2');
$arr[] = new Dummy('Dummy 3');
$arr2 = array();
$arr2[] = new Dummy('Dummy 1');
$arr2[] = new Dummy('Dummy 2');
$arr2[] = new Dummy('Dummy 3');
function serializeArrayWalk(&$item)
{
$item = serialize($item);
}
function unSerializeArrayWalk(&$item)
{
$item = unserialize($item);
}
$finalArr = array_merge($arr, $arr2);
array_walk($finalArr, 'serializeArrayWalk');
$finalArr = array_unique($finalArr);
array_walk($finalArr, 'unSerializeArrayWalk');
var_dump($finalArr);
</code></pre>
| php | [2] |
3,990,660 | 3,990,661 | Would like to concantenate list of fields one of which is a URL link | <pre><code>$list[] = '<li><a href="' . $row->tr_survey_link . '"> ' . $row->Survey_Subject . '</a></li>';
</code></pre>
<p>How would I add a field after the Href each time I try I get nothing showing in list... </p>
<p>want to add $row->Evaluator_Type before or after link.... but it just does not seem to work</p>
| php | [2] |
5,443,424 | 5,443,425 | C++ object oriented return value of virtual function in base class | <p>I am making a class which inherits off another and must return the value of a function in the base class... It is confusing so I will let the code speak for itself...</p>
<pre><code>class ParentClass {
public:
virtual bool getMyVal();
};
bool ParentClass::getMyVal() {
return true; // in my program there is a bit more to it
}
class ChildClass : public ParentClass {
public:
bool getMyVal();
};
bool ChildClass::getMyVal() {
CalculateMassOfSun();
return parent::getMyVal(); // Please make sure you read below...
}
</code></pre>
<p>So this is just an example of what I want to do, not the actual code. As you can see, in ChildClass::getMyVal(), is basically needs to do some pre-computation then run the same function in the parent class and return its value. I know that it is a virtual function in the parent, and that I have not gone about invoking the function in the parent the right way - it is how it is done in PHP and the only way I can think of that makes sense to me and hopefully others at the moment.</p>
<p>So how would I go about doing this? At the moment, I have found something along the lines of:</p>
<pre><code>bool ChildClass::getMyVal() : /*ParentClass::*/getMyVal() { ... }
</code></pre>
<p>however it does not return the value here.</p>
<p>Thanks in advance for your responses.</p>
| c++ | [6] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.