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 |
---|---|---|---|---|---|
3,104,462 | 3,104,463 | Android: Is that possible to implement a flip/page curl from top to bottom like iphone? | <p>I am implementing an app in which i need to flip/pagecurl a pageview? how can i do that? I didnot find a solution for this. I searched a lot in google? Can any one help me on this?</p>
| android | [4] |
5,364,401 | 5,364,402 | how to check installed application in iphone device | <p>I am developing an application in which i need to find the apps which are already installed in iphone device such as Skype, facebook. I need to check it objective -c . Please give me code snippet if possible otherwise a link to get the solution. If it not possible then tell me other way to check installed application in iphone deveice .</p>
<p>Thanks in advance ......</p>
| iphone | [8] |
3,528,443 | 3,528,444 | Why is a special file used in Android to store installation id instead of SharedPreferences? | <p>I am trying to figure out the best way to store my application key and other application specific data. Android uses a file to do it - <a href="http://android-developers.blogspot.com/2011/03/identifying-app-installations.html" rel="nofollow">http://android-developers.blogspot.com/2011/03/identifying-app-installations.html</a></p>
<p>I found that using SharedPreferences is faster and more efficient. Why does Android use a dedicated file just to store the installation ID instead of using preferences? Both require the application context, so that is not a reason.</p>
| android | [4] |
1,548,432 | 1,548,433 | checking a variable value using an OR operator | <p>So, a junior programmer on my team today wrote the following piece of code:</p>
<pre><code>if(status === ("incomplete" || "unknown"))
</code></pre>
<p>Which is obviously not going to do what he intended, which was this:</p>
<pre><code>if(status === "incomplete" || status === "unknown"))
</code></pre>
<p>But what I can't explain is why exactly the first snippet of code wouldn't work! Or why it evaluates to true if 'status' is set to 'incomplete' but to false when it's set to 'unknown'...</p>
| javascript | [3] |
3,568,520 | 3,568,521 | Storing all JS/CSS in PHP? | <p><strong>Background:</strong> I'm working on a single page web app that loads everything through AJAX and so started learning php a few days ago. I immediately thought of putting everything (html, css, javascript) in php files so that there is only one html file and one sprite request. For instance, external javascript could be stored in:</p>
<p><strong>main.js.php</strong> (adding the .js for organizational purposes only) which would look like:</p>
<pre><code><script>
...
</script>
</code></pre>
<p>or</p>
<pre><code><style>
...
</style>
</code></pre>
<p><strong>Question:</strong> Would storing everything in php be a bad idea? I have OCD and like to have related functions in separate files (and actually, folders too), so let's just say my project uses 100+ includes. These only get loaded exactly once, when the user visits (AJAX site). I want to reduce the number of Http Requests to just 1 html and 1 sprite (my app uses a custom font for images actually). My app will also be ran on mobile devices (using a different design, using far fewer includes but a similar method).</p>
<p><strong>Research:</strong> Here's what I know:</p>
<ul>
<li>You can have Apache handle js/css as php, but is not something I'm interested in (dangerous) - <a href="http://stackoverflow.com/questions/984148">link</a></li>
<li>This site gave me the idea, although I don't quite understand it - <a href="http://www.catswhocode.com/blog/3-ways-to-compress-css-files-using-php" rel="nofollow">3 Ways to Compress CSS</a></li>
<li>Caching with something like APC (not sure how it works, but out of the scope of this question) would improve php speeds (?)</li>
</ul>
| php | [2] |
5,355,435 | 5,355,436 | Show EditItemTemplate in gridview when handling event | <p>This has got to be simple one, but I am having issues finding it.</p>
<p>I have a gridview which I am yanking the ObjectDataSource from and putting all the data connections in the code behind. So now I have to manually write all the things that the Datasource handled for me (Man it does handle a lot for you).</p>
<p>So on my rowEditing event, I need to be able to display the EditItemTemplate. Any Ideas?</p>
<p>Thanks</p>
| asp.net | [9] |
142,909 | 142,910 | Jquery - get disabled elements | <p>I am trying to use Jquery to iterate through an array of textboxes where i only want textboxes that are 'enabled'.
can someone give me the best way to do this? Would i use the filter method ?</p>
<p>(ie:)</p>
<pre><code>var arrayOfTextBoxes = $("[id$='" + textBoxId + "']");
var enabledTextBoxes = $(arrayOfTextBoxes).????
</code></pre>
<p>Thanks!</p>
| jquery | [5] |
143,150 | 143,151 | value of ASP.NET variables for different users | <p>I'm using VS2010,C# to develop my ASP.NET web app, sometimes I need to declare public or even public static variable at start of my codebehind files, so that I can access them globally in the file and also they preserve their value between postbacks, everything works fine on my local server (as I'm the only person who runs the code). But I don't know exactly what happens when this page (and therefor its codebehind) are run by several web site visitors at the same time, I want my program to run the same for all users, but I think in this way something will cause problems, I can remember from my previous ASP.NET experience that using variable (public or public static) in codebehind can cause misunderstanding for different users of web site, for instance:
user A runs program, (public static int) my_int that had the value of -1 at startup has taken value of 100, and at this time user B runs the same page, so my_int is 100 and it will cause problems, also suppose that user A leaves the page while my_int has value of 100, then user B will visit the page my_int would be initially 100 (while that should be -1) so I think unexpected behaviors would occur</p>
<p>is it right? will this happen at all? if so, how can I prevent it? should I use session instead of variables? how can I have a better understanding about the whole situation</p>
<p>thanks friends</p>
| asp.net | [9] |
4,564,829 | 4,564,830 | Android development | <p>Does the Android Application Development comes under the J2ME programming or is it totally/partially different?</p>
<p>Please do let me know if anybody has a clear idea.</p>
| android | [4] |
994,310 | 994,311 | jQuery <function> is not a function | <p>I'm trying to create a simple text block that updates when 1 of 3 form fields is changed.</p>
<p>Here's my jQuery and it keep getting this error: <code>TypeError: $(...).updateTitlePrefix is not a function</code></p>
<p>Can anyone tell me what i'm doing wrong here?</p>
<pre><code>$ = jQuery.noConflict();
$(document).ready(function() {
$('#dataEntryForm\:studyId').updateTitlePrefix();
$('#dataEntryForm\:formNumberQualifier').updateTitlePrefix();
$('#dataEntryForm\:formVersionNumber').updateTitlePrefix();
});
// updates the titlePrefix when either the study#, form# or form version are changed
$.fn.updateTitlePrefix() = function() {
$(this).change(function() {
$('#dataEntryForm\:titlePrefix').text($('#dataEntryForm\:formNumberQualifier').text() + $('#dataEntryForm\:formVersionNumber').text() + $('#studyId').text())
});
}
</code></pre>
<p>Not sure if this is relevant, but i'm on jquery 1.3.2 because this is a JSF project and that's what is included in the Richfaces library.</p>
| jquery | [5] |
816,563 | 816,564 | jquery no conflicting error | <p>I have particular set of files for toggle effect. When I use these two files separtely it works for me. But I use to copy the files with collection of my js files so it start giving me error. Its giving me conflicting error. When firebug. It shows error on first file.</p>
<pre><code><script>
$(document).ready(function() {
//$.noConflict();
$('.toggle_block').toggleElements({
fxAnimation:'slide',
fxSpeed:'fast',
className:'toggler'
});
});
</script>
</code></pre>
<p>Firebug Error is: </p>
<pre><code>$(".toggle_block").toggleElements is not a function
className:'toggler'
</code></pre>
<p>Its minified version is on jsfiddle link.
<a href="http://jsfiddle.net/cHjMD/" rel="nofollow">http://jsfiddle.net/cHjMD/</a></p>
<p>Every time I got conflicting error, I use to remove it using <code>$.noConflict();</code> and sometime it sorted out my error also. But this time Its not helping me. I want to permanently sorted out this problem. Here also I have commented noconflict code.</p>
<p>Request please don't provide me link to read noConflict function. I have read it many times. If you define in more better way then I would be pleased.</p>
| jquery | [5] |
713,783 | 713,784 | java bit shifting | <p>I have the following line in my code :-</p>
<pre><code>if (( checker & (1 << val)) ) return false;
</code></pre>
<p>where checker is of type <code>int</code> and val is of type <code>int</code>. When I try to compile the same I get the following :-</p>
<pre><code>q11.java:38: incompatible types
found : int
required: boolean
if (( checker & (1 << val)) ) return false;
^
1 error
</code></pre>
<p>However if I modify the code to have :-</p>
<pre><code>if (( checker & (1 << val)) > 0 ) return false;
</code></pre>
<p>then I'm able to compile the source. I'm however unable to understand why the code did not work initially. Some pointers on why this happens?</p>
| java | [1] |
668,701 | 668,702 | add days on CURDATE() funcion in PHP | <p>I'm currently trying to add days to the current date function in PHP but I'm not really sure how. Below is my code..</p>
<pre><code>function due(){
$it=$_POST['item_name'];
$ab="select duration from item where item_name='$it'";
$cd=mysql_query($ab);
while($mn=mysql_fetch_array($cd)) {
$interval=$_POST['duration'];
$due='DATE_ADD(CURDATE(),INTERVAL'.$interval.'DAYS )';
$gh=$_POST['request_name'];
$ij=$_POST['requestid'];
$ef="insert into request (due_date) values ('$due') where request_name='$gh' && requestid='$ij'";
$kl=mysql_query($ef);
}
}
</code></pre>
<p>DURATION is the number of days I would like to add to the current date</p>
<p><em>*</em> I'll elaborate my question further</p>
<p>DURATION is inserted into a table (TBL_A)
CURDATE() value is inserted in another table (TBL_B)</p>
<p>I would use the FUNCTION DUE() to select DURATION and add to the CURDATE() as DUE_DATE
DUE_DATE is inserted into TBL_B</p>
<p>DURATION varies on the item_name in TBL_A</p>
<p>DUE_DATE is selected in another program</p>
| php | [2] |
313,596 | 313,597 | Printing mailing labels - php, MySQL, FPDF | <p>I'm having trouble getting this script to output a pdf for mailing labels. It throws this error:
Parse error: syntax error, unexpected $end </p>
<pre><code><?php
define('FPDF_FONTPATH','/home/directory/public_html/sub/font/');
require_once('fpdf.php');
//Connect to your database
mysql_connect("localhost", "db_user","db_pw") or
die ("Could not connect to database");
mysql_select_db("database_name") or
die ("Could not select database");
$query = "SELECT employee_name, street_address, City, state, zip_code FROM employees ORDER BY `employee_name` ";
$result = mysql_query($query) or die('Error, query failed');
$num_rows = mysql_num_rows($result);
function PrintAddressLabels($result){
$pdf=new FPDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$pdf->SetMargins(0,0);
$pdf->SetAutoPageBreak(false);
$x = 0;
$y = 0;
$i=0;
while (TRUE) {
if ($row=$result[$i]) {
//positions set above
$LabelText = sprintf("%s\n%s %s\n%s, %s, %s",
$row['employee_name'],
$row['street_address'],
$row['City'],
$row['state'],
$row['zip_code']);
Avery5160($x,$y,&$pdf,$LabelText);
$y++; // next row
if ($y == 10 ) { // end of page wrap to next column
$x++;
$y = 0;
if ($x == 3 ) { // end of page
$x = 0;
$y = 0;
$pdf->AddPage();
}
}
$i++; //counter through result
} else {
// Error quit printing
break;
}
{
$pdf->Output('mailing_labels.pdf','D');
}
?>
</code></pre>
| php | [2] |
489,331 | 489,332 | How can I catch a click event objects attribute using javascript only? | <p>I have the following coded using jQuery:</p>
<pre><code>$('.status-infos').click( function (e) {
var xx = $(this).attr('data-xx');
alert(xx);
return false;
});
</code></pre>
<p>Our site main page will no longer use jQuery and so I need to do something similar to this using only javascript. </p>
<p>I saw this as a way to get the click event:</p>
<pre><code>document.getElementById('element').onclick = function(e){
alert('click');
}
</code></pre>
<p>but how can I get the xx attribute. </p>
| javascript | [3] |
2,942,916 | 2,942,917 | How to make jQuery show Loading picture while doing a function? | <p>How to make jQuery show Loading picture while doing a function?</p>
| jquery | [5] |
4,068,098 | 4,068,099 | Set Page Validate Request attribute at run time | <p>Set Page Validate Request attribute at run time</p>
| c# | [0] |
192,114 | 192,115 | What's the name property of function object? | <pre><code><script>
function obj1(){}
alert(obj1.name);
var obj2 = function(){}
obj2.name = 'obj2';
alert(obj2.name=='');
</script>
</code></pre>
<p>I have tested the code in Chrome, ff, safari </p>
<p>But IE9 don't have this property . </p>
<p>question is where I can read documents to find all this kind of situations ?</p>
| javascript | [3] |
3,878,713 | 3,878,714 | Making object eligible to be cleaned up | <p>I have very simple question but the answer is still not clear. If i have class Person and inside class Person there is one attribute which references to other object(ex: Account). If Person object is eligible for GC so either that attribute will be eligible to be cleaned up?</p>
| java | [1] |
2,776,886 | 2,776,887 | Jquery: How can i track changes in input elements? ( not a keypress question ) | <p>I need to track changes on an input element but this should be done whenever anything change its value, not only users typing.</p>
<p>The keyup event is not what i need as already specified and the change event only works when the input loses focus.</p>
<p>Any ideas of how can i do this?</p>
<p>Thanks.</p>
| jquery | [5] |
3,749,041 | 3,749,042 | why to use "text/javascript"? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/985408/should-i-include-type-text-javascript-in-my-script-tags">Should I include type=“text/javascript” in my SCRIPT tags?</a><br>
<a href="http://stackoverflow.com/questions/9659029/difference-between-script-tag-with-type-and-script-without-type">Difference between <script> tag with type and <script> without type?</a> </p>
</blockquote>
<p>This:</p>
<pre><code><script type="text/javascript">
alert("Hello world!");
</script>
</code></pre>
<p>And this:</p>
<pre><code><script>
alert("Hello world!");
</script>
</code></pre>
<p>seem to accomplish the same thing (at least in chrome, firefox, ie), so, what is the difference? why should I put those extra 25 characters?</p>
| javascript | [3] |
4,516,707 | 4,516,708 | How to control screen birghtness with slider in android | <p>I want users to be able to control the birghtness with a slider. Please answer in the simplest way because im a noob when it comes to android. </p>
| android | [4] |
2,189,886 | 2,189,887 | how to stick gallery in left side insted of center in all device? | <p>When the Gallery first displays, it is centering the first item automatically. The behavior I want, is to left align the first item in the parent layout instead of centering it. How can I achieve this in all device?</p>
| android | [4] |
3,485,453 | 3,485,454 | how can i trigger action by span id? | <p>How can I trigger action by <code><span id=</code> in jquery?</p>
<p>my html: </p>
<pre><code><span id="span-1"></span>
<span id="span-2"></span>
<span id="span-3"></span>
<span id="span-4"></span>
</code></pre>
<p>what i've tried </p>
<pre><code>$('[id^="span-"]').click(function () {
alert("this_id");
});
</code></pre>
| jquery | [5] |
5,507,173 | 5,507,174 | Which will be returned in a program | <p>I was wondering what will be returned in a java program when you have multiple returns in a program.</p>
<pre><code>private int numberReturner()
{
if (a) return a;
else if (b) return b;
for (int i = 1; i < board.size()-1; i++)
{
if (c) return c;
}
return d;
}
</code></pre>
<p>So lets say a is true, (it should return a), but wouldn't it return d because that is the final line of code in the whole program? Why is this so?</p>
<p>Sorry if I worded this a bit strangely...</p>
| java | [1] |
4,982,476 | 4,982,477 | Php Estimated Shipping Date Function - Skipping Weekends | <p>I need some help with skipping weekends properly in an estimated shipping date function. The code I have now doesn't work correctly. The code that is currently giving me trouble is:</p>
<pre><code>$adddays = 0;
for ($i = 0; $i<$processdays; $i++) {
$dayofweek = $startdayofweek + $i;
if ($dayofweek == "6") { $adddays = $adddays+2; }
elseif ($dayofweek == "8") { $dayofweek = "1"; }
}
</code></pre>
<p>and</p>
<pre><code>if ($dayofweekfinal=='6') { $processdays = $processdays+2; }
else if ($dayofweekfinal=='7') { $processdays = $processdays+1; }
</code></pre>
<p>The top part skips the weekends and the bottom part kicks the final day in the count over to a Monday if it lands on a weekend. Seems it would work better if the code just pretended the weekend days didn't exist. I would think that if that was done correctly, there would be no need for that second part. I have searched all over for code to replace this but it either doesn't work or I can't get it to work with my current code. I could really use some help. Thank you.</p>
| php | [2] |
3,135,050 | 3,135,051 | checking text field value length | <p>I am trying to see if the text field length is at least a certain length. here is my code:</p>
<pre><code><form name="form2" id="form2" onsubmit="return validate()">
length 4: <input type="text" name = "t" id="t" />
<input type="button" name="submit" value="submit" />
</form>
<script>
function validate() {
document.write("good");
submitFlag = true;
if(document.form2.t.value.length!=4){
submitFlag=false;
alert("ivalid length - 4 characters needed!");
}
return submitFlag;
}
</script>
</code></pre>
<p>when I click submit, nothing happens.</p>
| javascript | [3] |
4,285,658 | 4,285,659 | Using closest command in success ajax callback | <p>I have multiple forms with id=#REQUESTFORM. To retrieve the correct information when sending data, I use closest command. But same command does not work when I tried using it in success ajax callback. How will else can I receive and print server's response in correct form?</p>
<pre><code> $("[name='respond']").live('click', function() {
$("[name='action']").val($(this).val());
$.ajax({
type: "POST",
data: $(this).closest('#REQUESTFORM').serialize(),
url: "content/requests/index.cs.asp?Process=RespondRequests",
success: function(output) {
$(output).closest('#REQUESTFORM').html(output)
},
error: function(xhr){
alert('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
}
});
</code></pre>
| jquery | [5] |
2,892,069 | 2,892,070 | Types of Declaring variables in C++ | <p>If I have a structure called student
so what's the difference between these </p>
<pre><code>Student& refFriend;
Student* ptrFriend;
Student valFriend;
</code></pre>
| c++ | [6] |
501,851 | 501,852 | android tab pane inside tab pane? | <p>Hello is it possible to add a tab pane inside another one?</p>
| android | [4] |
2,779,391 | 2,779,392 | Python: function returning numbers in ascending order | <p>How can I write a function that would give me a new number in ascending order every time i call it?</p>
<p>For example, if I call it for the first time it returns "1", if I call again, it returns "2". </p>
| python | [7] |
3,250,392 | 3,250,393 | # symbol use in variables and constants | <p>I have seen in many places in php that # sysmbol is used. whats the use of this and is it good to use # in constants and sql query or echo statements. I am writing some examples below:</p>
<pre><code>define("LOG_TABLE", '#logger_table');
SELECT
l.id
FROM
#listings l,
#users u
WHERE
u.gid = '$id'
</code></pre>
<p>Can you please guide me the use of # symbols here.</p>
| php | [2] |
1,299,818 | 1,299,819 | python: How to decrement and update values for a field in delimited text | <p>I have a text file (bowtie alignment file) that looks like this:</p>
<pre>
read_1 + 345995|PACid:16033981 599 AGTAGTAATCAGTCACCCGCAAGGTAGACAAGG qqqqqqqqqqqqqqqqqqqqq!!qqqqqqqqqq 0
read_2 + 949205|PACid:16054220 338 TACCAGCACTAATGCACCGGATCCCATCAGATC qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq!!q 0 31:A>T
read_3 + 932004|PACid:16034380 1226 GGCACCTTATGAGAAATCAAAGTTTTTGGGTTC qqqqqqqqqqqqqqq!!qqqqqqqqqqqqq!!q 3
</pre>
<p>I want to subtract one from Column #4 (the position), and print each line with the updated value.</p>
<p>I can read the file, then separated the fields based on tab, and also identify Column #4 as <code>data[3]</code>, but then I am stuck with subtracting one from each value in Column #4 and printing all the fields in each line with updated value for Column #4.</p>
<p>How can I do this using Python?</p>
<p>I tried something like this:</p>
<pre><code>in_file = open(sys.argv[1],'r')
out_file = open(sys.argv[2], 'w')
for line in in_file:
data = line.rstrip().split('\t')
position = int(float(data[3]) -1)
</code></pre>
<p>but I am not sure about how to proceed with printing the lines with updated position.</p>
| python | [7] |
1,146,089 | 1,146,090 | How to start another android application from code | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3872063/android-launch-an-application-from-another-application">Android Launch an application from another application</a> </p>
</blockquote>
<p>I want to start Another of my Android Application ( .apk ) using Android code. is it possible ?
I have one background kind of Android Application ( Service ). It is separate Android Application. I want to start this Application from my Another Android Application. </p>
| android | [4] |
5,338,584 | 5,338,585 | Using onPageFinished in WebView blocks phone number and street address links | <p>I'm loading a url into a webview and accessing the "onPageFinished" method to hide the loading spinner. However, this seems to block all phone number links and street address links from clicking through. They will appear as links but nothing happens when clicking them.</p>
<p>If I comment out the "mWebView.setWebViewClient ..." area below, then phone number links will bring up the dialer and street addresses will be mapped on Google Maps, but the spinner keeps on spinning in the title bar after the page loads.</p>
<p>Any ideas? thanks!</p>
<p>The xml:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</code></pre>
<p>And the java:</p>
<pre><code> mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
Map <String, String> headerAuth = new HashMap <String, String>();
headerAuth.put("Authorization", "Basic " + encodedString);
String url = "URL to my web page";
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView mWebView, String url) {
g_progressBar.setVisibility(View.INVISIBLE);
}
}); // commenting this out fixes problem, but I need it to remove loading indicator in title bar
mWebView.loadUrl(url, headerAuth);
</code></pre>
| android | [4] |
3,245,667 | 3,245,668 | Get image and show it on uiimageview in uitableview | <p>Pls help me for getting image form url my url is :</p>
<p><a href="http://dev.kuwait.tt/kuwait-news/news_mobile_staging/phpThumb.php/95x95;/var/www/html/kuwait-news/images/stories/article_default.png" rel="nofollow">http://dev.kuwait.tt/kuwait-news/news_mobile_staging/phpThumb.php/95x95;/var/www/html/kuwait-news/images/stories/article_default.png</a></p>
<p>this is working fine for webbrower but not working in iphone application will crashed when i get image from these type of url pls help me for getting image</p>
<p>Thanks,</p>
| iphone | [8] |
26,206 | 26,207 | Mysterious javascript behaviour: unequal equals | <p>I really don't know how is it possible, and I couldn't reproduce the error in a simplified environment, say JSFiddle. But here is how it looks in my application. </p>
<p>I'm trying to convert value that can be 'True', 'False' or 'something else' string into boolean if it is either True or False. In most cases it works just fine (although they may be a slicker way of doing the conversion) as it is shown on the picture below</p>
<p><img src="http://i.stack.imgur.com/8yVbg.png" alt="enter image description here"></p>
<p>however on occasion it fails and the value of the watch shows as follow:</p>
<p><img src="http://i.stack.imgur.com/DBgIZ.png" alt="enter image description here"></p>
<p>So suddenly string variable with a value of "True" is not equal to a "True" string literal. I'm lost. How is it possible? What am I missing here? </p>
<p>Thanks in advance</p>
| javascript | [3] |
5,665,650 | 5,665,651 | How to detect Android audiostream underflow/overflow? | <p>I'm currently using the AudioRecord java object to receive audio from the microphone. Sometimes I don't pull data sufficiently fast (E.g, when an application switch occurs). Is there any method for me to know that the audiostream was interrupted with an audiobuffer underflow ?</p>
| android | [4] |
458,918 | 458,919 | good way to write an array of shorts into file with LittleEndian | <p>I have a <strong>short[512x512] array</strong> need to write to a <strong>binary file</strong> with <strong>little endian</strong>. I know how to write <strong>one short</strong> to file with <strong>little endian</strong>. I think there is may be <strong>better ways</strong> than loop through the array writing <strong>one by one</strong>.</p>
| java | [1] |
74,146 | 74,147 | php jQuery with .change how can you automatically change the value | <p>I have this image and i like to work it out on jQuery now the image have a fixed size, but when I input on the <code><input type='text' name='img_logo' value='630px'></code></p>
<p>Like I put for example <code>530px</code> the image size should be change also.</p>
<p>Here's my code.</p>
<pre><code><form method='post'>
<input type="text" name="logo_width" value="632px">
<p>Format logo: <span id="logo_size">632px</span></p>
</form>
</code></pre>
<p>the jQuery codes</p>
<pre><code>$(function(){
$('input[name="logo_width"]').change(function(e) {
var chk = $('input[name="logo_width"]').val();
$('img#img_logo').attr(chk);
});
});
</code></pre>
<p>and the image</p>
<pre><code><div class="logo">
<img src="images/upload/' . $set_logo_img['filename'] . '"
width="630px" align="center" id="img_logo" />
<br />
</div>
</code></pre>
<p>But when i do input some value on the <code>input='name=logo_width'</code> nothings change
is my code jQuery wrong?</p>
| jquery | [5] |
3,068,768 | 3,068,769 | Android - how to reset a TextView | <p>I set an original TextView value like this:</p>
<pre><code>TextView problemName = (TextView) findViewById(R.id.some_variable);
</code></pre>
<p>But at some point I need to reset it to something new. I don't see a function like setText() or anything like that. How is the displayed text supposed to be reset?</p>
<p>Thanks!</p>
| android | [4] |
4,434,184 | 4,434,185 | Question about jQuery and reload a page | <p>this is a noob question, so, be generous with me please.</p>
<p>Take for example Twitter. There's an input text form at the top for writing tweet and below the tweets list. If you write a new tweet and click "Tweet" button, you'll see the your new tweet instantly in the tweet list, without reloading a page. I know this is a banal situation but by the way I want to ask you.</p>
<p>I've a page with a form at the top and below it there's a message list. When you fill the form and submit a new message the page it reloads and you see the updated message list with the new message. I want implement the same technique that Twitter use. Maybe should I use jQuery, and send data to a page with <code>$.post</code>. Can you explain me something about?</p>
| jquery | [5] |
2,853,414 | 2,853,415 | How to achieve feathering effect in Android? | <p>I am trying to create an Oval Bitmap and I need to get a feather effect around the margins,</p>
<p>Does anyone have any idea How I can achieve this ?</p>
<p>Thanks. </p>
| android | [4] |
411,981 | 411,982 | Iphone simulator display problem on macbook | <p>I'm having a problem getting my <strong>MacBook</strong> set up to build <strong>iPhone</strong> *<em>apps</em>* in <strong>xCode</strong>. The iPhone <strong>Simulator locks up</strong> and not show on desktop it only invoke after pressing the button f3.</p>
<p>I've tried everything I can think of, including</p>
<ul>
<li>resetting the simulator</li>
<li>tried all of the different hardware options in the Simulator (5 or 6)</li>
<li>tried the two debug build choices in xCode.</li>
<li>uninstalling the SDK and completely reinstalling</li>
<li>tried creating xCode projects on Desktop and in \Developer...</li>
</ul>
<p>I'hv same problm when i simply press on simulator. it invoke only when i press f3 button but not selected when i click on it after it's invocation.</p>
| iphone | [8] |
240,990 | 240,991 | How to Change Background of UIWebView Scrolling? | <p>in the iPhone SDK Interface Builder, any UIWebView has a default gray background that is shown when the view has been scrolled too far. Is it possible to change this background color so it doesn't look so obvious? The gray conflicts with my App :( Any help would be greatly appreciated.</p>
| iphone | [8] |
1,163,898 | 1,163,899 | Trying to call function on a dynamically generated object name | <p>I'm having some issues calling a function on an object whose name is determined dynamically. The code below illustrates how my code is currently set up, and the problem that I'm having is occurring in the function called doSomethingElse().</p>
<pre><code>var Obj = function(){
this.test = this.objMgr();
};
Obj.prototype.objMgr = function(){
var self = this;
function doSomething(){
//do some processing that seems unimportant to this particular prob
doSomethingElse();
}
function doSomethingElse(){
//The object that I need is determined at runtime, and is therefore dynamic
var callFuncOnThis = 'subObj';
//How the heck can I call function a on the object referenced in callFuncOnThis
this[callFuncOnThis].a(); //Doesn't work, this refers to dom window
self[callFuncOnThis].a(); //Doesn't work, self refers to obj
eval(callFuncOnThis).a(); //Works, but is there a better way?
}
var subObj = {
a:function(){
},
b:function(){
}
};
var subObj2 = {
a:function(){
},
b:function(){
}
};
doSomething();
return{
subObj:subObj,
subObj2:subObj2
}
};
var test = new Obj();
</code></pre>
| javascript | [3] |
5,561,775 | 5,561,776 | Scraping digg rss feed with python | <p>is there a way to get the link from digg through its rss feed? or do i have to get the website and manually scrape it with a regex?</p>
<p>i want to get the real link digg points to, not to the comments feed, from rss.</p>
<p>example -
<a href="http://feeds.digg.com/~r/digg/popular/~3/Hx0VATaafSw/Apple_Scaling_Final_Cut_Studio_Apps_to_Fit_Prosumers_2" rel="nofollow">http://feeds.digg.com/~r/digg/popular/~3/Hx0VATaafSw/Apple_Scaling_Final_Cut_Studio_Apps_to_Fit_Prosumers_2</a></p>
<p>goes to</p>
<p><a href="http://www.appleinsider.com/articles/10/05/18/apple_scaling_final_cut_studio_apps_to_fit_prosumers.html" rel="nofollow">http://www.appleinsider.com/articles/10/05/18/apple_scaling_final_cut_studio_apps_to_fit_prosumers.html</a></p>
| python | [7] |
1,461,992 | 1,461,993 | Meaning of 'this' inside jQuery code | <p>I am reading an excellent book about jQuery (Apress Pro jQuery) and I am a little confused about the use of 'this'.
For example I am reading the following code :</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
var isResult = $('img').is(function(index) {
return this.getAttribute("src") == "rose.png";
});
console.log("Result: " + isResult);
});
</script>
</code></pre>
<p>I am wondering at which object in this case 'this' refers to.
Thank you.</p>
| jquery | [5] |
1,757,811 | 1,757,812 | Concatenating different patterns of string | <p>I'm writing a function which concatenates different numbers of strings depending on their length. </p>
<p>Here is some c++ like pseudo code of what I'm currently doing:</p>
<pre><code>string foo(size_t maxLength)
{
string a, b, c, d, e, ret;
//...assign them
if(a.size() + b.size() + c.size() + d.size() + e.size() <= maxLength)
{
ret = a + b + c + d + e;
}
else if(a.size() + c.size() + d.size() + e.size() <= maxLength)
{
LOG << "B was removed.";
ret = a + c + d + e;
}
else if(a.size() + b.size() + c.size() + d.size() <= maxLength)
{
LOG << "E was removed"l
ret = a + b + c + d;
}
//... a large amount of code like the above
return ret;
}
</code></pre>
<p>Is there a nice way to clean this up?</p>
<p>Thanks.</p>
| c++ | [6] |
4,968,046 | 4,968,047 | Android Amazon payment system implementation | <p>Anyone can help me for implementing the Amazon payment System in the Android application?</p>
<p>Is there any link or library or sample source code available for that?</p>
<p>Thanks</p>
| android | [4] |
529,550 | 529,551 | What is the right way of showing data from a DB, but not on a gridview | <p>The title is not informative enough, couldn't come up with something that will fit, so I will appreciate if someone will change it, or at least offer another one.</p>
<p>My question:</p>
<p>I have a page that shows a user's profile by his ID: (Consider the next page as an example)</p>
<p><img src="http://i.stack.imgur.com/VWaQB.png" alt="enter image description here"></p>
<p>In the above, there are 3 fields which are dynamic:</p>
<ol>
<li>The user's name</li>
<li>The skin he is using</li>
<li>His profile image</li>
</ol>
<p>I don't want to add labels around the whole page, and set them before the page loads, in order to present his info (there will be more fields).</p>
<p>I want something that will be easy to maintain for future changes.</p>
<p>What is the correct way of doing this?</p>
<p>Thanks, Guy</p>
| asp.net | [9] |
1,326,112 | 1,326,113 | image comes with fade-in/fade-out effecta and image change every a fixed time in iPhone | <p>I have 4 images. I want to load image in first screen. Each image comes with fade-in/fade-out animation and image change after every 10 second. when we click any images than next screen come up.</p>
<p>please give me help i am new in iPhone.</p>
| iphone | [8] |
5,913,546 | 5,913,547 | php looping when looping second loop | <p>I have three tables section,section_usertype,SystemUType</p>
<p>I have the section table that keeps the master data and section_usertype stores the
section_id data from the section table
idSysUsers data from the SystemUType table
The idsysusers hold multiple ids wrt section_id in the section_usertype table.</p>
<p>The
$row im able to get the Section_Id,Section_Name etc but not the idSysUsers assigned to that section .
Im having problem with the looping ,could you help me?
Code is given below</p>
<pre><code> <?php
$rs = mysqli_query($dbc,"SELECT `Section_Id`,`Section_Name`,`Section_Description`,`Image_Path` FROM `section` limit $offset,$rows");
$items = array();
while($row = mysqli_fetch_object($rs))
{
$idSysUsers_qry = mysqli_query($dbc,"select `Section_User_Id`,`Section_Id`,`idSysUsers` from section_usertype where Section_Id='".$row->Section_Id."'");
while($rowsysusers = mysqli_fetch_object($idSysUsers_qry))
{
$qUTdd = "SELECT idSysUsers,uid,uidname,userTypeRol from SystemUType where `SystemUType`.`idSysUType` = '".$rowsysusers->idSysUsers."'";
$rUTdd = @mysqli_query ($dbc, $qUTdd);
$fetchuserrole = mysqli_fetch_object($rUTdd) ;
$userTypeRole[] = $fetchuserrole->userTypeRole;
}
// $row im able to get the Section_Id,Section_Name etc but not the idSysUsers assigned to that section .
$row = array(
'Section_Id' =>$row->Section_Id,
'Section_Name'=>$row->Section_Name,
'Section_Description'=>$row->Section_Description,
'Image_Path'=>$row->Image_Path,
'idSysUsers'=>$userTypeRole
);
array_push($items, $row);
}
?>
</code></pre>
| php | [2] |
1,626,311 | 1,626,312 | Can't pass variable with GET on localhost | <p>I'm having trouble passing variables with GET.</p>
<p>On the first page I have this link:</p>
<pre><code><a href="something?test=1">Test GET</a>
</code></pre>
<p>And on the page that this this anchor links to, I have this:</p>
<pre><code>if (isset($_GET['test']))
{
echo "Set";
}
else
{
echo "Not set";
};
</code></pre>
<p>The page echoes "Not set". I have MAMP installed and I'm running this example on localhost, could that cause my troubles?</p>
| php | [2] |
3,566,280 | 3,566,281 | char array compilation error | <p>What is the problem in my code? It does not compile..</p>
<pre><code> class FileNames
{
public:
static char* dir;
static char name[100];
static void Init3D()
{
FileNames::dir = "C://3D//";
FileNames::name = "abc";
}
};
</code></pre>
| c++ | [6] |
4,557,973 | 4,557,974 | Combining different datatypes into a void type | <p>I am creating a search tree that would handle concatenated key. ie a key is a combination of multiple data types. For example key might be a concatenation of student_id,student_name,student_age...How should i create such a key when i pass these three values to create key function? Also given two keys how can i compare them?</p>
| c++ | [6] |
5,426,301 | 5,426,302 | setting a string's char' by index | <p>I have an ArrayList of strings, and I want to randomly change a string's (random) char' by index.</p>
<p>ArrayListName.get(i).charAt(j) </p>
<p>exists. What's the equiv' for a setter?</p>
| java | [1] |
5,285,538 | 5,285,539 | Getting some errors on an experimental program, relating to System.out.println | <p>I'm getting a lot of errors in this piece of coding below. </p>
<p>first off, every period between "out" and "println" is drawing a red underline. the error reads, '''- Syntax error on token(s), misplaced construct(s)'''</p>
<p>Next, line 11's "println" has an error reading "'- Syntax error on token "println", = expected after this token"'</p>
<p>also, the (".......") phrases in lines 7,9, and 12 say, """"Syntax error on token ""(whatever words are in the quotation marks)"", delete this token""".</p>
<p>Finally, line 13's semicolon has an error of """- Syntax error on token ";", { expected after this token"""</p>
<p>Thanks for your help in advance! :)</p>
<pre><code>import java.util.Scanner;
public class Tennis_Pro
{
public static void main(String[]args){
}
Scanner in=new Scanner(System.in);
System.out.println("Welcome to Tennis Pro. Please enter the name of player one:");
String playerone=in.nextLine();
System.out.println("And player two?");
String playertwo=in.nextLine();
System.out.println("The players today are "+playerone+" and "+playertwo+". is this correct?");
System.out.println("type y or n");
String yorn=in.nextLine();
if (yorn.equals ("y"))
{
//The game will go here
}
else if (yorn.equals ("m"))
{
}
}
}
</code></pre>
| java | [1] |
421,576 | 421,577 | Will $_SERVER['HTTP_REFERER'] detect a site as a referer if it is using a redirect? | <p>In PHP I see that</p>
<pre><code>$_SERVER['HTTP_REFERER']
</code></pre>
<p>gives me the refering url if the refering page had a link that was clicked through to my current page. But what if page A has a htaccess redirect that sends the user to page B. If I have the above snippet on Page B will I get Page A as the referer?</p>
<p>Or does it only work if a user clicks on a link that takes them to page B?</p>
| php | [2] |
1,345,957 | 1,345,958 | for loop does not execute twice | <pre><code> createModelView: function (obj,vitalslength,headerValue) {
for(i = 0, vitalsLen = vitalslength; i < vitalsLen; i++) {
// Do some logic
}
}
</code></pre>
<p>Two Questions</p>
<ol>
<li><p>Where should i place my return statement for the function. If i place inside the for loop will it work. </p></li>
<li><p>When i call this function <code>Obj.createModelView(arguments);</code> Why does it not execute twice or n number of times depending upon the vitalsLength. <code>It only executes once.</code></p></li>
</ol>
| javascript | [3] |
6,003,764 | 6,003,765 | Text file containing empty spaces in c++! | <p>I have a problem with reading a txt file of the following form:</p>
<pre><code> 1 2 3 4 5 6 7 8 9 10
1 f f f f f
2 f f f f f f
3 f f f f f
4 f f f f f
5 f f f f
</code></pre>
<p>where: (1,2,3,,,,,) are indeces, f's are data of type double.<br>
I have tried to read the contents using matrix notation i.e. tab[i][j]; i've succeeded to do it when my file doesn't contain empty, but when it does have emty spaces as shown above, data is displayed randomly and i don't understand anything of it.</p>
<p>So, can anyone enlighten me please??</p>
<p>thanks in advance.</p>
| c++ | [6] |
168,535 | 168,536 | What is .DS_Store | <p>I hope to list all files in document directory using codes below</p>
<pre><code>for(NSString *path in [manager contentsOfDirectoryAtPath:[self appDelegate].gCurrentPath_AppDelegate
error:nil])
{
NSDictionary *modData=[manager attributesOfItemAtPath:
[appDelegate.gCurrentPath_AppDelegate
stringByAppendingPathComponent:path ]
error:nil ];
NSDate * dateModified=(NSDate *) [modData objectForKey:NSFileModificationDate];
NSNumber *fileSize=[modData objectForKey:NSFileSize] ;
FileObj *newobj=[[FileObj alloc] init ];
NSString *ss=[[NSString alloc] initWithFormat:@"%@",path] ;
[newobj setfileName:ss];
[ss release];
[ fileArray addObject:newobj];//fileArray: the data source of UITableView
[newobj release];
}
</code></pre>
<p>I found that there is a file with name ".DS_Store' in the list.
I browsed the simulator directory and can not found where is this file.</p>
<p>Welcome any comment</p>
<p>Thanks</p>
<p>interdev</p>
| iphone | [8] |
1,942,843 | 1,942,844 | python super question | <p>I have a syntax question about python's super() and multiple inheritance. Say I have class A and B, both of which have a method hello(). I have a class C that inherits from both A and B, in that order. </p>
<p>How do I call the hello() method of B explicitly from C? Seems simple enough, but I can't seem to find the syntax for it. </p>
| python | [7] |
1,360,601 | 1,360,602 | Alarm in android | <p>I am using the following code for alarm, it will alert after 10 secs. Its works fine in emulator but in real device its forcely closing..can you guide me in correct way..
this is my actvity..</p>
<pre><code> public class Alarm1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(this, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,001000,intent,0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), pendingIntent);
Toast.makeText(this,"Alarm set", Toast.LENGTH_LONG).show();
</code></pre>
<p>}
}`
This is receiver class</p>
<pre><code>public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Alarm worked", Toast.LENGTH_LONG).show();
try{
Intent back = new Intent(context,Alarm.class);
back.addFlags(Intent.FLAG_FROM_BACKGROUND);
back.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
back.setAction("android.intent.action.MAIN");
back.addCategory("android.intent.category.LAUNCHER");
context.startActivity(back);
}
catch(Exception e){}
}
</code></pre>
<p>}</p>
<p>This is to play Ringtone for alarm.</p>
<pre><code>public class Alarm extends Activity {
private MediaPlayer mp; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alarm);
mp = MediaPlayer.create(this, R.raw.up);
mp.start();
Button start = (Button) findViewById(R.id.Button01);
start.setOnClickListener(vvvvv);
}
private OnClickListener vvvvv = new OnClickListener() {
public void onClick(View v) {
mp.stop();
finish();
}
};
</code></pre>
<p>}</p>
<p>This is working fine in emulator but not on real device..i used permissions also..
I am using Samsung Galaxy 1.6.
Thanks in advance..</p>
| android | [4] |
982,158 | 982,159 | Is it a good practice to unset cookie expire parameter? | <p>I see the usage of the following code snippet:</p>
<pre><code> $cookieexpiry=(time()+21600);
setcookie("rwphp","$cookieid",$cookieexpiry,"/",$_SERVER["HTTP_HOST"],0);
unset($cookieexpiry);
</code></pre>
<p>Q1> My question is whether or not this is a good practice to unset $cookieexpiry.</p>
<p>Q2> In general cases, when should I unset variables?</p>
<p>Thank you</p>
| php | [2] |
2,670,804 | 2,670,805 | How to change the value of the Button using jquery | <pre><code><input type="button" id="badd" value="Add"/>
</code></pre>
<p>I have one more button on the page called Edit when I click on Edit button I need to Change the Add Button value to SAVE...using jquery..</p>
<p>thanks</p>
| jquery | [5] |
5,901,903 | 5,901,904 | How to publish an almost identical version of my android app in a different location | <p>I have released an android app downloadable in the UK, but I wish to release a (very slightly different) version of the app for the U.S. Currently I believe I need to do the following for the new version of the app ...</p>
<p><strong>1.</strong> Change the 'package' attribute in the manifest file to something different.</p>
<p><strong>2.</strong> Ensure that on Google Play only the US can download the app.</p>
<p>Is there anything else I am yet to discover I need to do, or any other problems I am yet to consider?</p>
<p><strong>Edit 19th July 13:19 GMT</strong> - I am currently warming towards using TelephonyManager.getNetworkCountryIso() as an initial country guess, and falling back on the locale if this fails (because of no SIM card). What do people think? Using GPS is also an option though, but is that overkill?</p>
| android | [4] |
1,859,874 | 1,859,875 | python dict setdefault, confused | <p>New to python. I was looking at an algorithm today and I can't figure out why the dict d has values in it and curr does not. To me it does not seem like anything is being done to dict d.</p>
<pre><code>>>> def what(*words):
... d = dict()
... print d
... for word in words:
... print 'word: ' + word
... curr = d
... for letter in word:
... curr = curr.setdefault(letter, {})
... curr = curr.setdefault('.', '.')
... print d
... print '?'
... print curr
... return 1
...
>>> what('foo')
{}
word: foo
{'f': {'o': {'o': {'.': '.'}}}}
?
.
1
</code></pre>
| python | [7] |
3,474,113 | 3,474,114 | How to set different resolutions in the android graphical layout | <p>i am a new developer in android applications.
Recently i've been working on creating some UIs.Here comes the problem.</p>
<p>Assume that i need to create an xml file for a UI with a resolution of 500 x 600.
When i create the file,i need to see how it looks like in the graphical layout window in eclipse from time to time.But i got only 3.7in WVGA or 4.0in QVGA or others,while no 500x600 resolutions.</p>
<p>So how can i be able to see this UI in the graphical layout window with the specified resolution?
I've been searching it for some days,yet i don't make it.</p>
<p>Any help will be appreaciate.
thanks a lot!
^_^</p>
| android | [4] |
635,132 | 635,133 | Why can't I return only in a nested body of my Method and not be forced to return in the scope of the main method? | <p>Why is it that if you declare a return type on a method, that you have to specify a return in the scope of that method? Meaning, if I have a If/Switch in my method I can't specify the return there "ALONE" and not in the main method body? Is the only way around this is to assign the value returned by the nested procedure to a variable and return the variable in the main body of the method?</p>
<p>Example:</p>
<pre><code>public Int GetNum()
{
var a = 1;
switch(a)
{
case 1:
return 1 + 5;
default:
return a;
}
return a; //Why must I specify this return if it is going to hit my switch statement
//and return some int.
}
</code></pre>
| c# | [0] |
344,021 | 344,022 | Why Can You Instantiate a Class within its Definition? | <p>A coworker (who is very new to Java) stopped in today and asked what seemed like a very simple question. Unfortunately, I did an absolutely horrible job of trying to explain it to him. He had a book that had a little code that looked like this:</p>
<pre><code>class XCopy {
public static void main(String[] args) {
XCopy x = new XCopy(); // 1
x.doIt();
}
public void doIt() {
// Some code...
}
}
</code></pre>
<p>He was confused on line 1. What he wanted to know was why a new instance of XCopy could be created within the definition of the class XCopy. He thought this would have given some sort of a forward referencing error. After all, we hadn't yet finished declaring what the class XCopy was, so how could we create one?</p>
<p>I certainly know that this is valid code but, when I tried to explain it to him, I found myself stumbling over the answer and I'm afraid I left him more confused than when he started. I'd like to hear some other explanations of why this works.</p>
<p>Any thoughts? Why can you instantiate an instance of a class within the definition of the class, itself?</p>
| java | [1] |
3,830,807 | 3,830,808 | checking assertions in a lambda in python | <p>I'm trying to use assertions to show some invariants (mostly in testing)
Thus i want to write something like the following: </p>
<pre><code>values = [ range(10) ]
expected_values = [ range(10) ]
map (lambda x: assert x[0] == x[1] ,zip( [ run_function(i) for i in values ], expected_values))
</code></pre>
<p>If I use this with unittest.assertEqual this works perfectly fine , but if I want to write this with an assertion it just fails. Is there a way to fix this?</p>
| python | [7] |
1,505,921 | 1,505,922 | PHP : how do i access a request variable outside of a class? | <p>I have a form passing a variable $oid to a php script. the form variable is pulled and needs to be passed into a function called get_name(). The header() function in the class implements an interface called header() in the parent class. </p>
<pre><code> require 'pdfclass.php';
$oid = $_REQUEST['oid'];
class p extends PDF {
function Header() {
$this->setF('Arial',10);
$this->Cell(50,10,get_name($oid),1,0,'c');
} //end Header()
} //end class
function get_name($oid) {... }
$pdf = new P();
$pdf->setF('Times',12);
$pdf->AddPage();
$pdf->Output();
</code></pre>
<p>When i run this, i get an error on the get_name($oid) call inside the class extension. I wish to avoid using a global variable. Any ideas how to do this? </p>
<p>thanks in advance</p>
| php | [2] |
5,245,447 | 5,245,448 | What's the best way to replace the ternary operator in Python? | <p>If I have some code like:</p>
<pre><code>x = foo ? 1 : 2
</code></pre>
<p>How should I translate it to Python? Can I do this?</p>
<pre><code>if foo:
x = 1
else:
x = 2
</code></pre>
<p>Will x still be in scope outside the if / then blocks? Or do I have to do something like this?</p>
<pre><code>x = None
if foo:
x = 1
else:
x = 2
</code></pre>
| python | [7] |
1,972,647 | 1,972,648 | Android drawable | <p>I've a little problem with drawable repertory : I added an image in all drawable repertory (hdpi,ldpi,mdpi,etc ..) but in my file xml, when I wrote </p>
<pre><code>android:backgroud="@drawable/fond_ecran"
</code></pre>
<p>I've this error message : <code>Error: No resource found that matches the given name (at 'background' with value '@drawable/fond_ecran').</code> </p>
<p>I don't understand why because the image <code>fond_ecran.png</code> is in all drawable repertory so if someone have an explication to give me, it's will be cool :) </p>
| android | [4] |
1,617,672 | 1,617,673 | how to use one collection as a parameter to function call in another collection of the same size? | <p>I have two collections known to be of the same size:</p>
<pre><code>List<Drivers> drivers;
List<Car> cars;
</code></pre>
<p>I need to put driver from the <code>i</code> place to <code>i</code> car:</p>
<pre><code>for (int i = 0; i < drivers.Count; i++)
cars[i].AssignDriver(drivers[i]);
</code></pre>
<p>May I do that without loop?</p>
| c# | [0] |
2,718,126 | 2,718,127 | Best way to collect all "visible" form elements with jQuery that don't have a specific class? | <p>I'm trying to re-assign a new tab-index on a given form. To do this I want to exclude any form elements that are invisible (not visible) -- and also exclude any form elements that possess a specific class (".offscreen").</p>
<p>I'm trying this method -- but, it's not working (and is perhaps not the most efficient method).</p>
<pre><code>function reassignTabOrders() {
var tabindex = 1;
$j('input,select,textarea').not('.offscreen').each(function() {
var $input = $j(this);
if ($input.is(':visible')) {
$input.attr("tabindex", tabindex);
tabindex++;
}
});
};
</code></pre>
<p>Any ideas?</p>
| jquery | [5] |
5,415,984 | 5,415,985 | i am not getting the alert blackberry or other | <pre><code><%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function getcss(cssfile)
{
alert("hi");
alert(navigator.appName);
}
if(navigator.appName("Blackberry"))
{
alert("blackberry");
}
else
{
alert("other");
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body onload="getcss()">
<div id="demo">
Hai Css
</div>
</body>
</html>
</code></pre>
<p>Why I am not getting the alert blackberry or other? I have more doubt in that code so I want that clarification for this.</p>
| javascript | [3] |
329,130 | 329,131 | Can't get custom scrollbar jquery plugin (tiny scrollbar) to work on another gallery plugin (galleria) | <p>Been at this for a while. Trying to add a custom scroll bar to the photo gallery (customized Jquery galleria plugin) on expression engine, but no matter what I do it doesn't seem to work.</p>
<p>The site is live at www.pleasuredoingbusiness.org, and it's the collections page that i'm having trouble with. Galleria works fine, and i've modified the tinyscrollbarcolgal.js file so that it creates the appropriate divs/classes for tiny scroll bar. But it doesn't load up the javascript for some reason</p>
<p>galleria creates .galleria-container which is what i'm targeting with the tiny scrollbar plugin.</p>
<p>I've tried to load the custom scrollbar with $(window).load instead of $(document).ready, which got it to finally show up, but only if you refresh the page. (on chrome) On IE it still just doesn't show up at all</p>
<p>I've also tested with another custom scrollbar plugin and got the same results. Doesn't show unless i do $(window).load instead of $(document).ready, but only works if you refresh it. I've actually thought of maybe forcing it to refresh/load just once, couldn't get that to work (it kept looping), and the refresh thing doesn't seem to work on ie either.</p>
<p>Can anyone help!!?? Thanks in advance.</p>
| jquery | [5] |
1,928,563 | 1,928,564 | Android command not working | <p>I am writing a code in which I am trying to open up the camera of the device but my command is not working , it is showing compiletime error , Please see that is the command correct or is it wrong and if it is wrong then please provide me the correct code , this is my code -</p>
<pre><code>Camera camera= Camera.open();
</code></pre>
| android | [4] |
673,171 | 673,172 | copy one directory to another in php | <pre><code> <?php
extract($_REQUEST);
if(isset($_POST['submit']))
{
$get_folder = $_POST['url'];
$q = mysql_query("insert into test (url) values ('$url')");
if($q)
{
copydir("test",$get_folder);
function copydir($source,$destination)
{
if(!is_dir($destination))
{
$oldumask = umask(0);
mkdir($destination, 01777);
umask($oldumask);
}
$dir_handle = @opendir($source) or die("Unable to open");
while ($file = readdir($dir_handle))
{
if($file!="." && $file!=".." && !is_dir("$source/$file")) //if it is file
copy("$source/$file","$destination/$file");
if($file!="." && $file!=".." && is_dir("$source/$file")) //if it is folder
copydir("$source/$file","$destination/$file");
}
closedir($dir_handle);
}
}
}
?>
</code></pre>
<p>this is my code ...it shows Fatal <code>error: Call to undefined function copydir()</code> in <code>C:\xampp\htdocs\mywork\creating-folder\1.php</code> on line 14. But when i copy from <code>copydir("test",$get_folder);</code> to <code>closedir($dir_handle);</code> in separate file it works perfectly but instead of $get_folder need to give some static name</p>
| php | [2] |
5,622,008 | 5,622,009 | Widget Size for OpenPeak Open Tablet 7 | <p>The OpenTablet 7 Homescreen grid is a 5x5 on a 1024x600 resolution. If I am correct, would I design a homescreen widget to be 409.6x240 in landscape?</p>
| android | [4] |
20,437 | 20,438 | Passing objects and id as parameters in a function | <p>Working on some code and I'm running into an issue I don't know how to fix using javascript.</p>
<p>I have <code>days</code> that is a collection of objects that look like:</p>
<pre><code>day: 1
a: 10
b: 5
c: 9
d: 6
</code></pre>
<p>and so forth.</p>
<p>What I want to do is have a function that I can pass <code>days</code> and one of the id's for <code>a, b, c, d</code> and have it do 'something'. (By something, I'm not sure yet).</p>
<p>I'm just struggling to figure out how to pass the identifier.</p>
<pre><code>function returnAll(data, id){
for (var day in data){
console.log('On day' + day + ' , ' + id + ' has a value of ' data[day].id)
}
}
</code></pre>
<p>Which would ideally put something like this into the console:
On day 1 , a has a value of ...
On day 2, a has a value of ...</p>
<p>When <code>returnAll(days, a)</code> is called, I just can't get the id to link up properly inside of the function. I'll need to call this function for either a, b, c...The <code>days</code> can be dynamic so I need a function that operates just on the values of the <code>id</code> passed as the parameter.</p>
<p>Any thoughts?</p>
| javascript | [3] |
676,880 | 676,881 | how do you know if document is ready | <p>I have a JavaScript that generates HTML blocks. This script is sometimes called somewhere in run time, and sometimes before document is loaded. I want a script that is able to tell if document is ready. If so, generate the HTML, otherwise, add a document.ready() function. What is jQuery's best way to know if document has been loaded?</p>
| jquery | [5] |
564,517 | 564,518 | Is There any aspx editor for aditing aspx page | <p>i want to edit aspx page using aspx editor..I dont want edit to html.can i edit direct edit aspx page without editing html</p>
<p>please help me
Thanks in Advnance</p>
| asp.net | [9] |
555,764 | 555,765 | Frost Bite 2 example wanted | <p>I want to make my own Battlefield game, but I can not find any full sourcecodes on Battlefield 3. Can anyone tell me where to find it. I have been looking all over the web to find it.</p>
| java | [1] |
5,103,030 | 5,103,031 | Java StringTokenizer troubles - Newbie | <p>I know I'm probably being incredibly stupid here, but can anybody shed any light on my problem? I'm trying to extract the title from a string containing html...</p>
<pre><code> public static void main(String args[]) {
System.out.println(getTitle("<title>this is it</title>"));
}
public static String getTitle(String a) {
StringTokenizer token = new StringTokenizer(a, "<title>", false);
return token.nextToken("</title>");
}
</code></pre>
<p>Keeps returning "h" and I can't work out why! Am is being naive? </p>
<p>Cheers</p>
| java | [1] |
4,049,948 | 4,049,949 | Increase in number of requests form server cause website slow? | <p>In My office website,webpage has 3css files ,2 javascript files ,11images and 1page request total 17 requests from server, If 10000 people visit my office site ...
This may slow the website due to more requests??
And any issues to the server due to huge traffic ??</p>
<p>I remember My tiny office server has</p>
<p>Intel i3 Processor
Nvidia 2Gb Graphic card
Microsoft 2008 server
8 GB DDR3 Ram and
500GB Hard disk..</p>
<p>Website developed on Asp.Net</p>
<p>Net speed was 10mbps download and 2mbps upload.using static ip address.</p>
| asp.net | [9] |
5,390,728 | 5,390,729 | Is it possible to bind a gridview column onto a seperate datasource? | <p>First, start with two objects.</p>
<pre><code>Object
{
int id {get; set;}
string description {get; set;}
}
ObjectName
{
int id {get;set;}
string name {get;set;}
}
</code></pre>
<p>Let's say I have your average gridview:</p>
<pre><code>List<Object> = GetListOfObjects();
MyGridview.DataSource = List<Object>;
</code></pre>
<p>But I want one of the columns to come from the list of names, where the ids are the same.</p>
<p>Psuedocode:</p>
<pre><code>the ID column from MyGridview = List<ObjectNames>.Where(x=> x.id = myGridview.Id);
</code></pre>
<p>So basically, replacing the column of IDs with the column of names with those ids.
Is that possible to do? How would I approach this?</p>
| asp.net | [9] |
1,597,234 | 1,597,235 | formatting the date | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2009296/date-formatting-in-php">Date formatting in PHP</a> </p>
</blockquote>
<p>Inside my print_r function when ran shows $message->date_sent as this 2012-03-05 00:00:00</p>
<pre><code>echo '<td>'.date('F d, Y', $message->date_sent).'</td>';
</code></pre>
<p>Aparrently the date function is not what I'm wanting here because I just want to turn it into March 05, 2012. </p>
| php | [2] |
5,547,071 | 5,547,072 | should we move #include into namespace? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6670738/is-it-a-good-idea-to-wrap-an-include-in-a-namespace-block">Is it a good idea to wrap an #include in a namespace block?</a> </p>
</blockquote>
<pre><code>// Method One
#ifndef XXX_H
#define XXX_H
#include <iostream>
#include "myhead.h"
namespace XXX
{
/...
}
#endif
OR
// Method Two
namespace XXX
{
#ifndef XXX_H
#define XXX_H
#include <iostream>
#include "myhead.h"
/...
#endif
}
</code></pre>
<p>When we define a new <code>namespace XXX</code>, should we move <code>#include directive</code> inside namespace or not?</p>
<p>Thank you</p>
| c++ | [6] |
5,134,996 | 5,134,997 | Ternary Expression Possible? | <p>I'm not sure if the following statement is possible to write as one line (i.e. Ternary form).</p>
<pre><code>if (A == B)
FunctionA();
else
FunctionB();
</code></pre>
<p>Both FunctionA and FunctionB are type void.</p>
| c# | [0] |
3,849,291 | 3,849,292 | How do I put extra number at the end of username if duplicate | <p>Hard to explain, and let me show an example.</p>
<ol>
<li>If username <strong>foo</strong> already exists in MySQL I want php script will allow it but to be <strong>foo1</strong></li>
<li>Then if <strong>foo1</strong> exists too, script will generate the username will be <strong>foo2</strong></li>
<li>If <strong>foo2</strong> existed then become <strong>foo3</strong></li>
</ol>
<p>How to make like that?</p>
<p>Like <a href="http://stackoverflow.com/questions/4498886/how-do-i-put-extra-number-at-the-end-of-username-if-duplicate/4499014#4499014">Col. Shrapnel</a> said <em>Natural increment which seems more sensible. just like "New Folder(3)" stuff in Windows</em></p>
| php | [2] |
942,550 | 942,551 | Question about the .html() function of jQuery? | <p>Right now when I replace content inside the "foo" div, the new content appears right away. Is
there a way to have the new content fade in slowly. </p>
<pre><code><div class="foo">Initial content to be replaced</div>
$('div.foo').html('New content');
</code></pre>
<p>I know about the fadeIn() function, the reason why I ask this question is because I can't understand how it can be technically possible since the foo div was never hidden to begin with, so how will it be able to "fade in". But still in case someone can think of a way it would be most super.</p>
| jquery | [5] |
5,368,429 | 5,368,430 | Dynamic updation on gallery in android | <p>I want to upload the images in gallery view,when i supposed to do the following error is thrown.
<strong>Error:Observer is null</strong></p>
<blockquote>
<pre><code> public void uploadGallery()
{
</code></pre>
</blockquote>
<pre><code> gallery.setAdapter(new GalleryAdapter(this));
}
</code></pre>
<p>if i call this function ,when i click the button the error is thrown</p>
| android | [4] |
3,124,001 | 3,124,002 | Is inline HTML valid inside a PHP function? | <p>Is the following valid PHP?</p>
<pre><code><?php
function a($a) {
?>
<p><?=$a?></p>
<?php
}
?>
</code></pre>
<p>(I know this is not a good idea, just want to know if it's possible.)</p>
| php | [2] |
4,929,335 | 4,929,336 | How to get xy coordinate but not starts from window browser, instead starts from div? | <p>Aloha all!!</p>
<p>I have a problem here...Im using jquery here..n using visual studio 2008..I need to find the coordinate of an image after being drag n drop in a div.But what I had got is that the coordinate counts from out of div..I want it counts from inside the div.. </p>
<p>Please...anyone??</p>
<p>Here's my code:</p>
<pre><code> $('#dragThis').draggable({
cursor: 'move', // sets the cursor apperance
containment: '#dragThis2',
drag: function() {
var offset = $(this).offset();
var xPos = Math.abs(offset.left);
var yPos = Math.abs(offset.top);
$('#posX').text('x: ' + xPos);
$('#posY').text('y: ' + yPos);
},
stop: function(event, ui) {
// Show dropped position.
var Startpos = $("#dragThis").position();
var Stoppos = $(this).position();
$("#dragThis2").val((Stoppos.left - Startpos.left));
var left = Math.abs(Stoppos.left);
var top = Math.abs(Stoppos.top);
$('#posX').text('left: ' + left);
$('#posY').text('top: ' + top);
}
});
</code></pre>
| jquery | [5] |
254,219 | 254,220 | return function value from $.post callback | <p><strong>js:</strong></p>
<pre><code> function verificaExistPed(numped){
var valida;
jQuery.post("procedures/class_oc.php", // ajax post
{
cache : false,
checkYear : true,
numped : numped
},
function(data)
{
if(data === "s"){
valida = true;
}else{
valida = false;
}
}
)
return valida;
}
</code></pre>
<p>and, calling the function in another place, should return <code>valida</code> result inside variable <code>check</code>, in my case, <code>true</code> or <code>false</code>.</p>
<pre><code>var check = verificaExistPed('".$numped."');
alert(check); // always undifined
</code></pre>
<p>but, always undefined.</p>
<p>how can i set <code>valida</code> to <code>true</code> or <code>false</code> from a <code>$.post</code> callback ? </p>
| jquery | [5] |
1,926,077 | 1,926,078 | how to write regex for below format using python | <p>I want to validate below data using regex and python.<br>
Below is the dump of the data which Can be stored in string variable</p>
<pre>
Start 0 .......... group=..... name=...... number=.... end=(digits)
Start 1 .......... group=..... name=...... number=.... end=(digits)
Start 2 .......... group=..... name=...... number=.... end=(digits)
Start 3 .......... group=..... name=...... number=.... end=(digits)
Where ......is some random data need not to validate
...
..
Start 100 .......... group=..... name=...... number=.... end=(digits)
</pre>
<p>Thanks in advance</p>
| python | [7] |
1,737,556 | 1,737,557 | How should I set up configs in PHP that can be accessed in includes? | <p>I'm building a PHP application and I'm not quite sure how to store global configuration settings that can be truely accessed anywhere - it seems that content that <strong>is</strong> included cannot access other content included from the main, starting page. For example, if index.php includes foo.php and bar.php, bar.php don't have foo.php but index.php has both of them - the included files just can't refer to the other ones. Is this correct? </p>
<p>If yes, how would I set up something like this up? </p>
<p>index.php</p>
<pre><code><?php
include 'functions/load.php'
echo getHeader();
?>
</code></pre>
<p>functions/load.php:</p>
<pre><code><?php
include_once 'config.php'
include_once 'header.php'
//loads the includes
?>
</code></pre>
<p>functions/config.php:</p>
<pre><code><?php
//I want to store the site URL here.
$siteURL = "http://127.0.0.1";
?>
</code></pre>
<p>functions/header.php:</p>
<pre><code><?php
function getHeader(){
return "Header for " . $siteURL;
}
?>
</code></pre>
<p>How can I set up an config file that can be then accessed anywhere, including inside other included files? Also, is including a file that lists the other includes good practice?</p>
| php | [2] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.