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
1,068,131
1,068,132
Comparing timestamp to current time from database
<p>I need to test current time against a datetime from database, if it has been 30 mins then execute code, if not then dont. This is where I am at and I am stuck:</p> <pre><code>$link = mysqli_connect("hostname", "username", "password", "database"); $q = "SELECT id FROM dwCache ORDER BY id DESC LIMIT 1"; $qu = mysqli_query($link, $q); while($row=mysqli_fetch_array($qu, MYSQL_ASSOC)){ $id = $row['id']; $cache = $row['cache']; $timest = $row['time']; } $newTime = $difference = $timest if($timest &gt;= ) </code></pre> <p>As you can see towards the bottom I lose it as I am not sure what to do.</p> <p>$timest returns : 2013-02-01 12:36:01 as the format Y-m-d h-i-s</p> <p>Apologies on double post, other deleted.</p>
php
[2]
5,006,650
5,006,651
How to implement infinite scrolling in table data?
<p>How to implement infinite scrolling in table data by using php and jquery?</p>
jquery
[5]
2,958,231
2,958,232
how to create application(exe) from python script for linux
<p>i'm newbie for python programming, i'm having a .py file, now what shall i do so i can create an application from .py file and it can be istall and run in any linux pc, i try to packaging it but its just create .tar file where i need python to run it, is it any to do so,</p> <p>thanks</p>
python
[7]
1,174,890
1,174,891
truncate text with double quotes in javascript
<p>I am using the below snippet to truncate text and it is working fine, except in cases where the text contains double quotes.</p> <pre><code>function truncateText(str, len) { return (str.length &gt; len ? $.trim(str).substring(0, len).split(" ").slice(0,-1).join("") :str); } </code></pre> <p>for example: len = 10 str = "helllllllo worlllld" - working fine.</p> <p>but in case like this:</p> <p>len = 10 str = "hellllll"o worlllld" - not working as expected.</p> <p>I have tried to do the followings with no success:</p> <pre><code>str = str.replace('"', '\"'); str = str.replace('"', '&amp;quot'); str = str.replace('"', '\x22'); </code></pre>
javascript
[3]
4,917,615
4,917,616
I can't set a value in a class
<p>I made two classes. The first one is the <code>Player</code> class and the second the <code>Bag</code>. What I want is to print the score of the player in <code>main()</code>. In <code>Bag</code>, I count the score and I want to set it in <code>Player</code>. This is a part of the <code>Bag</code> class </p> <pre><code> public void count( int number) { ............. scr=k*2;//gives an int setScore(scr);//set the score in Player class } </code></pre> <p><strong>Player:</strong></p> <pre><code>public class Player { public Player() { } private String name; private int score; public Player(String name, int score) { this.name = name; this.score = score; } public String getName() { return name; } public void setScore(int score) { this.score = score; } public int getScore() { return score; } </code></pre> <p>In main() I try to print the score with this code but I can't:</p> <pre><code>Player p=new Player(); System.out.println( p.getScore()); </code></pre> <p>It returns me <code>score=0</code> (which I set it at the begging of main)<br> I hope that you understand what I want to say.</p>
java
[1]
2,504,732
2,504,733
How to "negate"(?) a list - Python
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/12887398/python-takes-list-and-returns-only-if-negative-value-also-exists-using-set">python takes list and returns only if negative value also exists using set</a> </p> </blockquote> <p>I'm having problems with another homework problem.</p> <blockquote> <p>By using a set, write a method negated(a) that takes a list, a, as an argument and returns a list containing only the elements x such that -x is also in a</p> </blockquote> <p>His example shows that the input is</p> <blockquote> <p>[-6, 8, 7, 3, 2, -9, 1, -3, 2, -4, 4, -8, 7, 8, 2, -2, -7, 0, 1, -9, -3, -7, -3, -5, 6, -3, 6, -3, -10, -8]</p> </blockquote> <p>and the output is</p> <blockquote> <p>[-6, 8, 7, 3, 2, -3, 2, -4, 4, -8, 7, 8, 2, -2, -7, 0, -3, -7, -3, 6, -3, 6, -3, -8]</p> </blockquote> <p>I was able to figure out how to do it without using a set with</p> <pre><code>return [x for x in a if -x in a] </code></pre> <p>I'm just having problems implementing a set into the problem. Can someone give me the steps to take, how I should tackle the problem... I'm not looking for the complete work, but it would be nice to see how you do it also.</p>
python
[7]
1,671,090
1,671,091
What is event bubbling and capturing
<p>What is the difference between event bubbling and capturing? Which is the faster and better model to use?</p>
javascript
[3]
5,307,330
5,307,331
Change Call Settings Programmatically
<p>I understand that it is currently possible to change Android system settings via the <a href="http://developer.android.com/reference/android/provider/Settings.System.html" rel="nofollow">Settings.System</a> class and its <code>putString</code> method.</p> <p>However, the setting I wish to change programmatically (Text message reply under Call settings) is not in this class.</p> <p>How would I go about modifying call settings? Is there as class similar to Settings.System?</p>
android
[4]
13,197
13,198
animate UIImageView with flip animation
<p>I'm a noob in objective-c and cocoa, and I would like to implement a simple animation of UIImageView with flipping animation. But I'm having a hard time doing it. Below are my snippets:</p> <pre><code>UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,33,33)]; UIImageView *img1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:IMG1]]; UIImageView *img2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:IMG2]]; [containerView addSubview:img1]; [containerView addSubview:img2]; [self.view addSubview:containerView]; CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:nil context:context]; [UIView setAnimationDuration:0.75]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES]; [containerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; [UIView commitAnimations]; </code></pre> <p>Thanks.</p>
iphone
[8]
4,335,440
4,335,441
How to make advertising script be the latest element loaded?
<p>I want to make ads to load last.so,after all the website's page elements are loaded,what code do i need to make an ad load last ?</p> <p>thank you</p>
javascript
[3]
4,172,136
4,172,137
if "word" text will say "wrong" (iPhone SDK)
<p>I would like to change this code so that if the textName.text contains the word "Blue" it will say @"Wrong color"</p> <p>This code implies only that if the word has no letters it will say "Wrong color". How can I change it to a specific word (blue) instead of "length] == 0)"?</p> <pre><code>if([textName.text length] == 0) { text = @"Wrong color"; } </code></pre> <p>Thank you very much!</p>
iphone
[8]
778,530
778,531
JQuery rollover state and "Current" items
<p>I have a simple JQuery rollover. The problem is, there is always one "current" item and I am using Jquery to change that current item accordingly. I am using the .hover function to change the hover colors based on page name. Right now, everything works fine, except that as soon as you roll over the current item, it loses it's "current" color and blanks just like the rest of the nav items. Here is a check I tried but it doesn't work. Basically, checking to see if the item does not have the color, if it doesn't then run the rollover function.</p> <p>What am I doing wrong and is there a better way to do this? Thanks!</p> <pre><code>if (jQuery('.sub_navigation li a').css('color') != '#F37321') { jQuery(".sub_navigation li a").hover(function () { jQuery(this).css({'color' : '#F37321'}); }, function () { var cssObj = {'color' : ''}; jQuery(this).css(cssObj); }); } /*end if */ </code></pre>
jquery
[5]
5,681,590
5,681,591
My Acitivty not reading data
<p>Android 2.1 update 1 Eclipse 3.5</p> <p>I have a problem reading data from my 2nd activity that is called from the 1st activity using intent. I have androidmanifest.xml setup correctly. </p> <p>My First Activity has the following code:</p> <p><code> Intent myIntent = new Intent(MainMenu.this, Testmenu.class); myIntent.putExtra("com.tweaktool.MyAge",40); myIntent.putExtra("com.tweaktool.Enabled", false);<br> startActivity(myIntent); </code></p> <p>My 2nd Activity has the following code:</p> <p><code> Bundle bun = getIntent().getExtras();<br> int myAge = bun.getInt("MyAge");<br> boolean enabled = bun.getBoolean("Enabled"); </code></p> <p>When I look at the above code in 2nd Activity it lists the following: enabled = false myAge = 0 </p> <p>Why is this doing this??? Am I doing something simple wrong??</p>
android
[4]
4,387,934
4,387,935
Javascript function returns before its subroutine finishes
<p>I'm trying to test if urls dynamically passed to image tags would resolve or not. I'm using the following javascript function: </p> <pre><code> testImageUri = function(src) { var img = new Image(); var imgStatus = false; var goodUri = function() { imgStatus = true; }; var badUri = function() { imgStatus = false; }; img.onload = goodUri; img.onerror = badUri; img.src = src; return imgStatus; } </code></pre> <p>The functions badUri and goodUri get called as expected, but they appear to be "late" as the testImageUri function seems to return before they get to change the imgStatus variable.</p> <p>How do one resolve such problems in javascript?<br/> How do one avoid them?<br/> is there a rule of thumb to recognize situations susceptible to create this?</p> <p><strong>EDIT</strong> <br/>Thanks all for your replies. I think I understand what's going on now. I will be implementing the function as described in the first reply, but with an additional parameter for the callback as suggested.</p> <p>Thanks again.</p>
javascript
[3]
5,828,416
5,828,417
Retrieve Button value with jQuery
<p>A simple one, I'm trying to retrieve the value attribute of a button when its been pressed using jQuery, here's what I have:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('.my_button').click(function() { alert($(this).val()); }); }); &lt;/script&gt; &lt;button class="my_button" name="buttonName" value="buttonValue"&gt; Button Label&lt;/button&gt; </code></pre> <p>In Firefox my alert displays 'buttonValue' which is great but in IE7 it displays 'Button Label'.</p> <p>What jQuery should I use to always get the button's value? Or should I be using a different approach?</p> <p>Many thanks.</p> <p>ANSWER: I'm now using</p> <pre><code>&lt;input class="my_button" type="image" src="whatever.png" value="buttonValue" /&gt; </code></pre>
jquery
[5]
5,757,469
5,757,470
How to set this cases depends on if rule
<p>if i've the following</p> <pre><code>$x = "go"; $y = "went"; $z "gone"; </code></pre> <p>and i need to set title where title will be </p> <pre><code>$title = $x; //only if "y" empty no care about "z" if empty or not $title = $x . " - " . $y; // if "y" not empty and "z" is empty $title = $y . " - " . $z; // if "z" not empty and "y" not empty </code></pre> <p>this is my try but field and/or looks so permeative (i'm noob)</p> <pre><code>$empty = ""; // i've creaty empty example $x = "go"; $y = "went"; $z "gone"; if ($y==$empty) { $title = $x; // output should be go } else if($y!=$empty &amp;&amp; $z==$empty) { $title = $x . " - " . $y; // output should be go - went } else if($y!=$empty &amp;&amp; $z!=$empty) { $title = $y . " - " . $z; // output should be went - gone } else { $title = $x; // output should be go } </code></pre> <p>do anyone have better suggestion ! thanks a lot</p>
php
[2]
5,950,675
5,950,676
C++ Dynamic memory allocation
<p>I'm just learning about dynamic memory allocation, but there is one thing i'd like to be explained.</p> <p>One use for dynamic allocation is for dynamic sized arrays, and thats clear to me. Another use is for normal objects.</p> <p>What is a situation one should use it? Is it because normally objects are pushed on the stack, and could be popped of?</p> <p>And how do you recognise a situation you should use dynamic memory allocation?</p>
c++
[6]
3,000,135
3,000,136
Adding an integer number to a Unicode character - What does this do?
<p>I am learning C# in the beginners level. I do not understand what adding an integer number to a Unicode character does. What does the addition do in the example below?</p> <pre><code>int amount = int.Parse(number.Text); steps.Text = ""; string current = ""; do { int nextDigit = amount % 8; amount /= 8; int digitCode = '0' + nextDigit; char digit = Convert.ToChar(digitCode); current = digit + current; steps.Text += current + "\n"; } while (amount != 0); </code></pre>
c#
[0]
4,841,877
4,841,878
Remove values from array
<p>I have array:</p> <pre><code>$array = array('aaa', 'bbb', 333, 'ddd', 555, '666'); </code></pre> <p>I would like remove all values where key is > 3; </p> <p>How is the best way for this?</p>
php
[2]
107,013
107,014
how to customize subview that supports only landscape mode
<p>i have one view with 4 subviews.</p> <p>my application will supports both portrayed and landscape modes.</p> <p>Among the 4 subviews,one of the view is support only for portrayed.</p> <p>how can i done this.</p> <p>Thank u in advance. </p>
iphone
[8]
1,471,857
1,471,858
how to add select option to datagrid control in asp.net
<pre><code>&lt;asp:DataGrid runat="Server" id="dg"&gt;&lt;/asp:DataGrid&gt; </code></pre>
asp.net
[9]
4,754,733
4,754,734
how to change [1,2,3,4] to '1234' using python
<p>I want to get a string from a list.</p>
python
[7]
4,726,099
4,726,100
2 iPhone apps messed up when deploy to iPhone
<p>I have 2 iPhone apps and want to deploy to iphone and somehow the second app rewrote the first app on my iPhone. </p> <p>The second app project was copied from the first app and I made some changes including renaming the app name etc.</p> <p>I believe there might be some files messed up due to the shared path. Can anyone shed some light on this issue?</p>
iphone
[8]
4,790,920
4,790,921
How can i make a message pop up every 12 hrs?
<p>How can i make a message pop up every 12 hrs in c#?</p> <p>I'm just using a message as an example, thanks.</p>
c#
[0]
503,231
503,232
JavaScript dateFormat error?
<p>I am trying to get a field named <code>BASVURUTARIHI(Date)</code> from DataSet. But if I only bind it with Eval, it shows <code>dd/mm/yyyy HH/MM/SS</code>. I don't want the hours and minutes. So, I am trying to change the dateformat but it gives me the error:</p> <blockquote> <p>CS0103: The name 'dateFormat' does not exist in the current context</p> </blockquote> <pre><code>&lt;dx:ASPxLabel ID="ASPxLabel2" runat="server" Text='&lt;%# dateFormat(Eval("BASVURUTARIHI"),"dd/mm/yyyy") %&gt;'&gt;&lt;/dx:ASPxLabel&gt; </code></pre> <p>I don't know a lot about JavaScript. Can you help me with this please?</p>
asp.net
[9]
2,200,236
2,200,237
how to separate numbers string to send bulk sms
<p>i need to send sms to multiple numbers at a time.</p> <p>to send sms i am using MFMessageComposeViewController.</p> <p>i place a text field and pass that textfield text as recipients.</p> <p>now i need to send it to multiple numbers at a time.</p> <p>for that i think by placing the , as separator for mobile number.</p> <p>eg:9292929292,92929292992,9292929292.</p> <p>At the sending time i need to separate each and individual number.</p> <p>How can i done this,</p> <p>can any one pls help me.</p> <p>Thank u in advance.</p>
iphone
[8]
4,759,995
4,759,996
Android String.equals doesn't work when I trying to match from httpresponse
<pre><code>RestClient.post("auth/login/", loginparam, new AsyncHttpResponseHandler() { @Override public void onSuccess(String s) { Toast.makeText(getApplicationContext(), String.valueOf(s.toLowerCase().equals("ok")), Toast.LENGTH_LONG).show(); if (s.equals("ok")) { startActivity(new Intent(getApplication(), HomeActivity.class)); } } }); </code></pre> <p>This is the code I used for login in android app, In the Toast text, I can see the server did returned "ok", but s.equals always failed in my case, can someone explain that? Thank you.</p>
android
[4]
538,312
538,313
what is the meaning of Broken pipe Exception?
<p>what is the meaning of broken pipe exception and when it will come, please tell me</p> <p>Thanks,</p> <p>varakumar.pjd</p>
java
[1]
2,859,560
2,859,561
Where to keep simple counter value (except DB and File) [PHP]
<p>I have a counter which I increment every page visit. I do not want to keep this value in DB or in plain file. Is there any other approach to keep it?</p> <p>I need keep it for next visit. In the next visit I want to read it, increase and keep again.</p> <p>Why I do not want to use DB? Because in whole project I'm not using DB it's simple project.</p> <p>Plain file it's maybe the easiest solution. And every concurrency access can be solved by PHP. But maybe is there anything easier and lightweight than plain file (in performance sense ?</p>
php
[2]
3,664,310
3,664,311
Pointers to two different types of nodes
<p>I am coding a hash tree in C++, where I need two different types of nodes i.e. one for non leaf that will simply point to its children and other for leaf node which contains the required information. </p> <p>The problem I am facing is that how can I declare pointers in non leaf node. Because some non leaf nodes are to point other non leaf nodes and some have to point the leaf nodes. So I cant declare one pointer type to the pointer in non leaf node.</p> <p>Any help would be appreciated.</p>
c++
[6]
5,290,987
5,290,988
Does the GPLv2 preclude me from using KLone for my website?
<p>I recently discovered <a href="http://koanlogic.com/klone/features.html" rel="nofollow">Klone</a>. Being a C++ developer, I'm fascinated by the idea of getting to use C++ for my web development work (I know, I'm a glutton for punishment!)... Anyhow, it looks like the open source version of KLone is licensed under GPLv2... Normally, this would be fine, but since you're app is compiled and linked right into the server, it looks like KLone's license would also force me to open source the complete sources to any website I develop with it. The quote on their license page also leads me to this conclusion:</p> <blockquote> <p>This license is for those who develop (and possibly distribute) Free Software and want to use KLone to build their GPL product. GPL imposes that all code that is linked to any GPL'd object file must be released under GPL. This means that the patches applied to KLone source base (if any) and server embedded content (in the form of generated C files) must be provided on request as stated by GPL v2 license.</p> </blockquote> <p>First, is my read of this correct? If so, does anyone know of any similar open source project with a less restrictive license?</p>
c++
[6]
1,881,715
1,881,716
SurfaceView keeps overdrawing the menu
<p>When I create a SurfaceView and then try to open the menu, the menu is stuck under the SurfaceView. When I set the surfaceView to be transparant, this works when the SurfaceView is empty, but once it's filled, it will not allow anything to be in front of it.</p> <p>Does anyone know how to solve this? This is my init:</p> <pre><code> private void init(Context context) { this.context = context; SurfaceHolder holder = getHolder(); holder.setFormat(PixelFormat.TRANSPARENT); holder.addCallback(this); </code></pre> <p><img src="http://i.stack.imgur.com/Rfm2N.jpg" alt="SurfaceView over the menu"></p>
android
[4]
3,512,344
3,512,345
automatic way to detect objects passed by value to functions in c++
<p>I and my co-coder often forget to pass (large) objects by reference and instead pass by value. This might be hurting performance. Is it possible to configure the compiler to warn me in such cases? Is it possible to detect it automatically in a bunch of c++ source files ... maybe a regex that someone has already written?</p> <p>UPDATE: Thanks guys for your helpful answers. One problem with all answers is that they only work for classes I write ... not for existing classes .. like <code>std::vector</code> . I can subclass them, but it would be too tedious</p>
c++
[6]
4,875,554
4,875,555
Show how many times values are in an array
<p>The php code below displays the country location of the IPs stored in a database and outputs it in an HTML table. As is, it creates a long list of the country code for each individual IP.</p> <p>For example...</p> <p>US<br>US<br>MX<br>US</p> <p>What I would like to do is, rather than create a long list of each individual item, display the number of times an item shows up in the array. Using the example above...</p> <p>country frequency</p> <p>US 3 <br>MX 1</p> <p>How would I implement this? Here's the full code...</p> <pre><code>require_once("geoip.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); include_once($_SERVER['DOCUMENT_ROOT'] . 'connect.php'); /* Performing SQL query */ $data = mysql_query("SELECT * FROM the_ips LIMIT 100") or die(mysql_error()); echo "&lt;table&gt;"; echo "&lt;td&gt;&lt;strong&gt;Country&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Frequency&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;"; while($info = mysql_fetch_array( $data )) { $ip = $info['ip_address']; $country_code = geoip_country_code_by_addr($gi, $ip); $countrylist = array($country_code); $frequency = array_count_values($countrylist); echo "&lt;tr&gt;&lt;td style='width: 100px;'&gt;".$country_code."&lt;/td&gt;&lt;td style='width: 100px;'&gt;".$frequency."&lt;/td&gt;&lt;/tr&gt;"; } echo "&lt;/table&gt;"; geoip_close($gi); </code></pre> <p>I need to assign <code>$frequency</code> and remove rows that include duplicate "Country" value, but not sure how to do this. As is, $frequency returns "Array" when I was hoping for a number (i.e. US 3).</p>
php
[2]
5,422,981
5,422,982
What's the difference between these two object instantiation approaches?
<p>Suppose I have a class named A:</p> <pre><code>Class A { ... } </code></pre> <p>And what's the difference between the following 2 approaches to instanciate an object:</p> <pre><code>void main(void) { A a; // 1 A *pa=new A(); // 2 } </code></pre> <p>As my current understanding (not sure about this yet):</p> <ul> <li><p>Approach 1 allocate the object a on the stack frame of the main() method, and so this object cannot deleted because that deletion doesn't make sense (don't know why yet, could someone explain that?).</p></li> <li><p>Approach 2 allocate the object a on the heap of the process and also a A* vairable <em>pa</em> on the stack frame of the main() method, so the object can be deleted and and the pa can be assigned null after the deletion.</p></li> </ul> <p>Am I right? If my understanding is correct, could someone tell me why i cannot delete the <em>a</em> object from the stack in approach 1?</p> <p>Many thanks...</p>
c++
[6]
5,387,056
5,387,057
bad_alloc when allocating array
<p>I have this code on the constructor of a class:</p> <pre><code>verts=new GLfloat[nVerts]; </code></pre> <p>verts is a member variable of the class (GLfloat *) and nVerts is 4. Is something wrong with that code? I get the same error If i try to do malloc(sizeof(GLfloat)*nVerts) I think I'm not running out of memory, because If i change that line of code to another part of the code(for example to the method that calls the constructor just before calling it, like this: <code>GLfloat *test=new GLfloat[4]</code> it works)</p>
c++
[6]
5,867,458
5,867,459
Is it possible to get the caller context in javascript?
<pre><code>var test = { demo: function(){ //get the caller context here } } //when this gets called, the caller context should be window. test.demo(); </code></pre> <p>I tried <code>arguments.callee</code> and <code>arguments.callee.caller</code>,and no luck...</p>
javascript
[3]
455,472
455,473
How to build knob like spinner in iOS sdk?
<p>I want to build a spinner for menu selection like the one in where to? IPhone app as shown in image below. Any hints?</p> <p><img src="http://i.stack.imgur.com/RPRVZ.jpg" alt="alt text"></p>
iphone
[8]
3,429,776
3,429,777
How-to init a ListPreference to one of its values
<p>I'm trying to set a defaultValue to a ListPreference item.</p> <p>Here is an sample of my preference.xml file:</p> <pre><code>&lt;ListPreference android:key="notification_delay" android:title="@string/settings_push_delay" android:entries="@array/settings_push_delay_human_value" android:entryValues="@array/settings_push_delay_phone_value" android:defaultValue="????"&gt; &lt;/ListPreference&gt; </code></pre> <p>The two arrays:</p> <pre><code>&lt;string-array name="settings_push_delay_human_value"&gt; &lt;item&gt;every 5 minutes&lt;/item&gt; &lt;item&gt;every 10 minutes&lt;/item&gt; &lt;item&gt;every 15 minutes&lt;/item&gt; &lt;/string-array&gt; &lt;string-array name="settings_push_delay_phone_value"&gt; &lt;item&gt;300&lt;/item&gt; &lt;item&gt;600&lt;/item&gt; &lt;item&gt;900&lt;/item&gt; &lt;/string-array&gt; </code></pre> <p>When i go into the preference activity, no item of the ListPreference is selected. I've tried to set an int value like 1 in the "android:defaultValue" fied to select "10 minutes" but it does not work.</p> <pre><code>&lt;ListPreference android:key="notification_delay" android:title="@string/settings_push_delay" android:entries="@array/settings_push_delay_human_value" android:entryValues="@array/settings_push_delay_phone_value" android:defaultValue="1"&gt; &lt;/ListPreference&gt; </code></pre> <p>Any Idea?</p>
android
[4]
4,711,818
4,711,819
PHP class_exists acting case sensitive
<p>According to PHP's documentation <a href="http://php.net/manual/en/function.class-exists.php" rel="nofollow"><code>class_exists()</code></a> is not case sensitive. However, I'm experiencing that it is. For example, <code>class_exists("\\My\\Class")</code> returns true but <code>class_exists("\\My\\class")</code> returns false.</p> <p>I'm running <code>PHP 5.3.3.</code> I have two separate environments. This is working correctly in one environment, but the other environment is acting like it cares about case.</p> <p>What am I missing? Is there a config setting somewhere?</p> <p><strong>UPDATE:</strong></p> <p>For anyone else experiencing this problem, I found the issue. <code>class_exists()</code> uses the autoloader for any classes that have not been declared. <code>class_exists()</code> will behave as case insensitive as long as the class shows up in the list returned by <a href="http://php.net/manual/en/function.get-declared-classes.php" rel="nofollow"><code>get_declared_classes()</code></a>. However, if the class you are looking for does not show up in this list, it relies on the registered autoloader stack to find it. The autoloader my project is using is Symfony2's UniversalClassLoader which ultimately relies on <a href="http://php.net/manual/en/function.file-exists.php" rel="nofollow"><code>file_exists()</code></a> to autoload the class. <code>file_exists()</code> IS case sensitive as long as the system's environment is case sensitive. This is why I was seeing the problem on one environment and not the other. There are many ways to solve this problem by adding an autoloader that is not case sensitive. There are also some good examples of some case insensitive <code>file_exists()</code> implementations in the documentation comments.</p> <p>I sincerely apologize for wasting everyone's time by not effectively communicating the problem and providing a pseudo-example instead of actual code. Rather than my intention of getting to the core of my problem, my pseudo-example was a distraction. I have failed and for that I am truly sorry.</p>
php
[2]
2,304,639
2,304,640
PHP Headers - Content & Location
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4373440/download-a-file-and-redirect-or-alternative">Download a file and redirect&hellip;or alternative</a> </p> </blockquote> <p>Basically, we have a PHP file which outputs a file type using PHP headers.</p> <p>We want it to work like this:</p> <p>User clicks link, page opens, download prompt comes up and then the page that prompted the download (the main php page) redirects to another page...</p> <p>How can I go about doing this? I want it to only redirect once the download prompt has been delivered to the user.</p> <p>So.. sort of a thank you page.</p> <p>Can this be done like so:</p> <pre><code>header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: public', false); header('Content-Description: File Transfer'); header('Content-Type: '.$type); header('Accept-Ranges: bytes'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.filesize($file)); /* sleep for say 3 seconds.. */ header('Location: thankyou.php'); exit(); </code></pre> <p>This code was purely written as an example, but how can we create something like this?</p> <p>So the download prompt pops up, wait say 3 seconds, and then direct the origin page to a thank you page.</p>
php
[2]
3,938,555
3,938,556
store datagridview column value in a variable
<p>I want to store the column values (to be precise two column values in two variables). How this can be achieved. Any sample code will be of great help. Thanks.</p>
c#
[0]
1,274,748
1,274,749
User Control In Asp.net
<p>I created a user control. It contains one textbox. can I control this from parent web page. </p>
asp.net
[9]
2,700,303
2,700,304
Element in a form
<p>How to check if an html element [textbox, select, radiobutton etc] is in a form via Jquery?</p>
jquery
[5]
241,871
241,872
‘strcasecmp’ was not declared in this scope
<p>I am trying to build a source code called lipiTk</p> <p>I have lots of errors like this:</p> <pre><code>Documents/lipi/lipi/src/reco/shaperec/activedtw/ActiveDTWShapeRecognizer.cpp:1222:78: error: ‘strcasecmp’ was not declared in this scope </code></pre> <p>What should I do, there is too many cpp file in the code that gives similar errors. I do not think i can test with writing include string.h into every cpp file that gives error, might the problem be about my compiler?</p> <p>I am on Ubuntu and GCC is 4.5.</p> <p>My sw configuration is upper than lipitk needs as I read in manual.</p>
c++
[6]
5,343,988
5,343,989
How to implement weather functionality in iphone?
<p>I am implementing weather applciation for iphone but dont know which api i have to used. And how to implement this things.</p> <p>Please give me some advice for this.</p> <p>Thanks in advance</p>
iphone
[8]
2,900,968
2,900,969
looking for something like "array_and"
<p>I'm want to check an array like this, if every value is "true"</p> <pre><code>$arr = array(true, true, true) // would be true $arr = array(true, true, false) // would be false $arr = array(false, true, false) // would be false </code></pre> <p>PHP provides a funcion "array_sum()". Is there a short function like "array_and()"</p> <p>Currently I use something like that:</p> <pre><code>$result = true; foreach ($arr as $item) { $result = $result &amp;&amp; $item; } </code></pre> <p>Is there any shorter solution?</p>
php
[2]
4,539,038
4,539,039
PHP—"Defined or Exit" at the beginning of many files?
<p>I have been inspecting some PHP source codes and I more often than not find files starting with</p> <pre><code>defined('__someconstant__') or exit(); </code></pre> <p>I know that this prevents the file to be accessed directly if a previous file defining <code>__someconstant__</code>, but then I wonder if this is really necessary... Isn't there (even non-PHP based) a cleaner way of doing it without introducing this extra code in every file?</p>
php
[2]
4,034,240
4,034,241
How to implement Mobile express checkout using php
<p>I have created one php page and upon click of "Checkpres checkout" just redirecting into paypal sandbox url, however it's not working. We are using the php url in android webview to do payment everything. So i need your help to solve the problem. What are the information i need to POST to mobile paypal express checkout and with return, cancel url details? </p>
php
[2]
761,920
761,921
Multiple timer with different interval in C#.net
<p>I want different timer with different interval that i input.For example, if I input 4, 4 timer create and show time in 4 label, where 1st timer's time change in 1sec,2nd timer's time change in 2sec,3rd timer's time change in 3sec and 4tn timer's time change in 4sec.Here is my code,</p> <pre><code> string input = textBox2.Text; int n = Convert.ToInt32(input); for (i = 1; i &lt;= n; i++) { Timer timer = new Timer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = (1000) * (i); timer.Enabled = true; timer.Start(); Label label = new Label(); label.Name = "label"+i; label.Location = new Point(100, 100 + i * 30); label.TabIndex = i; label.Visible = true; this.Controls.Add(label); } private void timer_Tick(object sender, EventArgs e) { label.Text = DateTime.Now.ToString(); } </code></pre> <p>But i don't get any output.What can i do.I use windows application.</p>
c#
[0]
2,563,285
2,563,286
Algorithmic analysis:Random Number
<p>Am building Software for a clinic using VS2010 Pro.<br> Among the requirements are: </p> <ol> <li>It should generate patient Number based on the date of enrollment. </li> <li><p>Middle two digits for Male patient is 11. </p></li> <li><p>Middle two digits for Female patient is 22</p></li> <li><p>The Final two digits range from 0 to 99.<br> eg for Male patient enrolled today:2012-03-02. My Question is: What is the Maximum of patients that can be enrolled per day? </p> <p>here is part of my code: </p> <pre><code>public string GetCurrentDate() { DateTime currentDate = DateTime.Now; string todaydate = currentDate.ToShortDateString().ToString(); return todaydate; } public int RadomNum() { return _random.Next(00, 99); } public string GeneratePatientNumber(Gender gender) { return GetCurrentDate() + "-" + (int)gender + "-" + RadomNum(); } </code></pre></li> </ol>
c#
[0]
1,172,720
1,172,721
Android. Dynamic class loading and Java interfaces
<p>I've almost finished my first real Android project, a taxi ordering application, only some little usability concerns are left. For future releases we plan to implement built-in automatic updates of programming code and resources like some good programs do. I managed to run a simple example, based on <a href="http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html" rel="nofollow">http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html</a>, <a href="http://stackoverflow.com/questions/3022454/how-to-load-a-java-class-dynamically-on-android-dalvik">How to load a Java class dynamically on android/dalvik?</a> and <a href="http://stackoverflow.com/questions/6857807/is-it-possible-to-dynamically-load-a-library-at-runtime-from-an-android-applicat?rq=1">Is it possible to dynamically load a library at runtime from an Android application?</a>. I will not post here complete code, it looks much like over the links above. Main apk acts as launcher, it loads a jar-file from SD-card, loads a special class from there, instantiates an obect and calls its method via Java Reflect API, that simply brings up ab AlertDialog.</p> <p>But I want to be able to use common base Java interfaces both in launcher and in loaded library, acting as API. So I tried to declare an inteface called Problem both in launcher and library. The code is like this:</p> <pre><code>Class&lt;?&gt; problemClass = cl.loadClass("ru.homez.euler.Problem1"); Problem problem = (Problem)problemClass.newInstance(); problem.solve(this); </code></pre> <p>Dalvik VM doesn't like this, i get </p> <blockquote> <p>java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation</p> </blockquote> <p>I think this happens due to that Problem interface is defined both in launcher and library, I have seen issues like that here. How to deal with this?</p>
android
[4]
5,579,225
5,579,226
Access array element from function call in php
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1769020/how-to-avoid-temporary-variables-in-php-when-using-an-array-returned-from-a-func">How to avoid temporary variables in PHP when using an array returned from a function</a> </p> </blockquote> <pre><code>function array_test() { return array(0, 1, 2); } echo array_test()[0]; </code></pre> <p>Can anyone explain why this code doesn't work?</p>
php
[2]
1,410,992
1,410,993
iphone unit testing
<p>is it possible to make unit test using iphone simulator?</p> <p>Thanks.....</p>
iphone
[8]
5,129,579
5,129,580
Dynamically add TableRow to TableLayout
<p>When a button is clicked, the following method is run:</p> <pre><code>public void createTableRow(View v) { TableLayout tl = (TableLayout) findViewById(R.id.spreadsheet); TableRow tr = new TableRow(this); LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tr.setLayoutParams(lp); TextView tvLeft = new TextView(this); tvLeft.setLayoutParams(lp); tvLeft.setBackgroundColor(Color.WHITE); tvLeft.setText("OMG"); TextView tvCenter = new TextView(this); tvCenter.setLayoutParams(lp); tvCenter.setBackgroundColor(Color.WHITE); tvCenter.setText("It"); TextView tvRight = new TextView(this); tvRight.setLayoutParams(lp); tvRight.setBackgroundColor(Color.WHITE); tvRight.setText("WORKED!!!"); tr.addView(tvLeft); tr.addView(tvCenter); tr.addView(tvRight); tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } </code></pre> <p><code>R.id.spreadsheet</code> is an xml TableLayout. I can see from debugging that the method is being accessed, but nothing is drawn to the screen. What gives? Do I need to reset the Content View somehow?</p>
android
[4]
5,581,244
5,581,245
Delete local cookies in php
<p>How can I delete the cookies of a specific domain from php (ran on my computer)?</p> <p>It would be the same as the js function but in php.</p>
php
[2]
3,854,423
3,854,424
tkinter create labels and entrys dynamically
<p>Hello guys i need some ideas for my python script.</p> <p>i want to create a simple gui where i can enter some values. a label before and at the and an button to start the script.</p> <p>i was using something like this:</p> <pre><code>w = Label(master, text="weight:") w.grid(sticky=E) w = Label(root, text="bodyfathydrationmuscle:bones") w.grid(sticky=E) w = Label(root, text="hydration:") w.grid(sticky=E) </code></pre> <p>its ok but i want to do it dynamic. also when i would use w for all the entrys i only could cast w.get once. but i need all my data ;-)</p> <p>i was thinking of:</p> <pre><code> def create_widgets(self): L=["weight","bodyfat","hydration","muscle","bones"] LV=[] for index in range(len(L)): print(index) print(L[index]) ("Entry"+L[index])= Entry(root) ("Entry"+L[index]).grid(sticky=E) ("Label"+L[index])=Label(root, text=L[index]) ("Label"+L[index]).grid(row=index, column=1) </code></pre> <p>To call later: var_weight=Entryweight.get() var_bodyfat=Entrybodyfat.get()</p> <p>and so on. how can i make it work?</p>
python
[7]
2,952,977
2,952,978
EVO 3D screen size/DPI issue
<p>One of my beta testers has an EVO 3D and reported that my app draws things (some custom widgets) too small. Upon further inspection of both my app's log data and the output from the <code>glInfo</code> app, I realized why: the phone is reporting an incorrect DPI. Here's some of the output from glInfo:</p> <pre><code>Display Resolution Pixels = 540 x 960 DPIs = 159.48837 x 160.42105 </code></pre> <p>Now do the math. If you calculate the diagonal size of the screen from these numbers, it comes out to <strong>6.88 inches.</strong> The true size is 4.3 inches. What could be going on here? Is this a problem with the phone? It's relatively new, so this could be a possibility. I'm at a loss...</p> <p>Any ideas? My app needs a correct DPI to calculate the correct size to display some of its elements. Is only this guy's phone messed up, or do I need to find a workaround?</p>
android
[4]
1,710,315
1,710,316
How to get Ellipse2d boundary points in java?
<p>I am using Ellipse2d in java i want to get all its boundary points or pixels. I already have done that if a point lies into an ellipse using <code>.contains()</code> method but is there anyway to get its boundary pixels.</p>
java
[1]
1,039,645
1,039,646
Implement a Back Button on Navigation Bar in iPhone App
<p>Just recently took over a project from my developer. I'm a noob to coding, but can figure things out pretty well. I'm just trying to implement Back button on one of my screens. It already has the navigation Bar, but no back button, just the title. </p> <p>Is there a guide on how to get this implemented? Any help would be great!</p> <p>Thanks!</p> <p>Update = Here is the code:</p> <pre><code>&lt;object class="IBUINavigationController" id="144954994"&gt; &lt;reference key="NSNextResponder" ref="191373211"/&gt; &lt;int key="NSvFlags"&gt;290&lt;/int&gt; &lt;string key="NSFrameSize"&gt;{320, 44}&lt;/string&gt; &lt;reference key="NSSuperview" ref="191373211"/&gt; &lt;bool key="IBUIOpaque"&gt;NO&lt;/bool&gt; &lt;bool key="IBUIClearsContextBeforeDrawing"&gt;NO&lt;/bool&gt; &lt;int key="IBUIBarStyle"&gt;2&lt;/int&gt; &lt;object class="NSArray" key="IBUIItems"&gt; &lt;bool key="EncodedWithXMLCoder"&gt;YES&lt;/bool&gt; &lt;object class="IBUINavigationController" id="445217273"&gt; &lt;reference key="IBUINavigationController" ref="144954994"/&gt; &lt;string key="IBUITitle"&gt;Answer Question&lt;/string&gt; &lt;/object&gt; &lt;/object&gt; &lt;/object&gt; </code></pre>
iphone
[8]
2,123,759
2,123,760
Does it make sense to define a static final variable in Java?
<p>Does this definition make sense ?</p> <pre><code>private static final String string = "Constant string"; </code></pre> <p>I'm a beginner and I don't understand the difference between final and static...</p>
java
[1]
5,411,131
5,411,132
How to insert tags with JavaScript?
<p>I would like to insert in an aspx page the following code:</p> <pre><code>&lt;/ul&gt; &lt;/li&gt; &lt;li class="xxx" style="width: 650px; float: left; list-style: none outside none;"&gt; &lt;ul class="yyy"&gt; </code></pre> <p>The problem is that, serverside, it raises a problem (sharepoint...)</p> <p>What I would like to do, is to insert this code client side with a javascript script. How can I insert it using javascript ? I don't think innerHTML could do this work as it would put it inside another tag (div for instance).</p> <p>Thank you !</p>
javascript
[3]
2,320,287
2,320,288
Disable mouse double click using class(es) with pure JavaScript
<p>I want to disable double click for some elements and the best way would be to use a special class for that. </p> <p>I found <a href="http://stackoverflow.com/questions/5241981/disable-mouse-double-click-using-javascript-or-jquery">this</a> simple and short jQuery solution that is exactly what I want, but I need pure JavaScript code.</p> <p>Possible? Please advice.</p>
javascript
[3]
5,711,485
5,711,486
Why does this compile on Ideone?
<p>Ok so I was messing around on <a href="http://ideone.com">Ideone</a> and accidentally submitted this piece of code, however to my surprise it actually compiled and ran outputting a value of 0, <a href="http://ideone.com/Lkbjo">here</a>.</p> <pre><code>#include &lt;iostream&gt; using namespace std; const int five( ) { const int i = 5; } int main() { cout &lt;&lt; five( ) &lt;&lt; endl; return 0; } </code></pre> <p>I then tried this in Visual Studio, and on <a href="http://codepad.org">Codepad</a> however both failed to compile because <code>five()</code> does not return a value, as one would expect. My question, is of course, why does this compile fine on <a href="http://ideone.com">Ideone</a> even though the code, to my understanding is wrong and shouldn't compile.</p>
c++
[6]
4,443,180
4,443,181
What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wat' talk for CodeMash 2012?
<p>The <em><a href="https://www.destroyallsoftware.com/talks/wat">'Wat' talk for CodeMash 2012</a></em> basically points out a few bizarre quirks with Ruby and JavaScript.</p> <p>I have made a JSFiddle of the results at <a href="http://jsfiddle.net/fe479/1/">http://jsfiddle.net/fe479/1/</a>.</p> <p>The behaviours specific to JavaScript (as I don't know Ruby) are listed below.</p> <p>I found in the JSFiddle that some of my results didn't correspond with those in the video, and I am not sure why. I am, however, curious to know how JavaScript is handling working behind the scenes in each case.</p> <pre><code>Empty Array + Empty Array [] + [] result: &lt;Empty String&gt; </code></pre> <p>I am quite curious about the <code>+</code> operator when used with arrays in JavaScript. This matches the video's result.</p> <pre><code>Empty Array + Object [] + {} result: [Object] </code></pre> <p>This matches the video's result. What's going on here? Why is this an object. What does the <code>+</code> operator do?</p> <pre><code>Object + Empty Array {} + [] result [Object] </code></pre> <p>This doesn't match the video. The video suggests that the result is 0, whereas I get [Object].</p> <pre><code>Object + Object {} + {} result: [Object][Object] </code></pre> <p>This doesn't match the video either, and how does outputting a variable result in two objects? Maybe my JSFiddle is wrong.</p> <pre><code>Array(16).join("wat" - 1) result: NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN </code></pre> <p>Doing wat + 1 results in <code>wat1wat1wat1wat1</code>...</p> <p>I suspect this is just straightforward behaviour that trying to subtract a number from a string results in NaN.</p>
javascript
[3]
3,635,018
3,635,019
Is there a function like the magic method __call() for global scope in php?
<p>If a call is made to an undefined method in a class, the magic method __call can intercept the call, so I could handle the situation as I see fit: <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods" rel="nofollow">http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods</a></p> <p>Is there any mechanism provided in php whereby I can do the same thing with functions in global scope. The point is best illustrated with code:</p> <pre><code> &lt;?php function return_some_array(){ $a = array(); //Do stuff to array return array(); } // Now i call the function like so: $give_me_array = return_some_array(); // But sometimes I want the array to not contain zeroes, nulls etc. // so I call: $give_me_array_filtered = return_some_array_filtered(); // But i haven't defined return_some_array_filtered() anywhere. // Instead I would like to do something like so: function __magic_call($function_name_passed_automatically){ preg_match('/(.*)_filtered$/', $function_name_passed_automatically, $matches); $function_name_that_i_defined_earlier_called_return_some_array = $matches[1]; if($matches){ $result = call_user_func($function_name_that_i_defined_earlier_called_return_some_array); $filtered = array_filter($result); return $filtered; } } //So now, I could call return_some_other_array_filtered() and it would work provided I had defined return_some_other_array(). //Or even Donkey_filtered() would work, provided I had defined Donkey() somewhere. ?&gt; </code></pre> <p>Is this at all possible?</p>
php
[2]
5,739,473
5,739,474
plot data from a txt file
<p>hi i want to plot this from txt file to a graph</p> <pre><code>13/7/2009 12:50:50 147425826 0 4716298 36645030 3757926 228230 13/7/2009 13:5:1 147517368 0 4717954 36687455 3761270 228375 13/7/2009 13:10:0 147550312 0 4718599 36701448 3762634 228437 </code></pre> <p>the date will be the x axis and the other columns will be the y axis(in Separate lines) </p> <p>thanks pol </p> <p>. .</p>
python
[7]
3,272,941
3,272,942
Scanning duplicate file names
<p>Imagine several folders such as</p> <pre><code>d:\myfolder\abc d:\myfolder\ard d:\myfolder\kjes ... </code></pre> <p>And in each folder, there are files such as </p> <pre><code>0023.txt, 0025.txt, 9932.txt in d:\myfolder\abc 2763.txt, 1872.txt, 0023.txt, 7623.txt in d:\myfolder\ard 2763.txt, 2873.txt, 0023.txt in d:\myfolder\kjes </code></pre> <p>So, there are three <code>0023.txt</code> files, and two <code>2763.txt</code> files.</p> <p>I want to create a file (say, <code>d:\myfolder\dup.txt</code>) which contains the following information:</p> <pre><code>0023 3 0025 1 9932 1 2763 2 1872 1 7623 1 2873 1 </code></pre> <p>How can I implement that in Python? Thanks.</p>
python
[7]
4,240,673
4,240,674
Easiest way to substitute characters in the string
<p>Suppose I have a main form named "<code>main_form</code>" and I have few more forms name like "<code>w_main_form</code>","<code>g_main_form</code>" etc etc which are based on "<code>main_form</code>" and they vary according to the '<code>category</code>'.</p> <p>Now is there any easy way to <em>generate</em> names of derived forms and how to call them.</p> <p>Suppose the category is "<code>iron</code>" then the form name should be "<code>w_main_form</code>" and when the category is "<code>coal</code>" the form name should be "<code>g_main_form</code>".</p>
python
[7]
5,910,157
5,910,158
where to post C++ related article?
<p>I usually write lots of C++ stuff at home just for me. Now I wrote something which I would like to publish as an article/blog. COdeProject is nice but its more in the style "here is some nice tool ready to use". My article has a more wider scope (sure some of the code might be even of use :) ). Its about compiler performance comparison, image processing algorithms and parallelization with openMP.</p> <p>Do you know any blog provider that provides code uploads and code highlighting within the text. I would prefer something blog like as it makes it easier to edit the non sense I wrote afterwards :).</p> <p>Thanks,</p> <p>Tobias </p>
c++
[6]
4,218,120
4,218,121
Object serialization and deserialization when class field changed
<p>I have a question about Object serialization and deserialization when class field changed.</p> <p>If an object with type MyClass</p> <pre><code>MyClass { String str1; LinkedList mylist = new LinkedList(); String str2; </code></pre> <p>}</p> <p>has been serialized to file.</p> <p>Then I changed the code which changes MyClass definition to</p> <pre><code>MyClass { String str1; LinkedList mylist = new LinkedList(); Map myMap = new HashMap(); </code></pre> <p>}</p> <p>After that, I deserialize the object from file to a MyClass object using the changed code. Is it OK? Will there any exception thrown during deserialization? I want to reuse the old object. I.e. I want the de-serializing can be done. So I hope there is no exception thrown.</p> <p>Thanks.</p>
java
[1]
223,075
223,076
how to repeat the animation in jquery
<p>i am playing with the animate of jquery here's what i have</p> <pre><code> $('p:first').animate({ 'paddingLeft':'+=300px','opacity':'-=1' },10000,'swing',function(){ $(this).fadeOut('fast',function(){ $('&lt;p&gt;test&lt;/p&gt;').insertBefore($('p#2nd')); }); }); </code></pre> <p>now , my question is, how to repeat the same animate action on the inserterd <p> after the fadeOut effect ?, or, there's a better way to do this ?</p>
jquery
[5]
413,885
413,886
Get plain text from PDF file
<p>I know that there was a few questions about this topic.</p> <p>I need an framework / script / solution to <strong>get plain text from PDF file by php</strong>.</p> <p>Does exist a solution how to get plain text from PDF file?</p> <p>(And yes, I searched for this hours. This is the last chance).</p>
php
[2]
470,676
470,677
find the frequency of elements in a java array
<p>I have an int array:</p> <pre><code>{1,2,4,2,3,5,6,4,3} </code></pre> <p>How can I find frequencies of array elements like <code>1=1,2=2,3=2,4=4..</code>. I need a class which I can pass my array to and return an array which gives the count of array elements. ex:- <code>array{[0]=1,[1]=2,[2]=3,[3]=4..}</code> (for above example array); </p>
java
[1]
4,736,889
4,736,890
Want to optimize my android app performance
<p>I am developing an android app with an edittext which enables users to search songs. I want to incorporate an instant search in it. I mean I want the search results in my listview of my app to appear instantly as the user types in the edittext box in order of most visited songs . I am using a DB of songs containing field Songhit for it but I am afraid it may be too slow to process database each time a character is typed. Besides I want my edittext listner to slow down and wait till the user completes his text I am using <code>System.currentTimeMillis()</code> as marker and wait for .5 seconds but it's not waiting. I am new to android and dont know wheather it will work or not. I Need suggestion from someone having some experience with android app programming.</p> <p>My code: Edittext listener: </p> <pre><code>public void onTextChanged(CharSequence s, int start, int before, int count) { currentTime=System.currentTimeMillis(); if(currentTime - lastTimeTextChanged &gt; 500) { // do smthing serach song } lastTimeTextChanged = currentTime; } </code></pre> <p>It looks ok but it didn't worked... I want to trigger a search only when user stopped typing for say .5 sec. I was wondering if I could overrise setTextFilter() method please help with this as well as performace optimization.</p>
android
[4]
3,763,920
3,763,921
Customize Status/Action bar
<p>I'm in need of customizing the default status/action bar into my custom status/action bar, where I can list only display notification and hide settings up on pull down status bar need to hide default settings menu. In simple I override an default home screen into custom home screen hide recent app activity along with user not to view device settings.Let me know your valuable suggestions to achieve my need.</p> <p>Thanks in advance.</p>
android
[4]
3,917,535
3,917,536
Random number generation in c++ using GMP
<p>In java random number can get like</p> <pre><code>protected final static Random RANDOM = new Random(System.currentTimeMillis()); </code></pre> <p>In c++ using GMP Library how it possible to generate random number?</p> <p>I used code like</p> <pre><code> gmp_randstate_t s; unsigned long seed; seed = time(NULL); gmp_randinit_default(s); gmp_randseed_ui(s, seed); mpz_class ran; gmp_randclass rr(s); ran =rr.get_z_bits(125); long int random=ran.get_ui(); </code></pre> <p>But i dont get random number.</p> <p>Please help me.</p>
c++
[6]
2,182,334
2,182,335
categorize uploaded files
<p>I have a webapplication for uploading and showing files(Image and video).The administrator can upload files and the users can view this files.Now i am inserting the details of file to the sqlserver and populating links for the corresponding file in the user's form.There may have images and videos.</p> <blockquote> <p>I want to categorize the image and video files;ie ,i want to show files in two separate folders(Images and Videos)</p> </blockquote> <p>.This Categorizing also in sql(there should have a category table and it should be related with fileM table.</p> <p>If anyone can help me please.. thank you</p>
asp.net
[9]
5,896,043
5,896,044
determine height and width of dynamic html element by jquery
<p>suppose i have one js variable and my html data is stored into it like</p> <pre><code>var data = '&lt;div id="tst"&gt;here will be my othere html&lt;/div&gt;' </code></pre> <p>in this case can i determine that what would be height &amp; width of div tst using jquery?</p> <p>one guy give me solution like</p> <pre><code>var $test = $(data).appendTo('body'); var size; window.setTimeout(function(){ size = { height: $test.height(), width: $test.width() }; $test.remove(); }); </code></pre> <p>but the above code looks bit complicated. if anyone know easy solution then please give me a sample code to do so. thanks</p>
jquery
[5]
5,572,040
5,572,041
How do i replicate 10060 ( WSAETIMEDOUT ) error in c++ socket programming?
<p>In Socket programming, i am getting an error 10060 while sending data using <strong>WSASend</strong>, Can anyone help to replicate the error in code.This error occurs after 3 or more hours of continuous sending of data.</p>
c++
[6]
1,630,432
1,630,433
I'd like my private virtuals now, please
<p>What is the reasoning behind disallowing private virtual functions? </p> <p>Empty private virtuals would have enabled low friction pure customization points.</p> <p>Abstract functions have high friction and protected virtuals cause confusion and noise.</p> <p><strong>Some further explanation:</strong></p> <p>The Non Virtual Interface pattern separates the interface responsibility (public) from providing customisation points (virtual).</p> <p>When using NVI in class design I have to make my virtuals protected. Having the option to make them private makes the intent even stronger. It means that descendants can <em>only</em> provide customisation and there is no confusion over whether to call the base or not, in fact it is prohibited. There must have been a good reason to explicitly disallow it (Diagnostic: "Private method cannot be polymorphic"). </p>
c#
[0]
1,885,155
1,885,156
Prog error: for replacing spaces with "%20"
<p>below is the prog i am compiling for replacing spaces with "%20" but when I run it output window shows blank and a message "arrays5.exe has occurred a prob"</p> <pre><code>#include &lt;iostream&gt; #include&lt;cstring&gt; using namespace std; void method(char str[], int len) //replaces spaces with "%20" { int spaces, newlen,i; for (i=0;i&lt;len;i++) if(str[i]==' ') spaces++; newlen=len+spaces*2; str[newlen]=0; for (i=len-1;i&gt;=0;i--) { if(str[i]==' ') { str[newlen-1]='0'; str[newlen-2]='2'; str[newlen-3]='%'; newlen=newlen-3; } else { str[newlen-1]=str[i]; newlen=newlen-1; } } } int main() { char str[20]="sa h "; method(str,5); cout &lt;&lt;str&lt;&lt;endl; return 0; } </code></pre> <p>Please help me finding the error.Thanks</p>
c++
[6]
4,448,082
4,448,083
Android link in dialog
<p>How can I add a link to a dialog message?</p> <p>I tried the following code, but the link doesn't do anything on onclick:</p> <pre><code>builder.setMessage(Html.fromHtml( "Click on the " + "&lt;a href=\"http:\\www.google.com\"&gt;link&lt;/a&gt; " + "to download.")); </code></pre> <p>It didn't work for <code>//www.google.com</code> either.</p>
android
[4]
501,566
501,567
Android Camera App-Intents
<p>I want to develop an Android app which Captures an image on click of button and then directs me to a page where I can write the name of image and have an option to save or discard it. I have made 2 classes one(Photo.java) for capturing image and other(Capture.java) for renaming and saving image. I don't know how to call Capture.java from Photo.java Here is a part of my code. How do I call Capture.java from here.</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); this.imageView = (ImageView)this.findViewById(R.id.imageView1); Button photoButton = (Button) this.findViewById(R.id.button1); photoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, CAMERA_REQUEST); } }); } </code></pre>
android
[4]
2,399,785
2,399,786
Relationship between layout() and onLayout()
<p>I've a custom linearlayout which calls <code>layout()</code> on each child in its <code>onLayout()</code> function. My custom child (extended from <code>MapView</code>) receives in its <code>onLayout()</code> function completely different numbers than I passed in the layout function.</p> <p>What's the relation between both?</p>
android
[4]
1,017,565
1,017,566
Implement onScrollChanged Event
<p>I have an <code>AbsoluteLayout</code> xml:</p> <pre><code>&lt;AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/MeasureAbsLayout" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ImageView android:id="@+id/MeasureImageView" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;/ImageView&gt; &lt;RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;Button android:text="Previous" android:layout_height="wrap_content" android:id="@+id/MeasurePrev" android:layout_alignParentBottom="true" android:layout_width="wrap_content"&gt; &lt;/Button&gt; &lt;Button android:text="Result" android:layout_height="wrap_content" android:id="@+id/MeasureResult" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_width="wrap_content"&gt; &lt;/Button&gt; &lt;/RelativeLayout&gt; &lt;/AbsoluteLayout&gt; </code></pre> <p>I want to implement <code>AbsoluteLayout</code>'s <code>onScrollChanged</code> in my <code>Activity</code> class.</p> <p>How can I implement this?</p>
android
[4]
946,089
946,090
What is special about android:inputType="textPersonName" for EditText
<p>I tried</p> <pre><code> &lt;EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:inputType="textPersonName" &gt; </code></pre> <p>I realize it can accept any characters. So, what is special having <code>android:inputType="textPersonName"</code>, compared to not having it?</p>
android
[4]
1,035,031
1,035,032
LNK 2019 C++ Error
<p>I have a NewTree class that's been defined in NewTree.h. When I make a new instance of NewTree in my main method, it throws an LNK 2019 error.</p> <p>NewTree.h:</p> <pre><code>template &lt;class T&gt; class NewTree { public: treeNode&lt;T&gt; *current; treeNode&lt;T&gt; *root; NewTree(); ~NewTree(); bool insert(T *data, treeNode&lt;T&gt; *parent); treeNode&lt;T&gt; search(T *target); }; </code></pre> <p>Line to make new instance of NewTree:</p> <pre><code>NewTree&lt;xml_node&lt;&gt;&gt; *tree = new NewTree&lt;xml_node&lt;&gt;&gt;(); </code></pre> <p>Why is Visual Studio giving me an LNK error?</p> <p>Full Error: </p> <pre><code>main.obj : error LNK2019: unresolved external symbol "public: __thiscall NewTree&lt;class rapidxml::xml_node&lt;char&gt; &gt;::NewTree&lt;class rapidxml::xml_node&lt;char&gt; &gt;(void)" (??0?$NewTree@V?$xml_node@D@rapidxml@@@@QAE@XZ) referenced in function _main </code></pre>
c++
[6]
5,089,398
5,089,399
Accessing the associated string of a stringstream object
<p>I am trying to access the associated string of a stringstream object and keep iterators to it, but am not able to know whether this would be safe. Here is the code :</p> <pre><code> stringstream HTMLss; // string stream of HTML document // ... (load up HTMLss with HTML) const string &amp; HTMLstr = HTMLss.str(); // grab reference to associated string string::const_iterator begin,end; begin = HTMLstr.begin(); // grab iterators to that string as well end = HTMLstr.end(); boost::match_results&lt;std::string::const_iterator&gt; matches; // do some processing, updating the iterators along the way while( boost::regex_search(begin, end, matches, metaexp) ) { string key( matches[1].first, matches[1].second ); string raw_val( matches[2].first, matches[2].second ); // ... some processing which does NOT manipulate HTMLss stringstream in any way begin = matches[2].second; // updating the iterator } </code></pre> <p>My question is -- is the above safe to do ? Can it be assumed that one can keep/update iterators that point to the associated string of the stringstream object, and that the behavior is going to be correct? There are no other calls to any string stream function. How can one know whether this is safe or not? </p>
c++
[6]
4,783,293
4,783,294
Adding my first view to a window based application
<p>I'm beginner with iPhone and want to know how to add a view in a window based application.</p> <p>I crate the application, then I added the ViewControler+XIB to my project. I include the .h file in both AppDelegate-Files.</p> <p>Then I create a object of the View "StartViewController" with</p> <pre><code>StartViewController *startView; </code></pre> <p>and add the property in the AppDelegate.h file:</p> <pre><code>@property (nonatomic, retain) StartViewController *startView; </code></pre> <p>In the AppDelegate.m I add:</p> <pre><code>@synthessize startViewController </code></pre> <p>and in the application method:</p> <pre><code>[window addSubview:startViewController.view]; </code></pre> <p>But it doesn't appear when I start the application, what I forgot?</p>
iphone
[8]
224,065
224,066
PHP && switch and case statement
<p>I'm not to keen on PHP and as such don't spend much time learning the Syntax, I was just wondering if this switch and case operator would be grammatically correct, speaking in PHP terms.</p> <pre><code>case "msg" &amp;&amp; "username": /* enter the functions here */ break; </code></pre>
php
[2]
5,796,781
5,796,782
php string replace/insert
<pre><code>$example="this is an example of [link](http://webpage.com)" </code></pre> <p>this is an example of <a href="http://webpage.com" rel="nofollow">link</a></p> <p>how to do make this happen using php functions?</p> <p>many thanks</p>
php
[2]
4,254,239
4,254,240
Dropdownlist Error
<p>In .net win form application. I load dropdownlist like this.</p> <pre><code> private void loadChannelCombo() { string sql = "select channelID,channelName from rechannel where isActive=1 order by channelName"; DataTable dt = DBHandler.GetData(sql); ddlChannel.DataSource = dt; ddlChannel.DisplayMember = "channelName"; ddlChannel.ValueMember = "channelID"; } </code></pre> <p>now I want to do same in .net web aaplication. When I copy paste that code error occurred like <img src="http://i.stack.imgur.com/70kUM.png" alt="enter image description here"> </p> <p>I want to do same as in web application. How can I Do that????</p>
c#
[0]
676,584
676,585
Initializing collections that contain nested collections
<p>How do I initialize a collection of 'Quote' objects based on the class shown below where 'Quote' would contain a collection of at least 5 'Rate' objects.</p> <pre><code> List&lt;Quote&gt; quotes = new List&lt;Quote&gt; {new Quote { Id = 1, (need 5 Rate objects in here) } } public class Quote { public int Id { get; set; } public List&lt;Rate&gt; Rates { get; set; } } public class Rate { public int Id { get; set; } public string AccommodationType { get; set; } public decimal Price { get; set; } } </code></pre>
c#
[0]
404,452
404,453
datetime comparison
<p>The following code must be wrong (the relevant date time rows in the mysql table are 0000-00-00 00:00:00) as the if statement is not being read as true. Just wondered if i am making a blatant error?</p> <p>Never done a datetime like this before:</p> <pre><code>if($datetimecheck != "0000-00-00 00:00:00"); { //do something } </code></pre> <p>The "do something" is not happening. I've succesfully compared other (non-zero) date time formats. What's the best way forward? Many thanks in advance.</p>
php
[2]
137,472
137,473
MFMailComposeViewController adds null Content-Id
<p>This is my first post to the group so please be kind :)</p> <p>I am sending a couple of audio attachments from my app as follows:</p> <pre><code> MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; picker.modalPresentationStyle = UIModalPresentationCurrentContext; [picker setSubject:@"Test message"]; NSArray *toRecipients = [NSArray arrayWithObject:@"foo@bar.com"]; [picker setToRecipients:toRecipients]; // multiple attachments are made as follows NSData *myData = [NSData dataWithContentsOfFile:filePath]; [picker addAttachmentData:myData mimeType:@"audio/x-caf" fileName:fileName]; [picker setMessageBody:@"test message" isHTML:NO]; [controller presentModalViewController:picker animated:YES]; </code></pre> <p>A mailComposeController method takes care of dismissing the modal view.</p> <p>Unfortunately, when the message is delivered the mime headers for the attachments land up having the Content-Id set to null. Here is what it looks like:</p> <pre><code> Content-Type: audio/x-caf; name="audio_1.caf" Content-Transfer-Encoding: base64 Content-Id: &lt;(null)&gt; Content-Disposition: attachment; filename="audio_1.caf" </code></pre> <p>If I manually delete the Content-Id field and reload the message in my Mac Mail program (Mail Version 3.6) the attachments show up correctly. In other words, I don't really need/want theContent-Id to be inserted in the mime header.</p> <p>Also, its worth mentioning that for debugging purposes if I set the mime type to "image/jpeg" the mime header does get a valid Content-Id string. All my attachments show up in Mail. As is to be expected, in that case the attachments don't open correctly on the Mac or iPhone.</p> <p>Any help would be greatly appreciated.</p> <p>thanks, apurva</p>
iphone
[8]
696,232
696,233
jquery maphilight plugin - disable an area and prevent click
<p>I'm making a clickable map of post (zip) codes and want certain <code>&lt;area&gt;</code>s to be disabled for certain reasons. I need those particular areas to be, by default, filled with a certain colour (to indicate that they are disabled) and for the click on those areas to do nothing. The other areas will behave as normal, in my case with them being highlighted on click and then unhighlighted if clicked again.</p> <p>I can add the following to the <code>&lt;area&gt;</code>s I want disabled, which styles them correctly on load:</p> <pre><code>data-maphilight='{"stroke":false,"fillColor":"cccccc","fillOpacity":0.9,"alwaysOn":true}' </code></pre> <p>but they can still be clicked by the user which removes the grey overlay. This is what I want to prevent.</p> <p>Thanks for any pointers.</p>
jquery
[5]
2,537,117
2,537,118
javascript create url from form elements handling checkboxes
<p>So I had been using this generic code to create a URL from the form elements</p> <pre><code>function submiturl() { url="Search.do?call=JS"; var elem = document.getElementById('searchInput').elements; for(var i = 0; i &lt; elem.length; i++) { url = url + "&amp;" + escape(elem[i].name) + "=" + escape(elem[i].value); } url = url.substring(0,(url.length-1)); alert(url); } </code></pre> <p>however it does not handle checkboxes properly - I only want to add to the URL if the checkboxes are checked. So if you had this html</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form name="searchInput" id ="searchInput"&gt; &lt;input name="first" type="checkbox" value="123"/&gt;One two three &lt;input name="second" type="checkbox" value="456"/&gt;Four five six &lt;button type="button" onClick="submiturl();"&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>it will create the URL using the value for both checkboxes regardless if they were checked or not.</p> <p>So how can I modify my javascript to check if it is a checkbox and is checked?</p> <p>thanks!</p>
javascript
[3]
148,173
148,174
How is it that if statements check types?
<p>I come from a C# background and need to become more familiar with JS. I'm reading a book and in this example:</p> <pre><code>var as = document.getElementsByTagName('a'); for(var i=0;i&lt;as.length;i++){ t=as[i].className; //Check if a link has a class and if the class is the right one if(t &amp;&amp; t.toString().indexOf(popupClass) != -1) { //... } </code></pre> <p>Part of the <code>if</code> statement doesn't make sense. What is <code>if(t)</code>? I am used to if statements checking boolean values, but <code>t</code> is a string, right? </p>
javascript
[3]
280,601
280,602
jQuery watermark StackOverflow like?
<p>I'm trying to implement something like StackOverflow's watermark functionality.</p> <p>I'm using <a href="http://code.google.com/p/jquery-watermark/" rel="nofollow">jquery-watermark</a> for this. The problem I'm having is namely that the watermark text disappears as the input element gains focus, which doesn't happen here in SO (and I don't want it in my implementation either)</p> <p>Is there some quick fix I could do for this, or perhaps a more SO-like watermarking library?</p>
javascript
[3]