Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
5,977,269 | 5,977,270 | Circle that moves on the edge of a circle | <p>As the title describes, I want to make a tiny circle that circulates on the edge of the sector of the another big circle. I have implemented sector of the circle, now only issue here is how to make small circle circulate on the edge of this sector. I have tried various ways, however, none of them was proved to be successful, therefore I plead you to give me some tips of how to implement it. </p>
<p>Thanks in advance. </p>
| c++ | [6] |
4,641,580 | 4,641,581 | Python Regular expression to end of line | <p>Bit frustrated that I can't work this out but I want to define a regular expression that selects an unknown amount of words (some spaced, some incorporating numbers, some underscored).</p>
<p>When I say 'unknown amount of words' I'm happy to limit it to 10, if that's more realistic.
Basically I'm scanning file names and don't suspect there are any longer than 10 words, but it would be nice not to have to set a limit.</p>
<p>The best I have so far is:</p>
<pre><code>tc = re.findall(r'FROM CLIP NAME:\s\s(\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*)', text)
</code></pre>
<p>Where 'FROM CLIP NAME:\s\s' will be at the beginning of each line.</p>
<p>My attempt above is a complete fail as \s reads line breaks as well as spaces and so also grabs data from the next line.</p>
| python | [7] |
1,749,958 | 1,749,959 | Insert line break after every two rows of database | <p>I have a little script that prints a certain amount of rows in a mysql database. </p>
<p>Is there any way to make it so that after every <em>second</em> row it prints, there is a line break inserted? </p>
<p>Adding a line break after every row is simple, but I don't know how to add one after every other row. Is that possible?</p>
| php | [2] |
1,539,212 | 1,539,213 | Is this a safe way to reference objects in JavaScript? | <p>If I were to define two objects myDataStore and myDrawer something like this:</p>
<pre><code>var myDataStore = function(myObjectRef) {
this.myInternalObject = myObjectRef;
};
var myDrawer = function(myObjRef) {
this.myInternalObject = myObjectRef;
};
</code></pre>
<p>And if I were to create an object like so:</p>
<p>[[EDIT - Adjusted Object Creation to Ensure 'this' is being mapped to myObject, not the global window object]]</p>
<pre><code>(function(){
var myObject = window.myObject = function(){
this.dataStore = new myDataStore(this);
this.drawer = new myDrawer(this);
}
})();
</code></pre>
<p>Then myObject.dataStore.myInternalObject, and myObject.drawer.myInternalObject, would simply be pointers back to the original 'myObject' - not taking up any additional memory in the browser. Yes?</p>
<p>I am interested in implementing techniques like this - as it makes it easy for objects to communicate with each other.</p>
| javascript | [3] |
1,227,133 | 1,227,134 | Request for Advice c# Webplayer | <p>I am currently building an asp.net c# Website for a client of mine to promote their band, on there they would like to have a Webplayer which continues to play music as people are browsing the site. The player is located on the Master page so it is included on every site, but it stops playing every time the site does a postback or refreshes in any way.</p>
<p>I think it is possible to achive this using Iframes or Ajax, although i dont have alot of knowledge in either.The site is only about 6 pages with mainly static information on there, so the only postbacks/refreshes will be done by using the navigation menu to load each page.</p>
<p>My question to you is:</p>
<p>how can I achive this?</p>
<p>what would be the easiest method and what are the pros and cons?</p>
<p>are there any other/better ways of achiving this other than using Iframes or Ajax?</p>
<p>I can provide some code if needed.</p>
<p>Thanks,</p>
<p>Seb</p>
| c# | [0] |
2,340,384 | 2,340,385 | Python: Default Parameters Values | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument">“Least Astonishment” in Python: The Mutable Default Argument</a> </p>
</blockquote>
<p>I was reading <a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables" rel="nofollow">this</a> link and got confused with Python's default parameters values. here is the code snippet:</p>
<pre><code>def bad_append(new_item, a_list=[]):
a_list.append(new_item)
return a_list
>>> print bad_append('one')
['one']
>>> print bad_append('two')
['one', 'two']
</code></pre>
<p>In the second print statement why is 'one' persisted? Shouldn't the list ['one'] be out of scope after the first print statement?</p>
<p>Essentially I am confused about the scope of variable between the function calls.</p>
| python | [7] |
2,063,875 | 2,063,876 | calculate size of file | <p>i have following program to calculate size of file</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string line;
ifstream myfile ("C:\\Users\\7\\Desktop\\example\\text.txt",ios::in | ios::out |ios::binary);
if (!myfile){
cout<<"cannot open file";
exit (1);
}
while (!myfile.eof()){
getline(myfile,line);
cout<<line<<endl;
}
long l,m;
l=myfile.tellg();
myfile.seekg(0,ios::end);
m=myfile.tellg();
cout<<"size of text file is:";
cout<<(m-l)<<"bytes"<<endl;
myfile.close();
return 0;
}
</code></pre>
<p>for make more clarify in text.txt file i have wrote some copy of information from this site <code>http://en.wikipedia.org/wiki/List_of_algorithms</code>
but it shows me 0 bytes and why? what is wrong?</p>
| c++ | [6] |
1,890,454 | 1,890,455 | (Trivial?) C# namespace/class hierarchy problem | <p>I am somewhat new to C# and I am puzzled by a compilation result belonging to a VERY small, simple and transparent program I have written and which is part of a university project. The code:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Hemtenta_problem_1
{
public class Basklass
{
public virtual void SkrivTrams()
{
Console.WriteLine("Hej Hopp");
}
}
public class Avledd_klass : Basklass
{
public override void SkrivTrams()
{
Console.WriteLine("Hej Hå");
}
}
public class Avledd_klass_till : Avledd_klass
{
public new virtual void SkrivTrams()
{
Console.WriteLine("Tjo Hej");
}
}
public class Ytterligare_avledd_klass : Avledd_klass
{
}_ //row which gives compiler message
class Program
{
static void Main(string[] args)
{
}
}
}
</code></pre>
<p>The compiler's message, relating to the row with the comment, is </p>
<blockquote>
<p>A namespace cannot directly contain
members such as fields or methods</p>
</blockquote>
<p>Now, I perfectly well understand that any field or method can't be placed out there "in the open". It needs to be part of a class, and inside one. BUT IT IS NOT A FIELD OR A METHOD THAT I AM CODING, IT IS A CLASS IN ITSELF. None of the other classes, above in the code, gave this problem. It started when I wrote the very last and as yet empty class.</p>
<p>Is Visual Studio's compiler working right? Or what is it in 40-odd lines that I am not seeing? Very grateful for comments that could help.</p>
| c# | [0] |
1,686,031 | 1,686,032 | Submit a form on checkbox click | <p>I currently use the following code to submit a form and then insert the result in a div. The form is submitted by pressing a button:</p>
<pre><code><script type="text/javascript">
$(document).ready(function()
{
$('#create').live ('submit', function() {
$.ajax(
{
data: $(this).serialize(), // get the form data
type: $(this).attr('method'), // GET or POST
url: $(this).attr('action'), // the file to call
success: function(response)
{ // on success..
$('#created').html(response); // update the DIV
}
});
$('#url').val('');
return false; // cancel original event to prevent form submitting
});
$("#content").load("contentpage.php");
});
</script>
</code></pre>
<p>I would like to change this so that rather than submitting the form with the button, I submit it by clicking a checkbox. Is this possible? There are a lot of forms on the page (and several checkboxes). The one that would need to submit the form is called "submitcheckbox"</p>
<p>Any help would be great...</p>
<p>Ross</p>
| jquery | [5] |
3,883,120 | 3,883,121 | Login authentication Asp.net | <p>Hi I have created authentication using ASP.NET,
But I am not getting how to check user is logged in or not before redirection to other pages
Please help me..</p>
<p>Thank you.
ManojKumar</p>
| asp.net | [9] |
2,693,906 | 2,693,907 | disabling shell window while running c# program | <p>I wrote some basic program (from the empty project) which shows window with some buttons, but everytime when I run it visual studio shows me shell black windows, how can I disable this behaviour? thanks in advance</p>
| c# | [0] |
4,383,742 | 4,383,743 | how do i set a dynamic object in JS? | <p>I want to keep a value from a form by a js function
with <code>document.getElementById("form1")</code><br>
but in the form there are dynamic inputs amount1 , amount2 ect... (i dont know how many - its from database)<br>
how do i reach form1.amount (p)<br>
when p is the index of the amount ?<br>
thanks</p>
| javascript | [3] |
4,217,101 | 4,217,102 | PHP pass data from database to Checkbox with contains text | <p>I have an table like this :</p>
<pre><code>no | status
1 | ok, good
2 | ok, good, need to check
</code></pre>
<p>now How can I pass the data to checkbox if contains data like that?</p>
<pre><code><input type="checkbox" name="status" value=<?php Query for OK; ?> checked/> OK
<input type="checkbox" name="status" value=<?php Query for Good; ?> checked/> Good
<input type="checkbox" name="status" value=<?php Query for Need to check; ?> checked/> Need to check
</code></pre>
<p>Anyone have suggestions ?</p>
| php | [2] |
4,172,368 | 4,172,369 | How the construction function runs when call static function in Java | <p>I want a class to check if an input is valid, and all the valid input is record in a text file.</p>
<p>So in construction, it read in the text file and put all valid inputs into a HashSet. Then I have <code>static</code> function to receive an input and check if the input is in the HashSet.</p>
<p>Code structure is like following:</p>
<pre><code>public class Validator {
HashSet validInputs;
public Validator() {
//read in
}
public static boolean validate(String in) {
//check and return
}
}
</code></pre>
<p>Then in other class, I need to use <code>Validator</code> class to validate strings. Code is like:</p>
<pre><code>...
String a = XXX;
boolean valid = Validator.validate(a);
...
</code></pre>
<p>I haven't tested the code, but I have two questions:</p>
<ol>
<li>Does it work? Is the valid input text file read in?</li>
<li>When will the class read in the text file?</li>
<li>Will <code>Validator</code> read the text file every time I call the function <code>validate()</code>?</li>
</ol>
| java | [1] |
3,429,517 | 3,429,518 | What is the % operator in python for? | <p>I've seen the % operator being used in some Python code related to strings, such as:</p>
<pre><code>String = "Value: " % variable
</code></pre>
<p>What does that mean? How is it different from using:</p>
<pre><code>String = "Value: " + variable
</code></pre>
| python | [7] |
1,156,617 | 1,156,618 | jquery do stuff to html inside a var | <pre><code>var d = a piece of html, got it from the server;
//I want to do this to the html from "d"
$('#ls li .ae-lookup-mbtn').prepend("<a href='#' title='+' class='ui-icon <%=ai%>'>+</a>");
</code></pre>
| jquery | [5] |
5,595,330 | 5,595,331 | html table find row before last using jquery | <p>I have a standard HTML table.</p>
<p>Using jquery how do I find the row before the last row of the table ?</p>
<p><code>$('#table tr:last')</code> will give me the last row, but how do I access the row that comes right before the last ?</p>
<p>Thanks</p>
| jquery | [5] |
988,158 | 988,159 | Convert from LPWSTR to LPTSTR | <p>Im trying to convert arguments LPWSTR to LPTSTR, it there any library I can user for easy string convertion?</p>
| c++ | [6] |
4,336,619 | 4,336,620 | Dismissing and deleting an alarm | <p>I want to dismiss an alarm and also delete an alarm in 2 different Activities.What functions would I use for both? <code>alarmmanager.cancel()</code> dismisses or deletes the alarm?</p>
<p>I have written this code: </p>
<pre><code>Button DeleteButton = (Button) this.findViewById(R.id.dismiss_button);
DeleteButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// Build Intent and Pending Intent to Set Snooze Alarm
Intent AlarmIntent = new Intent(AlarmActivity.this,
AlarmReceiver.class);
AlarmManager AlmMgr = (AlarmManager) getSystemService(ALARM_SERVICE);
PendingIntent Sender = PendingIntent.getBroadcast(
AlarmActivity.this, 0, AlarmIntent, 0);
AlmMgr.cancel(Sender);
finish();
}
});
</code></pre>
<p>The app is crashing when I run this.
Can anyone kindly help?</p>
| android | [4] |
2,342,615 | 2,342,616 | C# match and export based on listbox textfile and wildcard | <p>I like to thank stackoverflow member AlbertEin for helping with this code. What I have is a file being created from a massive directory listing, and i also have a listbox full of items that are only part of the file name in the directory listing. What I want to do is write out a text file for every listboxitem in listbox1.item based on the item and a wildcard</p>
<p>Example Listbox:<br>
Apple<br>
Orange </p>
<p>Results Apple.txt:<br>
Apple13.txt<br>
Apple15.txt<br>
Apple19.txt </p>
<p>and just do this foreach item in the listbox. I'd also like to only read the master txt file once to save me from reading it everytime. Any help appricated.</p>
<p>Better explaination:</p>
<p>I have a listbox of 100 items, and 1 master text file that was created.</p>
<p>For all items in the listbox that match the master test file, I want to write out the matching contents of the master text file to a new textfile with the listboxs name.</p>
<p>The listbox items needs a wildcard in order to match the master text file.</p>
| c# | [0] |
3,211,743 | 3,211,744 | Exit Button on App? App Still Running? | <p>I have a question about the exit button. I have read several posts on here about use of an exit button/back button. Also the blog: <a href="http://blog.radioactiveyak.com/2010/05/when-to-include-exit-button-in-android.html" rel="nofollow">http://blog.radioactiveyak.com/2010/05/when-to-include-exit-button-in-android.html</a>, which clears discourages the use of an exit button.</p>
<p>Here is my question. I have an app that is very small; however it pulls data from the webservice/MySql database online. It is supposed to only pull data on first open. Or, if the user selects update data from a menu. I do not have an exit button in the app, However I thought that if the user would back completely out of the app, this would be the same as an EXIT. </p>
<p>After backing out of the app, I can still see the app in Setting>Applications>Running Services. It says "1 process and 1 service". In Manage Applicaions, it says that the app has been running for 36 hours.
Is this okay? I do not want users to think my app is using their battery.
On a separate note, I do not see an additional updating (pull from webservice) after backing out. But if I install the app on my galaxy Tablet 10.1 running Android 3.1, I do see an occasional update from the webservice. </p>
<p>Anyone have some advice for me?</p>
| android | [4] |
3,113,358 | 3,113,359 | how to convert image into bitmap | <p>hi there i have this code and how can i convert image into bitmap ? i am accessing image from gallery.</p>
<pre><code>_GaleryButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setAction(Intent.ACTION_PICK);
intent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivity(intent);
}
});
}
protected void onGActivityResult(int GrequestCode, int GresultCode, Intent Gdata){
super.onActivityResult(GrequestCode,GresultCode,Gdata);
Uri uriimg = Gdata.getData();
}
</code></pre>
| android | [4] |
1,926,234 | 1,926,235 | android- How to run the program when i am getting error | <p>Running the application in the Eclipse i am getting the following error.How to handle that.</p>
<p>[2011-06-29 10:35:46 - Roadbrake] Android requires .class compatibility set to 5.0. Please fix project properties.</p>
<p>thanks</p>
| android | [4] |
2,712,759 | 2,712,760 | Can I execute a link after a preventDefault()? | <p>Code :</p>
<pre><code>$('#myLink').click(function (e) {
e.preventDefault();
...
if (someCondition) {
... code ...
} else {
... execute the link
}
});
</code></pre>
<p>I'd like, if <code>someCondition</code> is false, execute the original href of the link (so, go that link, changing the page). Is it this possible?</p>
| jquery | [5] |
1,950,988 | 1,950,989 | Run php script every x mins using ajax request | <p>got this file 'functions.php':</p>
<pre><code><?php
function test ($url){
$starttime = microtime(true);
$valid = @fsockopen($url, 80, $errno, $errstr, 30);
$stoptime = microtime(true);
echo (round(($stoptime-$starttime)*1000)).' ms.';
if (!$valid) {
echo "Status - Failure";
} else {
echo "Status - Success";
}
}
test('google.com');
?>
</code></pre>
<p>I want to run it every 10seconds or so, i was told to use ajax request but i dont completely understand how it works. I tried creating a new file 'index.php', and then had this written in it:</p>
<pre><code><script>
var milliSeconds = 10000;
setInterval( function() {
//Ajax request, i dont know how to write it
xmlhttp.open("POST","functions.php",true);
xmlhttp.send();
}, milliSeconds);
</script>
</code></pre>
<p>I put both files into ftp but nothing happens, can someone help me write a propper ajax request?</p>
<p>Edit: eddited typo, still doesnt work tho</p>
| javascript | [3] |
1,662,269 | 1,662,270 | PHP to read a string from socket | <p>I bind with a socket as follows:</p>
<pre><code><?
// set some variables
$host = "x.x.x.x";
$port = 1234;
// don't timeout!
set_time_limit(0);
// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create
socket\n");
// bind socket to port
$result = socket_bind($socket, $host, $port) or die("Could not bind to
socket\n");
?>
</code></pre>
<p>Now how do I read strings coming from the socket and store it in a variable?
The socket has collection of strings in the following format:
12;3p6;4p</p>
<p>where p is the terminating character for each set of a;b values
Thank you</p>
| php | [2] |
1,171,179 | 1,171,180 | TableView custom cell | <p>how can I use custom cell in table view? Please give me suggestions!</p>
| iphone | [8] |
291,758 | 291,759 | How do I get the drag results when dragging to the desktop? | <p>When I drag a file to the desktop the drag succeeds. I know that simply by checking. But I want the program to know that. But - <code>DragDropEffects</code> is always <code>None</code>.</p>
| c# | [0] |
3,809,507 | 3,809,508 | how to remove a div with same ids but display='block' and display='none' in JAVascript | <p>I have more than 1 divs
with same id, but one has diplay='block'
and others have display='none'.</p>
<p>I want to delete all the divs which have display='none'.</p>
<p>Kindly tell the easiest way.</p>
| javascript | [3] |
2,003,196 | 2,003,197 | jQuery namespace does not bubble which custom event | <p>HTML:</p>
<pre><code><div class="parent">
<div class="child1" >
</div>
<div class="child2">
</div>
</div>
<a class="btn1">customClick.btn1</a>
<a class="btn2">customClick.btn2</a>
</code></pre>
<p>JavaScript:</p>
<pre><code> jQuery('div.child1')
.bind('customClick.btn1', function () {
alert('child1 reacted to customClick.btn1');
});
jQuery('div.child2')
.bind('customClick.btn2', function () {
alert('child2 reacted to customClick.btn2');
});
jQuery('div.parent')
.bind('customClick.btn1', function (e) {
alert('parent reacted to customClick.btn1');
})
.bind('customClick.btn2', function (e) {
alert('parent reacted to customClick.btn2');
});
jQuery('a.btn1')
.click(function(){
jQuery('div.child1').trigger('customClick.btn1');
});
jQuery('a.btn2')
.click(function(){
jQuery('div.child2').trigger('customClick.btn2');
});
</code></pre>
<p>When I click <code>a.btn1</code>, as expected, the <code>customClick.btn1</code> event is handled by <code>div.child1</code> and not <code>div.child2</code>. What is not expected is that the <code>customClick</code> event bubbles and triggers the handlers on <code>div.parent</code> for both <code>customClick.btn1</code> and <code>customClick.btn2</code>. Is this right? Is there any way to have custom events bubble with their namespace? In other words, when <code>customClick.btn1</code> is triggered, not all parent handlers for <code>customClick</code> are handled, just ones that handle <code>customClick.btn1</code>.</p>
| jquery | [5] |
2,368,893 | 2,368,894 | Hiding Side Menu Upon Browser Resizing | <p>User clicks the link "table of contents" and it appears as a side menu.
If the browser resizes below 1448px then the side menu does a fadeOut().</p>
<p>So, after having clicked the "table of contents" link, resizing the browser below 1448px, then resizing above 1448px...</p>
<p>How can I get the side menu to automatically fadeIn() again?</p>
<pre><code> var button = $("a#contents_link"); // the TOC link
var toc = $('#table-of-contents'); // the TOC div to show
var browser = $(window); // getting the browser width
toc.hide(); // hide the TOC div upon loading the page
button.click(function (event) { // toggling the TOC div
toc.fadeToggle(300);
event.preventDefault();
});
$(browser).resize(function() {
if ( (toc.is(':visible')) && (browser.width() >=1449) ) {
toc.fadeIn();
} else if( (toc.is(':visible')) && (browser.width() <=1448) ){
toc.fadeOut();
}
});
</code></pre>
| jquery | [5] |
3,616,042 | 3,616,043 | JS, selecting a div's child | <p>If I have</p>
<pre><code>function OnMouseIn (elem) {
elem.style.display= "block";
}
<div onmouseover="OnMouseIn (this.XXXXXXX)">
<div class="classname" style="display:none"></div>
</div>
</code></pre>
<p>What do I have to write in place of XXXXXXX to select the div's child "classname"? (note: there are a lot of the first div, and i have to select only the one where the mouse just got over.</p>
| javascript | [3] |
1,897,892 | 1,897,893 | Naming C++ Variables | <p>I'm learning c++. </p>
<p>MY question is, is this a valid variable name? </p>
<pre><code>int @variableName
</code></pre>
<p>I want to include the '@' symbol. </p>
<p>Thank you. </p>
| c++ | [6] |
5,187,245 | 5,187,246 | Overlay view over tab viewcontrollers | <p>using iphone sdk 4.1. I want to overlay a small view over all my tabcontroller views. this will present itself on the push of a button from one of the tab bar viewcontrollers but then i wish it to remain in place even if the user tabs to another view. How to do?</p>
<p>Thanks</p>
| iphone | [8] |
3,499,739 | 3,499,740 | One result array | <p>I'm trying to add the results of a script to an array, but once I look into it there is only one item in it, probably me being silly with placement </p>
<pre><code>function crawl_page($url, $depth)
{
static $seen = array();
$Linklist = array();
if (isset($seen[$url]) || $depth === 0) {
return;
}
$seen[$url] = true;
$dom = new DOMDocument('1.0');
@$dom->loadHTMLFile($url);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $element) {
$href = $element->getAttribute('href');
if (0 !== strpos($href, 'http')) {
$href = rtrim($url, '/') . '/' . ltrim($href, '/');
}
if(shouldScrape($href)==true)
{
crawl_page($href, $depth - 1);
}
}
echo "URL:",$url;
echo http_response($url);
echo "<br/>";
$Linklist[] = $url;
$XML = new DOMDocument('1.0');
$XML->formatOutput = true;
$root = $XML->createElement('Links');
$root = $XML->appendChild($root);
foreach ($Linklist as $value)
{
$child = $XML->createElement('Linkdetails');
$child = $root->appendChild($child);
$text = $XML->createTextNode($value);
$text = $child->appendChild($text);
}
$XML->save("linkList.xml");
}
</code></pre>
| php | [2] |
5,367,090 | 5,367,091 | PHP Logical Operators && || Question | <p>I'm trying to ignore IE7 and IE8 but am having a tiny bit of trouble getting the operators to work properly. </p>
<pre><code><?php
if(stristr(strtolower($_SERVER['HTTP_USER_AGENT']), "msie 8") && (strtolower($_SERVER['HTTP_USER_AGENT']), "msie 7") == false ){
echo "<script type=\"text/javascript\">
$(document).ready(function() {
// ok
});
</script>";
}?>
</code></pre>
<p>My other option gives me no errors but is not functioning properly:</p>
<pre><code><?php
if(stristr(strtolower($_SERVER['HTTP_USER_AGENT']), "msie 8" || ($_SERVER['HTTP_USER_AGENT']), "msie 7") == FALSE){
echo "<script type=\"text/javascript\">
$(document).ready(function() {
// OK
});
</script>";
}?>
</code></pre>
| php | [2] |
5,237,867 | 5,237,868 | Dynamic static method call? | <p>I have</p>
<pre><code>String str = "Bubble";
</code></pre>
<p>and I want to use <code>str</code> to call <code>BubbleSort.sort()</code></p>
<p>Is this possible?</p>
| java | [1] |
4,073,914 | 4,073,915 | How to display text content onclick of listview item | <p>I want to display a product detail page on click of a product name from list view.And for this i dont want to display in dialog alert. It should be new screen for product detail page.</p>
<p>based on clicked product name how can i show the product detail screen. Any ideas ?</p>
<p>can you pl help on this.</p>
<p>Thanks,
Sri</p>
| android | [4] |
4,024,150 | 4,024,151 | onAttach callback from fragment to activity | <p>I want to send String data from fragment to activity. I have read the article about communicating between fragment and activity in android developer, using onAttach calback. can anyone explain clearly how to send data fromfragment to activity...... </p>
| android | [4] |
4,935,931 | 4,935,932 | Question about the session in a c# web application | <p>User LoginUser = new User();
Session["User"] = LoginUser;</p>
<p>What does it mean to pass an object(LoginUser) to Session? Will the session get any time value from the object(LoginUser)?</p>
| c# | [0] |
1,284,863 | 1,284,864 | Help me simplify this JS code | <p>I'm a beginner in JS and want to know a way to simplify this code. There are 7 different divs with iframes, and also 7 different links. I have shown 1 div with iframe and 1 link. I have no idea where to start. Any help would be greatly appreciated.</p>
<p>NOTE: The code works to my needs, but I just need to simplify it (less js code in html, and more in js file).</p>
<p>JavaScript in .js file:</p>
<pre><code>function show_visibility(){
for(var i = 0,e = arguments.length;i < e;i++){
var myDiv = document.getElementById(arguments[i]).style;
myDiv.display = "block";}
}
function hide_visibility(){
for(var i = 0,e = arguments.length;i < e;i++){
var myDiv = document.getElementById(arguments[i]).style;
myDiv.display = "none";}
}
function refFrame() {
for(var i = 0,e = arguments.length;i < e;i++){
document.getElementById(arguments[i]).src = document.getElementById(arguments[i]).src;
}
}
</code></pre>
<p>Div/iframe to be modified:</p>
<pre><code><div id="r1-box">
<iframe id="frame-box1" class="work" src="youtubelink" width="720" height="405" frameborder="0"></iframe>
</div>
</code></pre>
<p>Link to execute JS:</p>
<pre><code><a id="r1" href="javascript:refFrame('frame-box2','frame-box3','frame-box4','frame-box5','frame-box6','frame-box7');show_visibility('r1-box');hide_visibility('r2-box','r3-box', 'r4-box','r5-box','r6-box','r7-box');">
</a>
</code></pre>
| javascript | [3] |
5,151,392 | 5,151,393 | Getting the list of distribution lists using ewp api in c# | <p>I want to get all distribution lists & the members of those lists using the ewp api in c#.
I made the connection to the outlook server and I can get the calendar information of mine using c#. But I couldn't find a way to get the distribution lists.</p>
| c# | [0] |
2,214,210 | 2,214,211 | how to iterate over entries in a file making a dictionary with unique values and calculate an average for each value that can occur multiple times? | <p>I have a table that looks like this:</p>
<pre><code>id value
AGA 0.211
AGA 0.433
AGA 0.123
AGH 0.002
DHI 0.063
DHI 0.193
DHI 0.004
KHI 0.543
KHI 0.064
HID 0.234
</code></pre>
<p>For each id there are sometimes different values. I want to count how many entrances there are for each id, the average and the sum of the values for each id so the outcome would be something like this:</p>
<pre><code>id cnt sum av
AGA 3 0.76 0.25
AGH 1 0.002 0.002
DHI 3 0.26 0.008
KHI 2 0.607 0.304
HID 1 0.234 0.234
</code></pre>
<p>I thouht it would be best to first make a dictionary where I count each entry, but got stuck after that, not knowing if it is best to have the value of the dictionary as an array (with the cnt, sum and av) and by then using the range of the Cnt to calculate, but could not think of ways to do that! This is how far I got:</p>
<pre><code>idDict = {}
for line in file:
line = line.rstrip()
f = line.split()
id = f[0]
idDict[id] = idDict.get(id, 0) + 1
</code></pre>
<p>But if I have already created the dictionary here with the cnt, I dont know how to iterate over each id to do the sum and av calculations :( </p>
| python | [7] |
1,801,516 | 1,801,517 | Watch for change of the input[type="checkbox"] | <p>How can I run a function on checkbox change?</p>
<p>I'm trying to write small checkbox replacing function base on that - but I'm doing something wrong.</p>
<p>Code:</p>
<pre><code>(function($) {
$.fn.checking = function() {
if( $('.checbox').prop('checked', false) === true ) {
$('.new-checkbox').prop('id','unchecked');
}
else {
$('.new-checkbox').prop('id','checked');
}
};
})(jQuery);
$(document).ready( function(){
$('.checkbox').wrap('<div class="checkbox-wrapper"></div>');
$('.checkbox-wrapper').append('<p class="new-checkbox">Blue = Checked, Red = Unchecked</p>');
$('.checkbox').checking();
$('.checbox').bind('change', function(){
$(this).checking();
});
});
</code></pre>
<p>PlayGround: <a href="http://jsfiddle.net/MrTest/yGBAK/" rel="nofollow">LIVE DEMO</a></p>
| jquery | [5] |
3,590,121 | 3,590,122 | Query whether file exists in different application | <p>I have I have two applications. I have a menu button on one application (service A) that is used to trigger an action in a different service (service B).</p>
<p>I want to make the menu item (service A) visible only if a file is present in service B.</p>
<p>Is there a clean mechanism for achieving this, rather than using absolute paths with File?</p>
| android | [4] |
4,053,889 | 4,053,890 | Major Green Android Newbie looking for advice | <p>I'm kind of a Jack of all Trades in the IT field, but have no programming experience.</p>
<p>Without having prior programing knowledge, will it be difficult to begin learning how to develop Android apps? Basically, I'm looking for advice on a road map, for example, should I learn C+ or Java first before I begin anything Android?</p>
<p>Thanks.</p>
| android | [4] |
1,298,936 | 1,298,937 | Dynamic Population of Sharepoint fields | <p>Can someone please help me with a query on Sharepoint?</p>
<p>Suppose, I have a list called employee database and the list has two columns Name and employee ID.</p>
<pre><code>Employee ID Name
1 John
2 Mary
3 Peter
4 Mark
</code></pre>
<p>Now, I create a new list called, employee registration tracker and have following field in this list;
Employee ID
Name
DOB</p>
<p>Is there any way by which, while entering a new item in this new list, I just enter employee id and using some javascript, it fetches ‘name’ corresponding to that ID from employee database list and automatically populates the field ‘Name’ in this list. So this way we do not have to again enter name.</p>
<p>We have approx 500 team members in different teams and we need to keep track of them.
I tried various ways like cascading dropdowns etc, but such a big list it does not allows. Also like I told you earlier, I need to make all this in my enterprise firewall and other restrictions where they do not allow sharepoint integration with MS access , Sharepoint developer etc and the only way I have is easy javascript in CAML.</p>
| javascript | [3] |
1,140,451 | 1,140,452 | UnicodeEncodeError: 'charmap' codec can't encode character | <p>Python throws this when using the wolfram alpha api:</p>
<pre><code>Traceback (most recent call last):
File "c:\Python27\lib\threading.py", line 530, in __bootstrap_inner
self.run()
File "c:\Python27\lib\site-packages\Skype4Py\utils.py", line 225, in run
handler(*self.args, **self.kwargs)
File "s.py", line 38, in OnMessageStatus
if body[0:5] == '!math':wolfram(body[5:], '')
File "s.py", line 18, in wolfram
print "l: "+l
File "c:\Python27\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\xd7' in position 3
: character maps to <undefined>
</code></pre>
<p>how can I solve this?</p>
| python | [7] |
1,398,760 | 1,398,761 | Why does a C++ string end in a null terminator? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4418708/whats-the-rationale-for-null-terminated-strings">What's the rationale for null terminated strings?</a> </p>
</blockquote>
<p>My question is very simple: why do C++ strings end in null terminators? Is this so that you do not need to keep count on the length?</p>
| c++ | [6] |
4,664,935 | 4,664,936 | for loop (conditional) and logical s operation in python | <p>I am trying to combine for loop and logical operation and as below and running into compilation error.</p>
<p>Any inputs on how to fix this?</p>
<pre><code>File "test.py", line 36
for ((num in list) and (num not in handled_list)):
^
SyntaxError: invalid syntax
</code></pre>
| python | [7] |
5,534,587 | 5,534,588 | Call dynamic Function with unknown number of params | <p>Not sure exactly how to describe this, but here goes ..</p>
<p>I have a large PHP function library that I want to expose via some sort of api interface.</p>
<p>For example, this query string:</p>
<pre><code>api.php?function=myFunction&param1=xxx&param2=xxx&
</code></pre>
<p>Would translate into this:</p>
<pre><code>$ret = myFunction( $param1, $param2 );
</code></pre>
<p>.. whereas this query string ..</p>
<pre><code>api.php?function=myFunction&param2=xxx&param1=xxx&
</code></pre>
<p>Would translate into this:</p>
<pre><code>$ret = myFunction( $param1, $param2 );
</code></pre>
<p>Note that I expect to have to rely on the query string to place the parameters required in the query, and in the order required.</p>
<p>Is this doable? I have a few ideas that <em>may</em> work, but thought I'd put it up here and perhaps get some better ideas from the PHP gurus.</p>
<p>Thanks -</p>
| php | [2] |
4,217,515 | 4,217,516 | what does each of these options mean? | <pre><code>java -Djava.library.path=../lib
-classpath ../lib/wrappertest.jar:../lib/wrapper.jar:Service.jar:../lib/mysql-connector-java-3.0.17-ga-bin.jar
-Dwrapper.key=Ksxtsmvr7iAmVJ-T
-Dwrapper.port=32001
-Dwrapper.jvm.port.min=31000
-Dwrapper.jvm.port.max=31999 -Dwrapper.pid=1731
-Dwrapper.version=3.3.0
-Dwrapper.native_library=wrapper
-Dwrapper.service=TRUE
-Dwrapper.cpu.timeout=10
-Dwrapper.jvmid=1
org.tanukisoftware.wrapper.WrapperSimpleApp com.jobirn.Service
</code></pre>
| java | [1] |
1,755,987 | 1,755,988 | I was unable to connect my android app with facebook again | <p>I conncetd my android app for first time. but for second time i was unable to connect it.i run my app through a android emulator.
In my manifest.xml file
$< uses-permission android:name="android.permission.INTERNET"/>$ this tag hi-lighted with warning line.</p>
| android | [4] |
1,633,015 | 1,633,016 | What is the most succinct way to test if either of two variables are set? | <p>What I'm doing is, if I haven't got an ID in either <code>$_POST</code> or <code>$_SESSION</code> then redirecting. Preference is given to <code>$_POST</code>. So I have this:</p>
<pre><code>$bool = 0;
if (isset($_POST['id'])) {
$bool = 1;
} elseif (isset($_SESSION['id'])) {
$bool = 1;
}
if (!$bool) {
...//redirect
}
</code></pre>
<p>Is there a quicker way to write this, APART from just removing the braces?</p>
| php | [2] |
3,844,809 | 3,844,810 | How can I conditionally set a div's class in jQuery? | <h3>CSS:</h3>
<pre><code> #outer{
background-color:#FFFF99;
}
#inner1{
float : left;
}
.New1{
width: 62%;
}
.New2{
width: 72%
}
</code></pre>
<p><hr /></p>
<p>I need to be able to change the class of a <code>div</code> after a condition in an event handler.</p>
<h3>Logic:</h3>
<pre><code> case '1': <div id="outer" class="New1">
</div>
case '2': <div id="outer" class="New2">
</div>
</code></pre>
<p><hr /></p>
<p>To do this, I wrote the following jQuery:</p>
<pre><code>$("#generate").click(function(){
// here I wrote code for case '1'
$("#outer").addClass("New1");
});
$("#choice").click(function(){
// here I wrote code for case '2'
$("#outer").addClass("New2");
});
</code></pre>
<ul>
<li><p>Do I need to remove the class that I previously added to it?</p></li>
<li><p>I need to toggle between two states. </p></li>
</ul>
<p>How can I do this?</p>
| jquery | [5] |
4,742,036 | 4,742,037 | Passing an Object from an Activity to a Fragment | <p>I have an <code>Activity</code> which uses a <code>Fragment</code>. I simply want to pass an object from this <code>Activity</code> to the <code>Fragment</code>.</p>
<p>How could I do it?
All the tutorials I've seen so far where retrieving data from resources.</p>
<p>EDIT :</p>
<p>Let's be a bit more precise:</p>
<p>My Activity has a ListView on the left part. When you click on it, the idea is to load a Fragment on the right part.</p>
<p>When I enter this Activity, an Object "Category" is given through the Intent. This Object contains a List of other Objects "Questions" (which contains a List of String). These "Questions" objects are displayed on the ListView.
When I click on one item from the ListView, I want to display the List of String into the Fragment (into a ListView).</p>
<p>To do that, I call the setContentView() from my Activity with a layout. In this layout is defined the Fragment with the correct class to call.
When I call this setContentView(), the onCreateView() of my Fragment is called but at this time, the getArguments() returns null.</p>
<p>How could I manage to have it filled before the call of onCreateView() ?
(tell me if I'm not clear enough)</p>
<p>Thanks</p>
| android | [4] |
187,024 | 187,025 | for the query of methods of rotation | <p>I have 1 UIViewController.</p>
<p>in that i wrote,</p>
<pre><code>- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
NSLog(@"A");
} in UIViewController.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
NSLog(@"b");
}
</code></pre>
<p>but this method is not called
why is it so?</p>
| iphone | [8] |
414,685 | 414,686 | Forms Authentication too many redirects issue | <p>I have a website that uses form authentication. For some reason it works fine at the first run. But on the second run it says too many redirects error.</p>
<p>Loginpage:Load event</p>
<pre><code> protected void Page_Load(object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
Response.Redirect("HomePage.aspx");
}
}
</code></pre>
<p>Login Page submit credentials</p>
<pre><code> protected void btnSubmit_Click(object sender, EventArgs e)
{
int recordExistCount = fc.Authenticate(txtUsername.Text.Trim(), txtPassword.Text.Trim());
if (recordExistCount == 1)
{
Session["User"] = "Authenticated";
Session["Username"] = txtUsername.Text.Trim();
fc.IsOnlineRecord(Session["Username"].ToString(),true);
FormsAuthentication.RedirectFromLoginPage(Session["Username"].ToString(), true);
Response.Redirect("HomePage.aspx");
}
else
{
lblStatus.Text = "Username or password specified are incorrect";
lblStatus.BackColor = Color.Yellow;
}
}
</code></pre>
<p>Masterpage signout button</p>
<pre><code>protected void lbSignOut_Click(object sender, EventArgs e)
{
Session.Abandon();
FormsAuthentication.SignOut();
Response.Redirect("LoginPage.aspx");
}
</code></pre>
| asp.net | [9] |
678,613 | 678,614 | Exception "java.lang.IllegalArgumentException: interface javax.persistence.Id is not visible from class loader" | <p>What is this error?
how can i fix this?
This is the error shown in apache log file after i deploy the war file and start the tomcat server..</p>
| java | [1] |
5,990,963 | 5,990,964 | Priority of the unary operations | <p>Here is an example that outputs <code>6</code>:</p>
<pre><code>public static void main(String[] args) {
int i = 1;
m(++i);
}
static void m(int i) {
i = ++i + i++;
System.out.println(i);
}
</code></pre>
<p>We get <code>6</code> because in the <code>m(int i)</code> method at first <code>3</code> and <code>3</code> are summarized, then <code>i</code> becomes <code>4</code> (due to the <code>i++</code>), but after that <code>i</code> from the left part takes the summarized <code>6</code> value. </p>
<p>But if the method is changed to the following, we get <code>7</code>:</p>
<pre><code>static void m(int i) {
i = ++i + ++i;
System.out.println(i);
}
</code></pre>
<p>But I expected to see <code>7</code> in both cases (I've been guided by the fact that unary operations, in this case incrementing, have a higher priority than binary operations). Could someone please provide an explanation (or a reference to an explanation) of the ignored <code>i++</code> in the first example?</p>
| java | [1] |
3,698,871 | 3,698,872 | Is there any way i can get the list of called methods in a class in java? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1069066/get-current-stack-trace-in-java">Get current stack trace in Java</a> </p>
</blockquote>
<p>Here is the thing, i want to get a list of all called methods in a java class. So far i've been using eclemma, but that just insn't enough. I also want the order in which the methods have been called.</p>
| java | [1] |
3,510,778 | 3,510,779 | jquery sum values from different divs with same classes | <p>I am loading dynamically divs that have a .totalprice class. At the end, I would like to sum of the values from all of the .totalprice.</p>
<p>Thank you. </p>
| jquery | [5] |
4,209,363 | 4,209,364 | Android Window Class | <p>Is their anyway to not display the bottom menu bar in my app on the tablet? I was able to get the title bar to disappear using -></p>
<pre><code> this.requestWindowFeature(Window.FEATURE_NO_TITLE);
</code></pre>
<p>What class am I looking for? Android 3.0.. Is this feature available in any android version?</p>
<p>Thanks</p>
| android | [4] |
5,516,826 | 5,516,827 | jquery getting element name - prop('name') or attr('name') | <p>I'm trying to get element name by jquery - </p>
<p>please check the following example code: (or <a href="http://jsbin.com/usujeq/2/watch" rel="nofollow">http://jsbin.com/usujeq/2/watch</a>)</p>
<pre><code><div name = "foo1">
<div name = "foo2">
<div name = "foo3">
<div name = "foo4">
<button id = "clickme" type="button">
</div></div></div></div>
<script type="text/javascript">
$('#clickme').click( function() {
$(this).parents().each( function() {
console.log($(this).prop('name'));
});
});
</script>
</code></pre>
<p>if I click <code>clickme</code>, it should go up all over the DOM from <code><div name="foo4"></code> to <code><html></code> and log their names.</p>
<p>expected result is :</p>
<pre><code>foo4
foo3
foo2
foo1
undefined
undefined
</code></pre>
<p><code>prop('name')</code> returns undefined while <code>attr('name')</code> gives expected names.
what is wrong with <code>prop('name')</code> in above code?</p>
| jquery | [5] |
4,537,102 | 4,537,103 | Is using a header('location: ') enough to password protect a page? | <p>Basically, I am checking to see if the user is logged in and if not I will use header('location: login.php') to redirect to the login page. </p>
<p>I am confused if the browser is actually redirecting or the server? If it is the browser then would it be possible for the user to prevent the browser from redirecting and view the contents of the page?</p>
| php | [2] |
5,790,163 | 5,790,164 | Show Menu Option Automatically At First Activity Of Application | <p>I develop a application</p>
<p>and in which i have a Menu option which i invoke from onCreateOptionMenu()</p>
<p>But this is called only when any user press the menu button</p>
<p>so now i want that my application start and first Activity is Welcome.java</p>
<p>then in onCreate(Bundle b)</p>
<p>can i write sone line from which the menu is invoked automatically without pressing Menu button</p>
<p>i used openOptionMenu() but it not works.</p>
<p>2) can i create a Button and simulate it as Menu button and then write button.performClick() so it act as a Menu Button and menu option will visible</p>
<p>So give me some suggestion on this</p>
<p>Thanks</p>
| android | [4] |
611,399 | 611,400 | How to blur without specific element | <p>When I use blur event the input form clear. But I need blur event to include all html page except submit button.</p>
<p>html code:</p>
<pre><code><form method="POST" action="#" id="form">
<table border="1">
<tr><td></td></tr>
<tr><td><input type="text" id="email" value="EMAIL ADDRESS_" maxlength="65"/></td></tr>
<tr><td><input type="submit" value="" id="submit"/></td></tr>
</table>
</form>
</code></pre>
<p>jQuery code:</p>
<pre><code>$(document).ready(function(){
$('#email[type=text]').focus(function(){
$(this).val("");
}).blur(function(){
if(this.value==""){
$(this).val("EMAIL ADDRESS_");
}
});
});
</code></pre>
| jquery | [5] |
1,088,499 | 1,088,500 | Objects and primitives in methods | <p>Please advice why primitives being used as method's parameters do a copy of its value while objects are used as is?</p>
| java | [1] |
4,461,594 | 4,461,595 | Which datatype is used to store large values? | <p>I am the beginner of android application.Now i am reading large json values in the server and append these values to stringbuilder.The string builder only accept 3500 line of values.I have added extra values.I am getting out of memory error..Please Help me............</p>
<p>Thank you,</p>
| android | [4] |
3,589,309 | 3,589,310 | Co or Contravariance vor Action Delegates | <p>I'm stuck, why isn't this working:</p>
<pre><code> var childAction = new Action<CancelCommand>(blabla);
Action<IDomainCommand> upperAction = (Action<IDomainCommand>) childAction;
</code></pre>
<p>Why isn't this working if CancelCommand implements IDomainCommand?
By the way: Is this co or contravariance what i'm trying to do here? ;)</p>
<p>thank you in advance
just the best
laurin</p>
<p><strong>EDIT</strong>
Thank you guys for your very fast responses!</p>
<p>The problem why i need this is because i construct a generic Action Template.
I have the following Interface:</p>
<pre><code>IMessageBus.RegisterAction<T>(Action<T> registerAction) where T : IDomainCommand
</code></pre>
<p>Because i have to build this action on runtime my code lookes as the follwing:</p>
<pre><code>var genericExecuteAction = this.GetType().GetMethod("ExecuteCommandAction",
BindingFlags.NonPublic | BindingFlags.Instance).MakeGenericMethod(commandType);
var actionType = typeof(Action<>).MakeGenericType(commandType);
var @delegate = Delegate.CreateDelegate(actionType, this, genericExecuteAction);
var actionDelegate = (Action<DomainCommandBase>)@delegate;
messageBus.Register(actionDelegate);
</code></pre>
<p>The problem is i need to cast it so that i can pass it to this method.
You see?
Behind the mesasge bus we are using is using RX and unfortunately all the methods there use generics, there a now non-generic-overloads.</p>
| c# | [0] |
4,670,125 | 4,670,126 | Why the size of a pointer is 4bytes in C++ | <p>On the 32-bit machine, why the size of a pointer is 32-bit? Why not 16-bit or 64-bit? What's the cons and pros?</p>
| c++ | [6] |
1,856,522 | 1,856,523 | using libusb header file | <p>I need to communicate with USB port by C++. so I searched the web and found a comppresd (.rar) file. Its name is <code>usblib-1.0.9.tar.bz2</code>. I extracted it and it contains several files and folders and some of them are header files (*.h). I think my necessary file is one of them that its name is <code>libusb.h</code>. </p>
<p>Moreover in this comppresed file there are some example programs to communicate via USB. I copied one of them to a C++ empty program for testing. This program uses libusb header file as one of library. </p>
<p>I added libusb.h to this program (right click on Header Files in solution explorer and choose <code>add > existing item</code> then browse <code>libusb.h</code>), but this library (<code>libusb.h</code>) is still unspecified (<code>#include <libusb.h></code> is unspecified ) and I can't debug this example program. Do I need to do another action to add this new library (<code>libusb.h</code>) to use in this program?</p>
| c++ | [6] |
4,016,656 | 4,016,657 | Using JAVA for the parsing of php | <p>->Using JAVA for the parsing of php(connect, manage, and query the MySQL database) and translates the value into an abstract level to make the data ready for the next level (Android Java code) to use(to display on my frontend).
how is that possible?</p>
| android | [4] |
835,691 | 835,692 | Variable isn't rewritten in a foreach loop | <p>I have this php code which I am pretty sure is OK.
But the $category variable isn't rewritten, i.e. even though $category is '251', the if loop does not execute to true.</p>
<p>Any ideas why?</p>
<pre><code>foreach($cars->cardata as $cardata ){
$category = $cardata->categorie;
if($category == '251'){
$category = 'BWM';
}
echo $category;
}
</code></pre>
| php | [2] |
2,680,112 | 2,680,113 | PHP Session. How can a admin destroy a user's session | <p>i have this question. My website is build whereby a user can only be in the member's page if he has login. therefore every page has this,</p>
<p>if (!$_SESSION['userid']) header index.php</p>
<p>Problem is that if i ban the user and the user did not end the session, he will still be allowed to use the site until he end the session and try to login again, and he will be denied due to the change in the status in the database.</p>
<p>I'm thinking that the only way is to delete the physical session file in the server, but i dont know how. Anyone?</p>
| php | [2] |
1,568,756 | 1,568,757 | iOS Keyboard or Button button press and release time | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6882808/detect-key-press-on-virtual-keyboard">Detect key press on virtual keyboard</a> </p>
</blockquote>
<p>I wanted to know is it possible to capture the exact keyboard key press time and release time in an iOS application development? </p>
<p>For example, let's say I type "<code>Hello</code>". I'd like to know the <code>H</code>-Key pressed time and release time, then <code>E</code>, <code>L</code> etc. I think the answer will be in microseconds but that is what I want.</p>
<p>Any help would be really useful. </p>
| iphone | [8] |
4,546,065 | 4,546,066 | Default PHP Config File | <p>I'm looking to find a copy of the default php.ini file for PHP 5.2.17. </p>
<p>Does anyone know where I can a copy to download?</p>
| php | [2] |
559,461 | 559,462 | Programmatically set layout for android | <p>I am trying to improve the layout for my game. The problem is that while I can create a </p>
<p>good layout for one android phone, it doesn't work for another, ie the trackball for MyTouch </p>
<p>is on the right side (landscape mode), but for the MyCliq, the DPad is on the left side. Is </p>
<p>there a way to programmatically set the layout based on which phone it is? Thanks.</p>
| android | [4] |
2,432,097 | 2,432,098 | How to hidden above title links in accordion menu? | <p>I am doing one accordion for now it's working fine but when i am clicking Title2 or Title1 next if i stepped to click Title3 only want to give Title link for this so no any sub links that's why i want to slide-up the above Titles.</p>
<p>fiddle
<a href="http://jsfiddle.net/cX68E/1/" rel="nofollow">http://jsfiddle.net/cX68E/1/</a> </p>
| jquery | [5] |
1,554,906 | 1,554,907 | Problem with Date Format in Java | <p>I have a problem with this code </p>
<pre><code>public static void main(String[] args) throws IOException, ParseException {
String strDate = "2011-01-12 07:50:00";
DateFormat formatter = new SimpleDateFormat("yyyy-mm-dd H:M:S");
Date date = formatter.parse(strDate);
System.out.println("Date="+date);
}
</code></pre>
<p>The output is:<br>
Date=Thu Feb 12 07:<strong>01</strong>:00 EET <strong>2015</strong><br>
What am i doing wrong??</p>
| java | [1] |
414,064 | 414,065 | Overload constructor/method for int and long | <p>Sample code:</p>
<pre><code>private long x;
public MyClass (int x)
{
this.x = x;
}
public MyClass (long x)
{
this.x = x;
}
</code></pre>
<p>Makes it any sense for performance?</p>
| c# | [0] |
3,325,427 | 3,325,428 | Wordpress custom image size on custom field image | <p>Hi can anyone tell me a good way to use a custom image size with a custom field image in a template without using something like timthumb/phpthumb.</p>
<p>I've set an image size with...</p>
<pre><code>add_action( 'after_setup_theme', 'theme_setup' );
function theme_setup() {
add_image_size( 'theme-custom-size', 329, 118, true );
}
</code></pre>
<p>which is fine for the featured image, I just call</p>
<pre><code>the_post_thumbnail( 'theme-custom-size' );
</code></pre>
<p>but could I apply this size to an image grabbed with get_post_meta from a custom field image.</p>
<p>Thanks!</p>
<p>EDIT:_</p>
<p>ok, I think a simple way to do it would be to use this plugin <a href="http://wordpress.org/extend/plugins/multiple-post-thumbnails/" rel="nofollow">http://wordpress.org/extend/plugins/multiple-post-thumbnails/</a>
and use multiple featured images rather than custom fields.</p>
| php | [2] |
2,463,228 | 2,463,229 | Separate first, middle and last names (Python) | <p>I have a list of several hundred members that I want to separate by First Name, Middle Name and Last name, but some of the members have prefixes (denoted by 'P'). All possible combinations:</p>
<pre><code>First Middle Last
P First Middle Last
First P Middle Last
P First p Middle Last
</code></pre>
<p>How do I separate First (with P, if available), Middle (with P, if available) and Last names in Python? This is what I came up with but it doesn't quite work.</p>
<pre><code>import csv
inPath = "input.txt"
outPath = "output.txt"
newlist = []
file = open(inPath, 'rU')
if file:
for line in file:
member = line.split()
newlist.append(member)
file.close()
else:
print "Error Opening File."
file = open(outPath, 'wb')
if file:
for i in range(len(newlist)):
print i, newlist[i][0] # Should get the First Name with Prefix
print i, newlist[i][1] # Should get the Middle Name with Prefix
print i, newlist[i][-1]
file.close()
else:
print "Error Opening File."
</code></pre>
<p>What I want is:</p>
<ol>
<li>Get first and middles names with their prefixes if available</li>
<li>Output each (first, middle, last) to separate txt files, or a single CSV file (preferable).</li>
</ol>
<p>Many thanks for your help.</p>
| python | [7] |
236,595 | 236,596 | is it possible to see contect of Documents folder on iphone from debuger console | <p>i want to see the content of Documents folder from console , i can see for simulator but its not working for device</p>
<p>my path is <strong>/var/mobile/Applications/3E79C7B3-2639-477F-B355-1A3C70D4ECBE/Documents</strong>
but how to check this ???</p>
| iphone | [8] |
4,997,904 | 4,997,905 | Convert Integer, Double to String in Java | <p>Which of the following ways is better to convert Integer, Double to String in Java.</p>
<pre><code>String.valueOf(doubleVal)
doubleVal + ""
doubleVal.toString()
</code></pre>
<p>Thanks.</p>
| java | [1] |
4,820,279 | 4,820,280 | There is white noise when I play an audio file in MediaPlayer | <p>I'm trying to implement a 'click' sound when the user interacts with buttons in the main screen of my application. I have no experience with audio in Android, however several sources suggest that to simply play a clip, I need only do the following - </p>
<ul>
<li>Put the audio file in /res/raw </li>
</ul>
<p>I did this, I had to create a /raw folder within /res/ - the file is named menuclick.wav (so seems to meet the guidelines for a-z0-0_ filenames) </p>
<ul>
<li><p>Create a MediaPlayer object </p>
<p>MediaPlayer mediaplayer;
mediaplayer.create(getApplicationContext(), R.raw.menuclick); </p></li>
<li><p>Prepare the player for playback (*within a try - catch block) </p>
<p>mediaplayer.prepare(); </p></li>
<li><p>Play the file </p>
<p>mediaplayer.start(); </p></li>
</ul>
<p><em>A sound plays, however it is not the sound file I specified, it is an unpleasant hissing / static sound.</em> </p>
<p><em>I tested the application again, only changing the sound file. It played some of the sound but there was still a lot of white noise. This doesn't occur when opening the sound files normally in other applications.</em> </p>
<p>I seem to be following the same steps as several textbooks / examples. Any idea where the problem may lie? </p>
| android | [4] |
359,065 | 359,066 | Where should I display or store data that is imported from a file? | <p>When I do an import of data from a file, such as csv or text file, I would like to display on a summary page (table view) about what is going to be imported to the database, and user can select or deselect what will be imported into the database. I would like to find out what is the best way of temporary storing these data to be displayed onto the summary page?</p>
<p>To give a clearer understanding about what i am talking about, for example: </p>
<ul>
<li>I have a csv file that holds a list of products. </li>
<li>I would do an importation to read the csv file and display onto a summary page with
table view and checkboxes to select/deselect some of the data.</li>
<li>After the selection, I would click the confirm button to store those checked data</li>
</ul>
<p>So between the process of getting the csv data to the summary page for display, where should I store the data, in the database as a tbl_temp data and clean off when done, or just read directly from the csv file?</p>
<p>Thanks.</p>
| php | [2] |
5,779,259 | 5,779,260 | How to shorten nested if-expressions? | <p>Is it possible to somehow shorten many if-expressions?
Example: imagine 3 numbers, and each will only count up if the former one reached count of 10.</p>
<pre><code>int a = 0, b = 0, c = 0;
a++;
if (a == 10) {
a = 0;
b++;
if (b == 10) {
b = 0;
c++;
}
}
return toString(a+b+c); //I know this is not valid
</code></pre>
<p>Is it possible to somehow shorten these kind of expressions?</p>
| java | [1] |
5,126,165 | 5,126,166 | Deleted the apk key by mistake | <p>I have put up an app in the market..but I have to update the app..but my mistake i deleted the old apk and have made changes to the code and when I try uploading the app it says I must have the same key..what should I do now? </p>
| android | [4] |
4,648,143 | 4,648,144 | How to use memory profiler tool instruments to check the memory leaks? | <p>I am new to iPhone programming. Can someone please help me by guiding how to use instruments to check if there are any memory leaks there in my application?
Also, What are other uses of this tool?</p>
| iphone | [8] |
515,831 | 515,832 | What's that feature of PHP with a section of html/text closed off with start/end functions? | <p>What's that feature of PHP where you have, say a "start" bit of code, then some html or text that would normally send to the browser, then a bit of code to "end" it?</p>
<p>For example,</p>
<pre><code><? start_something(); ?>
<html>some html</html>
<? end_something(); ?>
</code></pre>
<p>Yes, this is a built-in feature of php and I am sure of it, but I cannot remember what it's called.</p>
| php | [2] |
1,873,953 | 1,873,954 | jQuery Slider Issue ! | <p>I have This script </p>
<pre><code><div style="position:relative ;overflow:hidden ; height:195px;">
<div style="position:absolute" class="scroll">
{foreach from=$announce_list item=a}
<div>
<img src="imgsize.php?w=214&h=100&img=../uploads/announce/{$a.--------}.jpg" />
<h4 dir="rtl" style="padding-top:10px; padding-bottom:5px;">{$a.------}</h4>
<p dir="rtl" style="text-align:justify ;line-height:17px;">{$a.---------|truncate:"300":"..." }</p>
</div>
{/foreach}
</div>
</div>
{literal}
<script>
$(function(){
function change_announce()
{
console.log('asdasdasd');
var Scroll = $('.scroll') ;
Scroll.children('div:first').animate({marginTop:'-195px' } , 1000 ,
function(){
Scroll.children('div:first').appendTo(Scroll).css('marginTop' , '0px' ).fadeIn(2000);
}
);
}
setInterval(change_announce , 3000) ;
});
</script>
{/literal}
</code></pre>
<p>on this page in right pane of the site <a href="http://www.mahestan.ac.ir" rel="nofollow">www.mahestan.ac.ir</a> in this demonstration animation is not completlatly executed after second div hide next div dosen't complete animation a sudden jump occur !! :) i can't explain that very well sorry . Tank for Helping . </p>
| jquery | [5] |
3,663,804 | 3,663,805 | ObjectStore in C# | <p>Is there an ObjectStore implmentation for csharp that allows be to generate string handles for my own objects, lookup these objects later on on from the string handle.
I can see there are implementations for C++, but in dotnet we have a garbage collector!
Lars</p>
| c# | [0] |
4,112,090 | 4,112,091 | Transfer files between servers using php | <pre>Hello
I wrote a little code in php that enables me to download a file from one
website to my own!
but there is a little problem here!
I can only Download files from my website that are less than 4MB:(
Now my question is that in what way I can Download special
part of files from other websites!
like from 1st byte to 10th byte!
And second question is how to get file
Information before starting Download!
(I want files size for downloading)
</pre>
<p><a href="http://www.polarpengi.gigfa.com/code.htm" rel="nofollow">http://www.polarpengi.gigfa.com/code.htm</a></p>
| php | [2] |
4,812,156 | 4,812,157 | JFileChooser shows only d: drive content | <p>May I know how I can make JFileChooser to show only d: drive content? I cannot see any of its public method enables me to do so.</p>
<p>Thanks.</p>
| java | [1] |
734,149 | 734,150 | how do you remove the space | <p><strong>Got the immutable part, always miss that, Thanks all</strong></p>
<p>Hi All,</p>
<pre><code>String test = "John, Jane";
test.Replace(" ","");
String[] toList = test.Split(',', ' ', ';');
</code></pre>
<p>How would you remove just the space in the string or any space that shows up potentially?</p>
<p>Why is there 3 items in array and not 2?</p>
| c# | [0] |
2,862,263 | 2,862,264 | Confirm message before leaving site cross browser (JS) | <p>Want to make a confirm box appear before someone leave my site. They have information that will go lost if they leave and you don´t want that right. Pleas be specific with were I should put the code and so since I´m not the best of coders...</p>
| javascript | [3] |
4,679,400 | 4,679,401 | Can enum represent string numbers? | <p>I want a user to input "Sun" and have that represent "1".</p>
<pre><code>Console.Write("Enter a Day: ");
day = Console.ReadLine();
</code></pre>
<p>can enum do this?</p>
| c# | [0] |
4,927,905 | 4,927,906 | PHP code scraping a URL suddenly stopped working | <pre><code>$url = 'the web address I want to get the first and second numbers close to $' ;
$str = file_get_contents($url);
preg_match_all('/ ([$]) *(\d+(:?.\d+)?)/', $str, $matches, PREG_SET_ORDER);
$i=0;
foreach ($matches as $val) {
if($i==0) $first=$val[2] ;
if($i==3) $second=$val[2] ;
$i++;
}
$bad_symbols = array(",", "."); $first = str_replace($bad_symbols, "", $first);
$bad_symbols = array(",", "."); $second = str_replace($bad_symbols, "", $second);
echo $first . "</br>";
echo $second;
</code></pre>
<p>it worked fine till yesterday
what could be the problem?</p>
| php | [2] |
1,172,921 | 1,172,922 | Why does this not create a date? | <p>I'm passing in a string like "2012-02-20'T'01:01:01"</p>
<pre><code> /**
* Parse a workflowDate.
* @param workflowDate an instance of a workflowDate string.
* @return the date object containing parsed workflow date.
*/
private Date parseDate(final String workflowDate)
{
DateFormat df = new SimpleDateFormat("YYYY-MM-DD'T'hh:mm:ss", Locale.ENGLISH);
Date retVal = null;
try
{
retVal = df.parse(workflowDate);
}
catch (ParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return retVal;
}
</code></pre>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.