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 |
---|---|---|---|---|---|
215,509 | 215,510 | Working with associate array in javascript | <p>I making one application which contains 2 input box and one input button.My qestion is when user enter some input eg. "I used to going somewhere" then my result should be "I UD GNG somewhere." For that i am using this code <a href="http://pastebin.com/vHkhASdZ" rel="nofollow">http://pastebin.com/vHkhASdZ</a></p>
<p>Please,anyone have idea how to solve then pls reply me asap. I solved my issue in php but in case of javascript i don't have any idea. Here is my output link in php <a href="http://codepad.viper-7.com/SQvO6Y" rel="nofollow">http://codepad.viper-7.com/SQvO6Y</a>
I want my result in javascript.Pls anyone know then give reply.</p>
| javascript | [3] |
106,909 | 106,910 | jquery click function not getting called | <p>Why is the click function not called?</p>
<pre><code> <html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript" />
<script type="text/javascript">
$('#test').click(function () {
alert('clicked');
});
</script>
</head>
<body>
<a id="test" href="#">Click here</a>
</body>
</html>
</code></pre>
| jquery | [5] |
2,201,228 | 2,201,229 | getting all values in the row | <pre><code>var patientInfo = {}
patientInfo.patientID = row.patientID;
patientInfo.firstName = row.firstName;
patientInfo.lastName = row.lastName;
patientInfo.dateOfBirth = row.DateOfBirth;
patientInfo.age = row.age;
patientInfo.gender = row.gender;
</code></pre>
<p>When I print I <code>patientInfo</code>, I get only one row's data... how can I get all row's data?</p>
| javascript | [3] |
5,053,334 | 5,053,335 | How to add own OMX_decoder in Android? | <p>I want to add my own <code>OMX_Decoder</code> to <code>android</code>, I want to understand that, how much important it is to understand Opencore and Stagefright for same. </p>
<p>Say, I go ahead with Android 2.1 which has opencore,what will be the rework I need to do for <strong>Android 2.3</strong> or further android versions. </p>
<p>Please help me, how to move ahead what will be the best choice, what will be the steps to add OMX_Decoder in both cases?</p>
<p>Please do the needful. </p>
<p>Thank You!</p>
<p>Deepak C.</p>
| android | [4] |
5,473,539 | 5,473,540 | How to make 3d background for an android game | <p>I have started creating a 3d android game and of course this is my first experience in game development.I found out many tutorials and created a man like model in 3d as .md2 file and inserted animation into it. And now i got a perfect hero to make my game. </p>
<p>Now I want to show like he walks and the background was moving backwards. Please suggest me <strong>how can i create 3d background and make it move backwards</strong> so it will appear like perfectly he walks. Many more thanks for reading this and its great if u suggest any answer, so that my long search will comes to end. Thanks</p>
| android | [4] |
2,168,727 | 2,168,728 | Array not passing correct value | <p>i have following variable and need to use it in the array loop...</p>
<pre><code>$jointa="'nike-score', 'pack-cupcake', 'shor-burgundy'";
foreach (array($jointa) as $id) {
$yourSiteContent[] = array('permalink' => $id, 'updated' => $dated);
}
</code></pre>
<p><strong>but when i put the value direct in array loop its works fine....</strong></p>
<pre><code>foreach (array('nike-score', 'pack-cupcake', 'shor-burgundy') as $id) {
$yourSiteContent[] = array('permalink' => $id, 'updated' => $dated);
}
</code></pre>
<p>please check where i am doing mistake?</p>
| php | [2] |
3,363,755 | 3,363,756 | Pause between animations | <p>I have a bunch of < li > elements which I want to animate one after the other, so what I'm doing is the following:</p>
<pre><code><script type="text/javascript">
var i=-1;
var items = $('li');
animateAll();
</code></pre>
<p>The animateAll() function goes like this</p>
<pre><code>function animateAll(){
i++;
if(i<items.length){
var cual=items[i];
$(cual).css("position", "absolute");
var xPos=0;//to set the horizontal position
var yPos=0;//vertical position
var xInicial=$('#rec_int').position().left;//initial x position
var xFinal=xInicial+$('#rec_int').innerWidth();
var yInicial=$('#rec_int').position().top;
var yFinal=yInicial+$('#rec_int').innerHeight();
xPos=randomXToY(xInicial,xFinal);
yPos=randomXToY(yInicial,yFinal);
$(cual).css("top",xPos).css("left", yPos);
$(cual).delay(1000).animate({
left: parseInt($(cual).css('left'),10) == 0 ? -$(cual).outerWidth() :0,
top: parseInt($(cual).css('top'),10) == 0 ? -$(cual).outerHeight() : 0
},1000,animateAll());
}
</code></pre>
<p>The problem is that all the < li > are being animated after a 1 second delayed, all at the same time. What I want to achieve, is first move the first "< li >" then the second and so on.
Hope someone can help</p>
| jquery | [5] |
1,468,618 | 1,468,619 | Opacity when moving div NOT on mouse down JavaScript | <p>I have set an opacity to a draggable div, but the problem is that i don't want to add the opacity on mouse down, only when I start move the div.
Should be connected to the X and Y but i really don't get how to.</p>
<p>This is what i have.</p>
<pre><code> function startDrag(evt) { // To start the opacity function
this.style.opacity = "0.5";
}
</code></pre>
<p>And to stop in och mouse up</p>
<pre><code> function changeClass() {
var diceClass = document.getElementsByClassName("draggble");
for (var i = 0; i < diceClass.length; i++) {
diceClass[i].style.opacity="1";
}
}
</code></pre>
<p>jsFiddle
<a href="http://jsfiddle.net/dymond/tQdFZ/6/" rel="nofollow">http://jsfiddle.net/dymond/tQdFZ/6/</a></p>
| javascript | [3] |
5,882,924 | 5,882,925 | Expression value | <p>I have these declarations: </p>
<pre><code>var a;
var b = 1;
var c = 2;
var d = a || b, c;
</code></pre>
<p><code>d</code> is 1 , so what is the meaning of the <code>,c</code> in the expression?</p>
| javascript | [3] |
2,202,110 | 2,202,111 | How can I convert my string to a number in Javascript? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/12040769/how-to-convert-string-variable-to-int-in-javascript">How to convert String variable to int in javascript?</a> </p>
</blockquote>
<p>I have the following:</p>
<pre><code>var dataElapsed = $("#stats-list").attr("data-elapsed");
</code></pre>
<p>This creates a string called dataElapsed but I expect a number. How can I convert this?</p>
<p>Is there some way to convert with JQuery? or do I have to use some Javascript way?</p>
| javascript | [3] |
5,152,785 | 5,152,786 | Creating/resizing arrays...can't use non-constant? | <p>I have a struct defined as</p>
<pre><code>struct Point {
int x, int y
}
</code></pre>
<p>I am getting an array of Points passed into a function, as well as an integer i that tells me how many elements the array contains. How in the world can I just add an element into the array? I realize there is no method to just add new elements, as arrays can't be dynamically resized, so I need to create a new one and copy each element over...but when I try to do the following:</p>
<pre><code>Point newPoints[i+1];
</code></pre>
<p>I am told that it expects a constant value, which of course I can't give it since I need i+1, and i is variable. C++ makes me sad. (If it isn't obvious, I come from a land where some divine being manages all your objects for you...)</p>
<p>P.S. I <em>must</em> use arrays...forgot to mention that.</p>
| c++ | [6] |
1,804,550 | 1,804,551 | Showing grid of images with thumnail sized photos | <p>I have a requirement where I have to show a grid that contains thumbnail sized photos in say 2 rows and 5 columns. If there are more images, I need some scroller to show rest of images. Now, these are user uploaded images that could vary in size.</p>
<p>Can someone throw some light how can I dynamically resize each image to a thumbnail size and display them in a grid fashion? </p>
<p>Thanks</p>
| jquery | [5] |
2,986,040 | 2,986,041 | Is it possible to chain array.push() in Javascript? | <p>I have 3 separate arrays and I'm looking to load them all into to a single array. Am I able to use <code>.push()</code> several arrays into one? Is something like this possible?</p>
<pre><code> var activeMembers=[]; // Active Users
var noactiveMsg=[]; // Non-Active Users with a Pending Message
var noactiveNomsg=[]; // Non-Active Users without a Pending Message
var chatCenterMembers=[]; // Final Array of Chat Center Members
chatCenterMembers.push(activeMembers).push(noactiveMsg).push(noactiveNomsg);
</code></pre>
<p>Is there a way to chain .push()?</p>
| javascript | [3] |
3,595,685 | 3,595,686 | How to minify php html output without removing IE conditional comments? | <p>I minify my HTML pages whit this PHP script:</p>
<pre><code>function compress_html($html)
{
preg_match_all('!(<(?:code|pre|script).*>[^<]+</(?:code|pre|script)>)!', $html, $pre);
$html = preg_replace('!<(?:code|pre).*>[^<]+</(?:code|pre)>!', '#pre#', $html);
$html = preg_replace('#<!–[^\[].+–>#', '', $html);
$html = preg_replace('/[\r\n\t]+/', ' ', $html);
$html = preg_replace('/>[\s]+</', '><', $html);
$html = preg_replace('/\s+/', ' ', $html);
if (!empty($pre[0])) {
foreach ($pre[0] as $tag) {
$html = preg_replace('!#pre#!', $tag, $html,1);
}
}
return $html;
}
ob_start('compress_html');
</code></pre>
<p>There is a way to remove just the "HTML comments"...and not the IE conditional comments?</p>
<p>Thanks.</p>
| php | [2] |
3,103,196 | 3,103,197 | How to check if a custom protocol supported | <p>We are using software that registers its own protocol. We can run application from browser then by link like:</p>
<pre><code>customprotocol://do_this.
</code></pre>
<p>but is there a way to check is such custom protocol supported by user`s system? If not we would like to ask user to install software first.</p>
<p>E.g:</p>
<pre><code>if (canHandle ('customprotocol')) {
// run software
}
else {
// ask to install
}
</code></pre>
<p><strong>Edit</strong>
I know about protocolLong property but it works only in IE.</p>
| javascript | [3] |
4,914,968 | 4,914,969 | C# basic loop iterator | <p>Okay here's the question, using C# I need to create a program using a loop which asks for a number then displays the first 1000 multiples of it. So basically if the person enters 17 it would show 17, 34, 51, 68, 85 etc.</p>
<p>I've got so far this code.</p>
<pre><code>Console.WriteLine("Please enter a number");
int number = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= 1000; );
</code></pre>
| c# | [0] |
4,644,103 | 4,644,104 | Why isn't my JavaScript countdown function doing anything? | <p>I found this script:</p>
<pre><code><script language="Javascript" TYPE="text/javascript">
var container = document.getElementById('dl');
var seconds = 10;
var timer;
function countdown() {
seconds--;
if(seconds > 0) {
container.innerHTML = 'Please wait <b>'+seconds+'</b> seconds..';
} else {
container.innerHTML = '<a href="download.php">Download</a>';
clearInterval(timer);
}
}
timer = setInterval(countdown, 1000);
</script>
</code></pre>
<p>and I'm trying to call it with:</p>
<pre><code><input type="button" onclick="countdown()" id="dl" value="Download" />
</code></pre>
<p>but nothing happens. What am I doing wrong? I have JavasScript enabled but nothing happens after I click the button.</p>
| javascript | [3] |
3,303,451 | 3,303,452 | NSNumberFormatter currency negative number | <p>i use this</p>
<pre><code>NSNumberFormatter *f = [[[NSNumberFormatter alloc]init]autorelease];
[f setNumberStyle:NSNumberFormatterCurrencyStyle];
[f setCurrencySymbol:NSLocalizedString(@"CURRENCY", @"Get Currency")];
NSString * stringCurrecy = [f stringFromNumber:(-70.00)];
</code></pre>
<p>i using NSLog and check "stringCurrecy" is "($ 70.00)"
i change "(", ")" symbol. how change this symbol.</p>
<p>( $ 70.00 ) -> - $70.00 or $ -70.00</p>
<p>can</p>
| iphone | [8] |
4,675,534 | 4,675,535 | SQL query convert to array Android | <p>Hello i am new in android and i really need help with something. I got a prepopulate database in my sqlitehelper class and i need a query request returns a String[] table.
Example my database got 3 columns id, name, tel my query will be based on id so the cursor will get {1 mary 2134} i want that to be converted to an String [1 mary 2134]. Dont know if it helps but all my requests will be getting a single row returned, cause the query its primary key based.<br>
my code is something like that:</p>
<pre><code> public String[] getSingleRow(String id){
String[] asColumnsToReturn = new String[] { COLUMN_ID,COLUMN_NAME, COLUMN_TELEPHONE}
Cursor cursor = this.dbSqlite.query(TABLE_NAME, asColumnsToReturn, COLUMN_ID + "=" + id, null, null, null, null);
//here is where i need help
String table[]=new String[2];
int i = 0;
while (i < table.length) {
table[i] = cursor.getString(i);
i++;
cursor.moveToNext();
}
cursor.close();
return table;
}
</code></pre>
<p>I need that so in my main class i can set textview like: </p>
<pre><code>TextView myTextView = (TextView)findViewById(R.id.textView1);
Table= SQLiteHelper.getSingleRow(id);
myTextView.setText(Table[0]); // "0"for id "1" for name and "2" for telephone
</code></pre>
<p>So my question is how do i convert a single row returned query to a String[]</p>
| android | [4] |
2,500,333 | 2,500,334 | jQuery events .live() wierdness | <p>I have a page with a toolbar menu at the bottom. I have a function which checks the display property of a block that contains the menu items and sets it to "none" if it's "block" or sets it to "block" if it's "none".</p>
<p>I'm using jQuery to bind the event to the object. I want to use the live() method because I may dynamically add items to this toolbar and I want the event to automatically be attached to new menu elements.</p>
<p>The problem that I'm experiencing is that when I bind the event to the element with live(), the CSS display property of the element I'm checking is always "none". So, the menu never closes.</p>
<p>If I use bind() instead of live(), everything works like I expect it to.</p>
<p>What's causing this strange behavior with live()?</p>
<p>The demo page reproducing the problem is <a href="http://www.ghodmode.com/tbdemo" rel="nofollow">http://www.ghodmode.com/tbdemo</a></p>
<p>Thank you.</p>
<p>-- Ghodmode</p>
| jquery | [5] |
1,698,728 | 1,698,729 | ASP.net image.imageurl not showing anything | <p>i have a server image control the id is Picoftheday and i was trying to generate a url for that image control..
here is my image url generating code.....</p>
<pre><code>private string PicID()
{
DataTable dt = new DataTable();
Connection dbconn = new Connection();
SqlDataAdapter ad = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select top(1) picture_ID from t_picture order by Picture_UploadDate desc";
ad.SelectCommand = cmd;
cmd.Connection = dbconn.DBConnection;
ad.Fill(dt);
string value = null;
foreach (DataRow dr in dt.Rows)
{
value = dr[0].ToString();
}
string url = Server.MapPath("..\\ArchievedPic\\Thumbnail\\");
string[] files = Directory.GetFiles(@url, "" + value + ".*");
// string url = files[0].ToString();
string money = files[0].ToString();
return money;
}
</code></pre>
<p>on page load ....</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
Picoftheday.ImageUrl = PicID();
}
</code></pre>
<p>can anyone help please..</p>
| asp.net | [9] |
662,919 | 662,920 | PHP, MySQL table query syntax error? | <p>I hope someone can help see what's wrong here:
I have a form with two field <code>EMAIL</code> and <code>PASSWORD</code> that opens a php page where I intend to run a simple query on a table.
I get an error message that makes no sense:<br>
<code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com' at line 1</code>.<br>
The email address I entered in this case did end with '@gmail.com'<br>
Here's the code:</p>
<pre><code><?php
$dbhost = 'somewhere.net';
$dbuser = 'someUser';
$dbpass = 'pass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'medreunten_db1';
mysql_select_db($dbname) or die(mysql_error($conn));
$email = mysql_real_escape_string($_POST['email']);
$query = "SELECT * FROM employee WHERE email = $email";
$result = mysql_query($query, $conn) or die (mysql_error($conn));
extract(mysql_fetch_assoc($result));
while ($row = mysql_fetch_array($result)) {
extract($row);
echo $row['name'];
echo $row['surname'];
echo $row['age'];
}
?>
</code></pre>
<p>Any advice would be appreciated.</p>
| php | [2] |
4,652,791 | 4,652,792 | How to use ssh2_connect to connect to multiple connections? | <p>I have this php code to connect to ssh2, but I'm trying to make it so it connects too multiple hosts, instead of 1 </p>
<pre><code>$ssh = ssh2_connect('host', 22);
ssh2_auth_password($ssh, 'root', 'pass');
</code></pre>
| php | [2] |
3,193,832 | 3,193,833 | Why this line xmlns:android="http://schemas.android.com/apk/res/android" must be the first in the layout xml file? | <p>Why this line is needed in xml layout file ? </p>
<p>Can anybody give me an explanation?</p>
<p>I tried to understand, but not succeeded, so I post this question here.</p>
| android | [4] |
1,928,427 | 1,928,428 | sort a List<Tuple> from highest to lowest | <pre><code>List<Tuple<String, int[], int>>
</code></pre>
<p>I want to sort the <code>List</code> by the <code>int</code> from highest to lowest.</p>
| java | [1] |
2,917,955 | 2,917,956 | How to refactor the C++ code to support the dynamic array size | <p>I need to get rid of fixed array size in C++/ODBC apps.
Instead the hardcoded array size (ROWS =10 below) I want to pass the ROWS as the command-line argument. I know how to parse the command line.
But how to adjust the following code?</p>
<pre>
#define ROWS 10
SQLINTEGER idata[ROWS]
SQLCHAR cdata1[ROWS][256]
SQLFLOAT fdata[ROWS]
SQL_TIMESTAMP_STRUCT ts[ROWS]
SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE, ROWS)
SQLBindCol(1, &idata)
SQLBindCol(2, cdata1)
SQLBindCol(3, fdata)
SQLBindCol(4, &ts)
SQLExecDirect("query producing a result-set")
</pre>
<p>Update: I cannot modify the signature of SQLBindCol(..) </p>
<p>Let say I will create std::vector instead of SQLFLOAT fdata[ROWS] but how to pass it into SQLBindCol() which does not expect std::vector? </p>
| c++ | [6] |
4,185,147 | 4,185,148 | Display ListPopupWindow on most left of the screen | <p>I could display ListPopupWindow on most left of the screen by following code.</p>
<pre><code>@Override
public View onCreateActionView() {
LayoutInflater layoutInflater = LayoutInflater.from(mContext);
final View actionItem = layoutInflater.inflate(R.layout.list_table_view_action_provider, null);
final ImageButton button = (ImageButton) actionItem.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListPopupWindow = new ListPopupWindow(mContext);
mListPopupWindow.setAnchorView(actionItem);
mListPopupWindow.setAdapter(mAdapter);
mListPopupWindow.setModal(true);
mListPopupWindow.setContentWidth(150);
// Display mListPopupWindow on most left of the screen
mListPopupWindow.setHorizontalOffset(-1000);
mListPopupWindow.setOnItemClickListener(ListTableViewActionProvider.this);
mListPopupWindow.show();
mListPopupWindow.setOnDismissListener(ListTableViewActionProvider.this);
}
});
return actionItem;
}
</code></pre>
<p>"mListPopupWindow.setHorizontalOffset(-1000);" is too bad.
Is there other solutions?</p>
| android | [4] |
3,654,328 | 3,654,329 | how to check image behaviuor | <p>here is my image width and size code which is work perfectly but problem is that when i pass null fileupload it give me error 'argument not valid ' but i want pass null value also how will i do</p>
<pre><code>HttpPostedFile fil = this.FileUp.PostedFile;
System.Drawing.Image uploadimage = System.Drawing.Image.FromStream(fil.InputStream);
if (uploadimage.Height > 155 || uploadimage.Width > 124)
{
lblErrorMsg.Visible = true;
lblErrorMsg.Text = "<font class='orange'>Height and width not accpetable</font>";
return;
}
</code></pre>
| asp.net | [9] |
374,297 | 374,298 | How can 2 different classes point to the same datatable name | <p>I need to initialize an object in a method without specifying the class from where the object is. Can I do that?</p>
<p>can someone give me an example?</p>
<p>EDIT:</p>
<pre><code>MyClass{
...};
MySecondClass
{...
};
void method(*object); //how to write correct??
{..}
MyClass *x= new MyClass();
MySecondClass *y= new MySecondClass();
method(x);
method(y);
</code></pre>
| c++ | [6] |
5,165,125 | 5,165,126 | PushFront method for an array C++ | <p>I thought i'd post a little of my homework assignment. Im so lost in it. I just have to be really efficient. Without using any stls, boosts and the like. By this post, I was hoping that someone could help me figure it out.</p>
<pre><code>bool stack::pushFront(const int nPushFront)
{
if ( count == maxSize ) // indicates a full array
{
return false;
}
else if ( count <= 0 )
{
count++;
items[top+1].n = nPushFront;
return true;
}
++count;
for ( int i = 0; i < count - 1; i++ )
{
intBackPtr = intFrontPtr;
intBackPtr++;
*intBackPtr = *intFrontPtr;
}
items[top+1].n = nPushFront;
return true;
}
</code></pre>
<p>I just cannot figure out for the life of me to do this correctly! I hope im doing this right, what with the pointers and all</p>
<pre><code>int *intFrontPtr = &items[0].n;
int *intBackPtr = &items[capacity-1].n;
</code></pre>
<p>Im trying to think of this pushFront method like shifting an array to the right by 'n' units...I can only seem to do that in an array that is full. Can someone out their please help me?</p>
| c++ | [6] |
318,736 | 318,737 | How to determine whether the phone is ringing or making any other sound? | <p>I'm writing a recording application for sound measurements. I need find out if the phone is making any sound (ringing, incoming sms, music playing, ...) and whether the user is dialing. In that case, the measurements are temporally stopped and automatically resumed afterwards. Also vibration may influence the measurements, so I'd like to know that as well.</p>
<p>Any ideas how this can be found out? Thanks</p>
| android | [4] |
118,001 | 118,002 | Creating new structs on the fly | <p>I am (very) new to C++, and am having some issues understanding structs. I'm using example code from a course, so I have:</p>
<pre><code>struct Point {
int x;
int y;
}
</code></pre>
<p>In another bit of code, I want to write the following:</p>
<pre><code>drawLine(point1, new Point(x, y));
</code></pre>
<p>This does not work, and I understand that I am trying to declare a struct as if it were a class, but is there a way to do this? I have currently written a helper function which returns a Point from an x,y, but this seems roundabout.</p>
| c++ | [6] |
5,692,736 | 5,692,737 | how to create a range of random decimal numbers between 0 and 1 | <p>how do I define decimal range between 0 to 1 in python? Range() function in python returns only int values. I have some variables in my code whose number varies from 0 to 1. I am confused on how do I put that in the code. Thank you </p>
<p>I would add more to my question. There is no step or any increment value that would generate the decimal values. I have to use a variable which could have a value from 0 to 1. It can be any value. But the program should know its boundary that it has a range from 0 to 1. I hope I made myself clear. Thank you</p>
<p><a href="http://docs.python.org/library/random.html" rel="nofollow">http://docs.python.org/library/random.html</a></p>
| python | [7] |
4,511,902 | 4,511,903 | javascript Date diffrent days equal miliseconds | <p><a href="http://jsfiddle.net/skowron_line/zPCBc/1/" rel="nofollow">http://jsfiddle.net/skowron_line/zPCBc/1/</a></p>
<pre><code>var d1 = '31.05.2012';
var d2 = '01.06.2012';
var s1 = d1.split('.');
var s2 = d2.split('.');
var nd1 = new Date(s1[2], s1[1], s1[0]);
var nd2 = new Date(s2[2], s2[1], s2[0]);
$('#a').html(s1 + ' - '+ s2 +' = '+ nd2.getTime() +' - '+ nd1.getTime());
$('#b').html(
nd1.getFullYear() +'-'+ nd1.getMonth() +'-'+ nd1.getDate() +'<br />'+ nd2.getFullYear() +'-'+ nd2.getMonth() +'-'+ nd2.getDate()
);
</code></pre>
<p>
Can someone explain my what is wrong with this code ??. Why <code>31.05.2012</code> i equal to <code>01.06.2012</code></p>
| javascript | [3] |
5,591,133 | 5,591,134 | backlight in android | <p>In my android app , I have a menu for backlight options ,and I want that when the user selects one like " during this operation " to have the backlight on during that operation. Could I be be shown a way of accomplishing this . My problem is the that I don't know how to manipulate the backlight and how to properly arrange this in the code.</p>
<p>Thanks </p>
| android | [4] |
2,145,739 | 2,145,740 | jQuery append html element with variable string | <p>I'm a JQuery Newbie. I'm trying to append an object property( declared in an array form) to an html element like the following</p>
<p>HTML:</p>
<pre><code><div id="container">
<p>some text </p>
<p>some text </p>
<p>some text </p>
</div>
</code></pre>
<p>JQuery Script:</p>
<pre><code>var obj{
property : {'apple', 'orange', 'banana'}
}
for(i=0; i<=2; i++){
$("#container p:eq("+i+")").append(obj.property[i]);
}
</code></pre>
<p>and hope to get this:</p>
<pre><code><p>some text apple</p>
<p>some text orange</p>
<p>some text banana</p>
</code></pre>
<p>There are no appending shown at all, though my Firebug console shows no error report.</p>
<p>What am I doing wrong? Also, is there any way to replace the for loop with .each(), if it's a better practice?</p>
<p>Thank you</p>
| jquery | [5] |
3,276,170 | 3,276,171 | MVC 4 empty template page not found using model data | <p>I have started with an empty template in MVC 4 and I can access model data from views fine. However when I add a Shared folder, _Layout.cshtml and _ViewStart.cshtml, any time I try to output information from a model I get "page not found". </p>
<p>If I remove the model data from the markup and use plain HTML my layout and view load correctly. Any ideas? </p>
<p>I know I could of used the Internet Application template but I wanted to start from scratch and have already completed a lot of my model classes and configured DI.</p>
<p>Many thanks</p>
| asp.net | [9] |
2,158,122 | 2,158,123 | How can i change the focus to be on Form1 from being on the new Form? | <p>I have a button click wich i click on and it open a new Form.</p>
<p>Then i can click on the new Form listBox and everything.</p>
<p>Now when i want to back to the Form1 and click there on the menu or a button i need to click on it twice since the control/focus was on the new opened Form.</p>
<p>What's the best way to bring back the focus/control to Form1 without clicking on it first ?</p>
<p>Maybe to use an event that if i move the mouse over Form1 area it will bring the focus/control to the Form1 ?</p>
<p>This is how im doing to open/show the new Form:</p>
<pre><code>if (toolStripComboBox2.SelectedIndex == -1 && toolStripComboBox1.SelectedIndex == -1)
{
}
else
{
Lightnings_Extractor.Lightnings_Mode lightningsmode1 = new Lightnings_Extractor.Lightnings_Mode(this);
lightningsmode1.Show();
}
</code></pre>
<p>I want to make that even if the new Form is open without closing it im moving back to Form1 so the control/focus will be on Form1. And also if im closing/exiting the new Form so the control/focus will be on Form1 automatic without the need to click on it area first. </p>
| c# | [0] |
119,252 | 119,253 | Infinite nested elements in a json file - How to get specific element? | <p>this is my json file:</p>
<pre><code>{
"categories": {
"category": [
{
"id": "1",
"title": "Android",
"subcategory": [
{
"id": "1",
"title": "JavaScript",
"question": [
</code></pre>
<p>My question is: if subcategory element can appear infinite number of times
as nested in itself how can I get all the elements of every subcategory in my json file to be displayed with the help of javascript?, how can i get dipper in the nesting?
if i'm writing my code:</p>
<pre><code>data.categories.category[i].subcategory[0].subcategory[0].subcategory[0].title
</code></pre>
<p>that means that I need to add <code>subcategory[0]</code> infinite number of times to get to each
title attribute - creating a lot of different functions to handle every different situation - and this is my problem.</p>
| javascript | [3] |
2,010,010 | 2,010,011 | Javascript - take every fifth number from an input list | <p>Say I have an input consisting of 30 numbers, and I want the 1st, 5th, 10th, 15th, etc - all in one output. How would I do this?</p>
<p>Thanks much in advance</p>
<p>Joe</p>
| javascript | [3] |
1,775,586 | 1,775,587 | unable to read data from more than 1 row | <p>i have a problem reading data from the table. This is the sample of my coding</p>
<pre><code>Dim SqlQry As String = "SELECT Distinct(RechargeAmt) from KioskItem where TelcoID='" & TelcoID & "'"
Dim SqlCmd As New SqlCommand(SqlQry, Conn)
Dim dr As SqlDataReader = SqlCmd.ExecuteReader
dr.Read()
If dr.HasRows Then
While dr.Read()
Dim SqlQry As String = "SELECT Distinct(RechargeAmt) from KioskItem where TelcoID='" & TelcoID & "'"
Dim SqlCmd As New SqlCommand(SqlQry, Conn)
Dim dr As SqlDataReader = SqlCmd.ExecuteReader
dr.Read()
If dr.HasRows Then
While dr.Read()
RechargeAmt = dr(0)
a = a & RechargeAmt & ";"
End While
End If
If a = 0 Then
Return RechargeAmt
Else
Return a
End If
</code></pre>
<p>My problem is if the data has more than one row, it has no problem saving the data into a string but when my data in the table has only one rowm, it is unable to read the data. i try this</p>
<pre><code>If dr.HasRows Then
RechargeAmt = dr(0)
While dr.Read()
a = a & RechargeAmt & ";"
End While
End If
If a = 0 Then
Return RechargeAmt
Else
Return a
End If
</code></pre>
<p>but it still unable to read the data from the table</p>
| asp.net | [9] |
3,807,276 | 3,807,277 | Quick jQuery Question | <p>I have this code:</p>
<p><code><a href="javascript:$('#searchPost').submit()">Search</a></code></p>
<p>This submits my search form. I'm trying to keep it from submitting when empty. I know that'll be difficult to do inline, but when I tried to take the JS code out of the link, it ceases to work, even when the inline code calls a function outside of the link.</p>
<p>I was told to use this code:</p>
<pre><code>$('#searchPost').submit(function(event) {
if ($(this).find('#searchBox').val() == '') {
event.preventDefault();
}
});
</code></pre>
<p>But I'm not sure where to put it to make it work. Of course, inline, that code doesn't do what I want it to. I put that completely in the head of my document and it didn't change much either. Any help?</p>
| jquery | [5] |
1,482,515 | 1,482,516 | Is importing a file good in Python | <p>I have around 80 lines of a function in a file. I need the same functionality in another file so I am currently importing the other file for the function.</p>
<p>My question is that in terms of running time on a machine which technique would be better :- importing the complete file and running the function or copying the function as it is and run it from same package.</p>
<p>I know it won't matter in a large sense but I want to learn it in the sense that if we are making a large project is it better to import a complete file in Python or just add the function in the current namespace.....</p>
| python | [7] |
5,696,139 | 5,696,140 | How to save an instance of a custom class in onSaveInstanceState? | <p>I created an instance of a custom class RestaurantList to hold my data (a list of restaurant data received from a web service as json data).</p>
<p>How can I save it in <code>onSaveInstanceState</code>?</p>
| android | [4] |
4,985,871 | 4,985,872 | what's wrong with this jQuery code? | <p>My following code works fine.</p>
<pre><code>$(document).ready(function() {
$('a.address').click(function() {
$('#box').slideDown("slow");
$.ajax({
type: "POST",
url: "details.php",
success: function(html){
$("#msg").html(html);
}
});
});
});
</code></pre>
<p>However the following does not (only 1 line is changed inside the success:), it loads nothing.. only slidesdown the #box, and #msg inside, however does not load #address.</p>
<pre><code>$(document).ready(function() {
$('a.address').click(function() {
$('#box').slideDown("slow");
$.ajax({
type: "POST",
url: "details.php",
success: function(html){
$("#msg").html($(html).find('#address').html());
}
});
});
});
The details.php is:
<div id="info">some text.</div>
<div id="address">The address</div>
</code></pre>
| jquery | [5] |
2,609,235 | 2,609,236 | Javascript element is null | <p>I am a begginer at javascrit, and im trying to get a form result globaly</p>
<p>the radio button</p>
<pre><code><input type='radio' name='supporter' id='supporter' value='yes'>
</code></pre>
<p>and the javascript on the nother page</p>
<pre><code><script type="text/javascript">
function show(){
var supporter = document.getElementById('supporter');
if (supporter.value == "yes") {
alert("it works")
}
}
show();
</script>
</code></pre>
<p>and i keep getting an error, this: supporter is null</p>
<p>can please someone tell me what im missing?</p>
| javascript | [3] |
2,205,987 | 2,205,988 | Sending ajax call when active? | <p>Hey, i just noticed something on facebook.com, facebook was in my other tab, and i was browsing on SO, after a while i switched back to facebook.com and it like fades in new news in the wall. How did they make a script that knows when you are active again without clicking anywhere it shall refresh new messages etc. ? Just like facebook chat also if you have it on another tab/window then you'll hear "blub" or Facebook: **NEW MESSAGE FROM: name. How does it do that? </p>
<p>Do it run a timeout checker each second, i dont think so ? , that would be really alot of traffic and server response time, if around 3-4-500 million users would do that each day.</p>
<p>Could someone provide example where to place ajax call if it the user has left the focus and its getting onfocus again, how to make a code that runs a ajax call there? jquery?</p>
| javascript | [3] |
1,812,045 | 1,812,046 | clarification on comparing objects of different types | <p>The following sentences are a cause of confusion for me(from Guido's Tutorial on python.org):</p>
<blockquote>
<p>"Note that comparing objects of
different types is legal. The outcome
is deterministic but arbitrary: the
types are ordered by their name. Thus,
a list is always smaller than a
string, a string is always smaller
than a tuple, etc."than a tuple, etc."</p>
</blockquote>
<p>That means that for :</p>
<pre><code>a=[90]
b=(1)
a<b
</code></pre>
<p>the result should be <code>True</code>. But it is not so!
Can you help me out here?than a tuple, etc."</p>
<p>Also, what is meant by "The outcome is deterministic but arbitrary"?</p>
| python | [7] |
497,357 | 497,358 | why the code doesn't alert Worky-worky? | <pre><code>var a = function() {
function someSetup(){
var setup = 'done';
}
function actualWork() {
alert('Worky-worky');
}
someSetup();
return actualWork;
}();
</code></pre>
<p>why the above code doesn't alert Worky-worky?it shows undefined.thank you</p>
| javascript | [3] |
1,273,522 | 1,273,523 | How can I know witch web site load my image? | <p>I try to create some free HTML Templates, to share them for free, but I like to know where my templates are installed.</p>
<p>What I have in my mind, in order to track the template installation, is to create a php script that will generate a single pixel image. That script except the one pixel image generation, I like to collect information about the web site that load my picture.</p>
<p>So, how can I know what is the server that request my image ? Any Idea ?</p>
<p>Kind regards
Merianos Nikos</p>
| php | [2] |
2,963,087 | 2,963,088 | How can i change the int array to string | <p>I have an <code>int</code> array that i want to display in a text box as follows, <code>(5 4 2 8 6)</code>. Please help me.</p>
| c# | [0] |
1,357,295 | 1,357,296 | .load(function) firing twice | <p>I have a click event that loads an iframe, which is followed by a .load(function() for the iframe. The problem is the load function gets fired twice for each click event. Can someone explain me the reason why this is happening? And how can it be prevented?</p>
<pre><code>$(document).ready(function() {
$('.Popup').click(function() {
$('#myiframe').attr('src', $(this).attr('href')).load(function() {
alert('done loading')
})
return false;
});
});
</code></pre>
| jquery | [5] |
2,274,106 | 2,274,107 | Validation XML with XSD | <p>I try to validate my XML with XSD File. But I have some doubts that it validate it in any case. Here is the code of validation:</p>
<pre><code> var schemaFileName = directory + fileInfo.Name;
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(null, schemaFileName);
string msg = "";
xdoc.Validate(schemas, (o, e) =>
{
msg = e.Message;
});
</code></pre>
<p>So if there is a validation error msg is not empty as I think. But when I take xml that is surely not ok for this scheme msg is empty.</p>
| c# | [0] |
545,400 | 545,401 | Load links as unselected in jQuery | <p>I have sets of links with id and name attributes, id for individual identifiers and names for groupings. In my jQuery, I have a click function that manipulates the CSS based on what a user clicks on.</p>
<p>But I want to start the freshly loaded page with some of the links disabled (no href attribute) and with a style applied. I tried this, but it didn't work.</p>
<pre><code>$(function() // Alias for $(document).ready()
{
var $links = $('li a');
$links.(function(){
$('a[name="beam"]').filter(function() {
$(this).addClass('unavailable');
$(this).removeAttr('href');
});
}); ......
</code></pre>
<p>Ideas? (Beam is one of the groupings by name).</p>
| jquery | [5] |
5,257,038 | 5,257,039 | How to re-read in the last point ! python | <p>hello everyone
how to read txt file and stop then continue at last read line</p>
<pre><code>example:
Joe
LOley
Hana fat
oh beef come one
</code></pre>
<p>example = the txt file
and that last line i had read it is Hana fat
so how i can continue ?
like that:</p>
<pre><code>#!/usr/bin/python
#this script name is x.py don't forget that
import os
f= open("Str1k3r.txt", "r")
for pwd in f.readlines():
con(pwd.replace("\r", "").replace("\n", ""))
os.system('x.py')
</code></pre>
<p>x.py= the script file when i run it again he continue in last line he had read !
\\\\
why i need that ?because my script try to connect pop3.live.com
and try to log in with so many password from txt file
and the only way to pass is run the script over and over again but with different line of the txt file
so how we can do ?
that my code .. so how to do it?
because my script try to connect pop3.live.com
and try to log in with so many password from txt file
and the only way to pass is run the script over and over again but with different line of the txt file</p>
<p>that is my code </p>
<pre><code> import poplib
def con(pwd):
M = poplib.POP3_SSL('pop3.live.com', 995)
try:
M.user("[email protected]")
M.rset(M.pass_(pwd))
except:
print "[-]password incorrect"
else:
print '[+]really Password is:', pwd
exit()
f = open("Str1k3r.txt", "r")
for pwd in f.readlines():
</code></pre>
| python | [7] |
3,053,705 | 3,053,706 | How to call a method on specific time in java? | <p>Is it possible to call a method in java at specific time? for example: If i have a peice of code like this:</p>
<pre><code>class Test{
....
// parameters
....
public static void main(String args[]) {
// here i want to call foo at : 2012-07-06 13:05:45 for instance
foo();
}
}
</code></pre>
<p>How this can be done in java? </p>
| java | [1] |
5,658,367 | 5,658,368 | Is there a good, frequently updated, well written news site for c# developers preferably with a alt.net bent | <p>I would love to visit a web site and catch up on the latest <strong>C# news</strong>, Microsoft Framework and other alt.net news.</p>
<p>Is there something out there that offers a bit of editorial or is aggregating blog feeds into Google reader the only solution.</p>
<p>The only thing that I'm aware of that comes close to my requirements is:</p>
<ul>
<li><a href="http://dotnetkicks.com/default.aspx" rel="nofollow">DotnetKicks</a> - lack of editorial, no ability to customise a home page to filter interests to create pseudo editorial</li>
<li><a href="http://msdn.microsoft.com/en-gb/vcsharp/ee677534.aspx" rel="nofollow">Visual C# Developer Center - Team and Community Blogs</a> - again no real editorial</li>
</ul>
<h2>Related posts</h2>
<ul>
<li><a href="http://stackoverflow.com/questions/2892753/where-to-read-about-programming">Where to read about programming?</a> (Not c# specific)</li>
</ul>
| c# | [0] |
2,681,113 | 2,681,114 | A paste event triggered manually has no .originalEvent property? | <p>When I trigger a paste event with .trigger(), the ensuing captured paste event has no .originalEvent property. Is this expected behavior? Why?</p>
<p>See example - <a href="http://jsfiddle.net/2uxEr/" rel="nofollow">http://jsfiddle.net/2uxEr/</a></p>
<pre><code><textarea>Paste something here</textarea>
<button>Click for fake trigger</button>
$('textarea').on("paste", function(e){
alert(e.hasOwnProperty("originalEvent"));
});
$('button').click(function(){
$('textarea').trigger("paste");
});
</code></pre>
| jquery | [5] |
5,030,863 | 5,030,864 | Parsing firewall rules in Python | <p>I am writing a script to parse firewall rules from the configuration of a Cisco ASA.</p>
<p>Examples of my input include:</p>
<pre><code>access-list myACL line 1 extended permit tcp host 10.8.13.200 host 10.32.53.22 eq 1122
access-list myACL line 2 extended permit tcp 10.8.13.0 255.255.255.0 host 10.1.206.17 eq 445
access-list myACL line 3 extended permit udp host 10.8.13.200 eq 54345 host 10.1.206.17 eq 445
access-list myACL line 4 extended permit icmp any any
</code></pre>
<p>My desired output, in the form of a .csv, for the three lines above would be the following. However, these could just as well be tuples to be stored in a database.</p>
<pre><code>#aclName,lineNumber,action,protocol,sourceIP,sourcePort,destIP,destPort
myACL,1,permit,tcp,10.8.13.200,*,10.32.53.22,1122
myACL,2,permit,tcp,10.8.13.0/24,*,10.1.206.17,445
myACL,3,permit,udp,10.8.13.200,54345,10.1.206.17,445
myACL,4,permit,icmp,*,*,*,*
</code></pre>
<p>I'm having trouble choosing an approach to this project. I've looked at many options including ats, shlex, or even just using a regex, but I'm having difficulty determining what the best option is. Would PLY help here?</p>
<p>What would be a suitable approach for this?</p>
| python | [7] |
5,267,719 | 5,267,720 | Interesting call to main method | <p>I was around Wikipedia reading about a programming language called <a href="http://en.wikipedia.org/wiki/D_%28programming_language%29" rel="nofollow">'D'</a>, it is the first time I read about it.</p>
<p>It was curious to me that the syntax looks very similar to Java.
But most interesting was when I saw their main method uses char[][].</p>
<p>I opened up Eclipse and I tried this:</p>
<pre><code>public static void main(char [][] args){
}
</code></pre>
<p>I was surprised when I saw it compiled with no syntax errors, but I did not understand why.<br>
Can someone explain to me why this call to the main method can compile in Java?</p>
| java | [1] |
2,505,689 | 2,505,690 | Why is List<String> not a subtype of List<Object>? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2660827/java-generics-covariance">java generics covariance</a> </p>
</blockquote>
<p>I am trying to make sense of the fact that <code>List<String></code> is <strong>not</strong> a subtype of <code>List<Object></code>. </p>
<p>In effective Java, Josh Bloch notes that although it may seem counter-intuitive,it does make sense. The reason he stated is that you can put any Object in <code>List<Object></code>, but can only put String in <code>List<String></code>. I am not sure how this justifies why the String list is not a subtype of Object list. </p>
<p>Maybe I am confused by the term <code>subtype</code>. What I think it means is that when S is a subtype of T, an instance of S is an instance of T. Therefore, for <code>List<String></code> to be a subtype of <code>List<Object></code>, Object has to be a super class of String, which it technically is. Any idea where my reasoning went wrong? </p>
| java | [1] |
343,440 | 343,441 | deselect list view item? | <p>I have list view with names and numbers and checkbox populated from contacts with SimpleAdapter, and on item click I listen event and change color of item, also I want to change checkbox to enabled and after user click one more time on the same item I want to deselect that item.
How can I do that?
Thanks Wolf.</p>
<p>This is my code, I can successfully change color, but I don't now how to change checkbox state for that specific item and than on second click to change that state again:</p>
<pre><code>lImenik.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
// TODO Auto-generated method stub
Object obj = lImenik.getItemAtPosition(position);
String tmp = obj.toString();
view.setBackgroundColor(Color.GRAY);
for(int i = 0; i < adapter.getChildCount(); i++){
if(i == position){
if(position != prePos){
adapter.getChildAt(i).setBackgroundColor(Color.GRAY);
prePos = position;
} else {
adapter.getChildAt(i).setBackgroundColor(0x191919);
prePos = -1;
}
}
}
}
});
}
</code></pre>
| android | [4] |
5,322,265 | 5,322,266 | LoaderCallbacks as a static inner class (to handle multiple Loaders with different data types returned) | <p>I have an activity which uses two Loaders. Each of them returns different type of data. To get data from a single Loader one just implements <code>LoaderCallbacks<D></code> into an Activity. I guess I could just implement <code>LoaderCallbacks<Object></code> and check the type of the object and then decide which of the two LoaderCallbacks it is, but it seems like a hack to me (mostly because of the lack of type safety here).</p>
<p>So I thought about making the LoaderCallbacks object a static inner class, something like this:</p>
<pre><code>private static class geocoderLoaderCallbacks implements LoaderCallbacks<List<Address>>{
@Override
public Loader<List<Address>> onCreateLoader(int arg0, Bundle arg1) {
GeocoderTask loader = new GeocoderTask(context, "");
return loader;
}
@Override
public void onLoadFinished(Loader<List<Address>> loader, List<Address> data) {
// TODO Auto-generated method stub
}
@Override
public void onLoaderReset(Loader<List<Address>> loader) {
// TODO Auto-generated method stub
}
}
</code></pre>
<p>And then using <code>lm.initLoader(0, null, geocoderLoaderCallbacks)</code>.</p>
<p>Two question arise: is it ok to do, or should I rather stick to implementing LoaderCallbacks into Activity? And how do I safely pass the context into the onCreateLoader? Should I just make a constructor in geocoderLoaderCallbacks and pass the context there like this <code>lm.initLoader(0, null, geocoderLoaderCallbacks(this))</code>?</p>
<p>There is a similar question here <a href="http://stackoverflow.com/questions/7957418/loadermanager-with-multiple-loaders-how-to-get-the-right-cursorloader">LoaderManager with multiple loaders: how to get the right cursorloader</a> but it doesn't explain how to manage two loaders with different data types.</p>
| android | [4] |
2,002,583 | 2,002,584 | Failing to retrieve a page with file_get_contents | <p>I want to scrape some google page with file get contents function:</p>
<pre><code> $encoded='http://www.google.co.il/#hl=en&biw=1440&bih=799&sclient=psy-ab&q=site:'.urlencode("http://stackoverflow.com/");
echo file_get_contents($encoded);
</code></pre>
<p>When I do this:</p>
<p>echo $encoded;</p>
<p>I get this: </p>
<pre><code>http://www.google.co.il/#hl=en&biw=1440&bih=799&sclient=psy-ab&q=site:http%3A%2F%2Fstackoverflow.com%2F
</code></pre>
<p>When I put it in the url.. I get the page that I want</p>
<p>But when I use the function , I simply get the main google page..why does this happen?</p>
| php | [2] |
4,178,560 | 4,178,561 | How to chain jQuery removeAttr for radios inside a Div | <p>I have a checkbox that shows/hides a div that contains a grid of radio buttons. At the bottom of my page I have this jQuery:</p>
<pre><code>$(document).ready(function(){
$('#cb1_1').click(function(){ $('div#QxGrid').slideToggle('slow');
});
});
</code></pre>
<p>And this works great. When the radio buttons are hidden though I would like the page to auto-uncheck any radios that were selected, so I tried chaining a <strong>removeAttr('checked')</strong>:</p>
<pre><code>$('#cb1_1').click(function(){ $('div#Qx1').removeAttr('checked').slideToggle('slow'); });
</code></pre>
<p>This doesn't work... Is that because the jQuery is expecting a radio with id Qx1? (not a bunch of radios inside the Qx1 div?) HTML extract (abbreviated) looks like</p>
<pre><code><div id="Qx1">
<p class="ans">
<input type="radio" name="q1" id="q11" value="1"> etc.
<input type="radio" name="q1" id="q12" value="2"> etc.
<input type="radio" name="q1" id="q13" value="3"> etc.
</p>
</div>
</code></pre>
| jquery | [5] |
2,557,404 | 2,557,405 | PHP system function strange behavior | <p>I have a strange behavior with PHP system function. In this php script there are only 2 instructions (the rest being pure html):</p>
<pre><code><?php echo system('cgi-bin/gallery2/galleryheaderview.cgi'); ?>
<?php echo system('cgi-bin/gallery2/galleryview.cgi'); ?>
</code></pre>
<p>The first cgi just returns a single line as you can check here
<a href="http://reboltutorial.com/cgi-bin/gallery2/galleryheaderview.cgi" rel="nofollow">http://reboltutorial.com/cgi-bin/gallery2/galleryheaderview.cgi</a></p>
<p>It returns </p>
<blockquote>
<p>My Gallery</p>
</blockquote>
<p>But the whole php script returns My Gallery Twice:</p>
<blockquote>
<p>My Gallery
My Gallery</p>
</blockquote>
<p><a href="http://reboltutorial.com/gallery2.php" rel="nofollow">http://reboltutorial.com/gallery2.php</a></p>
<p>Is there a reason (I don't use My Gallery in second cgi script of course see <a href="http://reboltutorial.com/cgi-bin/gallery2/galleryview.cgi" rel="nofollow">http://reboltutorial.com/cgi-bin/gallery2/galleryview.cgi</a>) and how to prevent this ?</p>
<p>Thanks.</p>
| php | [2] |
4,862,281 | 4,862,282 | Undefined index php mvc model | <p>Undefined index: first_name </p>
<pre><code>$view = $user->VIEW_EMP($connect);
if (is_array($view)) {
foreach($view as $key => $value){
echo $view['first_name'];
}
}
</code></pre>
<p>Function:</p>
<pre><code>static function VIEW_EMP($db){
$sql = "SELECT * from employees LIMIT 0, 30 ";
if($output = mysql_query($sql)):
$columns = array();
while($result = mysql_fetch_assoc($output)):
$columns[] = $result;
endwhile;
endif;
return $columns;
}
</code></pre>
| php | [2] |
4,801,166 | 4,801,167 | Remake old web forms application in asp.net mvc | <p>I've inherited the code maintenance of a complex web site for a customer that continuously requests enhancements for it. This application took years to develop and I'm facing increased difficulties to enhance it. It's organized but at the same time the .net code is mixed with ajax, javascripts and old school html that it takes me days to figure out how some pages work.</p>
<p>First off, I not new to asp.net but I'm not familiar with the new MVC stuff but from what I've read it seems to be a step in a better direction.</p>
<p>The current code is all in one big dll. The application code is divided into multiple folders representing the different departments and each department has it's own pages for handling general stuff like employee management, reports, budget and also their own information.
For example, even though each department uses a different webpage for employee information handling, they want different fields and so it was simpler to create different pages than to use a single page that adapts to each department.
But it is really a nightmare to maintain right now and I would like to create a parallel project where I could start a fresh project, create a better structure and from there start migrating the old code to this new environment and refactor it as I go.</p>
<p>The idea is to migrate the old application to a new web site that has a similar look while maintaining both operating until everything is running in the new site.</p>
<p>It may sound insane but it really is used extensively for hundreds of people everyday and it bugs me that I have to modify crappy code to make it work.</p>
<p>How would you go about this issue?</p>
<p>Thanks</p>
<p>[edit]
If found this link <a href="http://www.joelonsoftware.com/articles/fog0000000069.html">Things You Should Never Do</a> on another post, very much to the point of my question.</p>
| asp.net | [9] |
5,640,316 | 5,640,317 | jquery How to remove an item with or without a comma/space? | <p>Given a Input which can contain values like:</p>
<pre><code><input type="hidden" value="XXXXXXX" />
<input type="hidden" value="XXXXXXX, YYYYYYYY" />
<input type="hidden" value="XXXXXXX, YYYYYYYY, ZZZZZZZZZZ" />
</code></pre>
<p>I want to use jQuery to remove: XXXXXXX, but if XXXXXXX has a comma after (XXXXXXX,) I need the comma removed to.</p>
<p><strong>This is what I have now:</strong></p>
<pre><code>uuid = XXXXXXX
.val(attachedUUIDs.replace(uuid + ',', '' ));
.val(attachedUUIDs.replace(uuid, '' ));
</code></pre>
<p>Ideas to do this cleanly? Thanks</p>
| jquery | [5] |
5,176,195 | 5,176,196 | Android - Signing an apk | <p>Hi<br />
I have written a little program, by default, it is signed with debug certificate.
I checked the documentation at Android developer site, I don't know how to get the certificate and key, could someone advice me?</p>
<p>Thanks</p>
| android | [4] |
5,557,410 | 5,557,411 | PHP: how can I load the content of a web page into a variable? | <p>how can I load the content of a web page into a variable ?</p>
<p>I need to store the html in a string</p>
<p>thanks</p>
| php | [2] |
3,613,818 | 3,613,819 | Using one sqlconnection/sqlcommand through 2 DB-bound methods | <p>I have a class with a method which gets data from a database through a SELECT stored proc. This method uses a <code>SqlDbReader</code> by returning <code>ExecuteReader()</code> on a <code>SqlCommand</code>.</p>
<p>The connection and everything is made in this method, with fields (such as connection string) set as class level fields.</p>
<p>I now need to populate an array based on the results of this query (so the columns of each row will go into the array with its own index).</p>
<p>However, this query will not select all of the data from one table which is involved. I can write the queries to get what I need, but how can I use one connection throughout the class? If I instantiate the connection object and call <code>Open()</code> in the constructor, I get an exception at runtime.</p>
<p>I'm hoping for something like this:</p>
<pre><code>// At class level:
sqlconn.Open();
// sqlcommand set up
Method()
{
// Fire stored proc
// Insert results in a collection
}
Method2()
{
// Pass same collection in (use same one),
// Add new row columns into same collection
}
</code></pre>
<p>How can I do this with strict performance in mind?</p>
| c# | [0] |
5,947,932 | 5,947,933 | jquery get value with '&' character | <p>I have a textbox which has value like "PN & J".I am storing it in</p>
<pre><code>var sState = $('#txtState').val();
</code></pre>
<p>and making Ajax call by</p>
<pre><code> data: 'Service=' + sSvendor + '&City=' + sCity + '&Sub=' + sCitySub + '&State=' + sState + '&Network=' + sNetwork,
</code></pre>
<p>But at the receiving end i m retrieving Value as only <code>"PN "</code> it is neglecting string after <code>'&'</code> character. how to overcome this ?</p>
| jquery | [5] |
3,426,256 | 3,426,257 | Using global variable as default parameter | <p><strong>a.py</strong></p>
<pre><code>#!c:/Python27/python.exe -u
from connection import Connection
import globals
globals.server_ip = '192.168.0.1'
connection = Connection()
</code></pre>
<p><strong>globals.py</strong></p>
<pre><code>#!c:/Python27/python.exe -u
server_ip = '127.0.0.1'
</code></pre>
<p><strong>connection.py</strong></p>
<pre><code>import globals
class Connection:
def __init__(self, server_ip = globals.server_ip):
print 'Connection is ' + server_ip + '\n'
</code></pre>
<p>I was expecting I will be getting <code>Connection is 192.168.0.1</code> being printed. But, instead, <code>Connection is 127.0.0.1</code> is being printed.</p>
<p>Unless I try to construct the connection by passing in the parameter explicitly (which is not something I wish to, as I am reluctant to make change any more on Connection with 0 parameter)</p>
<p><code>connection = Connection(globals.server_ip)</code></p>
<p>Why is this so? Is there any other techniques I can apply?</p>
| python | [7] |
2,896,518 | 2,896,519 | Could not find operator< for pointer type | <p>I'm trying to order a vector of pointers using insertion sort with an overloaded < operator (cannot use any library).
Having a class which contains another, something like:</p>
<pre><code>class A {
vector<B*> v;
void order();
}
class B {
int id; //each one is unique
virtual double num() {} const;
bool operator<(const B* b2) const;
}
class B1: public B {
double num() {} const;
}
class B2: public B {
double num() {} const;
}
</code></pre>
<p>Each child has a different way of calculating num, and the sorting is done using the double returned by num as first criteria, and then id. (sorry for the indentation)</p>
<pre><code>void A::order() {
for (unsigned int p = 1; p < v.size(); p++)
{
ClassB* tmp = v[p];
int j;
for (j = p; j > 0 && tmp < v[j-1]; j--) // Error on this line
v[j] = v[j-1];
v[j] = tmp;
}
}
bool B::operator<(const B* b2) const {
cout << "Operator <\n";
if(this->num()!=b2->num())
return this->num()<b2->num();
return id<d2->id;
}
</code></pre>
<p>I can't understand why the operator isn't being called when trying to compare the 2 pointers.</p>
| c++ | [6] |
4,631,922 | 4,631,923 | Getting User signature | <p>Him what would be the best way to provide a view where a user can provide their signature, i.e a drawing platform?</p>
<p>Well, how would it be implemented in a view using OpenGL ES?</p>
| iphone | [8] |
1,938,228 | 1,938,229 | Cycling through an array of form elements | <p>I am returning form elements into a form from ajax. I can count the number of elements returned, but I don't know how to cycle through them. I need to be able to get the value of each element returned.</p>
<p>I am pretty sure this is a basic javascript thing that I just don't know. The problem only looks more complicated with the Ajax.</p>
<p>My code looks like this:</p>
<pre><code> // The view page
<html>
<head>
<script language="javascript">
function calculateAlphaTotals(){
var length = document.myForm["alpha[]"].length;
alert( length ); // correctly outputs 3
for( var i = 0; i < length; i++ ){
try{
alert( document.myForm["alpha[]"].value ); // HTML ObjectCollection
alert( document.myForm["alpha["+i+"]"].value ); // Object Required
} catch( error ) { }
}
}
</script>
</head>
<body>
<form name="myForm" id="myFormId" method="post">
<div id="ajaxOutputId"></div>
</form>
</body>
</html>
// The Ajax page:
<input name="alpha[]" onchange="calculateAlphaTotals()" />
<input name="alpha[]" onchange="calculateAlphaTotals()" />
<input name="alpha[]" onchange="calculateAlphaTotals()" />
</code></pre>
| javascript | [3] |
3,196,905 | 3,196,906 | Does Android support .dat extension file? | <p>Actually i just want to know that whether Android Mobile phones support " .dat " file extensions. I want to save a dynamic graph in " .dat " extension format. </p>
<p>Please go through the below video link</p>
<p><a href="http://www.youtube.com/watch?v=td75nzaCrX8" rel="nofollow">http://www.youtube.com/watch?v=td75nzaCrX8</a></p>
<p>In this link someone has saved the graph in " .dat " extension.</p>
<p>Please help me guys. Best wishes and thanks in advance.</p>
| android | [4] |
1,630,538 | 1,630,539 | Getting the android username stored in the phone | <p>I am writing an application that requires to retrieve the android username [email protected] from the phone. I have been looking at AccountManager class. This is what I have for now in my code.</p>
<pre><code> AccountManager accountManager = AccountManager.get(this);
Account[] accounts =
accountManager.getAccountsByType("com.google");
String email="";
email=accountManager.getUserData(accounts[0], accountManager.KEY_USERDATA);
</code></pre>
<p>However, I am getting a caller uid 10085 is different than the authenticator's uid exception.
Anyone knows how to do it?</p>
<p>PS. I don't need password or authentication token, I just need the username.</p>
<p></p>
| android | [4] |
1,498,609 | 1,498,610 | Converting exponential value in java to a number format | <p>I am trying to read the values from excel sheet using java. When i type more than 10 letters in a cell in excel it is displaying in exponential form like "9.78313E+2". but this is not the real number what i given.
Can any body help me out in this. How can i convert the above exponential form to original number using java language.</p>
<p>Thanks in advance</p>
| java | [1] |
3,155,432 | 3,155,433 | How to make strings equal? | <p>In this a and "v1" does not come out to be equal...although the content is same..can someone help in suggesting a way such that a comes out to be equal to "v1"</p>
<pre><code>int main()
{
stringstream s;
string a;
char *c="v1";
s<<c;
a=s.str();
cout<<a;
int i=strcmp(a, "v1");
cout<<"i="<<i;
}
</code></pre>
<p>On comparing a and "v1" do not come out to be equal...please suggest some way such that i may make a to be equal to "v1"...the end goal is to make a to be equal to "v1".</p>
| c++ | [6] |
744,831 | 744,832 | How to get dropdown option label from POST request? | <p>I have this array that populates a dropdown menu. The key is my database key and the value is the corresponding database value. The issue I am having is that when I POST the form, I am getting the POSTed numerical value instead of the string value in the dropdown list. I could query the database to get the string but there has to be a better way of doing this as I already have both values in an array. I can't use array_search because the the array is multidimensional. Can someone please offer a hand?</p>
<p>Thanks</p>
<pre><code>foreach($dd as $k=>$v)
{
echo'<option value="'.$v['ace_id'].'">'.$v['arua'].'</option>';
}
</code></pre>
| php | [2] |
5,300,279 | 5,300,280 | How to render text on path? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8337221/how-to-write-curved-text">How to write curved text?</a> </p>
</blockquote>
<p>I want to render text as in given image (in place of "AMEX 3"). Please tell me how to achieve this.</p>
<p><img src="http://i.stack.imgur.com/97a8u.png" alt="Image with the text "AMEX 3" inside a curved arrow"></p>
| android | [4] |
785,299 | 785,300 | document object of window.open | <pre><code>var theNewWindow = window.open('http://www.example.com', 'example', '');
</code></pre>
<p>How can I use the <code>document</code> object of <code>theNewWindow</code> to dynamically update the dom of the new window. </p>
| javascript | [3] |
3,952,762 | 3,952,763 | Jquery shuffle cards or divs | <p>i need to do a shuffling effect using jquery. I have 8 no.of divs, it has the different designs. when the customer click on the shuffle button all this 8 cards/divs need shuffle random wise. it should be reach different x,y positions. any idea regarding to do this?</p>
| jquery | [5] |
469,834 | 469,835 | Avoid splitting of HTML tags in string | <p>I have a custom made news page in my website. The problem is adding a "more" option if the string returned from the database exceeds 400 characters. Splitting the string after 400 characters may sometimes mean that an HTML tag might be split in half, or text contained within the html tag will be split, not giving the right look when splitted. </p>
<p>Is there anyway I can possibly avoid this, or am I going at this all wrong?</p>
<p>I am currently using the Literal Control to display the string, and if the string.length > 400 I use the substring method to obtain the first 400 characters for display.
If the "more" option is clicked, I will display the full string.</p>
| asp.net | [9] |
5,902,738 | 5,902,739 | jQuery Partial Selectors | <p>I have a number of tables, which have nested tables. I using jQuery to hide some of the table cells as a number are empty or the contents irrelevant.</p>
<p>I use jQuery to hide all TD's and then jQuery to show them, for instance, if they contain a <code><P></code>.</p>
<p>Unfortunately some of the TD's don't contain anything but still need to be shown. The class the TD's are given is dynamic so I wont be able to code for them all (Sensibly) however they do all end 'Node'</p>
<p>I was wondering if its possible to do something like...</p>
<pre><code>$(function() {
$('TR .*Node').css('display','inline');
});
</code></pre>
| jquery | [5] |
4,363,723 | 4,363,724 | AutoComplete with vectors - android | <p>I've have a Vector like this in my app:</p>
<pre><code> Vector<Firm> firmVector= new Vector<Firm>();
</code></pre>
<p>As you may see, this is a vector of objects from my own class <code>Firm</code></p>
<p>So to my question, is it possible to add a <code>AutoComplete</code> to this `Vector?</p>
<p>Like this one, from <a href="http://developer.android.com/resources/tutorials/views/hello-autocomplete.html" rel="nofollow">developer.android.com</a>:</p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AutoCompleteTextView textView = (AutoCompleteTextView)findViewById(R.id.autocomplete_country);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES);
textView.setAdapter(adapter);
}
</code></pre>
| android | [4] |
1,604,226 | 1,604,227 | I'll upload a photo when the picture is not small. Just resize the-php mod_frontpage | <p>This is my methimazole code.</p>
<p>I'll upload a photo when the picture is not small. Just resize the</p>
<p>See line 244 source.</p>
<p><a href="http://www.koders.com/php/fid136A4B6F430643CDD142AFB26F9E06F0DA5EBD2F.aspx?s=rss" rel="nofollow">view source</a></p>
<p><strong>This part of the code will only change size, not small picture</strong></p>
<pre><code> if ($show_thumbs == 1) {
echo '<a href="'.$itemlink.'" title="'.$row->title.'">';
if (!empty($row->images)) {
if (preg_match('#^(http\:\/\/)#', $row->images)) { //url link from custom image
if (strstr($row->images, $mainframe->getCfg('live_site').'/images/')) { //in this site --> gd resize
$simg = str_replace($mainframe->getCfg('live_site').'/images/', '', $row->images);
$iurl = $mainframe->getCfg('ssl_live_site').'/includes/thumb.php?fi=';
$iurl .= base64_encode($thumb_width.','.$thumb_height.','.$keepratio.',images/'.$simg);
$image = '<img src="'.$iurl.' " width="'.$thumb_width.'" height="'.$thumb_height.'" class="modfpg-img" alt="'.$row->title.'" />';
} else { //in other site -> html resize
$image = '<img src="'.$row->images.'" width="'.$thumb_width.'" height="'.$thumb_height.'" class="modfpg-img" alt="'.$row->title.'" />';
</code></pre>
| php | [2] |
2,587,048 | 2,587,049 | Unseen C++ syntax | <p>A friend sent me this and I really don't know what it is, inside the loop. Whatever it be it calls the std::set constructor half million times.... any help appreciated. I would expect a compiler error, but it actually compiles in g++ 4.4 and 4.5 and the behavior is different to copy construction...</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <boost/unordered_map.hpp>
#include <set>
#include <string>
typedef boost::unordered_map<int, std::set<int> > mymap;
int main () {
mymap map;
for ( int i = 0 ; i < 1000 ; i++ )
{
std::set<int> map[i] ;
}
return 1;
};
</code></pre>
| c++ | [6] |
4,733,885 | 4,733,886 | Android AlarmManager | <p>I have an Alarm Manager which send Intent to BroadcastReceiver. This Broadcast is not in Manifest. I register it onResume and unregister onPause in my Activity. What I need is to Save 2 boolean Preferences when app is not active and time of alarm is come. How to do that ?</p>
| android | [4] |
4,066,924 | 4,066,925 | Adding a condition in the url | <p>I would line to add a test condition in an asp.net form such that:</p>
<p>1) From page1.aspx I manually add a query string parameter so that I can trigger the rest of the process in test mode like so: page1.aspx?test=true . This flag must be added in the query string.
2) When I click on a asp.net button in page1.aspx, I am redirected to page2.aspx in test mode
because of teh attached querystring</p>
<p>It seems that I have to work around the postback model of asp.net this is not very straight forward.</p>
<p>Any idea how I can achieve the above behavior?</p>
<p>Thanks</p>
| asp.net | [9] |
5,514,249 | 5,514,250 | populating text box with DropDownList using sql server | <p>I have a Textbox to enter category name, and it should populate with the DropDownList when I click the save button. Please can someone help me how to write the code? Thanks in advance.</p>
| asp.net | [9] |
1,999,174 | 1,999,175 | How many changes in Desktop Application After it become Android Application | <p>In MNC company Interview
this is the qusestion that How many changes in Desktop Application After it become Android Application
Question by company Employer That I have cheply Android mobile Not As much Internal Storage
Internal storage is around 5-10 MB.
And
Desktop App NFS its space like 1-2 GB & I want to Same this App for Android so what r the changes to make that do this App for Android</p>
<p>In simple words Company want to Desktop App to Android App so what r the efforts to do this ?</p>
<p>Advanced Thanks for Answer</p>
<p>Pls reply me </p>
| android | [4] |
2,988,664 | 2,988,665 | Print out all the possible combinations of a string | <pre><code>public static void combinations(String s) {
char[] original = s.toCharArray();
int original_size = s.length();
String temp = new String();
for (int i = 0; i < original_size; i++) {// add the first element
String sb = "";
temp = "";
sb = "" + original[i];
temp = sb.toString();
System.out.println(sb);
for (int j = i + 1; j < original_size; j++) {// add the other
// element in the
// array
if (i == j)
continue;
sb = temp + "" + original[j];
System.out.println(sb);
}
// sb = "";
}
}
public static void main(String[] args) {
combinations("abc");
}
</code></pre>
<p>The results should be:
a, ab, ac, abc, b, bc, c</p>
<p>But my program is:
a, ab, ac, b, bc, c. I can't print out abc</p>
| java | [1] |
880,255 | 880,256 | How to log into port 80 to enter credentials via a webbrowser control in c#? | <p>I have to use a webbrowser control which needs to log into an html page of the router .
I would like to log into it but bypassing the log in pop up screen . </p>
<p>Please give me suggestions as to how I could achieve this via a webbrwoswer control on a windows form.</p>
<p>Edit : This is what i could see in the source page after I inter the credentials . Not sure if it helps .</p>
<pre><code>if(F.now_proto.value == "pppoe" || F.now_proto.value == "pptp" || F.now_proto.value == "l2tp" || F.now_proto.value == "heartbeat"){
if(F.ppp_username.value == ""){
// alert("You must input a username!");
alert(errmsg.err0);
F.ppp_username.focus();
return false;
}
if(F.ppp_passwd.value == ""){
// alert("You must input a passwd!");
alert(errmsg.err6);
F.ppp_passwd.focus();
return false;
}
</code></pre>
<p>Update : Solution </p>
<p>webBrowser1.Navigate(http://username:[email protected]) </p>
<p>does it . </p>
| c# | [0] |
2,417,054 | 2,417,055 | How to construct jQuery object from variables storing html content | <p>As question stated, would like to know is that possible to construct jQuery object from variables. Example as such:</p>
<pre><code>var data = "<div id='bird'>halo world</div>";
console.log($("#bird",$(data)));
</code></pre>
<p>JSfiddle link <a href="http://jsfiddle.net/mochatony/nRQqh/" rel="nofollow">provided</a>.</p>
| jquery | [5] |
4,492,402 | 4,492,403 | Is it safe to replace a self object by another object of the same type in a method? | <p>I would like to replace an object instance by another instance inside a method like this:</p>
<pre><code>class A:
def method1(self):
self = func(self)
</code></pre>
<p>The object is retrieved from a database.</p>
| python | [7] |
5,009,021 | 5,009,022 | How to Change Image Source using Jquery using effects and looping? | <p>I want change the image source from <code>image1.png</code> to <code>image2.png</code> (with <code>fade</code>) and loop.
I have this code below but this isn't looping to image1.png. </p>
<p><strong>My code</strong></p>
<pre><code>setInterval(function(){
$('.class')
.attr('src','image2.png')
.stop(true,true).hide()
.fadeIn('slow');
}, 1000);
</code></pre>
<p>Please help me. Thanks a lot!</p>
| jquery | [5] |
502,823 | 502,824 | Any use of declaring a private static class in c#? | <p>Is there any use of declaring a static class as private.Here is the code below:</p>
<pre><code>static class DerivedClass
{
private static string GetVal()
{
return "Hello";
}
}
</code></pre>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.