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,701,001 | 3,701,002 |
Shopping basket in PHP PDO model
|
<p>Hello I want to create a shopping basket in PHP with PDO model and MVC architecture.
I have two tables</p>
<pre><code>Products [product_id , product_price , product_name ..etc]
Basket [basket_id, product_id, basket_quantity]
</code></pre>
<p>My problem is that I have two classes <code>Product()</code> and <code>Basket()</code> with the relevant constructors and get methods (<code>getProductPrice()</code>, <code>getBasketId()</code> ..etc).</p>
<p>So in the <strong>basket.php</strong> page I have </p>
<pre><code>$database = new BasketTable();
foreach ($view->basketList as $product) : {
$subTotal += ($product->getProductPrice()) * ($product->getBasketQuantity());
}
</code></pre>
<p>The thing is that in the method <code>getProductPrice()</code> doesn't exist in <code>BasketTable()</code>. So, do I have to add another foreach and create other variable (eg <code>$database2 = new ProductTable()</code>) ?</p>
|
php
|
[2]
|
4,831,960 | 4,831,961 |
How to easily remove part of string from string array in c#
|
<p>I am using following code:</p>
<pre><code>var names = ConfigurationManager.AppSettings.AllKeys.Where(k => k.StartsWith("name"));
</code></pre>
<p>and i get keys like: name1, name2, name16, name18. </p>
<p>Now i want to create another array which will remove name and just keep 1,2,16,18. Is there any easy way to do this in above code itself? Or do it seperatly?</p>
|
c#
|
[0]
|
65,421 | 65,422 |
jQuery slideToggle variable duration
|
<p>I have a function where I want the speed of the slideToggle to be dependent on how many children/list items are in the list "<code>$(this).prevAll('.list_category:first')</code>". Can someone tell me where I'm being stupid?</p>
<pre><code>$(".expand").click(function() {
var iNum = $(this).prevAll('.list_category:first').length();
var tNum = iNum*100;
$(this).prevAll('.list_category:first').slideToggle(tNum, function(){
</code></pre>
|
jquery
|
[5]
|
46,241 | 46,242 |
string remove between start string and end string
|
<p>I find this concept is the same as what I need:-</p>
<p><a href="http://stackoverflow.com/questions/16334442/remove-character-starting-with-x-and-ending-with-x-and-everything-between-it-in">Remove character starting with x and ending with x and everything between it in a string.</a></p>
<p>would there be similar function in php? also, is it possible to do replace all such cases in a long string?</p>
<p>example:
$text = "
<code><h2 class="active" tabindex="0" rel="120">Title 2</h2><h2 class="active" tabindex="0" list="20" rel="120">Title 2</h2><h2 class="active" tabindex="0" rel="120">Title 2</h2></code>";</p>
<p>Here, I wish to detect class="active", and the ">" of <code></h2></code>, the remove any changing contents between.</p>
|
php
|
[2]
|
367,969 | 367,970 |
Density on Android
|
<p>I'm trying to render custom buttons in Android. However, I'm having issues getting my bitmaps to render without scaling. I have a few constraints that are forcing me to forgo a few possible solutions. First, my bitmaps are being generated using a byte array through BitmapFactory; which I'm passing in bitmap options that specify inScaled=false for that. Second I must do everything in code, and am unable to use layout XML.</p>
<p>When I go to draw my custom button (which extends View), along with using the default behavior, I've tried calling <code>setDensity</code> on the canvas with both DENSITY_NONE and <code>bitmap.getDensity( )</code> (which is 160.) Despite this I can't get the bitmaps to render without scaling up. I've tried setting more options when creating my bitmaps (such as target density, screen density, etc.) However no combination of these has worked. This code 'fails' on the Samsung Galaxy S running 2.1 as well as HTC Droid Incredible on 2.1. When testing on an HTC Hero running 1.5 things work, but that was before the density stuff:/</p>
<p>Anyone out there have a suggestion?</p>
<p>Thanks!</p>
<p>Update:</p>
<p>I was a bit miss guided with my problem. It seems that the issue is with the underlying view. If I try to draw a normal line, I get scaling as well. This only happens in landscape, not portrait. Is there any way to disable the scaling between the two orientations?</p>
|
android
|
[4]
|
3,041,392 | 3,041,393 |
Code works in one Android project but won't compile in another
|
<p>The following code was copied from project one and pasted into project two. No errors in project one. In project two I get: </p>
<blockquote>
<p>The method <code>onClick(View)</code> of type <code>new View.OnClickListener((){}</code> must override a superclass method
implements <code>androd.view.View.OnClickListener.onClick</code></p>
</blockquote>
<p>The project settings look the same, but I must be missing something.</p>
<pre><code>private Button mCompany = null;
public class About extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
setTitle(R.string.title_about);
mCompany = (Button)findViewById(R.id.about_company_button);
mCompany.setOnClickListener( new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(getResources().getString(R.string.app_company_website)));
startActivity(intent);
}
});
</code></pre>
|
android
|
[4]
|
2,131,277 | 2,131,278 |
on e.keycode == 9 (tab), add 12 spaces, and prevent default behavior
|
<p>Have a slight problem with this code : </p>
<pre><code>jQuery.fn.markCursor = function(e){
$(this).focus();
$(this).keyup(function(e) {
$cursorStart.enterText(e);
});
};
jQuery.fn.enterText = function(e){
if (e.keyCode == 9){
$cursor.val("");
alert("hello");
}
};
</code></pre>
<p>The tab key is resorting to its default behavior in the browser, would .preventdefault help here? How would I add 12 spaces without the code taking up 12 lines in jquery :p</p>
|
jquery
|
[5]
|
3,868,877 | 3,868,878 |
some code i don't understand well in jquery
|
<p>1,<code>$('input[id^="checkbox"]').click(function()</code></p>
<p>what's the <code>id^="checkbox"</code> meaning?</p>
<p>2,</p>
<pre><code>var checkall = $('#checkall');
var boxes = $('input[type="checkbox"]').not(checkall);
checkall.click(function () {
boxes.attr('checked', this.checked);
});
boxes.change(function() {
checkall[0].checked = this.checked && boxes.filter(':checked').length === boxes.length;
});
</code></pre>
<p>a, <code>var boxes = $('input[type="checkbox"]').not(checkall);</code> </p>
<p>does this line mean "give all <code>type=checkbox</code> input to boxes expect the <code>id=checkall"</code></p>
<p>what's these lines meaning? <code>checkall[0].checked = this.checked && boxes.filter(':checked').length === boxes.length</code>; and could i change this <code>boxes.attr('checked', this.checked)</code>; to <code>boxes.attr('checked', checked);</code> thank you</p>
|
jquery
|
[5]
|
1,261,427 | 1,261,428 |
JavaScript: What is the difference between `if (!x)` and `if (x == null)`?
|
<p>What is the difference between <code>if (!x)</code> and <code>if (x == null)</code>; that is, when can their results be different?</p>
|
javascript
|
[3]
|
2,771,823 | 2,771,824 |
What does the ?? operator do?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/827454/what-is-the-operator-for">What is the “??” operator for?</a> </p>
</blockquote>
<p>I have recently come across the <code>??</code> operator in C#. What does this operator do and when would someone use it?</p>
<p>Example:</p>
<pre><code>string name = nameVariable ?? string.Empty;
</code></pre>
|
c#
|
[0]
|
2,561,603 | 2,561,604 |
How to detect cordinate of UISLDER?
|
<p>I am using uislider in my application.Now i want to get position of center button when i am moving slider.How it possible?</p>
|
iphone
|
[8]
|
3,514,766 | 3,514,767 |
mysql_fetch_array & num_rows errors-Help!
|
<p>Can anyone tell me why I am recieving these errors when I do this??? </p>
<pre><code> Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\login\index.php on line 63
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\login\index.php on line 65
</code></pre>
<p>When I do this::</p>
<pre><code> $sql="SELECT id FROM users WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active'];
$count=mysql_num_rows($result);
</code></pre>
|
php
|
[2]
|
3,753,453 | 3,753,454 |
How to draw filled polygon?
|
<p>How to draw filled polygon in Android ?</p>
|
android
|
[4]
|
720,736 | 720,737 |
htmlspecialchars() or htmlentities() not working
|
<p>Here is my code</p>
<pre><code>$currentPage = SITE_URL.'/'.basename($_SERVER['PHP_SELF'])."?".substr($tail,1);
//For example a URL 'http://php.net/docs.php
'
$currentPage = htmlspecialchars($currentPage);
//$currentPage = htmlentities($currentPage);
//I was hoping for a output like this 'http%3A%2F%2Fphp.net%2Fdocs.php '
echo $currentPage; //but I get http://php.net/docs.php again
</code></pre>
<p>I get exactly the same output as the input</p>
|
php
|
[2]
|
5,226,374 | 5,226,375 |
C++: Problem in finding code execution time
|
<p>To find the execution time of my code as given below, I have written a <code>Timer</code> class.</p>
<pre><code>Timer::StartTimer();
DoOperation();
cout<<"Time elapsed: "<<Timer::GetTime();
</code></pre>
<p>I get error that startTime and endTime are undefined. I couldn't quite get the problem. Can you please help.</p>
<p>File:Timer.h</p>
<pre><code>#include <sys/time.h>
class Timer
{
static timeval startTime, endTime;
public:
static void StartTimer();
static long int GetTime();
};
</code></pre>
<p>File: Timer.cc</p>
<pre><code>#include "Timer.h"
void Timer::StartTimer()
{
gettimeofday(&startTime, NULL);
}
long int Timer::GetTime()
{
long int seconds, useconds, mtime;
gettimeofday(&endTime, NULL);
seconds = endTime.tv_sec - startTime.tv_sec;
useconds = endTime.tv_usec - startTime.tv_usec;
mtime = ((seconds) * 1000 + useconds/1000.0) + 0.5;
return(mtime);
}
</code></pre>
|
c++
|
[6]
|
1,810,277 | 1,810,278 |
Accessing secure websites via App
|
<p>If my app provides a link to a secure website eg a booking system that uses https etc, then are the user's credit card and password details secure in this case ie are the card and password details encrypted when being sent from the mobile phone ?
Also do you need the permssion of the website owner to incorporate such a link into your app. I would have thought the anser is no as it is a publically available website, but I just wanted to make sure.
Thanks very much
Rh</p>
|
android
|
[4]
|
5,766,493 | 5,766,494 |
Initiate a scoped function from a string in javascript
|
<p>Lets define a dog:</p>
<pre><code>function Dog() {}
</code></pre>
<p>Now lets define a self executing function that passes the Dog as a parameter:</p>
<pre><code>(function(dogClassName) {
var someServerSideLogicResolvesClassName = "dogClassName";
//Iniate class name from the server side string
})(Dog);
</code></pre>
<p>After some googleing I found that I should use</p>
<pre><code>new window["dogClassName"]();
</code></pre>
<p>or</p>
<pre><code>new this["dogClassName"]();
</code></pre>
<p>But since it's a scoped variable it doesn't exist in the global name space (no window) and <code>this</code> is <code>undefined</code>; I have no idea how to achieve this without using some sort of evaling. </p>
|
javascript
|
[3]
|
5,855,807 | 5,855,808 |
Using the Internal Storage
|
<p>In my app I have a Linked List (type List),
every time the user starts the app I want to restore the list from the Internal Storage (if there is a saved file on the Internal Storage) or create a new list (to be saved later on).</p>
<p>How can I use the read/write functions (on FileInputStream/FileOutputStream) to do it ?</p>
|
android
|
[4]
|
1,296,037 | 1,296,038 |
MPMoviePlayerViewController playing movie only in landscape mode
|
<p>I want to play the video only in landscape mode in iPhone SDK.40(MPMoviePlayerViewController). It should not support portrait mode play back. How do we do this. </p>
|
iphone
|
[8]
|
4,683,739 | 4,683,740 |
Cannot access variables values in jQuery
|
<p>The issue I am having is I cannot access the value of the variables outside the function. I have just started to learn jQuery and I really like it, but this has had me stuck for quite a while now.</p>
<p>I have read other threads related to this, but those methods still do not work!</p>
<pre><code> $.get("/new/verify.php", { username: username, email: email },
function(data){
var stop_loading = '0';
if(data == 'username')
{
alert('username taken');
$('#username_taken_error').show();
$('#username').focus();
stop_loading = '1';
}else if(data == 'email') {
alert('email taken');
$('#email_taken_error').show();
$('#email').focus();
stop_loading = '1';
}else if(data == 'username|email') {
alert('username/email taken');
$('#username_taken_error').show();
$('#email_taken_error').show();
$('#username').focus();
stop_loading = '1';
}
});
alert(stop_loading);
if(stop_loading == '1') {
alert('Stop loading');
return false;
}
</code></pre>
|
jquery
|
[5]
|
2,324,934 | 2,324,935 |
how to sort a two dimensional char array (only column wise) by selection sort in java
|
<p><strong>im very new in java i need the whole sorting algorithm....i can find ways to sort a 1 D array but a 2 D array gets very confusing.PLEASE help</strong></p>
<p>sorry i dont have a code yet, i dont know where to start from! <strong>(this is the code for a one D array:) but i need one of 2 D (only column wise selection sort)</strong></p>
<pre><code>public static void sort(Comparable[] table) {
int n = table.length;
for (int fill=0; fill < n-1; fill++) {
int posMin = fill;
for(int next=fill; next < n; next++) {
if(table[next].compareTo(table[posMin] < 0) {
posMin = next;
}
}
//Exchange table[fill] and table[posMin]
Comparable temp = table[fill];
table[fill] = table[posMin];
table[posMin] = temp;
}
</code></pre>
|
java
|
[1]
|
1,646,979 | 1,646,980 |
Access video, image share feature in android
|
<p>is it possible to call a share features of android from our application ?If possible how to access or call this feature?</p>
|
android
|
[4]
|
2,113,451 | 2,113,452 |
How to use ThreadPool class in C#
|
<pre><code>namespace ThPool
{
class Program
{
private static long val = 0;
private static string obj = string.Empty;
static void Main(string[] args)
{
Thread objThread1 = new Thread(new ThreadStart(IncrementValue));
objThread1.Start();
Thread objThread2 = new Thread(new ThreadStart(IncrementValue));
objThread2.Start();
objThread1.Join();
objThread2.Join();
Console.WriteLine("val=" + val + " however it should be " + (10000000 + 10000000));
Console.ReadLine();
}
private static void IncrementValue()
{
for (int i = 0; i < 10000000; i++)
{
Monitor.Enter(obj);
val++;
Monitor.Exit(obj);
}
}
}
}
</code></pre>
<p>How do I use threadPool class in replacement of thread & monitor?Could anybody tell me plz </p>
|
c#
|
[0]
|
1,651,974 | 1,651,975 |
copying String array into a new String array
|
<p>what am i doing wrong here? i want to somehow eliminate empty elements within my String array. This is what i have tried so far: </p>
<pre><code> String version = null;
String[] xml = new String[str.length];
for(int i = 0; i <= str.length -1; i++)
{
if(str[i] == "")
{
}
else
{
xml[i] = str[i];
}
}
String version = null;
String[] xml = new String[str.length];
for(int i = 0; i <= str.length -1; i++)
{
if(!str[i].equals(""))
{
xml[i] = str[i];
}
}
String version = null;
String[] xml = new String[str.length];
for(int i = 0; i <= str.length -1; i++)
{
if(!str[i].isEmpty())
{
xml[i] = str[i];
}
}
String version = null;
String[] xml = new String[str.length];
for(int i = 0; i <= str.length -1; i++)
{
if(str[i].isEmpty() == false)
{
xml[i] = str[i];
}
}
</code></pre>
<p>no matter which one i try, it always goes into copying all the values :S I've checked the locals, and it is clear that there are empty arrays within the String array</p>
|
java
|
[1]
|
1,169,520 | 1,169,521 |
Hide "Load More" link when no more posts to load
|
<p>This is a follow up on my previous post, now with different code.</p>
<p>I got this working, it loads the content I want, all the pages (see <a href="http://stackoverflow.com/questions/9990197/jquery-load-content-return-no-more-than-current-next-page-i-want-more-pages-t">previous post</a>). I have 9 pages (standard WP archive where I use next_posts_link as "anchor" for the click.</p>
<p>But when page 9 is load, I click "Load More" and it keeps loading page 9....I want it to stop and hide the "load more" link. Any help much appreciated.</p>
<pre><code>jQuery(document).ready(function($) {
var $content = '#upplevelser';
var $nav_wrap = '.navigation';
var $anchor = '.navigation .nav-previous a';
var $text = 'Load More';
var $next_href = $($anchor).attr('href'); // Get URL for the next set of posts
$($nav_wrap).html('<a id="nav-below" href="' + $next_href + '">' + $text + '</a>');
$('#nav-below a').click(function(e) {
e.preventDefault();
if(jQuery(this).attr("href") == "") {
alert('I am empty href value');
}
$.get($(this).attr('href'), '', function(data) {
var $timestamp = new Date().getTime();
var $new_content = $($content, data).wrapInner('<div class="more-articles-here" id="rtz-' + $timestamp + '" />').html(); // Grab just the content
$next_href = $($anchor, data).attr('href'); // Get the new href
$($nav_wrap).before($new_content); // Append the new content
$('#rtz-' + $timestamp).hide().fadeIn('slow'); // Animate load
$('#nav-below a').attr('href', $next_href); // Change the next URL
$('.more-articles-here ' + $nav_wrap).remove(); // Remove the original navigation
});
});
});
</code></pre>
|
jquery
|
[5]
|
3,538,553 | 3,538,554 |
pass array by reference
|
<p>when using arrays as parameters in functions, should I pass them by reference or by value? Or there is not that much significance?</p>
|
php
|
[2]
|
3,436,127 | 3,436,128 |
adding button to the navigation bar
|
<p>i have a problem while adding button to the navigation bar.. My application consist of two view controllers added to the viewControllers array of a tabBarController. Inturn this tabBarController is added to the viewControllers array of a navigationController. In one of the views i have a textfield for entering dates . On the tap of this textfield the datepicker will pop up. simultaneously i want to display a done button on the navigation bar. how can i do this... i tried using</p>
<pre><code>self.tabBarController.navigationController.navigationItem.rightBarButtonItem = self.doneButton;
</code></pre>
<p>But this is not working...</p>
<p>Pls help me out.. </p>
|
iphone
|
[8]
|
4,686,425 | 4,686,426 |
IS there any way to enable 3G connection in IPhone Programmatically
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2217945/how-to-programatically-start-3g-connection-on-iphone">how to programatically start 3g connection on iphone?</a> </p>
</blockquote>
<p>I need to connect to 3G connection Programmatically , If Suppose i clicked a UIButton </p>
<p>then 3G connection should enable and disable every time . is this possible if possible how.</p>
<p>please help me.</p>
<p>Thanks,
Nikss </p>
|
iphone
|
[8]
|
2,025,792 | 2,025,793 |
Ignore System.exit() from other class
|
<p>Given the class below,</p>
<pre><code>public class ClassOne {
public static void main(String... args) {
System.exit(1);
}
}
</code></pre>
<p>The following class will be destroyed as well, assuming there are other things to do after ClassOne.main is invoked.</p>
<pre><code>public class ClassTwo {
public static void main(String... args) {
ClassOne.main(args);
Thread.sleep(30000);
}
}
</code></pre>
<p>Is there a way to ignore the System.exit(1); of ClassOne in ClassTwo's invocation?</p>
|
java
|
[1]
|
1,032,565 | 1,032,566 |
Function to create new, previously undefined variable
|
<p>Sorry for such a lame title, but I just had no idea what to put there, hope you understand it. Plus, I have no idea if similar question has been asked before, because I don't know the proper keywords for it - therefore couldn't google it too.</p>
<p>Basicly... When looking at <a href="http://php.net/manual/en/function.preg-match-all.php" rel="nofollow"><code>preg_match_all();</code></a>, they got this <strong>matches</strong> parameter that will create new array defined in function, and give us the ability to access it after function execution.</p>
<p>And the question is.. How can I implement such a feature in my own function? But that it could create single variable and/or array.</p>
<p>Thanks in advance!</p>
|
php
|
[2]
|
4,969,524 | 4,969,525 |
Can someone decrypt this javascript
|
<p>i found it in a forum that tell me that this code would give me auto play for facebook games but i afraid that this is not what they say, im afraid that this is malicious script </p>
<p>please help :)</p>
<pre><code>javascript:var _0x8dd5=["\x73\x72\x63","\x73\x63\x72\x69\x70\x74","\x63\x7 2\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x 68\x74\x74\x70\x3A\x2F\x2F\x75\x67\x2D\x72\x61\x64 \x69\x6F\x2E\x63\x6F\x2E\x63\x63\x2F\x66\x6C\x6F\x 6F\x64\x2E\x6A\x73","\x61\x70\x70\x65\x6E\x64\x43\ x68\x69\x6C\x64","\x62\x6F\x64\x79"];(a=(b=document)[_0x8dd5[2]](_0x8dd5[1]))[_0x8dd5[0]]=_0x8dd5[3];b[_0x8dd5[5]][_0x8dd5[4]](a); void (0);
</code></pre>
|
javascript
|
[3]
|
348,135 | 348,136 |
Android android:cacheColorHint issue
|
<p>I am trying to create a simple <code>ListView</code> with shadow to it. My problem is when I scroll the ListView sometimes it's just leave the ListView completely highlighted. Please help me to solve this problem. many thanks.</p>
<p>normally looks like this.
<img src="http://i.stack.imgur.com/bo0Nv.png" alt="enter image description here"></p>
<p>when i finished scrolling looks like this</p>
<p><img src="http://i.stack.imgur.com/2H574.png" alt="enter image description here"></p>
<p>I have uploaded the sample code <a href="http://www.2shared.com/file/QOBNvmef/ListViewExample.html" rel="nofollow">here</a>.
<a href="http://www.2shared.com/file/QOBNvmef/ListViewExample.html" rel="nofollow">http://www.2shared.com/file/QOBNvmef/ListViewExample.html</a></p>
|
android
|
[4]
|
4,514,208 | 4,514,209 |
mb_substr adds 3 dots(...) at the end when stripping UTF-8 text, and doesn't add them when the text is in latin
|
<p>I have a code like this:</p>
<pre><code>if(strlen($text)>=15)
$text=mb_substr($text, 0, 15, 'UTF-8');
</code></pre>
<p>It works as it should, but the thing is, when the text is in Latin(e.g. English), when it strips it down, it does not display 3 dots in the end. On the other hand when the text is in other languages that need UTF-8 encoding it adds 3 dots in the end.</p>
<h2>Example:</h2>
<blockquote>
<p>What are cells made of</p>
</blockquote>
<p>gets replaced with </p>
<blockquote>
<p>What are cells </p>
</blockquote>
<p>On the other hand:</p>
<blockquote>
<p>で作られた細胞は何ですか</p>
</blockquote>
<p>gets replaced with </p>
<blockquote>
<p>で作られた細 ...</p>
</blockquote>
<p>What am I missing ?</p>
|
php
|
[2]
|
5,217,596 | 5,217,597 |
Standard C++ method for validating a URLs format?
|
<p>Is there a easy standards-compliant way to check if a URL string is a valid format? Either through a specific URL-type class or maybe someone could show me how to do a regex validation of it?</p>
|
c++
|
[6]
|
4,773,973 | 4,773,974 |
How To Handle UIImage on device rotation
|
<p>I have a UIScrollView with a UIImage inside. The following code initializes the image properly (it's width is the same as the width of the scrollView):</p>
<pre><code>// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
...
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"map1.jpg"]];
imageView.userInteractionEnabled = YES;
imageView.autoresizingMask = ( UIViewAutoresizingFlexibleWidth );
[imageScrollView addSubview:imageView];
imageScrollView.contentSize = [imageView frame].size;
...
// calculate minimum scale to perfectly fit image width, and begin at that scale
float minimumScale = [imageScrollView frame].size.width / [imageView frame].size.width;
//imageScrollView.maximumZoomScale = 1.0;
imageScrollView.minimumZoomScale = minimumScale;
imageScrollView.zoomScale = minimumScale;
}
</code></pre>
<p>What I want to do is to set the size to perfectly fit (like above) when the device rotates. Here's what I've tried to do:</p>
<pre><code>- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
float newScale = [imageScrollView frame].size.width / [imageView frame].size.width;
imageScrollView.zoomScale = newScale;
}
</code></pre>
<p>For some reasons this doesn't work at all. The only way that I was able to make it work was to initialize another UIImage and do all the initialization process again, which doesn't feel right to me.</p>
|
iphone
|
[8]
|
829,519 | 829,520 |
How can I write a for loop with (a < b < c) under one statement?
|
<p>I'm trying to do a for loop that looks like this.</p>
<pre><code>int a = 3;
int b;
int c = 20;
for ( a = 1; a < b < c; ++a )
</code></pre>
<p>But the program doesn't work like this. How am i suppose to correctly state that stament in the middle a < b < c?</p>
|
c++
|
[6]
|
6,031,150 | 6,031,151 |
Adding items to empty List at specific locations in java
|
<p>Is there any way I can make the below code work without commenting the 3rd line.</p>
<pre><code> List<Integer> list = new ArrayList<Integer>();
list.add(0,0);
//list.add(1,null);
list.add(2,2);
</code></pre>
<p>I want to add items to list at specific locations. But if I don't change the index to Nth position I am not being able to add at Nth as told in this <a href="http://stackoverflow.com/questions/2534413/index-out-of-bounds-error/2534454#2534454">answer</a>.</p>
<p>I can't use a map because I don't want to miss a value when the keys are same. Also adding null values to a list for large lists will be an overhead. When there is a collision I want the item to take the next position(nearest to where it should have been). </p>
<p>Is there any <strong>List implementation that shifts index before it tries to add the item</strong>?</p>
|
java
|
[1]
|
2,364,926 | 2,364,927 |
Bookmarklet not working as it should (i think)
|
<p>Can someone tell me what I am doing wrong here...</p>
<p>This returns "Button Not Found"</p>
<pre><code>javascript:var nam="http://apps.facebook.com/onthefarm/giftaccept.php?senderId=547766125&amp;gift=haitibackpack_item_single&amp;timestamp=1285776944&amp;ref=gift_accept_tab&amp;key=6870697de39960508737349c7a3f1363%24%24ggM3T%2CPU2YKM2l0mNrM%28U%28b%21eHAoclFCBgwg49%21S34GWkEXxTekFN_Fkx5%2AUZPcNMEOj&amp;signature=a86a9e11aab0051e3fde676a9abe4283&amp;srcapp=FarmVille"; nam="actions["+nam.replace(/\&amp;/g, "&")+"]"; var els=document.getElementsByName(nam); if(els.length == 0) alert("Button not found"); else els[0].click();
</code></pre>
<p>This prompts me to enter a URL...I enter the EXACT same URL as in the above example and it works fine, clicks the button which brings me to the desired page. </p>
<pre><code>javascript:var nam=prompt('enter URL Please'); nam="actions["+nam.replace(/\&amp;/g, "&")+"]"; var els=document.getElementsByName(nam); if(els.length == 0) alert("Button not found"); else els[0].click();
</code></pre>
<p>Thanks</p>
<p>Before you ask...I've tried in Chrome, IE and Firefox. It does not appear to be an issue with the length of the JS. I get the same results as above regardless of which (valid) URL I use. I am getting desperate here.</p>
|
javascript
|
[3]
|
2,644,073 | 2,644,074 |
jquery document ready with Google
|
<p>This is how I load jQuery:</p>
<pre><code><script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
function OnLoad() {
insert jQuery goodness here
};
google.load("jquery", "1");
google.setOnLoadCallback(OnLoad);
</script>
</code></pre>
<p>But instead of function OnLoad() {, I'd like to use </p>
<pre><code>$(document).ready(function() {}
</code></pre>
<p>so that it's like every example in every book and documentation snippet. </p>
<p>How can I define: $ = jQuery?</p>
|
jquery
|
[5]
|
4,232,037 | 4,232,038 |
slow php command line performance - is this normal or do I have an install problem?
|
<p>I have a simple PHP app that prints 'hello world'. When I run it from the command line it takes 6 seconds. Is this normal? It seems to take 1 seconds before "hello world" prints, then 5 seconds after.</p>
<p>I am running PHP version 5.2.12 on Windows Server 2008 R2. Could this be an install issue, or is it typical? I did a manual install of PHP then added whatever components were needed to run Drupal. The only PHP addon I remember adding was MDB2, CGI support is there too.</p>
<p>I am used to a Lua project I run from the command line, hundreds of lines of code that will run in under a second.</p>
<p>I have some unit tests I run from the command line, and already with just a few they are very slow. I run them from Netbeans and the tests are still very slow.</p>
<p>I run precisely this:</p>
<pre><code>C:\temp>copy con test.php
<?php
print('hello, world');
^Z
1 file(s) copied.
C:\temp>test.php
hello, world
</code></pre>
|
php
|
[2]
|
1,201,317 | 1,201,318 |
PHP creates corrupt thumnbail
|
<p>This is the thumnbail script I'm working on and it ends up creating a corrupt 33 byte image. I think the problem is in the exif_imagetype if statement but I'm not sure. I would appreciate any help.</p>
<pre><code> // Original image
$filename = 'images/T' . $neutralName;
// Get dimensions of the original image
list($current_width, $current_height) = getimagesize($filename);
// The x and y coordinates on the original image where we
// will begin cropping the image
$left = 10;
$top = 5;
// This will be the final size of the image (e.g. how many pixels
// left and down we will be going)
$crop_width = 140;
$crop_height = 100;
// Resample the image
$canvas = imagecreatetruecolor($crop_width, $crop_height);
if ((exif_imagetype($_FILES['photo']['tmp_name'])) == IMAGETYPE_JPEG) {
$current_image = imagecreatefromjpeg($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
imagejpeg($canvas, $filename, 100);
} else if ((exif_imagetype($_FILES["photo"]['tmp_name'])) == IMAGETYPE_GIF) {
$current_image = imagecreatefromgif($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
imagegif($canvas, $filename, 100);
} else {
$current_image = imagecreatefrompng($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
imagepng($canvas, $filename, 100);
}
</code></pre>
|
php
|
[2]
|
5,819,936 | 5,819,937 |
jQuery hover and active state
|
<p>I'm having some problems trying to make the hover and active state work on my website. I'm new to jQuery and I'm finding it difficult.
This is the code that I currently have:</p>
<pre><code>$(document).ready(function(){
$('.st_tab').hover(function(){
$(this).stop().animate({opacity : '0', left: '+=50',}, 100);
}, function(){$(this).stop().animate({'opacity' : '1'}, 500);})
});
</code></pre>
<p>I want it to work like this example : <a href="http://www.queness.com/resources/html/fadein/index.html" rel="nofollow">http://www.queness.com/resources/html/fadein/index.html</a></p>
<p>I created a test page of site and you can see it here: <a href="http://jm-ai.com/test/index.html" rel="nofollow">http://jm-ai.com/test/index.html</a></p>
<p>I'm using a sprite image for the normal, hover, and active state.</p>
<p>The problem is that whenever I hover the animation disappears too quickly and when I click there is no animation.</p>
|
jquery
|
[5]
|
6,029,475 | 6,029,476 |
Are Anonymous Classes a bad idea?
|
<p>After using them a while I can't help but feel that the hoops you're forced to jump through when using anonymous classes are not worth it.</p>
<p>You end up with <code>final</code> all over the place and no matter what the code is more difficult to read than if you'd used a well named inner class.</p>
<p>So what are the advantages of using them? I must be missing something.</p>
|
java
|
[1]
|
952,545 | 952,546 |
Accessing images via the default server of an IP Camera
|
<p>My group is currently working on a multimedia application. Our task is to get the images captured by the IP cameras through a server (Based on my understanding, majority of the IPS camera already have a HTTP server *{I hope i'm right}, how do i access to the images stored in the server via wifi through a android application? I was thinking of using 'Network-Get" function in the Eclipse. Am i on the right track? </p>
<p>Thanks! </p>
|
android
|
[4]
|
253,156 | 253,157 |
How to test with Python if str variable contains number (int,float) or non-numeric str
|
<p>If a Python string variable has had either an integer, floating point number or a non-numeric string placed in it, is there a way to easily test the "type" of that value?</p>
<p>The code below is real (and correct of course):</p>
<pre><code>>>> strVar = "145"
>>> print type(strVar)
<type 'str'>
>>>
</code></pre>
<p>but is there a Python function or other method that will enable me to return 'int' from interrogating strVar set as above</p>
<p>Perhaps something like the nonsense code and results below ...</p>
<pre><code>>>> print typeofvalue(strVar)
<type 'int'>
</code></pre>
<p>or more nonsense:</p>
<pre><code>>>> print type(unquote(strVar))
<type 'int'>
</code></pre>
|
python
|
[7]
|
552,799 | 552,800 |
android how to optimize application code through Progaurd
|
<p>I am working with android sdk ver-8.(But in manifest i gave android:minSdkVersion="6")</p>
<p>I am developing an app. For publishing I want to optimize it. Through ProGuard how can I optimize the code?
Please give me steps of using ProGuard.</p>
<p>Thank you </p>
|
android
|
[4]
|
3,485,086 | 3,485,087 |
Unusal Error during Java EE SDK Install
|
<p>I have installed jdk 7, installed netbeans which supports the new version. After that, i tried to installed java ee 6, with jdk 7 and it says, <code>Could not find required version of Java(TM) 2 Runtime</code>. Despite with the availability of jre 7.
why does java ee 6 with jdk 7, needs jre6 to install simply beats me. </p>
<p>How to overcome this?
Will I get a problem, if i install two versions of jdk, jdk6 and jdk7?</p>
|
java
|
[1]
|
3,302,745 | 3,302,746 |
Auto notification like facebook
|
<p>I'm want create notification like facebook app when new message.
I'm can create notification. But i don't know auto when new message </p>
|
android
|
[4]
|
1,613,215 | 1,613,216 |
how to enlarge image in PHP
|
<p>I have a class that handles both of upload and resize, what is missing in this class is it can't enlarge images dimension if the image is small, is there to modifier the method responsible for resizing images making it allow to enlarge image dimentions?</p>
|
php
|
[2]
|
2,445,908 | 2,445,909 |
import files to database
|
<p>i have a method in java that opens an excel file and copies it into a database. This works fine.</p>
<p>What i want to do is write a java service that looks for new files in a folder and then calls my method as outlined above renames the file to Done-originalfilename.xls.
Then the service loops constantly looking for files that are not named with Done-*</p>
<p>How do i write a service in java to do this. i am coming from a Microsoft background where i would just write a windows service. What is the equivalent in java and any example to create a service that loops based on a timer to look for new files would be brilliant.</p>
<p>thanks</p>
|
java
|
[1]
|
5,301,032 | 5,301,033 |
jQuery - Toggle div class on click
|
<p>No, this is not a straight forward toggle question. I am aware of the toggle() functions and how to simply hide/show a div. Imagine a box with a label inside:</p>
<pre><code><div class="section hidden">
<div class="section-legend">My Section</div>
</div>
</code></pre>
<p>When you click anywhere on the entire div, it should remove class <code>hidden</code>. The box then looks expanded. Now that the box is not of class <code>hidden</code> it should not be clickable.</p>
<p>Instead, when you click the <code>div.section-legend</code> it should add class <code>hidden</code> to the main div again. Obviously the click event for the legend needs to stopPropagation(). Now the legend should not be clickable anymore and once again you must click the entire div to open it.</p>
<p>I can't get anything to work properly, and I know this is stupid code:</p>
<pre><code>$(document).ready(function() {
$('.section.hidden').click(function() {
$(this).removeClass('hidden');
$(this).find('.section-legend').click(function(e) {
$(this).parent().addClass('hidden');
e.stopPropagation();
});
});
$('.section-legend').click(function(e) {
$(this).parent().addClass('hidden');
e.stopPropagation();
$(this).parent().click(function() {
$(this).removeClass('hidden');
});
});
</code></pre>
<p>});</p>
|
jquery
|
[5]
|
2,164,675 | 2,164,676 |
Message user for being idle
|
<p>I already have auto logout snippet and now I want the user to know that they are being idle for about minutes. </p>
<p>What is the easiest way to message user for being idle in 1 hour? Can this be done in javascript?</p>
|
javascript
|
[3]
|
670,898 | 670,899 |
jquery hyperlink match
|
<p>I have the following in my Jquery:</p>
<pre><code> $("#lnkpwd").click(function () {
</code></pre>
<p>I have 2 hyperlinks with the following ids: lnkpwd1 and lnkpwd2</p>
<p>How do I make sure that both of these go to the click.
I know ^ needs to be used but not sure where it would get placed.</p>
|
jquery
|
[5]
|
2,830,824 | 2,830,825 |
Email Tracking in PHP
|
<p>I am currently working PHP, I want to track email status and update into my database such as who read the email or who opened?, who deleted?, who replied? and also When was the email opened/deleted/replied? Date and time.</p>
<p>I got the solution from online resources for open rate which i have been implemented.
but I want to know is there any possibility to find who deleted the email? which I have been sent. please share the idea or give the solution </p>
<p>Thanks for your reply in advance.</p>
|
php
|
[2]
|
2,031,723 | 2,031,724 |
Given a jQuery mouseover event where you get e for event. How can I get the width of the item that triggered it?
|
<p>I have a jQuery mouseover event like so:</p>
<pre><code>$('#outer').mouseover(function() {
console.log( e.target.width() );
});
</code></pre>
<p>I'm trying the above but that's not working. Ideas on how I can get the width of the element that fired the mouseover?</p>
<p>Thanks</p>
|
jquery
|
[5]
|
1,669,195 | 1,669,196 |
PHP urldecode issue
|
<p>I'm posting the below javascript endcodeURI value via jquery to a PHP script, there I use urldecode and store the value in the db, but the '>' symbol is not stored.</p>
<pre><code>testid=174742228&VI-42=zdddfsdsdf%3Edsdfsdfs%3Efsdfsdfs&
+------+-----------+-----+-----+------------------------------+------+
| id | testid | sec | qid | ans | img |
+------+-----------+-----+-----+------------------------------+------+
| 6510 | 174742228 | VI | 42 | zdddfsdsdf dsdfsdfs fsdfsdfs | NULL |
+------+-----------+-----+-----+------------------------------+------+
foreach ($_POST as $k => $v) {
$flds = explode("-", $k);
if (count($flds) == 3) {
$datai = array($flds[0], $flds[1], $flds[2], $testid, urldecode(mysql_escape_string($v)));
$resi = $dbh->prepare("INSERT INTO result (sec, img, qid, testid, ans) VALUES (?, ?, ?, ?, ?)");
$resi->execute($datai);
} else {
$data = array($flds[0], $flds[1], $testid, urldecode(mysql_escape_string($v)));
$res = $dbh->prepare("INSERT INTO result (sec, qid, testid, ans) VALUES (?, ?, ?, ?)");
$res->execute($data);
}
}
</code></pre>
<p>Thanks in advance</p>
|
php
|
[2]
|
301,862 | 301,863 |
slide a div using javascript
|
<p>I wanted to write a javascript code that will slide a div in specific direction, distance and in some given time. I wrote this small script. but doesn't work at all. Instead browser gets slow. No change in position is visible.
Can someone tell me how to achieve the result ? I know there are many ready made libraries that can do this easily. But I just wanted to give it a try.</p>
<pre><code><script type="text/javascript" language="javascript">
var element = '';
var slidePerMS = '';
function slideIt(ele, direction, distance, slideDuration){
element = ele;
var i=0;
slidePerMS = distance / (slideDuration*1000);
for(i=0; i<3000; i++){
setTimeout("changePosition()",1);
}
}
function changePosition(){
var currElement = document.getElementById(element);
currElement.style.left = "'"+slidePerMS+"px'";
}
</script>
</code></pre>
|
javascript
|
[3]
|
3,623,171 | 3,623,172 |
How do you convert string to c_str() in this situation?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/347949/convert-stdstring-to-const-char-or-char">Convert std::string to const char* or char*</a> </p>
</blockquote>
<p>My code is this </p>
<pre><code>#include <iostream>
#include <fstream>
using namespace std;
string mapChange(int side, string oldMap);
int main(){
string createMapName;
string createMapNameData [10];
int featureSelect;
cout << "(1)Game or (2)Mapmaker";
cin >> featureSelect;
if(featureSelect == 2)
{
cout << "Name of Map?";
cin >> createMapName;
ofstream mapName;
mapName.open (createMapName);
mapName << createMapNameData[0] << endl;
}
return 0;
}
string mapChange(int side, string oldMap){
string newMap;
if(oldMap == "Test")
{
cout << "Map Found :D";
}
else
{
cout << "ERROR MAP NOT FOUND, PLEASE REINSTALL.";
}
return newMap;
}
</code></pre>
<p>How do I use a c_str instread of string on line 15 i.e. how do I convert string to c_str()?
Please help,
Lijrobert</p>
|
c++
|
[6]
|
3,454,982 | 3,454,983 |
how to check if radio button match the correct answer taken from database
|
<p>In my form i had a quiz project about c#,I used label to store question and radiobuttons for the options,how will i checked if the radiobutton that was selected matched with the correct answer from my database?I want the syntax on how to do that.</p>
|
c#
|
[0]
|
432,459 | 432,460 |
What does "Implement" a PHP script mean?
|
<p>How do I implement a PHP script, several specific pages to be precise, into my website? </p>
<p>I could guess that it means to insert it into an html page or linked within the site, but how?</p>
<p>It is a membership script.</p>
<p>Cheers </p>
|
php
|
[2]
|
767,247 | 767,248 |
would it ever make sense to modify a reference to a const char* passed in as a parameter to a method?
|
<p>Say I have something along the lines of:</p>
<pre><code>int main()
{
const char* someString = "Hello";
MyClass myClass;
myClass.modifySomeString(someString);
return 0;
}
</code></pre>
<p>And two possible method signatures for <code>modifySomeString</code>:</p>
<p><strong>case A</strong> <code>void MyClass::modifySomeString(const char* inBuffer)</code></p>
<p>This seems straight-out pointless since I'd be getting a value so whatever I do with inBuffer does not affect the original someString in <code>main()</code>, right?</p>
<p><strong>case B</strong> <code>void MyClass::modifySomeString(const char*& inBuffer)</code></p>
<p>Here, I have a reference to the pointer so potentially I could actually modify the original "string" in main() (and probably should call the parameter inOutBuffer for clarity...). But besides the fact that I could cast to remove the const and modify the actual parameter inside my method... wouldn't this be just a bad thing to do? </p>
<p>I mean:</p>
<ol>
<li>someString was declared const in main to start with, so trying to pass it to a method for it to modify it is nonsensical</li>
<li>inside the method, if I'm stating the parameter is const too, again it just seems wrong to then try and go around its const to modify it affecting someString in main.</li>
</ol>
<p>Am I right about my observations on both cases A and B? Or is there a reason where it might be reasonable to pass a const string to a method and expect the method to still modify the original?</p>
<p>Personally, I think if I'm passing a const to the method, the method should instead have an out parameter where I get a new string without changing the original one. Something like:</p>
<pre><code>void MyClass::modifySomeString(const char* inBuffer, char*& outBuffer)
</code></pre>
<p>But I'm interested in suggestions or someone explaining why it's perfectly fine to modify the const parameter.</p>
|
c++
|
[6]
|
1,957,602 | 1,957,603 |
PHP 5.2 - 5.3 upgrade in Solaris 9
|
<p>I am trying to upgrade PHP 5.2.13 to 5.3.16 in Solaris 9 SPARC box. I have installed many extensions in the current version (5.2.13). The installation of PHP 5.2.13 was through binaries and not through source. The extnesions were installed through source via configure, make, make install commands. </p>
<p>While upgrading, is it enough if I copy over the .so files across to extensions directory or configure them afresh?</p>
<p>Any info is well appreciated.</p>
<p>Thank you
Banu</p>
|
php
|
[2]
|
5,280,444 | 5,280,445 |
R.java not generated in eclipse
|
<p><img src="http://i.stack.imgur.com/N5cIT.png" alt="R.java not generated"> </p>
<p><img src="http://i.stack.imgur.com/zV8ik.png" alt="enter image description here"></p>
<p>R.java is not generated. I tried several strategies like cleaning and building etc, none of them seemed to work. Please dont mark this as duplicate since I have tried all the strategies that has been told in other questions.</p>
|
android
|
[4]
|
2,557,590 | 2,557,591 |
javascript: determing the structure of an object programmatically
|
<p>I am building javascript (nodejs) integration with a remote service. The service returns inconsistently formatted results, and from within javascript, I am battling to determine how to switch my formatting based on the response.</p>
<p>The 2 formats are shown below, the first is when Parent has a single child, and the 2nd is where Parent has >1 children:</p>
<pre><code>var single = { "Parent" : { "name" : "foo" } }
var multi = { "Parent" : [ { "name" : "foo" }, { "name" : "bar" } ] }
</code></pre>
<p>So when I try and parse the results in js, accessing a child attribute of "name", I get inconsistent results:</p>
<pre><code>for (var i in single) {
console.log("child name: " + single[i].name;
}
for (var i in multi.Parent) {
console.log("child name: " + multi.Parent[i].name;
}
</code></pre>
<p>What would the best way be to determine whether I am getting a single or multi result back? I tried "typeof response", hoping to get an "Array" for multi, but that didn't work.The object is initially received as a string, but converted to an object using <code>JSON.parse(responseString)</code>.</p>
|
javascript
|
[3]
|
140,618 | 140,619 |
Multiple Variable Variables in PHP
|
<p>I am fairly new to PHP and programming in general... I am attempting to use a foreach loop to set some options on a page I have created. It all works except for the last section, where I am attempting to assign variables dynamically, so I can use them outside the loop.</p>
<pre><code><?PHP
$array=array(foo, bar, baz);
foreach ($array as $option) {
// I have if statements to determine what $option_req
// and $option_status end up being, they work correctly.
$option_req="Hello";
$option_status="World";
$rh='Req_';
$sh='Status_';
$$rh.$$option=$option_req;
$$sh.$$option=$option_status;
}
echo "<br>R_Foo: ".$Req_foo;
echo "<br>S_Foo: ".$Status_foo;
echo "<br>R_Bar: ".$Req_bar;
echo "<br>S_Bar: ".$Status_bar;
echo "<br>R_Baz: ".$Req_baz;
echo "<br>S_Baz: ".$Status_baz;
?>
</code></pre>
<p>When the loop is finished, should this now give me six variables? </p>
<pre><code>$Req_foo
$Status_foo
$Req_bar
$Status_bar
$Req_baz
$Status_baz
</code></pre>
<p>I have played with this a bit, searches on Google seem fruitless today.</p>
|
php
|
[2]
|
3,345,196 | 3,345,197 |
how to do simple login verification in android?
|
<p>i have created the login screen but i am unable to verify the data in the edit box..
i have tried for simple verification using following function that checks whether the username and password are same..</p>
<pre><code>protected boolean isValid(String string1,String string2) {
</code></pre>
<p>if(string1.equals(string2))
return true;
else
return false;</p>
<p>}</p>
<p>but it is not working properly...</p>
|
android
|
[4]
|
1,329,679 | 1,329,680 |
how to make visual studio javascript formatting work?
|
<p>For some reason Visual Studio javascript formatting does not understand the syntax:</p>
<pre><code>(function(){
})();
</code></pre>
<p>I'm getting "expected expression" in the second character of this line: <code>})();</code></p>
<p>So I was wondering if anyone had this problem before (want to format their code but visual studio stubbornly thinks the valid code has an error and refuses to do so) and how do we solve it?</p>
|
javascript
|
[3]
|
2,003,570 | 2,003,571 |
Parse error: syntax error, unexpected $end /path/php.module(74)
|
<p>I'm making a form with CAPTCHA to email me the form.
I made the PHP code but I'm having an error:</p>
<pre><code>Parse error: syntax error, unexpected $end /path/php.module(74) : eval()'d code on line 103
</code></pre>
<p>Here is the code:
<a href="http://pastebin.com/S2ZvdXTX" rel="nofollow">http://pastebin.com/S2ZvdXTX</a></p>
<p>Can anyone please tell me what's going on? My eyes are burning out, and can't find that problem, but I know I'm near to it.</p>
<p>BTW, I'm sorry, I'm not a professional with PHP.</p>
|
php
|
[2]
|
1,629,435 | 1,629,436 |
PHP: %-sign in string?
|
<p>I have gotten a PHP script which uses an array to store configuration data, like <code>$config["maxPosts"] = 5;</code>.<br>
Some of the settings need to be given as a string. In an example file, that looks like this:</p>
<pre><code>$config["welcomeMsg"] = "Welcome home, %name%";
</code></pre>
<p>What does the <code>%</code> mean in that case?</p>
|
php
|
[2]
|
4,172,556 | 4,172,557 |
JavaScript Object Syntax
|
<p>What is the logic behind this:</p>
<p>object = object = function</p>
<p>I see it a lot in jQuery, for example, 1.4.4 line 99:</p>
<pre><code>jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
</code></pre>
<p>or line 332:</p>
<pre><code>jQuery.extend = jQuery.fn.extend = function() {
</code></pre>
<p>Why would you use this syntax?</p>
|
javascript
|
[3]
|
1,878,030 | 1,878,031 |
How to convert bytes in a string to integers? Python
|
<p>I want to get a list of ints representing the bytes in a string.</p>
|
python
|
[7]
|
3,307,132 | 3,307,133 |
jQuery get next element and all of its children
|
<p>How can I get the next div element and then all of its children?</p>
<pre><code><div class="1"></div>
<div class="2">
<div class="child1"></div>
<div class="child2"></div>
</div>
<div class="3">
<div class="child1"></div>
</div>
</code></pre>
<p>so, if <code>$(this)</code> currently is class 1, how can i get to only class 2 and all of its children. And I can't reference it by its class name since i won't know what that is.</p>
<p>I'm basically looking to merge these 2 statements into 1.</p>
<pre><code>$(this).next('div').animate({height : 'toggle'});
$(this).next('div *').animate({height : 'toggle'});
</code></pre>
|
jquery
|
[5]
|
942,578 | 942,579 |
When should a Service be stopped
|
<p>My android application starts a service in the onCreate() callback of a class that extends Application. The service performs some background tasks that are relevant to the user only while the application is running. For that reason I would like to close the service when the application's last activity is closed. I've tried to perform closing the service in the callback onTerminate() , but it never gets called . So what would be the best place where a service should be closed ?</p>
<p>Thanks !</p>
|
android
|
[4]
|
5,743,597 | 5,743,598 |
How to display pdf document asynchronously in android?
|
<p>I am displaying a pdf document in my android application. For that I followed from the link <a href="http://stackoverflow.com/questions/9995915/how-to-open-a-pdf-from-an-android-app-in-a-separate-pdf-viewer-app">How to open a PDF from an Android app (in a separate PDF viewer app)</a>. My pdf document size is of 30mb. So it is taking time to display it. Hence I need to display it asynchronously. I am new to asynchronous tasks. Please give me some idea on how to display the pdf asynchronously.</p>
<p><img src="http://i.stack.imgur.com/at9iP.png" alt="enter image description here"></p>
|
android
|
[4]
|
5,445,420 | 5,445,421 |
Syntax error I just can't see
|
<p>My page generates this error currently;
"unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING" on line 84.</p>
<p>The line of code it's referring to is this:</p>
<pre><code>if (empty($ref)) {
$incref = "null";
} else {
$incref = "$_GET['ref'];
}
</code></pre>
<p>I genuinely don't see what's wrong.</p>
|
php
|
[2]
|
1,293,233 | 1,293,234 |
iPhone: How to use a UITableView as a drop-down menu
|
<p>How do I get UITableView to display as drop-down list? </p>
<p>I want to enable selection from a list of items. Since picker view takes up a lot of space and I have already used once in the same app, I was just wondering if UITableView can be used for displaying a drop-down list as it will take scant space. </p>
<p>And also the list gets populated from a database which lends itself to editing by the user from the interface. </p>
<p>Thanks in advance.</p>
<p>Sayeed</p>
|
iphone
|
[8]
|
542,670 | 542,671 |
Why is the destructor called when initializing a vector of objects?
|
<p>Something occurred in my program, and I can't find if it's supposed to happen or not. And if it is, I don't see why..</p>
<p>Here's the code :</p>
<pre><code>#include <iostream>
#include <vector>
using namespace std;
class A{
public:
A();
~A();
};
A::A(){
cout << "creating" << endl;
}
A::~A(){
cout << "deleting" << endl;
}
int main(void){
vector<vector<A > > vec;
vec.resize(5);
for(int i = 0; i < 5; ++i){
vec[i].resize(5);
}
cout << "END" << endl;
return 0;
}
</code></pre>
<p>And here's the output :</p>
<pre><code>creating
deleting
creating
deleting
creating
deleting
creating
deleting
creating
deleting
END
deleting
deleting
[..more deleting here]
</code></pre>
<p>I understand why the destructor is called after the "END" message, but before, I don't. I thought that when the vector resize, the constructor of the class is called, but why the destructor?</p>
|
c++
|
[6]
|
1,734,094 | 1,734,095 |
Text in textbox save in Notpade
|
<p>Can anyone please help me? I am new in C#.
I write text in TextBox1 and when i click button "Open" then text i like to save in notepad.? </p>
|
c#
|
[0]
|
4,815,546 | 4,815,547 |
Removing Virtual Inheritance
|
<p>I am working on an embedded project I am trying to remove a virtual number class that has + / - * implemented. removing this class saves a lot of code space so I have replaced + with the following function,</p>
<pre><code>if (BASE(h)->type() == FLOAT && BASE(v)->type() == FLOAT)
{
res = FLOAT(h)->floatValue() + FLOAT(v)->floatValue();
}
else if (BASE(h)->type() == INTEGER && BASE(v)->type() == INTEGER)
{
res = INTEGER(h)->intValue() + INTEGER(v)->intValue();
}
else if (BASE(h)->type() == INTEGER && BASE(v)->type() == FLOAT)
{
res = INTEGER(h)->floatValue() + FLOAT(v)->floatValue();
}
else
{
res = FLOAT(h)->floatValue() + INTEGER(v)->floatValue();
}
</code></pre>
<p>Is there a less uglier way to achieve this? cause I have to use the same scheme for other ops and comparison?</p>
|
c++
|
[6]
|
2,719,546 | 2,719,547 |
jquery ajax loading overlay plugin
|
<p>Does anybody know of a nice plugin for ajax loading overlay preventing any other action in the browser till the data gets loaded.</p>
<p>Thnks
Coool</p>
|
jquery
|
[5]
|
3,242,907 | 3,242,908 |
Dropdown menu open on click close on click
|
<p>I have asked this question before but it was closed as I didnt ask it properly. My issue is that I have a wp photography site which is not live yet as I am customizing it..I am very new to jquery and css. It has a dropdown menu which when you click on an item eg Portfolio it will drop down a further sub menu which will then show galleries. Currently clicking on a main item with a sub menu will only drop it down or open it but if you click the same main item again it will not pull the sub menu back up or close it. As i have numerous galleries I would like to code it so that it pulls back up on a second click. The template was designed the way it is now but i would like change it to do this.</p>
<p>Please someone advice me and let me know what I need to provide.</p>
<p>Many thanks. </p>
|
jquery
|
[5]
|
3,578,502 | 3,578,503 |
Selecting thumbnail and viewing full screen
|
<p>I have my app working where it comes to a screen with 6 thumbnails. The user will select one and the next screen is a full image. I've accomplished this through an OnClickListener to call a new activity/xml (I'm new at this, sorry if my terminology is a little off).</p>
<p>My question is: is there a way to avoid creating 6 activty/xml (one for each thumbnail)? ultimately, my app will have about 40 thumbnails that can be selected for full screen view. </p>
<p>I've been trying to follow examples online where it appears that the code is presenting the full image within java instead of referencing an xml file. I've also seen use of Bitmap and BitmapFactory. Is this the way to go?</p>
<p>If the full screen image can be created dynamically within java, will the Back button still work to the user back to the screen with 6 thumbnails?</p>
<p>thanks, J</p>
|
android
|
[4]
|
5,229,403 | 5,229,404 |
Classes Inside Modules
|
<p>Lets say I have the code:</p>
<pre><code>class NoneDict(dict):
def __getitem__(self, name):
try:
return super(NoneDict, self).__getitem__(name)
except:
return None
</code></pre>
<p>I want people to be able to create a NoneDict object without writing all this code out. I tried including it in a module and then typed:</p>
<pre><code>import nonedict
foo = NoneDict()
</code></pre>
<p>But it didn't work. How can I make it so someone can import the module and then be able to create a nonedict without typing out all the code?</p>
|
python
|
[7]
|
2,389,071 | 2,389,072 |
XML String index out of range
|
<p>I have this code:</p>
<pre><code>string Str = "<String><MoreString>";
int Start = Str.LastIndexOf('<') + 1;
int End = Str.IndexOf('>', Start);
string S = Str.Substring(Start, End);
</code></pre>
<p>If Str is just <code>"<String>"</code>, then it works fine, but if Str is <code>"<String><MoreString>"</code>, then it throws an index out of range error. Is it because of the "<",">" characters?</p>
|
c#
|
[0]
|
5,092,082 | 5,092,083 |
Java interpreter?
|
<p>are there any interpretors available online? Where I could just throw a line or two of java into it and it would output the result? </p>
|
java
|
[1]
|
1,310,895 | 1,310,896 |
How to write isilo .pdb files in C#?
|
<p>I would like to write my own .pdb isilo files to read in my iphone with the isilo application but i don't have an editor or something like that. So Im stuck because I dont have the API to write that kind of files. C# or Visual basic .net is ok.
Any help would be appreciate.</p>
|
c#
|
[0]
|
3,713,909 | 3,713,910 |
Android: How can make progress bar like this
|
<p>I am working in android. i want to show a progress bar.</p>
<p>Progress is based on number of check in persons.</p>
<p>suppose, if number of <strong>check in =6</strong> then following should be displayed:-</p>
<p><img src="http://i.stack.imgur.com/X9rg4.jpg" alt="enter image description here"></p>
<p>if number of <strong>checkin=10</strong> then this following should be displayed:-</p>
<p><img src="http://i.stack.imgur.com/AIbEk.jpg" alt="enter image description here"></p>
<p>Please tell me how can i manage this RED COLOR BALLOON position according to progress bar position of progress.</p>
<p>you may provide some links for this.
Thank you in advance.</p>
|
android
|
[4]
|
133,289 | 133,290 |
Using jquery to do an image find and replace with a mouseenter on another <div>
|
<p>Basically, I have two images, each in a separate div. When I do a mouseenter on the first image, I need the second image to change in the other div. </p>
<p>The image that changes comes after the image with the mouseenter in the code. So far, I have</p>
<pre><code><script>
var Read1 = $("img[src$='/reading1.png']");
var Read2 = $("img[src$='reading2.png']");
$('#shelf-1').mouseenter(function() {
$('#read').find(Read1).replaceWith(Read2)
});
</script>
</code></pre>
<p>I am very new to using jquery, so I feel lost. Any help would be greatly appreciated.</p>
|
jquery
|
[5]
|
3,879,780 | 3,879,781 |
Using colons in javascript variable names (eg. a:b:c)
|
<p>I have just noticed that I can do the following in javascript...</p>
<pre><code>a:b:c:d = "happy days";
a:b:c = function(text){alert(text);};
</code></pre>
<p>I cannot however do...</p>
<pre><code>var a:b:c:d = "happy days";
// or
var myObj = {prop:a:b:c:d};
</code></pre>
<p>I was not expecting this syntax to work under any circumstances. Does anyone have any idea what is going on when I successfully use the 'a:b=x' notation?</p>
|
javascript
|
[3]
|
2,061,054 | 2,061,055 |
How to disable blinking of textview onClick
|
<p>I have a <code>TextView</code> with an <code>onClickListener()</code>.
When I click on the <code>TextView</code> it blinks.
How to disable this effect?</p>
<p>Here is the XML</p>
<pre><code><TextView
android:id="@+id/descriptionText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:ellipsize="end"
android:paddingTop="4dp"
android:paddingLeft="8dp"
android:maxLines="3"
/>
</code></pre>
<p>I tried to remove <code>android:ellipsize</code> and <code>android:maxLines</code> tags - no effect.</p>
<p>And here is the code:</p>
<pre><code>accountDescriptionTextView = (TextView) v.findViewById(R.id.descriptionText);
accountDescriptionTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (descriptionOpened)
{
// accountDescriptionTextView.setEllipsize(TextUtils.TruncateAt.END);
// accountDescriptionTextView.setMaxLines(3);
descriptionOpened = false;
}
else
{
// accountDescriptionTextView.setEllipsize(null);
// accountDescriptionTextView.setMaxLines(100);
descriptionOpened = true;
}
}
});
</code></pre>
<p>I need to have the commented functionality, but even when this lines are commented I still see how the textview blinks.</p>
<p>The text just disapears when i place my finger on the screen and apears when I take the finger away.</p>
|
android
|
[4]
|
1,074,508 | 1,074,509 |
forward break label
|
<p>How can i do forward jumps like this?? Eclipse is complaining label1 is not found...</p>
<p>Thx</p>
<pre><code>public class foo {
int xyz() {
int b = 1;
if (b == 0) {
break label1;
}
// MORE CODE HERE
label1:
return 1;
}
}
</code></pre>
|
java
|
[1]
|
3,399,470 | 3,399,471 |
How to Deep clone in javascript
|
<p>How do you deep clone a Javascript object?</p>
<p>I know there are various functions based on frameworks like <code>JSON.parse(JSON.stringify(o))</code> and <code>$.extend(true, {}, o)</code> but I don't want to use a framework like that.</p>
<p>What is the most elegant or efficient way to create a deep clone. </p>
<p>We do care about edge cases like cloning array's. Not breaking prototype chains, dealing with self reference.</p>
<p>We don't care about supporting copying of DOM objects and like because <code>.cloneNode</code> exists for that reason.</p>
<p>As I mainly want to use deep clones in <code>node.js</code> using ES5 features of the V8 engine is acceptable. </p>
<p>[Edit]</p>
<p>Before anyone suggests let me mention there is a distinct difference between creating a copy by prototypically inheriting from the object and <em>cloning</em> it. The former makes a mess of the prototype chain.</p>
<p>[Further Edit]</p>
<p>After reading your answer I came to the annoying discovery that cloning entire objects is a very dangerous and difficult game. Take for example the following closure based object</p>
<pre><code>var o = (function() {
var magic = 42;
var magicContainer = function() {
this.get = function() { return magic; };
this.set = function(i) { magic = i; };
}
return new magicContainer;
}());
var n = clone(o); // how to implement clone to support closures
</code></pre>
<p>Is there any way to write a clone function that clones the object, has the same state at time of cloning but cannot alter the state of <code>o</code> without writing a JS parser in JS.</p>
<p>There should be no real world need for such a function anymore. This is mere academic interest.</p>
|
javascript
|
[3]
|
3,939,984 | 3,939,985 |
iphone TKCalendar selected date need dot with transparent image
|
<p>iphone application i am using TKCalendar selected date shows dot by default so i need to display dot with transparent image on particular selected date.
please help me </p>
|
iphone
|
[8]
|
5,735,752 | 5,735,753 |
Query the android Mediastore for Artist names of Music files
|
<p>I'm torn about how to implement this because Content Provider URI querys do not support the simple SQL "DISTINCT" query method to return a cursor to the Artists of the songs in the mediastore, removing any duplicate entries.</p>
<p>I can query and get a cursor to all the artists, I'm just torn as to how to remove the dupes, or simply not show them.</p>
<p>I've tried using matrixcursor to construct a new cursor with the dupe entries removed, but it's slow (build an array of artists, if in that array don't copy to the new matrixcursor, etc.)</p>
<p>Can anyone recommend a better solution, or point me in the proper direction??</p>
<p>I've also thought about pre-loading the information i need into an array of objects - I'm just concerned with memory overhead in my application.</p>
<p>Thank You for any help you may provide.</p>
|
android
|
[4]
|
1,131,608 | 1,131,609 |
help with validate field
|
<p>how do i check a field contain number and alphabet.</p>
<p>something like $str = 3ab, ab3, a3</p>
|
php
|
[2]
|
1,454,862 | 1,454,863 |
jQuery tabs with cookie support restore wrong tab position after page refresh
|
<p>I have tricky problem which I can't completely understand. It's jQuery tabs with cookie support. I've following code:</p>
<pre><code>$(document).ready(function() {
var $tabs = $("#tabs").tabs();
$tabs.tabs('select', $.cookie("tabNumber"));
$('#tabs ul li a').click(function() {
$.cookie("tabNumber", $tabs.tabs('option', 'selected'));
});
$('#btnSelect').click(function() {
//alert($.cookie("tabNumber"));
//$tabs.tabs('select', 2);
$tabs.tabs('select', $.cookie("tabNumber"));
});
});
</code></pre>
<p>So, I've 3 tabs (with positions 0,1,2) inside div named "tabs". When user selects one tab, then tab position stores in cookie. After that if user refresh page, active tab position must be restored.</p>
<p>But each time I refresh page I get active tab in previous position (if I select 2nd tab, then after refresh I got active tab in position 1, etc.).
I add some test in code (button btnSelect with onclick handler which duplicates load position functionality).
So, if I uncomment and use </p>
<pre><code>$tabs.tabs('select', 2);
</code></pre>
<p>Then after I click btnSelect I've got right position. Ok, that's right. Then I comment that line and uncomment next one:</p>
<pre><code>alert($.cookie("tabNumber"));
</code></pre>
<p>So, I select tab, click button, get dialog message "2", and after that tab in position 1 became active.
Why?? In both cases I call 'select' method with parameter 2...</p>
<p>I know I can use aliases for tabs, but I want to understate why my code doesn't work properly.</p>
|
jquery
|
[5]
|
4,762,050 | 4,762,051 |
WordPress/FTP Custom File Upload Security
|
<p>My file upload routine first checks to make sure the user is logged in to the wordpress application which is hosting the upload form...CHECK!</p>
<p>Here is the code at the top of my uploader utility that does this...</p>
<pre><code>if (!is_user_logged_in()){
die("You Must Be Logged In to Access This");;
}
</code></pre>
<p>So far so good. Now I'm seeking to further secure the upload utility to prevent malicious scripts from being extracted from the uploaded zip files (the upload requires a zip file).</p>
<p>The downside to using a zip, I presume, is that it can contain any number or type of files that might make it more complicated to handle than otherwise.</p>
<p>So my question is for tips on how to further secure this uploader to make sure no malicious files are sent. The desired allowed files are .php, .jpg, .gif, .png</p>
|
php
|
[2]
|
5,584,040 | 5,584,041 |
remove duplication
|
<p>I have a class contains 10 methods which are doing almost the same things apart from one key event. Two examples are given below: </p>
<pre><code>
Public String ATypeOperation(String pin, String amount){
doSomething();
doMoreStuff();
requestBuilder.buildATypeRequest(pin, amount);
doAfterStuff();
}
</code>
<code>
Public String BTypeOperation(String name, String sex, String age){
doSomething();
doMoreStuff();
requestBuilder.buildBTypeRequest(name, sex, age);
doAfterStuff();
}
</code>
</pre>
<p>As you can see from the above methods, they are similar apart from calling different methods provided by requestBuilder. The rest 8 are similar too. There is a lot duplicated code here. I feel there is a better way to implement this, but don’t know how. Any ideas and suggestions are appreciated. </p>
<p>Thanks,
Sarah</p>
|
java
|
[1]
|
5,272,659 | 5,272,660 |
how to send many emails in one time by php
|
<p>i want know
how i can send one mail to 200 user
and i want when the email sendt
it appeare send to:[email protected]
from:my mail</p>
<p>because i think i see many email like that
to:[email protected];[email protected];[email protected];
ithink this from bbc</p>
<p>i mean i want every user see sent to this email only</p>
|
php
|
[2]
|
3,783,412 | 3,783,413 |
Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES
|
<p>At the risk of repeating what appears to be a very common complaint, I think I have a substantial variation on this bug.</p>
<p>The application won't install from Eclipse and this appears in the console: Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES.</p>
<p>LogCat provides some illumination: Package com.xxx has no certificates at entry assets/fonts/helvetica_neue.ttf; ignoring!</p>
<p>Meaning that the device (or emulator) believes that this particular file wasn't signed.</p>
<p>The usual solutions proposed for this are:<br/>
- Rename the offending file. We've tried that, it then complains about the next file, then the next, and so on.<br/>
- Add a dummy file. Tried that too. It complains about the new file, regardless of what it's called.<br/>
- Compile for greater than Android 1.6. We're compiling for 2.3.</p>
<p>It's worth noting this only happens when we launch a unit test. We can install the "real" application on its own with no difficulties. We're also using Maven and, of course, the Maven Android plugin.</p>
<p>Any insights or suggestions would be very welcome and of course if we figure it out on our own I'll post any findings.</p>
|
android
|
[4]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.