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,064,625
3,064,626
Cloning objects of inner classes
<p>I have written a class A such as following</p> <pre><code>class A &lt;E&gt; { // class A has objects of E int x; private B&lt;T&gt; next // a object of inner class class B&lt;T&gt; { // an inner class having objects of type T T[] elements = (T[]) Object[x]; // has other stuff including many objects } public A&lt;E&gt; func ( B&lt;E&gt; val ){ Here I want to clone the value of val so that I can do different operations on other } </code></pre> <p>The problem comes that I wish to write <code>B&lt;E&gt; Temp = B&lt;E&gt;Value.clone()</code> where Value is defined in the code.</p> <p>but it says that clone is not visible.</p> <p>What should I do to make it so....</p> <p>Thanks a lot...</p>
java
[1]
231,826
231,827
Running multiple commands simultaneously from python
<p>I want to run three commands at the same time from python. The command format is query.pl -args</p> <p>Currently I am doing </p> <pre><code>os.system("query.pl -results '10000' -serverName 'server1' &gt;&gt; log1.txt") os.system("query.pl -results '10000' -serverName 'server2' &gt;&gt; log2.txt") os.system("query.pl -results '10000' -serverName 'server3' &gt;&gt; log3.txt") </code></pre> <p>I want to query all three servers at the same time but in this case, each command executes only after the last one has finished. How can I make them simultaneous? I was thinking of using '&amp;' at the end but I want the next part of the code to be run only when all three command finish</p>
python
[7]
1,799,126
1,799,127
How can I get the addition object for integers?
<p>Is there any way in Python to get the addition object (operator +) for integers in Python and store it somewhere? </p>
python
[7]
5,153,294
5,153,295
Best approach avoid naming conflicts for javascript functions in separate .js files?
<p>Is there a preferred approach to isolating functions in a .js file from potential conflicts with other .js files on a page due to similar names?</p> <p>For example if you have a function</p> <pre><code>function AddTag(){} </code></pre> <p>in Core.js and then there is a </p> <pre><code>function AddTag(){} </code></pre> <p>in Orders.js they would conflict. How would you best structure your .js files and what naming conventions would you use to isolate them?</p> <p>Thanks</p>
javascript
[3]
1,643,068
1,643,069
Javascript JSON.parse or directly access
<p>When we can read a property directly from string:</p> <pre><code>var data = {"id":1,"name":"abc","address":{"streetName":"cde","streetId":2}}; console.log(data.address.streetName); // cde </code></pre> <p>Why do people use <code>JSON.parse</code>:</p> <pre><code>var obj = JSON.parse(data); console.log(obj.address.streetName); // cde </code></pre>
javascript
[3]
5,784,006
5,784,007
how can i change the image of Imageview[android]
<p>How can i change the image through Image view </p> <p>plz help</p> <p>thanks</p>
android
[4]
2,595,554
2,595,555
match a list of words in a line using regex in python
<p>I am looking for an expression to match strings against a list of words like <code>["xxx", "yyy", "zzz"]</code>. The strings need to contain all three words but they do not need to be in the same order. </p> <p>E.g., the following strings should be matched:</p> <pre><code>'"yyy" string of words and than “zzz" string of words “xxx"' </code></pre> <p>or </p> <pre><code>'string of words “yyy””xxx””zzz” string of words' </code></pre>
python
[7]
729,002
729,003
how to get back to Activity from Activity called by startActivityForResult in the TabWidget?
<p>There is tabwidget as MainActivity with tab1 and tab2. And, Activity1 is set to tab1as contentview, Activity2 is set to tab2.</p> <p>User need to input information to use tab2 page. So i want to call an Activity by startActivityForResult() . </p> <p>My question is 'in this situation, how to get back to tab2 on tabwidget?'</p> <p>Just finish()?</p>
android
[4]
1,715,148
1,715,149
PHP - Need help with some string functions
<p>I am trying to write a script to pull schedule data out of a database used at work.</p> <p>The employees working times are stored daily as a string like this</p> <pre><code>000000000000000000000000000000001111111111111111111111111111111111111111000000000000000000000000 </code></pre> <p>Every character represents 15 min. The first character space is 12:00 AM second is 12:15 AM and so on....</p> <p>The example above the employee works 8:00 - 6:00.</p> <p>I created an array like this for every character position.</p> <pre><code>$time[0] = "12:00"; $time[1] = "12:15"; $time[2] = "12:30"; $time[3] = "12:45"; $time[4] = "1:00"; $time[5] = "1:15"; $time[6] = "1:30"; $time[7] = "1:45"; $time[8] = "2:00"; </code></pre> <p>and I can display the employees time like this </p> <pre><code>echo $time[strpos($string, '1')] . "-" . $time[strpos($string, '0', strpos($string, '1'))]; </code></pre> <p>but I cannot figure out how to make this work if someone has a split shift, such as 9:30 - 2:00 / 4:00 - 7:00</p> <pre><code>000000000000000000000000000000000000001111111111111111110000000011111111111110000000000000000000 </code></pre> <p>Sorry if my English is poor.</p> <p>Thanks</p>
php
[2]
3,842,155
3,842,156
python and %s
<p>What does %s mean in python? And does this bit of code translate to?</p> <p>for instance... </p> <pre><code> if len(sys.argv) &lt; 2: sys.exit('Usage: %s database-name' % sys.argv[0]) if not os.path.exists(sys.argv[1]): sys.exit('ERROR: Database %s was not found!' % sys.argv[1]) </code></pre> <p>Thanks</p>
python
[7]
3,354,117
3,354,118
Determine HTML page that called a function in an external js file
<p>Is it possible to determine this at runtime?</p> <p>contents of external.js:</p> <pre><code>function x() { //can i get the path/name of the html file that included this js file? //which is test.html } </code></pre> <p>contents of test.html</p> <p>script src="external.js"</p>
javascript
[3]
2,933,236
2,933,237
Is it possible to make a login programitically to twitter in android
<p>I want to make a login to twitter by myself programitically. Is it possible to make a login programitically to twitter by importing their jar files.</p> <p>Please help me.</p> <p>Thanks in advance .</p>
android
[4]
169,751
169,752
Python - Print a string a certain number of times
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6293421/python-printing-multiple-times">Python, Printing multiple times,</a> </p> </blockquote> <p>I'd like to know how to print a string such as "String" 500 hundred times?</p>
python
[7]
3,304,402
3,304,403
Apply fadein effect to tooltip?
<p>I have this code, which shows the tooltip within a box with the id of "tooltip-container" - currently it just pops in...how can I make it fade nicely and fade out on roll-off? </p> <p>Current code:</p> <pre><code>$(document).ready(function(){ $('.tippytrip').hover(function(){ var offset = $(this).offset(); console.log(offset) var width = $(this).outerWidth(); var tooltipId = $(this).attr("rel"); $('#tooltip-container').empty().load('tooltips.html ' + tooltipId).show(); $('#tooltip-container').css({top:offset.top, left:offset.left + width + 10}).show(); }, function(){ $('#tooltip-container').hide(); }); }); </code></pre>
jquery
[5]
1,687,105
1,687,106
Returning the value that for statement prints
<p>I would like to return all the information as output that the for statement prints.</p> <p>For instance:</p> <pre><code>public static int countNumbers(int x) { for (int i = 1; i &lt;= x; i++) { System.out.println(i); } return SOMETHING; // This something should be the values for statements prints. // For example, countNumbers(5) returns 12345. } </code></pre> <p>So when I call the method somewhere else, I will get the output.</p> <p>So:</p> <pre><code>int output = countNumbers(3); //output = 123; </code></pre> <p>How can this be done?</p>
java
[1]
4,471,111
4,471,112
Freezing Android APK version for older SDKs
<p>I understand how multiple APKs work on Google Play, but so far I've supported a single APK for V7 (2.1) and up. I'd like to start using Android 3.x-4.x+ features that could be more difficult to make backwards compatible, and I wouldn't mind not having to build in that growing compatibility library. But I still want to make the product available to Android 2.x users, even though that version will be "frozen" and not receive future product enhancements.</p> <p>So how should this best be done? I could use the basic multiple-APK approach, but then users of 2.x devices might see things in the product description that are not in the APK that they would be installing. But would the version number show up correctly based on the APK that matches the user's device?</p> <p>Any other ideas from someone who's done this?</p>
android
[4]
5,053,714
5,053,715
comma operator and comma seperator in c++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3128346/when-all-does-comma-operator-not-act-as-a-comma-operator">When all does comma operator not act as a comma operator?</a> </p> </blockquote> <p>when does comma(,) behave as operator and when does it behave as separator?And what are the consequences of it.If possible please give small examples too for both.</p>
c++
[6]
529,702
529,703
Reducing similar commands
<p>How can I reduce the amount of similar commands into a loop?</p> <p>Something like</p> <pre>pictureBox7.BackColor = Color.FromArgb(187, 187, 187); pictureBox9.BackColor = Color.FromArgb(187, 187, 187); pictureBox10.BackColor = Color.FromArgb(187, 187, 187); pictureBox11.BackColor = Color.FromArgb(187, 187, 187); pictureBox12.BackColor = Color.FromArgb(187, 187, 187); pictureBox13.BackColor = Color.FromArgb(187, 187, 187);</pre>
c#
[0]
1,098,303
1,098,304
If module `example` contains both function `run` and submodule `run`, can I count on `from example import run` to always import the former?
<p>If I have a Python module implemented as a directory (i.e. package) that has both a top level function <code>run</code> and a submodule <code>run</code>, can I count on <code>from example import run</code> to always import the function? Based on my tests that is the case at least with Python 2.6 and Jython 2.5 on Linux, but can I count on this generally? I tried to search information about the import priorities but couldn't find anything.</p> <p>Background:</p> <p>I have a pretty large package that people generally run as a tool from the command line but also sometimes use programmatically. I would like to have simple entry points for both usages and consider to implement them like this:</p> <p><code>example/__init__.py</code>:</p> <pre><code>def run(*args): print args # real application code belongs here </code></pre> <p><code>example/run.py</code>:</p> <pre><code>import sys from example import run run(*sys.argv[1:]) </code></pre> <p>The first entry point allows users to access the module from Python like this:</p> <pre><code>from example import run run(args) </code></pre> <p>The latter entry point allows users to execute the module from the command line using both of the approaches below:</p> <pre><code>python -m example.run args python path/to/example/run.py args </code></pre> <p>This both works great and covers everything I need. Before taking this into real use, I would like to know is this a sound approach that I can expect to work with all Python implementations on all operating systems.</p>
python
[7]
1,373,985
1,373,986
Table View Controller
<p>can u explain Table View Controller with sample code </p>
iphone
[8]
4,494,162
4,494,163
regular expression sequence numbers 1 to 15
<p>I need a way to use a regular expression to validate that numbers in a string are consecutive, from 0 to 9. For example:</p> <ul> <li>12345</li> <li>1234567890</li> <li>2345678</li> <li>456789</li> </ul> <p>The maximum length of the string should be 5 characters.</p>
javascript
[3]
2,287,069
2,287,070
Seeing the actual error behind ‘An unexpected error has occurred’ in Sharepoint 2010
<p>In MOSS 2007, we could update the tag's callstack attribute to true and then customerrors mode to "Off" to see the actual error behind the 'An unexpected error has occurred' message. Does it apply on SharePoint 2010 as well ? I tried it but I get the following error:<BR><BR></p> <p>Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.</p> <p>Details: To enable the details of this specific error message to be viewable on the local server machine, please create a tag within a "web.config" configuration file located in the root direc...</p>
asp.net
[9]
523,781
523,782
No new lines with custom text?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6756975/draw-multi-line-text-to-canvas">Draw multi-line text to Canvas</a> </p> </blockquote> <p>I'm trying to draw text to a canvas using a paint, and I've uploaded my own text tff file, and it works, but when I try to do a new line, either via '\n' or The System property, its still all on the same line, but there is a box where the line should break. What gives? </p>
java
[1]
4,428,081
4,428,082
Android - Avoiding an activity to destroy, just stopping or pausing it when pushing the back button
<p>I would like to pausing or putting the application on background when pressing the back button, I don't want the application to go through the destroy state. Things are when I override onKeyDown and when I force to pause or stop the application by using onPause, I have some issuees with the wakelock and application crash, but when I press home button I go through onPause method and I have no exception, it's weird!! </p>
android
[4]
284,220
284,221
ImageView getting chopped off in relative layout, while performing transalate animation
<p>from many days i have stuck up in the following problem. </p> <p>I am translating an imageView which is present in child relative layout from bottom to top. Translate animation is working fine, but the problem is "An imageView <code>android:id="@+id/img_weasel"</code> gets CHOPPED OFF" when it crosses its relative layout <code>android:id="@+id/rl_wood"</code>. Working on API level 8. </p> <p>And its xml snippet is as follows:</p> <pre><code>&lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;ImageView android:id="@+id/ivForAll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/ibMoreAppsButton" android:layout_alignParentRight="true" android:layout_marginBottom="30dp" / &lt;RelativeLayout android:id="@+id/rl_wood" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="200dp" &gt; &lt;ImageView android:id="@+id/img_weasel" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p></p> <p>Please help in finding the solution, thanks in advance.</p>
android
[4]
386,618
386,619
Is an UIApplication object, UIWindow object, UIView object or any UIView subclass an "Responder object"?
<p>Am I right with my understanding, that an UIApplication object, UIWindow object, UIView object or any UIView subclass is an "Responder object"?</p> <p>Here they say:</p> <blockquote> <p>Responder objects in an application include instances of UIApplication, UIWindow, UIView, and all UIView subclasses.</p> </blockquote> <p>My english is not so well to understand what they mean by the "include". So they may "include" an Responder object, or the big group of famous Responder objects "includes" these classes (or in other words: They belong to this group, called "Responder objects"). Any idea what this means really?</p>
iphone
[8]
4,930,031
4,930,032
audio pitch change in android
<p>I am developing a sound related application. I am trying to change the audio sound in to completely different like robot sound or make the audio echo. I tried with soundpool , but no any idea, anyone knows how to achieve that? i need only a basic idea to achieve this, please help. many thanks.</p>
android
[4]
1,107,345
1,107,346
How to do multiline strings?
<p>I am wondering how can you do multi line strings without the concat sign(+)</p> <p>I tried this</p> <pre><code> string a = String.Format(@"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz {0}xxxxxxx", "GGG"); string b = @"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz xxxxxxx"; string c = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + "xxxxxxx"; Console.WriteLine(a); Console.WriteLine(b); Console.WriteLine(c); </code></pre> <p>This works but the first 2 render alot of whitespace. Is there away to write multi lines without the concat sign and ignore end whitespace without using something like replace after the string is rendered?</p> <p><strong>Edit</strong></p> <blockquote> <p>using System; using System.Collections.Generic; using System.Linq; using System.Text;</p> <p>namespace ConsoleApplication2 { public class Test {</p> <pre><code> public Test() { } public void MyMethod() { string someLongString = "On top of an eager overhead weds a </code></pre> <p>pressed vat. How does a chance cage the contract? The glance surprises the radical wild."; }</p> <pre><code>} } </code></pre> </blockquote> <p>Look how it goes right though my formating of the braces and is sticking out(sorry kinda hard to show on stack but it is sticking way to far out).</p> <p>Sad thing is notepad++ does a better job and when it wraps it goes right under the variable.</p>
c#
[0]
3,116,419
3,116,420
Android title bar removal
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2445999/what-do-i-have-to-add-to-a-layout-to-hide-the-titlebar">What do I have to add to a layout to hide the titlebar?</a> </p> </blockquote> <p>How do I remove the title below the battery, time bar from showing up?</p> <p>Not sure the terminology for that bar, but on this picture it is the "Nested XML Layout" bar:</p> <p><img src="http://ezmobile.files.wordpress.com/2009/02/020209-2053-isthereanyw72.png" alt=""></p>
android
[4]
4,847,280
4,847,281
store each value of foreach loop into string array
<p>how I need to store each values of a foreach loop into an string array.</p> <pre><code>string [] elements = new string [3]; foreach(xmlnode anode in somecollection) { //here i need to set the string array for each element of SomeCollection. } </code></pre> <p>thanks </p>
c#
[0]
4,738,170
4,738,171
Putting a Background Image behind TabWidget
<p>I have a custom TabView, what I wanna do is to put a background image behind my Tabs. So the background image will behave like a frame for the Tabs. The tabs will stay in the middle of the background. With the code I have below, my TabWidget is just covering the background image.</p> <p>How am I able to achieve that?</p> <p>Here's my xml layout for my TabView</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;LinearLayout android:id="@+id/tab_background" android:layout_width="320dp" android:layout_height="45.33dp" android:orientation="vertical" android:background="@drawable/tab_bg" &gt; &lt;HorizontalScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:fillViewport="true" android:layout_marginTop="5.33dp" android:layout_marginBottom="5.33dp" android:scrollbars="none" &gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/TabWidget&gt; &lt;/HorizontalScrollView&gt; &lt;/LinearLayout&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginTop="-2dp" &gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre>
android
[4]
3,244,912
3,244,913
How to impersonate a user for a short period to access a page/file?
<p>I'm using FormsAuthentication to allow users to login. However I have a Excel file that gets generated in memory by one of my pages, for example when they go to:</p> <p><a href="http://www.mywebsite.com/report?date=050809" rel="nofollow">http://www.mywebsite.com/report?date=050809</a></p> <p>This generates an Excel report for that date given, in a memory stream and passes it back to the user to download as long as they are logged in. But what I need to do is allow them to access that URL and the Excel report from that link, without having to login manually, is there a quick and dirty way to login them in (impersonate?) for a very short period to get the file and then expire their cookie after a few seconds?</p> <p>(I'm doing this through asp.net mvc by the way, but it should make no difference I assume in webforms either)</p>
asp.net
[9]
1,819,515
1,819,516
Determine which browser is being used to visit my site
<p>Can someone tell me how I can determine (using JavaScript etc.) what browser is being used to visit my site?</p> <p>I want to redirect to a different page based on these scenarios:</p> <ul> <li>Wheater the user is browsing using Safari on the iPhone.</li> <li>Using IE on a desktop</li> <li>Using IE on a WP7 mobile device.</li> </ul> <p>Thanks.</p>
javascript
[3]
5,641,491
5,641,492
Py_Initialize and Py_finalize and MatPlotlib
<p>This is a known problem, but I want to ask the experts for the best way to solve it for me. </p> <p>I have a project (Euler Math Toolbox), which runs Python as a script language. For this, a library module "python.dll" is loaded at run time, which is linked against "python27.lib". Then Py_Initialize is called. This all works well. </p> <p>But Euler can be restarted by the user with a new session and notebook. Then I want Python to clear all variables and imports. For this, I call Py_Finalize and unload "python.dll". When Python is needed, loading and initializing starts Python again. </p> <p>This works. But Python crashes at the first call, if MatPlotlib is imported in the previous session. It seems that Py_Finalize does not completely clear Python, nor does unloading my "python.dll". I tried unloading "python27.dll" (the Python DLL), but this does not help. Most likey, another DLL remains active, but corrupts during Py_Finalize. </p> <p>To solve this, it would suffice to clear all variables and imports. I could live with not calling Py_Finalize. But how? </p> <p>PS: You may wonder, why I do not directly link euler.exe to Python. The reason is that this prevents Euler form starting, if Python is not installed, even if it is never needed. </p> <p>Thanks for any answers! You duplicate your answer to renegrothmann at gmail, if you like. That would help me. </p>
python
[7]
281,140
281,141
calling a unix exectuable via a java enterprise application
<p>can a java application call a unix executable written in c++? basically i have written code in unix in c++ and shared the executable with a couple of companies. All is well save for this on e company that is using java under a linx platform. would it not be possible for them to just call my executable from their java app? of course i make sure my unix os matches their etc etc. but i don't want to redevelop my code using java for this. any solution to this problem?</p>
java
[1]
2,607,288
2,607,289
Set folder browser dialog start location
<p>Is there any way to set the initial directory of a folder browser dialog to a non-special folder? This is what I'm currently using<pre><code>fdbLocation.RootFolder = Environment.SpecialFolder.Desktop;</code></pre> but I want to use a path I have stored in a string something like this<pre><code>fdbLocation.RootFolder = myFolder;</code></pre>This causes an error "Cannot convert 'string' to 'System.Environment.SpecialFolder'".</p>
c#
[0]
798,231
798,232
how to fix 'T' is a 'type parameter' but is used like a 'variable' compile error
<p>I need to check if a generic type parameter <code>T</code> is <code>MyEntity</code> or a subclass of it.</p> <p>Code below causes this compiler error:</p> <pre><code>'T' is a 'type parameter' but is used like a 'variable' </code></pre> <p>how to fix?</p> <pre><code>public class MyEntity { } static void Test&lt;T&gt;() { // Error 34 'T' is a 'type parameter' but is used like a 'variable' if (T is MyEntity) { } } </code></pre>
c#
[0]
1,476,750
1,476,751
Android vs other mobiles
<p>1.How to upgrade latest version of android os on android phones?</p> <p>2.Is it possible to upload android applications to other mobiles?</p> <p>Thanks for ur precious time!..</p>
android
[4]
2,856,041
2,856,042
Timeout in Dropdown selectindex changed event
<p>I have built one web application and in that i had bound drop down with 10K records and when i will change index then i will get page timeout error!!</p> <p>can anyone suggest me the cause of this problem?</p>
asp.net
[9]
3,363,696
3,363,697
What are Nullable Types in C#?
<pre><code> int? _fileControlNo = null; public int? FileControlNo { get { return _fileControlNo; } set { _fileControlNo = value; } } </code></pre> <p>I'm getting a syntax error when I assign null values to the above properties.</p> <pre><code>objDPRUtils.FileControlNo =sArrElements.Value(3)==null ? null : Convert.ToInt32(sArrElements.Value(3)); </code></pre> <p>Please, can anyone explain to me why the error occurs if I'm able to set null value in valuetype object using Nullable Type. </p>
c#
[0]
1,528,388
1,528,389
Where can we use Object.clone() method in java?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2326758/how-to-properly-override-clone-method">How to properly override clone method?</a> </p> </blockquote> <p>Can anyone give me any example where we can use the same?</p>
java
[1]
1,103,408
1,103,409
php - generate non linear urls
<blockquote> <p><strong>Update:</strong></p> <p>Ok.. I have read a lot of solutions... Thank you so much everybody. I think I will keep it simple and avoid the encryption and just rely on two fields matching in the database. I can keep the id as it is (sequential) but add for example a timestamp (with : removed). Then I can put both through the youtube style url generator... leaving me with a really short, unique and not easily guessed url. e.g</p> <p>before the youtube url gen blah.com?id=10345&amp;s=134025</p> <p>after blah.com?id=H2s&amp;s=tL2s</p> <p>I log the unique views to each id anyway... so I will record unsucessful ones too and if a user hits 10 non matching url's in an hour then I can block his ip (I know a proxy will evade this...but it makes it more difficult). </p> <p>What do you think?</p> </blockquote> <p>This may sound like a bit of an odd question... what I am looking to achieve is a way to generate an id to be used in a url which can not be guessed or calculated. What I mean is it is not id=1, id=2...</p> <p>I was looking at a youtube style script <a href="http://stackoverflow.com/questions/1853471/php-help-improve-the-efficiency-of-this-youtube-style-url-generator">here</a>. Which has a padding option, but the padding is so obvious with urls like wTTTa and b666o. I considered MD5 ing the id... but thats hardly foolproof and makes for rather long urls.</p> <p>The solution must be url based (can't be cookie or session based) and before you panic and think that I am trying to work out a way to secure my admin page - i am not, its part of a game I am developing.</p>
php
[2]
2,090,090
2,090,091
Ellipsize works with hint, but not with text
<p>I have a custom edittext and I'm having some problems with the ellipisze.</p> <p>My edittext is build programmatically and has the following attributes:</p> <pre><code>setSingleline(true); setInputType(InputType.TYPE_NULL); setCursorVisible(false); setEllipsize(TruncateAt.END); setText(com.telecomIT.digicare.R.string.comment_hint); </code></pre> <p>But the ellipsize isn't working. The weird thing is that if I change setText to setHint, the 3 dots are displayed.</p> <p>So, why does it work with hint, but not with text? </p> <p>I already tried to set the inputtype to text, but this doesn't work either.</p>
android
[4]
4,387,403
4,387,404
Mongoose Embedded Webserver
<p>This code is taken from the example program in Mongoose embedded web server. </p> <p>The event MG_NEW_REQUEST is called twice. Is this the expected behavior? Why would it process the same request twice? How would you prevent this from doing so?</p> <pre><code>int i =0; static void *callback(enum mg_event event, struct mg_connection *conn, const struct mg_request_info *request_info) { if (event == MG_NEW_REQUEST) { i++; printf("%d \n", i); // Echo requested URI back to the client mg_printf(conn, "HTTP/1.1 200 OK\r\n" "Content-Type: text/html\r\n\r\n" "%s", request_info-&gt;uri); mg_printf(conn, "Hello World!!" "%s", ""); //request_info-&gt;query_string return const_cast&lt;char *&gt;("done"); // Mark as processed } else { return NULL; } } int main(void) { struct mg_context *ctx; const char *options[] = {"listening_ports", "8080", NULL}; printf("Test web server, open browser to http://localhost:8080 "); ctx = mg_start(&amp;callback, NULL, options); getchar(); // Wait until user hits "enter" mg_stop(ctx); return 0; } </code></pre>
c++
[6]
3,611,733
3,611,734
javascript Array comparision to check weightage is 100 or not for same program
<p>i have 2 arrays as bellow</p> <p>1)ProgramId(numeric)<br> 2)Weightage(numeric)<br> How to check,for the same programid weather weightage of that programid is 100 or not ie </p> <p><strong>ProgramId</strong><br> 2<br> 2<br> 3<br> 3<br> 2<br> 4<br> <strong>Weightage</strong><br> 25<br> 25<br> 30<br> 70<br> 50<br> 45<br> here for <strong>ProgramId</strong> 3 <strong>Weightage</strong> becomes 100(30+70) so now onwards <strong>ProgramId</strong> 3 should not be insert into array(programid)</p> <p>next same to programid 2<br> here also weightage=25+25+50=100 so nowonwards should not insert programid 2</p> <p>thanks in advance</p>
javascript
[3]
2,361,102
2,361,103
How to map between android.os.Build values to retail device names?
<p>My android application records logs of connected devices, with infos such as:</p> <ul> <li>android.os.Build.MANUFACTURER</li> <li>android.os.Build.DEVICE</li> <li>android.os.Build.MODEL</li> <li>more...</li> </ul> <p>On top of that, I use <a href="http://code.google.com/p/acra/" rel="nofollow">ACRA</a> to log crash reports.</p> <p>With these two sets of datas, I should be able to track what is going wrong, for each manufactorer and model of Android phone.</p> <p>My problem is the following: I can't link the references returned by <code>android.os.Build.*</code> with the devices names. For example, I just got a comment from the Android market saying "It sucks. Doesn't work on Acer Liquid". But I can't find the matching records in my data sets, because I have no idea how Acer Liquid is represented in <code>android.os.Build.*</code>.</p> <p>I'd like to find a list of match between the devices names and the values possibly returned by <code>android.os.Build.*</code>. Do you know any please ?</p>
android
[4]
4,355,742
4,355,743
Input parameters in java
<p>I was wondering why do Java programs take parameters only in the form on Strings from the command line when they are run? I have <a href="http://stackoverflow.com/questions/10183611/using-int-instead-of-string-public-static-void-main-int-args">read</a> that if the parameters are declared as int, it still converts the int into String. Why does this happen? And is there any way to accept only int values from the command line when running a java program?</p>
java
[1]
4,903,757
4,903,758
Android MapView: animateTo doesnt work while map is panning
<p>The code below does the following: When checking the "focus" checkbox, the map animates to the single overlay item in the map. There is one problem: When i drag the map so that the map is still moving when I check the checkbox, the checking has no visual effect. Any ideas?</p> <pre><code>List&lt;Overlay&gt; mapOverlays; Drawable drawable; AssetMarkersOverlay itemizedOverlay; private CheckBox autofocusCheckBox; MapView mapView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapview); mapView.getController().setZoom(4); mapView.setBuiltInZoomControls(true); mapOverlays = mapView.getOverlays(); drawable = this.getResources().getDrawable(R.drawable.bubble_blue); itemizedOverlay = new AssetMarkersOverlay(drawable); String assetName = "TEST"; int lat = 3; int lon = 3; ArrayList&lt;GeoPoint&gt; geoPointList = new ArrayList&lt;GeoPoint&gt;(); GeoPoint point = new GeoPoint(lat, lon); autofocusCheckBox = (CheckBox) findViewById(R.id.showInMap); autofocusCheckBox.setTag(point); autofocusCheckBox .setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked &amp;&amp; buttonView.getTag() != null) { focusAsset((GeoPoint) buttonView.getTag()); } } }); geoPointList.add(point); itemizedOverlay.addOverlay(lat, lon, assetName, assetName); mapOverlays = mapView.getOverlays(); mapOverlays.clear(); mapView.postInvalidate(); mapOverlays.add(itemizedOverlay); fitPoints(geoPointList, mapView); mapView.postInvalidate(); } private void focusAsset(GeoPoint point) { mapView.requestFocus(); mapView.clearAnimation(); mapView.getController().stopAnimation(true); mapView.getController().setZoom(14); mapView.getController().animateTo(point); mapView.postInvalidate(); } </code></pre>
android
[4]
4,577,183
4,577,184
Checking the size of file before uploaing it
<p>Is there is any way to check file size before uploading it using javascript?</p>
javascript
[3]
1,021,845
1,021,846
Just one PHP page won't run - it wants to download
<p>All PHP pages are all running just fine on my site, except for one for which Firefox says "You have chosen to open checkpage.php which is a PHP script" and then wants me to select an application with which to open it.</p> <p>The site is running PHP Version 5.2.10 on Centos 5.5.</p> <p>I'm using exactly the same code on another site (PHP Version 5.2.10-2ubuntu6.4 on Ubuntu 9.10) and it's fine. </p> <p>I've Googled myself silly trying to work out what the issue is! </p> <p>Does anyone have any ideas why this one page might be causing a problem? The page is about 200 lines long but I'll post it here if it'll help...</p> <p>All thoughts much appreciated Mike</p> <p><strong>PasteBin:</strong> <a href="http://pastebin.com/A6uNj9CN" rel="nofollow">http://pastebin.com/A6uNj9CN</a></p>
php
[2]
4,593,662
4,593,663
Generic Interface with property
<p>i have one interface </p> <pre><code>/// &lt;summary&gt; /// Summary description for IBindable /// &lt;/summary&gt; public interface IBindable&lt;T&gt; { // Property declaration: T Text { get; set; } } </code></pre> <p>Now i want to implement this interface in my class </p> <pre><code> public class MyTextBox :IBindable&lt;string&gt; { //now i how can i implement Text peroperty here } </code></pre> <p>I don't want to implement it like</p> <pre><code>string IBindable&lt;string&gt;.Text { get { return "abc";} set { //assigne value } } </code></pre> <p>i want to implement it like </p> <pre><code> public string Text {get{} set {}} </code></pre>
c#
[0]
3,288,985
3,288,986
Get the dynamic height of a clone object
<p>In jQuery, I would like to get the height of a clone object BEFORE it is appended to the body.</p> <p>Note: I didn't specify the width and height in CSS (this is the requirement).</p> <p>Is it possible?</p> <pre><code>&lt;body&gt; &lt;style&gt;.square {}&lt;/style&gt; &lt;script&gt; jQuery(function($) { var o = $(".square").clone(true); $(o).css('height','auto').html("Some stuff...&lt;br/&gt;&lt;br/&gt;"); // output 0 (Question: how to get the height?) console.log($(o).height()); $(o).appendTo("body"); // output the height (i.e. 38) console.log($(o).height()); }); &lt;/script&gt; &lt;div class="square"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre>
jquery
[5]
209,754
209,755
Scrollview is bouncing back. Intersting issue
<p>I have a app where in once I tap on a textfield it slides on top of keyboard.</p> <p>My scrollview is bouncing back when I scroll down my content. iPhone documentation says "by default, it “bounces” back when scrolling exceeds the bounds of the content." </p> <p>Any clue how to get rid of this? Should I increase the content size of scrollview? Please suggest</p>
iphone
[8]
4,689,059
4,689,060
jquery load data
<p>dumbest question ever... but I want to somehow fill 'gid' value in data load</p> <pre><code>gid = 123; from = 33; to = 44; $('#x').load('y', {'range['+gid+'][]' : [from , to]}); </code></pre> <p>so I could get</p> <pre><code>[range] =&gt; Array ( [123] =&gt; Array ( [0] =&gt; 33 [1] =&gt; 44 ) ) </code></pre> <p>but with this syntax 'range['+gid+'][]' I get 'missing : after property id'. I'm desperate...</p>
jquery
[5]
3,408,270
3,408,271
Using a button to open a link in a new tab/window in ASP.NET
<p>I’m trying to use a button click to open a page in a new tab/window. I’ve looked at solutions similar to <a href="http://stackoverflow.com/questions/6248702/redirecting-new-tab-on-button-click-response-redirect-in-asp-net-c-sharp">this</a>, but the answers given there are either to use a link or have it open in the same window. I need to use a button because it needs to generate the link based on criteria data entered in the form (string manipulation). This button is not submitting the form though; it’s just validating some of the data on an external site. I need this in a different window or tab so they can go back and forth between my form and the validation site. This is basically my current <code>Button_Click</code> event:</p> <pre><code>var Address = AddressTextbox.Text.Trim(); Address = Address.Replace(' ', '+'); var Url = "http://www.example.com/query?text=" + Address + "&amp;param1=foo&amp;param2=bar"; Response.Redirect(Url); </code></pre> <p>This works except that <code>Response.Redirect(Url)</code> only opens in the same window, not a new one. </p>
asp.net
[9]
4,665,335
4,665,336
Doubts with destructor
<p>Suppose I have a class:</p> <pre><code>class ClassX{ private: int* p; int i; .... } </code></pre> <p>And somewhere I do:</p> <pre><code>ClassX x; ..... //and in a friend function or in a ClassX function p = (int*) malloc (.....); </code></pre> <p>Then when <code>x</code> exit its scope a the destructor is invoked; but it does not free the memory allocated by the <code>malloc</code> right?</p> <p>And if I redefine it:</p> <pre><code>ClassX::~ClassX(){ delete [] p; } </code></pre> <p>it frees the memory allocated by the <code>malloc</code> but not the memory allocated for the class' fields (i.e. <code>i</code> and <code>p</code>)?</p> <p>Am I missing something?</p> <p>Thank you.</p>
c++
[6]
2,162,871
2,162,872
How do I extract the middle name from the full name?
<p>My program is supposed to extract the middle name of a full name. I have another method and I can't call it properly in my main method. The code is working if it is in the main method, but it doesn't work in the other method; I assume the problem is when calling the method. I am using Eclipse.</p> <pre><code>import java.util.Scanner; public class MiddleNames { public static void main(String[] args) { getMiddleName(" "); System.out.println(); } public static String getMiddleName(String middleName) { Scanner input = new Scanner(System.in); System.out.println("Enter your full name: "); String fullName = input.nextLine(); int firstSpace = fullName.indexOf(" "); int lastSpace = fullName.lastIndexOf(" "); middleName = fullName.substring(firstSpace,lastSpace); return middleName; } } </code></pre>
java
[1]
46,048
46,049
How to select a row with particular class name in JQuery
<p>I have a table as follows </p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td id="start"&gt;Starting Point&lt;input type="button" value="start the test" onclick="get_the_next()" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;not the right class - skip me&lt;/td&gt; &lt;/tr&gt; &lt;tr class="concept1"&gt; &lt;td&gt;get me if you can!&lt;/td&gt; &lt;/tr&gt; &lt;tr class="concept2"&gt; &lt;td&gt;but not me, I'm not the next&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;not the right class - skip me&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I need to select row with class name "concept2". How can I do that in JQuery?</p>
jquery
[5]
4,543,895
4,543,896
what is the difference between response.redirect and response status 301 redirects in asp?
<p>Our asp application is moving to new server and i want to implement a permenant url redirection. I am aware of following two approaches , i need to understand which one to user over other and when ?</p> <p>Option 1:</p> <pre><code>&lt;%@ Language=VBScript %&gt;&lt;% Response.Redirect "http://www.example.com" %&gt; </code></pre> <p>Option 2:</p> <pre><code>&lt;%@ Language=VBScript %&gt;&lt;% Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www.example.com/" %&gt; </code></pre> <p>Thanks,</p> <p>Nikhil.</p>
asp.net
[9]
4,410,156
4,410,157
iterator for map - problem with searching
<p>hello i got an iterator running on a multimap ,my multimap includes two fields the first 1 is the key value which is a string Lastname and the second 1 is the data which is a pointer to an object called Employee. in my program i need to be able to find an element inside my map using iterator (cause i am trying to find the data by its ID and not by the key value). i want to have some sort of indicator that will tell me if the element i am looking for is inside my map or not. thanks in advance. and this is my Find code :</p> <pre><code>MultiMap::iterator iterator; iterator=m_municipalityMap.begin(); bool flag = false; while(!(flag) &amp;&amp; iterator != m_municipalityMap.end()) { if(strcmp(iterator-&gt;second-&gt;GetId() , id) == 0) { flag=true; break; } iterator++; } if (flag==false) cout &lt;&lt; "could not find Employee"&lt;&lt;endl; return iterator; </code></pre> <p>what i need to know if there is a way to know if the iterator stands on nothing like comparing to NULL on pointers </p>
c++
[6]
4,024,045
4,024,046
What C# data store should I use?
<p>I am trying to create a test framework and not sure what is best to use to store test case names and data that will be provided in XML file. For example, I want to test printer functionality so it has constructor, open printer connection, send data to printer, close printer connection. So the XML would be:</p> <pre><code>&lt;Printer&gt; &lt;TestCaseName&gt;"Printer_Construct"&lt;/TestCaseName&gt; &lt;Data1&gt;"Printer1"&lt;/Data1&gt; &lt;TestCaseName&gt;"Printer_OpenConnection"&lt;/TestCaseName&gt; &lt;Data1&gt;"Printer1"&lt;/Data1&gt; &lt;TestCaseName&gt;"Printer_PrintString"&lt;/TestCaseName&gt; &lt;Data1&gt;"Printer1"&lt;/Data1&gt; &lt;Data2&gt;"Printing my string"&lt;/Data2&gt; &lt;TestCaseName&gt;"Printer_CloseConnection"&lt;/TestCaseName&gt; &lt;Data1&gt;"Printer1"&lt;/Data1&gt; &lt;/Printer&gt; </code></pre> <p>Here is how my test framework wanted to work:</p> <p>1- when test operator runs the test framework, first it will load all the case names only into listbox1. It will not load test case data yet.</p> <p>2- when test operator selects specific test case to run, it will load that test case into listbox2. So when it loads test case into listbox2, it will display test case name and test data(data1 and data2 as shown in xml struct above).</p> <p>3- So now that test case in listbox2 is ready to be tested whenever test operator clicks the Run button.</p> <p>So how can I store test case data? Should I store these data in memory? If so, what storing data feature should I use? If not storing these data in memory, does that means I will have to read the XML every time when accessing to test case data so is it good practice to do that?</p> <p>thanks.</p>
c#
[0]
3,480,210
3,480,211
Refresh NSTableView After Click - Not Refreshing
<p>I have an app with a UITableView, using both icons and disclosure buttons. I want to update the icon on a row with a "selected" icon, and update the previously-selected row with an "unselected" icon. I have the code in place, but when I click on the rows, it sets both rows to the "selected" state, even though via debugging I can see that my state variable is being set to the correct row. If I keep clicking rows I can sometimes get the "unselected" state to show. I suspect it's a refresh issue, but I've tried the setNeedsDisplay method on the cells and the tableView itself, but with no luck. Anyone run into this before? BTW, this is in the simulator (2.2.1) - haven't tried it on the device.</p> <p>Here's the code:</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int newRow = [indexPath row]; int oldRow = [lastIndexPath row]; if (newRow != oldRow) { [[tableView cellForRowAtIndexPath:indexPath] setImage: [UIImage imageNamed:@"IsSelected.png"]]; c_oListPtr.c_sCurItem = [[tableView cellForRowAtIndexPath:indexPath] text]; [[tableView cellForRowAtIndexPath:lastIndexPath] setImage: [UIImage imageNamed:@"NotSelected.png"]]; [lastIndexPath release]; lastIndexPath = indexPath; [[tableView cellForRowAtIndexPath:lastIndexPath] setNeedsDisplay]; [[tableView cellForRowAtIndexPath:indexPath] setNeedsDisplay]; [tableView setNeedsDisplay]; } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } </code></pre> <p>Thanks -Mike</p>
iphone
[8]
690,336
690,337
Obscure JavaScript syntax
<p>...obscure to me, anyway. Can anyone tell me what this means? I have various bits of code that look like this:</p> <pre><code>node[foo](bar, function() { ...do something to 'node' }); </code></pre> <p>'node' is a single DOM node. 'foo' and 'bar' are both strings, though the code sets 'bar' to a boolean occasionally. The 'do something' code is occasionally executed, but only (I think) if 'bar' is <code>true</code>. Thanks.</p>
javascript
[3]
3,133,731
3,133,732
Change Default Contact Manager to My own
<p>I writing a contact manager for android and I want to know how can I change default contact manager to my own program?</p>
android
[4]
1,357,905
1,357,906
Javascript multitouch lib
<p>I need to implement application for multitouch devices (mobile and desktop) with JavaScript. There will be ability to manipulate elements and multiple users should be able manipulate elements in same time. But all libs I tried don't allow to do this, and I unable to manipulate multiple elements simultaneously. Could you advise me a js lib which meets my needs ?</p> <p>Thanks</p>
javascript
[3]
4,337,764
4,337,765
How to make unix timestamp to show time over 24 hours?
<p>I would like to show any give time in hours only.</p> <p>Example:</p> <p>Unix timestamp: 169200</p> <p>Which is equal to 1 day and 23 hours...</p> <p>But how can I convert this to hours so it shows 47:00:00 (47 hours)?</p> <p>Thanks</p> <p><strong>Edit</strong>: It must show minutes and seconds too ;)</p>
php
[2]
4,373,042
4,373,043
should I detach action after attaching?
<p>I'm attaching action like that in constructor:</p> <pre><code>model.DataArrived += new Action&lt;List&lt;ConsoleData&gt;&gt;(model_DataArrived); </code></pre> <p>Should I detach it in <code>OnDispose</code>? Is it ok to create a new instance like that?</p> <pre><code>protected override void OnDispose() { model.DataArrived -= new Action&lt;List&lt;ConsoleData&gt;&gt;(model_DataArrived); </code></pre> <p>Or I should detach exactly the same instance that I've created in constructor? Should I keep this instance in private field only for detaching purposes?</p>
c#
[0]
5,766,051
5,766,052
Can we write a program without a class in core Java?
<blockquote> <p>Every Java program requires the presence of at least one class.</p> </blockquote> <p>Is the above statement always true ?</p>
java
[1]
2,719,811
2,719,812
Can i retrieve the current telephone number?
<p>I'm writing an app for android (2.1+) and I'd like to use the telephone number of the current phone. Lots of googling brought me the following:</p> <pre><code>String number=(TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE).getLine1Number(); </code></pre> <p>That along with permission: READ_PHONE_STATE.</p> <p>My problem however is that it returns null. While searching i noticed this question has been asked many times before and nearly in all of those questions it is said that the number simply isn't always available.</p> <p>While testing I found that on my very own phone it gives me null. BUT another app (e.q. WhatsApp) was able to recognize my phone number.</p> <p>So then i wonder, how did they do it?</p>
android
[4]
3,274,442
3,274,443
python logic error
<p>please help me figure out what is wrong with this code; the first function works fine but the second one returns the wrong number. what the second variable is sup post to return is the remainder of minutes passed since midnight. </p> <pre><code> def get_hours(s): time=s/3600 return time #The get_hour function returns how many hours have passed since midnight. The # parameter is the time in seconds that has passed since midnight. def get_minutes_remainder(s): hours=get_hours(s) minutes=s/60 a=round(hours) b=a-hours b=abs(b) minutes=minutes*b return minutes </code></pre>
python
[7]
871,078
871,079
Share text/image to QQ app
<p>My app needs to share text/image to QQ app (this app here <a href="https://itunes.apple.com/jp/app/qq-ri-ben-ban/id526025182" rel="nofollow">https://itunes.apple.com/jp/app/qq-ri-ben-ban/id526025182</a>, <a href="http://www.imqq.jp/sp/" rel="nofollow">http://www.imqq.jp/sp/</a>), please help me. I'm thinking about using Custom URL Scheme but I can't find out it.</p>
iphone
[8]
2,122,932
2,122,933
Java Exception handling
<p>I would like to know what happens in java if a method call signature has a exception but there is no try catch block in the method what happens when a exception happens at runtime.</p> <pre><code>public void someMethod (Collection&lt;file&gt; files) throws Exception for(File f : files) { process(f); } </code></pre>
java
[1]
5,022,358
5,022,359
PHP if function
<p>I am using php mail to send the data via email.</p> <p>In my mail script I need to add an if script.</p> <p>I need it to be : If choice1 is empty then do not display the </p> <pre><code>$message .= "&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Choice1(main):&lt;/strong&gt; &lt;/td&gt;&lt;td&gt;" . $_POST['choice1'] . "&lt;/td&gt;&lt;/tr&gt;"; </code></pre> <p>ANy help ?</p>
php
[2]
2,155,569
2,155,570
Should I learn/become proficient in Javascript?
<p>I am a .NET webdev using ASP.NET, C# etc... I "learned" javascript in college 5+ years ago and can do basic jobs with it. But I wonder if it is useful to become proficient in it.</p> <p>Why should I learn Javascript? Is it more advantageous then learning JQuery or a different <a href="http://stackoverflow.com/questions/913/what-javascript-library-would-you-choose-for-a-new-project-and-why">library</a>?</p>
javascript
[3]
528,423
528,424
Displaying activity with blur effect in Android Tabs
<p>I have a tab bar in my application, with third tab named About. When user clicks on this About tab, I want activity to be displayed with blur effect. More specifically, About activity should be on front, while previous tab should be displayed behind with blur effect. I did the following code in the about.java onCreate Method, but it opens new window and the previous windows are not being displayed. </p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //This is the code used to add blur effect getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); setContentView(R.layout.about); } </code></pre> <p>If I do it without tab bar it works. Any suggestions on what might be going wrong or how to do it in a different way?</p>
android
[4]
316,847
316,848
Javascript function aliasing without .apply
<p>I read <a href="http://stackoverflow.com/questions/1007340/javascript-function-aliasing-doesnt-seem-to-work">this</a>, and I understand it, but, is there a way to attach a function to always execute a function alias on a specific scope, without the user of the function alias have to use the sort of clunky .apply stuff?</p>
javascript
[3]
1,328,531
1,328,532
Page redirect query
<p>When my user enters their email and password into a form on login.php, the form action uses the below code to make sure they are a valid user, and that neither of the fields are blank. My problem is that even when valid email and password is used the user is directed back to the login.php page instead of the logged_in.php lage, can anyone suggest why?</p> <pre><code>&lt;?php session_start(); include("connection.inc.php"); $connection = connect(); $txtEmail = $_POST['email']; $txtPassword = $_POST['password']; if ((empty($txtEmail)) || (empty($txtPassword))) { header("Location: login.php"); exit; } $sql = "SELECT * FROM subscriber WHERE email = '$txtEmail' AND password = '$txtPassword'"; $result = @mysql_query($sql) or die ("Unable to run query"); $count = mysql_num_rows($result); if($count != 0) { $_SESSION['email'] = $txtEmail; $_SESSION['attempt_info'] = "authenticated"; header("Location: logged_in.php"); } ?&gt; </code></pre>
php
[2]
2,890,189
2,890,190
Is this bad practice: getMyObject().method()
<p>Suppose I have a function which returns an object :</p> <pre><code>getMyObject(){ //do stuff here return object; } </code></pre> <p>Is it bad practice to call a method (that doesn't return anything) on the function name itself:</p> <pre><code>getMyObject().method(); </code></pre> <p>instead of assigning a variable to the return object and then calling the method on that variable :</p> <pre><code>var returnedObject = getMyObject(); returnedObject.method(); </code></pre> <p>I am working with an html page that has many nested frames, and I have access to a function that returns one of these frames. The frame might be used several times within other functions in my script, and I was wondering if it would be ok for me to access the frame in the way asked above, or if it would be better to declare a global variable.</p> <p>*<em>EDIT: *</em> Ahh I haven't gotten a chance to use jQuery. Good to know! </p>
javascript
[3]
546,222
546,223
opening a html page on the client from server side
<p>On the server I receive xml from a webservice, I use xslt transformation on this xml to create a htm page. Now I need to show this htm page to the user by opening it in a new browser window. How do I achieve such functionality? My website is written in ASP.NET.</p> <p>I have tried using</p> <p>Response.Write(""); Response.Write("window.open('" + Server.MapPath("~/App_Data/HTMLPage.htm") + "','_blank')"); Response.Write("");</p> <p>But this throws me an access denied error.</p> <p>Thanks in advance. </p> <p>Chandrasekhar</p>
asp.net
[9]
4,059,317
4,059,318
Using Interface variables
<p>I'm still trying to get a better understanding of Interfaces. I know about what they are and how to implement them in classes.</p> <p>What I don't understand is when you create a variable that is of one of your Interface types:</p> <pre><code>IMyInterface somevariable; </code></pre> <p>Why would you do this? I don't understand how IMyInterface can be used like a class...for example to call methods, so:</p> <pre><code>somevariable.CallSomeMethod(); </code></pre> <p>Why would you use an IMyInterface variable to do this?</p>
c#
[0]
2,747,532
2,747,533
Why does casting a function to a function type that is identical except for return type fail?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/290038/is-the-return-type-part-of-the-function-signature">Is the return type part of the function signature?</a> </p> </blockquote> <p>Following up on a related but tangential question ( <a href="http://stackoverflow.com/questions/13684264/how-to-disambiguate-function-templates-that-differ-only-by-return-type">How to disambiguate function templates that differ only by return type?</a> ), I would like to ask a question related to the fact that the <em>return type</em> of a function is not considered to be part of the signature of a function.</p> <p>Consider the following code:</p> <pre><code>#include &lt;iostream&gt; int foo() { return 0; } int main() { long n = static_cast&lt;long(&amp;)()&gt;(foo)(); // Error: incorrect return type int p = static_cast&lt;int(&amp;)()&gt;(foo)(); // Compiles just fine } </code></pre> <p>The line of code noted above results in a compilation error, because the <em>return</em> type of the function type to which <code>foo</code> is being cast does not match the <em>return</em> type of the function <code>foo</code>.</p> <p>But I thought the return type of a function does not play a role in the signature of the function!</p> <p>According to a certain line of thinking, since the function signature <code>long(&amp;)()</code> matches the signature of <code>foo</code>, the cast of <code>foo</code> to a function of this type should succeed.</p> <p>However, the cast does not succeed. Where does the reasoning go wrong? If the cast cannot fail due to the function signature, then why does the cast fail?</p>
c++
[6]
1,819,194
1,819,195
How the Android system starts the main activity when the application launcher is clicked?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8515936/android-activity-life-cycle-difference-between-onpause-and-onstop">Android Activity Life Cycle - difference between onPause() and OnStop()</a> </p> </blockquote> <p>What happend when the application launcher icon was clicked? </p> <p>How the Android system instantiates the main activity and objects it refers to? What is the methods call hierarchy?</p> <p>Thanks</p>
android
[4]
3,586,972
3,586,973
How can I sort an array returned from File.ReadAllLines on an alphabetical member?
<p>I am reading a .csv file and returning its lines in string array. One of the members is manufacturer, for which I have Toyota, Ford, etc.</p> <p>I want to sort an array (Can be another collection) of the rows, by the value in manufacturer and alphabetical order.</p> <p>So I'd have:</p> <pre><code>28437 Ford Fiesta 328 Honda Civic 34949 Toyota Yaris </code></pre> <p>and so forth...</p> <p>What would be the best way to do this using C# and no database? I say no database because I could insert the csv into a table in a sql server database, and then query it and return the data. But this data is going into a html table built on the fly, which would make the database approach a little long winded.</p>
c#
[0]
1,801,777
1,801,778
php - smtp server
<p>I am working on a project. For that i have downloaded smtp server on ubuntu. Could any one please tell me the command to check whether the smtp server install properly or not. because email is not getting generated.</p> <p><strong>Below is the code for your reference</strong></p> <pre><code>&lt;?php ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); include('config.php'); // table name $tbl_name="temp_members_db"; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $email=$_POST['email']; $country=$_POST['country']; // Insert data into database $sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')"; $result=mysql_query($sql); // if suceesfully inserted data into database, send confirmation link to email if($result){ // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email; // Your subject $subject="Your confirmation link here"; // From $header="FROM: your email"; // Your message $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; //$message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code"; $message.="http://localhost/confirmation.php?passkey=$confirm_code"; // send email $sentmail = mail($to,$subject,$message,$header); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } ?&gt; </code></pre>
php
[2]
3,349,256
3,349,257
add new element at the beginning of a JSON
<p>I have this JSON:</p> <pre><code>var myVar = { "9":"Automotive &amp; Industrial", "1":"Books", "7":"Clothing" }; </code></pre> <p>I want to add a new element at the beginning, I want to end up having this:</p> <blockquote> <pre><code>var myVar = { "5":"Electronics", "9":"Automotive &amp; Industrial", "1":"Books", "7":"Clothing" }; </code></pre> </blockquote> <p>I tried this but it is not working:</p> <pre><code>myVar.unshift({"5":"Electronics"}); </code></pre> <p>Thanks!</p>
javascript
[3]
4,769,347
4,769,348
Passing parameters in jQuery
<p>What i have is working, so I'm just asking if there's a more elegant way to do this. I have:</p> <pre><code>&lt;form method="post" action="15Action.cfm"&gt; &lt;p&gt;&lt;input id="A" name="A1"&gt;&lt;/p&gt; &lt;p&gt;&lt;input id="B" name="B1"&gt;&lt;/p&gt; &lt;p&gt;&lt;input id="C" name="C1"&gt;&lt;/p&gt; &lt;input name="Submit" type="submit" value="submit"&gt; &lt;/form&gt; </code></pre> <p>If the changes either A or B, then concatenate the two fields together and place them into C. What I have is:</p> <pre><code>function doit(A,B) { return A+B; }; $(function() { var A = $('#A'); var B = $('#B'); $('#A, #B').change(function() { $('#C').val(doit(A.val(),B.val())); }); }); </code></pre> <p>I wonder if I should write</p> <pre><code>$('#C').val(doit(A,B)) </code></pre> <p>instead, or is it acceptable to pass A.val(), B.val()?</p>
jquery
[5]
3,689,224
3,689,225
How to programmatically open "Access Point Names" screen in Android?
<p>How to open that page? Wireless &amp; Networks -> Mobile Networks -> Access Point Names</p> <p>Please provide the sample code for this</p>
android
[4]
4,388,373
4,388,374
How to identify that the given string ends with newline or not
<p>In java how to identify that the provided string ends with newline character or not?</p>
java
[1]
501,552
501,553
MediaMetadataRetriever extractMetadata method returning null
<p>I am using MediaMetadataRetriever class to get metadata about a video but while getting the information about the height it is returning null and for width it is returning zero. Here is my code:</p> <pre><code>MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); String width = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH); String height = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); </code></pre> <p>Is there any other way to get width and height of a video?</p>
android
[4]
521,904
521,905
javascript event
<p>I have an interesting question, i hope..I have a textarea in my form..when a user comes to enter values in it it displays some cached values in an autocomplete format..thats fine..I want to call an ajax function after the user selects such a cached value in it..so that the ajax call should pass this selected value..so my question is on which can i get the final selected value, so i call ajax at that time,... i tried with onblur etc, but not worked..</p> <p>help please.. thanks in advance...</p>
javascript
[3]
5,434,476
5,434,477
C++ interview question involving class pointers
<p>Lets say there is a base class pointer which is pointing to a base class object:</p> <pre><code>baseclass *bptr; bptr= new baseclass; </code></pre> <p>now if i do </p> <pre><code>bptr= new derived; </code></pre> <p>what is the problem here?</p>
c++
[6]
174,913
174,914
how to remove the bluetooth module from android
<p>I have a device which runs android 4.1. But the device does not have a bluetooth, so I want to remove bluetooth related items from the 4.1 platform (like sharing menu, setting items which contain "bluetooth ").</p> <p>but it seems a miscellaneous work ( settings, filesharing , ).</p> <p>Is there any method that can tell the platform that the current devices don't have a bluetooth only by config some files???</p>
android
[4]
1,976,447
1,976,448
Accessing data from text box
<pre><code>function testTask06() { var cipherText = document.getElementById('cipherTextBox').value; var indexCharacter = document.getElementById('indexCharacterTextBox').value; document.getElementById('plainTextBox').value = (decryptMessage(cipherText, indexCharacter, plainArray, cipherArray)); } </code></pre> <p>I want to get values from textbox called 'cipherTextBox' and 'indexCharacterTextBox', then use those values in my function decryptMessage and then display result in textbox 'plainTextBox'. It doesnt work but i'm wondering if it's because my function decryptMessage is wrong.</p>
javascript
[3]
2,381,863
2,381,864
In Python, what's the best way to get the closest integers for two dimensions?
<p>I have a list of 2 dimensional tuples, unsorted, and of <code>n</code> size. I want to find which tuple has the closest dimensions to X and Y. What's the best way to do this?</p> <pre><code>target = (75, 75) values = [ (38, 61), (96, 36), (36, 40), (99, 83), (74, 76), ] </code></pre> <p>Using the <code>target</code> and <code>values</code>, the method should produce the answer <code>(74, 76)</code>.</p> <p><strong>Edit</strong></p> <p>The <a href="http://stackoverflow.com/a/12697090/28360">answer below</a> lead me to this exact method, for anyone who lands here:</p> <pre><code>def distance(item, target): return ((item[0] - target[0]) ** 2 + (item[1] - target[1]) ** 2) ** 0.5 best = min(values, key=lambda x: distance(x, target)) </code></pre> <p>This is a <a href="http://en.wikipedia.org/wiki/Cartesian_coordinate_system#Distance_between_two_points" rel="nofollow">Cartesian Distance</a> problem.</p> <ol> <li>First take the square of the test value's <code>x</code> minus the optimal <code>x</code> value.</li> <li>Then take the square of the test value's <code>y</code> minus the optimal <code>y</code> value.</li> <li>Finally take the square root of step 1 plus step 2, which gives you the distance.</li> <li>Apply this to all items in the list, and the lowest number (using the <code>min</code> function) will give you the best fit.</li> </ol>
python
[7]
2,391,919
2,391,920
Android system / system context / replace classes
<p>Hi I'm engineer but more from a chip/assembler x86 level. I'm new to Android. Still figuring some general things out. I have written some apps, but have a general question. If I were to write an improved version of - let's say - TextView. Is it possible to make all app's on the system using this class, basically replace TextView? How are the java classes on the Android system, are they compiled, can I replace the library? Is this protected? Thanks for help</p>
android
[4]
3,096,063
3,096,064
Declaring class object datatypes
<p>I have a class <code>Foo</code> which contains a datamember of type <code>Bar</code>. I can't make a generalized, "default" <code>Bar.__init__()</code> - the <code>Bar</code> object is passed into the <code>Foo.__init__()</code> method. </p> <p>How do I tell Python that I want a datamember of this type? </p> <pre><code> class Foo: # These are the other things I've tried, with their errors myBar # NameError: name 'myBar' is not defined Bar myBar # Java style: this is invalid Python syntax. myBar = None #Assign "None", assign the real value in __init__. Doesn't work ##### myBar = Bar(0,0,0) # Pass in "default" values. def __init__(self, theBar): self.myBar = theBar def getBar(self): return self.myBar </code></pre> <p>This works, when I pass in the "default" values as shown. However, when I call <code>getBar</code>, I do <em>not</em> get back the one I passed in in the <code>Foo.__init__()</code> function - I get the "default" values. </p> <pre><code> b = Bar(1,2,3) f = Foo(b) print f.getBar().a, f.getBar().b, f.getBar().c </code></pre> <p>This spits out <code>0 0 0</code>, <strong>not</strong> <code>1 2 3</code>, like I'm expecting. </p> <p>If I don't bother declaring the <code>myBar</code> variable, I get errors in the <code>getBar(self):</code> method (<code>Foo instance has no attribute 'myBar'</code>). </p> <p>What's the correct way to use a custom datamember in my object?</p>
python
[7]
2,952,889
2,952,890
How to open a particular contact number's call history activity in android?
<p>I am developing an android application which shows call logs and messages in a tab view. I just want to show the particular contact number's default call history activity on clicking of a contact in my application. I know how to show the all call logs activity using intent, but didn't get any example or trick to show the particular number's default call history activity.</p> <p>Any help appreciated.</p>
android
[4]
2,322,985
2,322,986
Is it possible in c++ to forbid calling a certain function at compile time?
<p>I have 2 classes:</p> <pre><code>class Entity { void addChild(Entity* e); }; class Control : public Entity { }; </code></pre> <p>What I want to do is to not allow adding a Control as a child of something that's not a Control. So, for example:</p> <pre><code>Control c; Entity e; e.addChild(c); // This line would throw an error (at compile time if possible); </code></pre> <p>The first thing I thought of is adding this to Entity:</p> <pre><code>void addChild(Control* c){ assert(false); }; </code></pre> <p>NOTE: both Entity and Control are abstract classes but both has many subclasses. </p> <p>But is there any way to get an error at compile time?</p>
c++
[6]
2,752,938
2,752,939
How to make jQuery selector run faster or run it in chunks
<p>I have a simple jQeury code that runs on a web page that has more than 50,000 lists of people. On IE I get the message that a script is taking too long. I would like to get rid of that annoying popup in IE.</p> <p>If I need to add 50,000 DOM elements then I could use timer to defer work in chunks. I am not sure if timer would be of any help in this case when I am selecting from the large chunk of data.</p> <p>my jquery code is </p> <pre><code>$('#all_member').click(function(){ $("#people_form input:checkbox").attr('checked', true); return false; }); </code></pre>
jquery
[5]
5,719,867
5,719,868
Start fading object after it has passed X miliseconds along animation
<p>I have an object animating, which I would like to start fading out, after a certain period of time. In other words, as an object moves from the top to the bottom of the screen, at about 75% of the way it starts to fade out.</p> <p>For example, my function is so far:</p> <pre><code>function parachute_drop(drop_object, animation_duration) { var life = animation_duration * .75; $(drop_object) .animate({top: "750px"},animation_duration) .animate({top:"-150px", opacity: 100 },{ duration: 0, complete: function(){ parachute_drop(drop_object,animation_duration); } }); } </code></pre> <p>Therefore if I were to run:</p> <pre><code>parachute_drop('#parachute1',100000); </code></pre> <p>Then after the 'life' has been reached (100000 x .75) = 75000ms it would start fading out to 0. After which the animation completes, and returns back to full opacity.</p> <p>I have been struggling to do this and haven't quite got my head around how the whole queue system works with jquery.</p> <p>I know I can put something like :</p> <pre><code>delay(life).animate({opacity:0},5000) </code></pre> <p>in there, but then it holds up the whole function. </p> <p>How would you tackle something like this?</p>
jquery
[5]