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
611,967
611,968
Example of Camera preview using SurfaceTexture in Android
<p>I am trying to render camera preview using <a href="http://developer.android.com/reference/android/graphics/SurfaceTexture.html" rel="nofollow">SurfaceTexture</a>. I read the document but unable to understand how it works.</p> <p>Can anyone provide one sample example(very basic one) or link which uses <a href="http://developer.android.com/reference/android/graphics/SurfaceTexture.html" rel="nofollow">SurfaceTexture</a> to preview camera. I googled this but not found what I am looking for.</p> <p>Thanks in advance.</p>
android
[4]
3,225,660
3,225,661
Getting variable from function
<p>Is there a way for me to get the file url from this function without changing the javascript and without running the function? </p> <pre><code> jwplayer('jsCmgPlayer').setup({ flashplayer: 'http://website.com/player.swf', file: 'http://website.com/0015980.mp3', autostart: true, 'skin': 'http://www.website.com/skin.xml', 'controlbar': 'bottom', height: 28, width: 620 }); </code></pre> <p>I want to get <code>http://website.com/0015980.mp3</code> as a separate variable.</p>
javascript
[3]
3,659,847
3,659,848
simple python list problem
<p>According to the docs:</p> <pre><code>list.append(x): Add an item to the end of the list </code></pre> <p>So, if I do:</p> <pre><code>list = [] list.append("banana") print list[0] --&gt; which is suppose to print the FIRST item of the list &gt; banana </code></pre> <p>So far so good, however if now I append another item:</p> <pre><code>list.append("apple") print list[0] </code></pre> <blockquote> <p>apple</p> </blockquote> <p>Wasn't it suppose to append to the END of the list? How do I keep the order of the list when appending? How should I print the first and last items of the list -- in the order they were added to it?</p> <p>Thanks</p>
python
[7]
4,705,609
4,705,610
Opening doc,docx,Excell files inline of Ie 7.0
<p>Problem :- I am dealing with doc,.docx,xls,.xlsx, Pdf, files with in a ASP.NET application.,</p> <p>While I am clicking a button of Gridview, I need to open that file with in IE 6.0/7.0 BROWSER window., Office files like .docx, .doc, .xls, .xlsx , asking for <strong>open and save</strong> .. or Opening out side of the BROWSER. Browser getting close automatically..</p> <p>But for pdf its working fine..</p> <p>Code: Response.Clear(); Response.ContentType = "application/pdf"; strFilePath= Response.WriteFile(strFilePath);</p> <p>SAME CODE USED - with the content type of "application/msword";</p> <p>But instaed of opening with in browser, its opening out side and automatically, Browser getting closed.</p> <p>Could you please help me on this.. </p> <p>Thanks Karthikeyan</p>
asp.net
[9]
1,066,701
1,066,702
If I set MPMovieControlStyleNone to the property controlStyle at the MPMoviePlayerController, Why is the reference count goes up 2?
<p>If I set MPMovieControlStyleNone to the property controlStyle at the MPMoviePlayerController, Why is the reference count goes up 2? In addition, How can I release _player object ? </p> <p>I made a Class that inherits from UIViewController.</p> <p>Instance variable</p> <pre><code>NSString* _movieFilename; MPMoviePlayerController* _player; </code></pre> <p>Implementation</p> <pre><code>- (MPMoviePlayerController*)makeMoviePlayer:(NSString*)res { NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:res ofType:@""]]; MPMoviePlayerController* player = [[MPMoviePlayerController alloc] initWithContentURL:url]; if (url == nil) return nil; player.controlStyle = MPMovieControlStyleNone; return player; } - (void)viewDidLoad { [super viewDidLoad]; [self.view setBackgroundColor:[UIColor blackColor]]; _player=[self makeMoviePlayer:_movieFilename]; if(_player == nil) return; NSLog(@"[_player retainCount]=%d", [_player retainCount]); } </code></pre> <p>Implementation 1 The implementation as described above. Implementation 2 Delete the fifth row of the implementation. player.controlStyle = MPMovieControlStyleNone;</p> <p>Result 1</p> <pre><code>[_player retainCount]=3 </code></pre> <p>Result 2</p> <pre><code>[_player retainCount]=1 </code></pre> <p>In implementation 2 _payer object can be released in [_player release] . In implementation 1, retainCount is 3. After the execution of [_player release] , retainCount is 2. _player object will not be released. Why retainCount increase 2 ? How can I release _player object ?</p>
iphone
[8]
376,901
376,902
How to get start and end of day in Javascript?
<p>How to get start ( 00:00:00 ) and end ( 23:59:59 ) of today in timestamp ( GMT )? Computer use a local time.</p>
javascript
[3]
4,098,198
4,098,199
to compare double and decimal should I cast double to decimal or decimal to double?
<p>I need to compare two values. One value is <code>price</code> which represents current price of something and so <code>decimal</code> because you actually can buy or sell something by this price.</p> <p>Another value is <code>estimatedPrice</code> which is the result of mathematical calculations and so <code>double</code> because it's just <code>estimation</code> and you can not actually do any "operations" by this <code>esitmatedPrice</code></p> <p>now i want to buy if <code>price &lt; estimatedPrice</code>.</p> <p>So should i cast price to double or estimatedPrice to decimal?</p> <p>I understand that after casting I will get "slighty another" numbers, but it seems I don't have other options.</p>
c#
[0]
5,382,754
5,382,755
Remove clicked element, its parent and parent's previous element
<p>I'm trying to remove all elements below after clicking on the <code>p</code> element. Could you give me any pointers where am I going wrong?</p> <pre><code>&lt;h2&gt;Heading&lt;/h2&gt; &lt;a href="#"&gt; &lt;p&gt;Click me to delete everything&lt;/p&gt; &lt;/a&gt; $('p').click(function() { $(this).remove().parent().remove().prev().remove(); }); </code></pre> <p>Here is a <a href="http://jsfiddle.net/BcAa9/1/" rel="nofollow">jsfiddle</a>.</p>
jquery
[5]
1,355,295
1,355,296
which is better in such java code sample. util or has members due to method parameters both as telephone
<pre><code> public final class TelephoneUtil { private TelephoneUtil() { // no instance } public static void chooseEnglish(Telephone telephone) { SleepForAudioUtil.sleepForChooseLanguage(); telephone.getMediaManager().sendDtmf("1"); } public static void chooseLanguage(Telephone telephone, Language language) { SleepForAudioUtil.sleepForChooseLanguage(); telephone.getMediaManager().sendDtmf(String.valueOf(language.getIndex())); } public static void sendSign(Telephone telephone, Sign sign) { telephone.getMediaManager().sendDtmf(sign.getKeyStr()); } } public final class TelephoneUtil { private Telephone telephone; public TelephoneUtil(Telephone telephone) { this.telephone=telephone; } public void chooseEnglish() { SleepForAudioUtil.sleepForChooseLanguage(); telephone.getMediaManager().sendDtmf("1"); } public void chooseLanguage(Language language) { SleepForAudioUtil.sleepForChooseLanguage(); telephone.getMediaManager().sendDtmf(String.valueOf(language.getIndex())); } public void sendSign(Sign sign) { telephone.getMediaManager().sendDtmf(sign.getKeyStr()); } } </code></pre> <p>which is better in such java code sample. has members due to method parameters both as telephone? or it is just one util tool?</p>
java
[1]
3,506,192
3,506,193
comma in regex in String.replaceAll() method?
<p>My code tries to replace "," with "/" in a string. Should I escape "," in the regex string? Both of the two code snippets generated the same results, so I am confused.</p> <p>Code snippet 1:</p> <pre><code> String test = "a,bc,def"; System.out.println(test.replaceAll("\\,", "/")); </code></pre> <p>Code snippet 2:</p> <pre><code> String test = "a,bc,def"; System.out.println(test.replaceAll(",", "/")); </code></pre> <p>Should I use "," or "\,"? Which is safer?</p> <p>Thanks.</p>
java
[1]
4,443,330
4,443,331
Disable 2 buttons on form submission ( ASP.NET )
<p>I have this solution for a single button:</p> <pre><code>myButton.Attributes.Add("onclick", "this.disabled=true;" + GetPostBackEventReference(myButton).ToString()); </code></pre> <p>Which works pretty well for one button, any ideas on how to expand this to 2 buttons?</p>
asp.net
[9]
4,137,764
4,137,765
How to write the following functions in python?
<p>Suppose there are only four drinks: tea, milk, coffee, and coke,</p> <p>a list of student drinking preference is given, and I want to count how many preferences ranking eg:</p> <pre><code> [['coke', 'milk', 'coffee', 'tea'], ['cola', ',milk', 'tea', 'coffee'], ['cola', 'milk', 'coffee', 'tea']] </code></pre> <p>then return :</p> <pre><code> {('cola', 'juice', 'coffee', 'tea'): 2, ('cola', 'juice', 'tea', 'coffee'): 1} </code></pre>
python
[7]
3,396,885
3,396,886
I need to resize an array of pointers
<p>Lets say i want to resize an array of int pointers, i have a function that looks like this</p> <pre><code> template&lt;typename T&gt; static void Resize(T* arr, UINT oldsize, UINT newsize) { T* ret = new T [newsize]; memcpy(ret, arr, sizeof(arr[0]) * oldsize); delete[] arr; arr = ret; }; </code></pre> <p>The problems begin when i try and resize an array of elements that were created with the "new" keyword (even though the data itself inside the class is POD) because the delete[] triggers their deconstructor which then leaves the new array with pointers to objects that dont exist anymore. So.. even though the objects were created with "new", cant i just use the free command to get rid of the old array? or somehow delete the array without triggering the deconstructor of each member?</p>
c++
[6]
167,770
167,771
concat strings in array and other arrays
<p>I have three arrays:</p> <pre><code>htext[i], ptext[i], and ytext[i] </code></pre> <p>I was wondering how I can walk through these arrays and concat the strings stored in htext[i] and then take this glued string and concat it with strings in ptext[i], and ytext[i], while separating each string by a space. Right now they get merged without a space between them.</p>
php
[2]
4,810,033
4,810,034
Enable href navigation after JQuery addclass
<p>I need to use jQuery's <code>addClass</code> to change the selected anchor tag's style. It is working fine. But after changing the style I want to navigate to a link specified in the <code>href</code>. This is not working since I am using <code>return false;</code> or <code>e.preventDefault()</code>.</p> <p>Please help me.</p> <p>The code which I am using is:</p> <pre><code>$("li").click(function (e) { e.preventDefault(); $("li").removeClass("active"); $(this).addClass("active"); }); &lt;div id="navigation" class="right"&gt; &lt;ul&gt; &lt;li id="nav1"&gt;&lt;a href="../WebForm1.aspx"&gt;&lt;span&gt;Home&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="nav2"&gt;&lt;a href="../AboutUs.aspx"&gt;&lt;span&gt;About Us&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Here the style is applied after clicking the Home link but I want it to navigate to <code>webform1.aspx</code> after this.</p>
jquery
[5]
1,859,983
1,859,984
php strip_tags issue
<p>i want to strip all the html tags from a string except ( <code>&lt;img&gt; and &lt;br&gt;</code> ).</p> <p>i used strip_tags(); but it stript all the html tags.</p> <p>regards</p>
php
[2]
2,641,289
2,641,290
A basic animation not showing up
<p>I still try different basics with android, and now I'm stuck with animation. I'm trying to implement a simple animation. I've defined animation in xml file like this:</p> <p><code>alpha android:interpolator="@android:anim/accelerate_interpolator" android:fromAlpha="0.0" android:toAlpha="1.0" duration="3000" repeatCount="infinite"</code></p> <p>In my main view group I have an ImageView defined like this:</p> <pre><code>&lt;ImageView android:id="@+id/someb" android:src="@drawable/earth_normal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dip"/&gt; </code></pre> <p>And this is from my starting activity class:</p> <p>public class Ohayou extends Activity {</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView earth = (ImageView)findViewById(R.id.someb); Animation earthFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in); earth.startAnimation(earthFadeInAnimation); } </code></pre> <p>It finds ImageView successfuly and creates animation. but when I start emulator ImageView just shows the original src image, not an animation. What am I doing wrong?</p> <p>Thanks</p>
android
[4]
4,772,307
4,772,308
PreviousPage = null in crosspage posting
<p>I'm trying to pass post data from one page to the next but PreviousPage always equals null.</p> <p>This is what I have in the original page (inside an updatepanel )</p> <pre><code>&lt;asp:Button ID="mmGo" runat="server" Text="Merge" PostBackUrl="~/Default2.aspx?action=merge"/&gt; </code></pre> <p>Then in the following page I have:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %&gt; &lt;%@ PreviousPageType VirtualPath="~/Default.aspx" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>...and in the .cs file:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if (PreviousPage != null) { string action = Request.QueryString["action"]; if (action == "merge") { UpdatePanel SourceControl = (UpdatePanel)PreviousPage.FindControl("UpdatePanel1"); HiddenField SourceTextBox = (HiddenField)SourceControl.FindControl("txtListIDs"); if (SourceTextBox != null) { Label1.Text = SourceTextBox.Value; } } } else { Label1.Text = "page is not cross page post back!"; } } </code></pre> <p>Any ideas why the PreviousPage is always equal to null?</p>
asp.net
[9]
3,837,078
3,837,079
how may I access the option values withing an object
<p>I have an object which looks like</p> <pre><code> options = { offers : $$("div.sonan"), prev : offers[0], next : offers[1] } </code></pre> <p>where the property <code>prev</code> represent the first element of <code>offers</code> array and <code>next</code> represent the second element of <code>offers</code> array.</p> <p>How may I use <code>offers</code> property within the <code>options</code> object</p>
javascript
[3]
4,013,893
4,013,894
File upload via FTP gaieerror Python 2.6
<p>I'm trying to upload a text file to an FTP server, but I am getting this error:</p> <p><code>gaierror: [Errno 11004] getaddrinfo failed</code></p> <p>Here is my code.</p> <pre><code> s = ftplib.FTP("ftp://xbrera.co.cc", "myuser", "mypass") f = open(path + "LD.txt", "r") s.storbinary("STOR " + path + "LD.txt") f.close() s.quit() </code></pre> <p>What am I doing wrong, and why am I getting this error? Thanks!</p>
python
[7]
5,405,821
5,405,822
please help with this error : Operator '^' cannot be applied to operands of type 'double' and 'int'
<p>i have the following C# code.</p> <pre><code>double a = 0; double d = 0; double er = 0; int N = numbers.Length; a=(N*N/6) + N d=(N-(N/2))*2 for(int aa=1;aa&lt;=data.length;aa++) { er=((10-aa)*(-a\) + d - (numbers[aa,12]))^2; } </code></pre> <p>numbers is a double array with this format :</p> <pre><code>1 0.3232 0.361 0.5214 0.233 -0.7678 2 0.3451 0.321 0.134 0.224 -0.706268 3 0.3123 0.351 0.155 0.523 -0.70626 4 0.36 0.312 0.216 0.233 -0.6453351 5 0.269 0.3331 0.162 0.224 -0.584962 </code></pre> <p>but when running the code , i got this error on this line:</p> <pre><code> er=((10-aa)*(-a\) + d - (numbers[aa,12]))^2; </code></pre> <p>any help would be appreciated.</p>
c#
[0]
5,857,659
5,857,660
put comma after values but not for last one
<p>I am just a beginner in php. I used the following code to display the user names fetched from the database.</p> <pre><code>$select_tl = "SELECT `varTeamleader` FROM `tbl_team` WHERE `intTeamid` = '" . $id . "'"; $select_tl_res = mysql_query($select_tl); $select_tl_num = mysql_num_rows($select_tl_res); if ($select_tl_num &gt; 0) { $fetch_tl = mysql_fetch_array($select_tl_res); $tl = $fetch_tl['varTeamleader']; $sep_tl = explode(",", $tl); foreach ($sep_tl as $key =&gt; $value) { $sel_tlname = "SELECT * FROM `tbl_user` WHERE `intUserid` = '" . $value . "'"; $sel_tlname_res = mysql_query($sel_tlname); $sel_tlname_num = mysql_num_rows($sel_tlname_res); if ($sel_tlname_num &gt; 0) { $fetch_username = mysql_fetch_array($sel_tlname_res); $user_name = $fetch_username['varName']; echo $user_name . ", "; } } } </code></pre> <p>I need to echo the user_name with comma after every value but not after last one. How can i do that?</p>
php
[2]
1,730,711
1,730,712
How to find the closest descendants (that matches a selector) with jQuery?
<p>We can use <code>closest(selector)</code> to find the first ancestor element that matches the selector. It travels <strong>up</strong> the DOM tree until it finds a match for the selector. But what if I want to travels <strong>down</strong> the DOM tree until it finds a match for the selector? Is there any jQuery function for doing this? Or do I need to implement this using breadth-first search?</p> <p>Give an example. For the DOM tree below,</p> <pre><code>&lt;div id="main"&gt; &lt;div&gt; &lt;ul&gt;&lt;!-- I want to match this ul --&gt; &lt;li&gt; &lt;ul&gt;&lt;!-- but not this ul --&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;ul&gt;&lt;!-- and match this ul --&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>how to do something like <code>$('#main').closestDescendants('ul')</code>?</p>
jquery
[5]
5,470,913
5,470,914
How to force the user to complete a task before pressing back?
<p>I show to user a list of categories, he must choose one.<br> How to force the user to choose before pressing back? </p>
android
[4]
2,834,452
2,834,453
Android Context menu with multiple check boxes
<p>Is it possible to generate a Context menu with multiple checkboxes on clicking a button?</p>
android
[4]
3,346,881
3,346,882
Is there a site with C# recipes similar to ActiveState Recipes for Python?
<p>I really like the way that ActiveState has a collection of recipes for various dynamic languages.</p> <p>Are there similar sites for static languages like C#?</p> <p>Besides the recipes, the discussions are also educational.</p>
c#
[0]
1,175,602
1,175,603
Dispose the handle on exit of application using c#
<p>I am using the below code to block the taskbar which is working perfectly. But since my application is running in background, the only way to exit the application is by killing the .exe from task manager. So while exiting like this, the blocked task bar remains at the same state. But actually it shud resume the taskbar on exiting the application.</p> <p>The reason i am doing this is, it is a kiosk application.</p> <p>what is the way to overcome this.</p> <pre><code>public class Taskbar { [DllImport("user32.dll")] public static extern int FindWindow(string className, string windowText); [DllImport("user32.dll")] public static extern int ShowWindow(int hwnd, int command); public const int SW_HIDE = 0; public const int SW_SHOW = 1; public int _taskbarHandle; protected static int Handle { get { return FindWindow("Shell_TrayWnd", ""); } } public Taskbar() { _taskbarHandle = FindWindow("Shell_TrayWnd", ""); } public static void Show() { ShowWindow(Handle, SW_SHOW); } public static void Hide() { ShowWindow(Handle, SW_HIDE); } } </code></pre>
c#
[0]
3,422,690
3,422,691
Detect and Report typedef Errors... What's This Doing?
<p>I was reading about making code more portable by using fixed-width integers. I found <a href="http://www.netrino.com/node/140" rel="nofollow">this</a> article which helped explain things, and at the end it suggests using this anonymous union to detect and report typedef errors:</p> <pre><code>static union { char int8_t_incorrect[sizeof( int8_t) == 1]; char uint8_t_incorrect[sizeof( uint8_t) == 1]; char int16_t_incorrect[sizeof( int16_t) == 2]; char uint16_t_incorrect[sizeof(uint16_t) == 2]; char int32_t_incorrect[sizeof( int32_t) == 4]; char uint32_t_incorrect[sizeof(uint32_t) == 4]; }; </code></pre> <p>I'm a little lost and I was hoping someone could explain what this is doing?</p>
c++
[6]
2,831,248
2,831,249
jquery select child elements
<p>I'm very new to jQuery.</p> <p>I wrote this code to select child TD elements.</p> <pre><code>$(this) .children("div.tablescroll_wrapper") .children("table.tablescroll_body") .children("tbody") .children("tr.first") .children() </code></pre> <p>It <strong>works fine but looks bad</strong>, Is there a better way to do this?</p> <p>Sorry for my low level English and thank you</p>
jquery
[5]
2,028,157
2,028,158
jQuery - Detect the div id automatically
<p>I'm trying to automatically detect what div is clicked, and then add the text for a specific div. </p> <p>So, here is what I'm trying to do: </p> <pre><code>$('#sjalland').live("click", function(e) { e.preventDefault(); $('#searchBoxBig').val('Sjælland, '); $('#searchBoxBig').focus() return false; }); </code></pre> <p>Now, I have 6 div's that has to activate this function (like #sjalland) when clicked. But right now it looks like I have to create 6 of the same function? </p> <p>How do I create something smart to detect which div is clicked, instead of creating 6 of the same function and then replace #sjalland with #midtjylland, #nordjylland etc etc.? </p>
jquery
[5]
1,080,504
1,080,505
How to get the current dpi at run time in android
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3166501/getting-the-screen-density-programmatically-in-android">getting the screen density programmatically in android?</a> </p> </blockquote> <p>How can I get the dpi of the running device at runtime in android, Thank you</p>
android
[4]
5,588,571
5,588,572
android filesharing with http
<p>I have two android phones.... On first - there is a server with shared folder through WebService.... Another phone is a client, which sends requests to server to download and upload files from android server with requests as Async tasks... </p> <p>When client tryes to download server is vibrating... Code is here.. </p> <pre><code>SharedPreferences settings = getSharedPreferences(PREFS_NAME, MODE_PRIVATE); mPort = settings.getInt("port", DEFAULT_PORT); try { mWebServer = new WebServer(this, settings, new CookiesDatabaseOpenHelper(this).getWritableDatabase(), mPort); mWebServer .setOnTransferStartedListener(new WebServer.TransferStartedListener() { public void started(Uri uri) { Vibrator v1 = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.folder, null, System.currentTimeMillis()); PendingIntent pendingIntent = PendingIntent.getActivity( FileSharingService.this, 0, new Intent( FileSharingService.this, FileShare.class), 0); notification.setLatestEventInfo(FileSharingService.this, "File Share", "Transfer Started", pendingIntent); v1.vibrate(1000); nm.notify(1, notification); } }); } catch (IOException e) { Log.e(TAG, "Problem creating server socket " + e.toString()); } mWebServerThread = new Thread() { @Override public void run() { mWebServer.runWebServer(); } }; mWebServerThread.start(); Log.i(TAG, "Started webserver"); } </code></pre> <p>But I want server vibrate when downloading or uploading are finished.... How could I do it...?</p>
android
[4]
4,863,879
4,863,880
php regex or html dom parsing
<p>I use regex for html parsing but i need yours help to parse following table...</p> <pre><code> &lt;table class="resultstable" width="100%" align="center"&gt; &lt;tr&gt; &lt;th width="10"&gt;#&lt;/th&gt; &lt;th width="10"&gt;&lt;/th&gt; &lt;th width="100"&gt;External Volume&lt;/th&gt; &lt;/tr&gt; &lt;tr class='odd'&gt; &lt;td align="center"&gt;1&lt;/td&gt; &lt;td align="left"&gt; &lt;a href="#" title="http://xyz.com"&gt;http://xyz.com&lt;/a&gt; &amp;nbsp; &lt;/td&gt; &lt;td align="right"&gt;210,779,783&lt;br /&gt;(939,265&amp;nbsp;/&amp;nbsp;499,584)&lt;/td&gt; &lt;/tr&gt; &lt;tr class='even'&gt; &lt;td align="center"&gt;2&lt;/td&gt; &lt;td align="left"&gt; &lt;a href="#" title="http://abc.com"&gt;http://abc.com&lt;/a&gt; &amp;nbsp; &lt;/td&gt; &lt;td align="right"&gt;57,450,834&lt;br /&gt;(288,915&amp;nbsp;/&amp;nbsp;62,935)&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>i want to get all domains with their volume(in array or var) for example </p> <pre><code>http://xyz.com - 210,779,783 </code></pre> <p>Should i use regex or HTML dom in this case, but i really don't know how to parse large table, can you please help, thanks.</p>
php
[2]
5,292,681
5,292,682
What's your naming convention for the View IDs?
<p>I believe that many of us were bothered while naming the View IDs. Unlike the package mechanism, the IDs of the resources in a project are using one common namespace. Therefore, we have to figure out some ways to name the fields with the same functionality but in different layout files.</p> <p>My way is to add the noun or the verb that the layout file's Acitvity class name used in the front of the original ID, separated by a dot. For example,an ID originally named "description" in a Activity displaying a movie's information may become "movie.details.description".</p> <p>Is there any better ideas? </p>
android
[4]
3,813,112
3,813,113
Probed Assembly Paths in code
<p>I'm trying to use the following block of code to force asp.net to look in a subdirectory in addition to the standard ~/bin directory for assemblies. I'm not having any luck getting it to find the assemblies in the sub directory.</p> <p>I'm getting an unable to load type when viewing a page that uses a page class in the subdirectory. </p> <p>Page Header:</p> <pre><code>&lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SubProjects._Default" %&gt; </code></pre> <p>Web.config:</p> <pre><code>&lt;runtime&gt; &lt;assemblyBinding&gt; &lt;probing privatePath="bin;subprojects\bin" /&gt; &lt;/assemblyBinding&gt; &lt;/runtime&gt; </code></pre> <p>A few questions: Is there a configuration problem somewhere that I'm not seeing here? Is there a way using reflection to get a list of the probing directories to see if it's even being read?</p> <p>Looking at the returned list of loaded assemblies, my assemblies in the sub project are not listed.</p> <pre><code>Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies(); </code></pre>
asp.net
[9]
4,510,114
4,510,115
python code slow skin detection
<p>This code changes the color space to LAB and using a threshold finds the skin area of an image. but it's ridiculously slow. I don't know how to make it faster ? </p> <pre><code>from colormath.color_objects import * def skinDetection(img, treshold=80, color=[255,20,147]): print img.shape res=img.copy() for x in range(img.shape[0]): for y in range(img.shape[1]): RGBimg=RGBColor(img[x,y,0],img[x,y,1],img[x,y,2]) LABimg=RGBimg.convert_to('lab', debug=False) if (LABimg.lab_l &gt; treshold): res[x,y,:]=color else: res[x,y,:]=img[x,y,:] return res </code></pre>
python
[7]
5,916,534
5,916,535
How to prevent first onclick execution
<p>I'm writing a javascript function that dynamically creates an Iframe with a button that if pressed can delete its iframe.</p> <p>These are my javascript functions:</p> <pre><code> function createIframe (iframeName, width, height) { var iframe; if (document.createElement &amp;&amp; (iframe = document.createElement('iframe'))) { iframe.name = iframe.id = iframeName; iframe.width = width; iframe.height = height; var connectIP = document.getElementById("ip").value; var connectPORT = document.getElementById("port").value; iframe.src = "http://"+connectIP+":"+connectPORT; document.body.appendChild(iframe); addElement(iframe.name); } return iframe; } function removeIframe(iframeName) { iframe = document.getElementById(iframeName); if (iframe) { var x=iframe.parentNode.removeChild(iframe) } } function addElement(iframeName) { var butt = document.createElement('button'); var butt_text = document.createTextNode('Remove'); butt.appendChild(butt_text); butt.onclick = removeIframe(iframeName); document.body.appendChild(butt); } </code></pre> <p>The problem is that, when the button is created, the onclick function is executed immediately and not only when the user presses it, so my new Iframe is immediately deleted and I cannot see it.</p> <p>How can I solve this problem?</p> <p>Moreover, is it possible to add the button not in the parent body but directly into the new created iframe?</p> <p>Thanks in advance.</p>
javascript
[3]
762,181
762,182
Java Main - Calling another method
<p>I have the following code below:</p> <pre><code>public static void main(String args[]) { start(); } </code></pre> <p>i get this error: Non-static method start() cannot be referenced from a static context.</p> <p>How can i go about doing this?</p>
java
[1]
4,412,240
4,412,241
jQuery Get Class Name
<p>I'm trying to get the class name from an selection of images when clicked.</p> <p>The code below retrieves the first images class name but when I click on my other images with different class values they display the first images class.</p> <p>How can I get each images class value?</p> <p>HTML</p> <pre><code>&lt;a href="#" title="{title}" class="bg"&gt;&lt;img src="{image:url:small}" alt="{title}" class="{image:url:large}" /&gt;&lt;/a&gt; </code></pre> <p>jQuery Code</p> <pre><code> $(".bg").click(function(){ var1 = $('.bg img').attr('class'); </code></pre>
jquery
[5]
5,218,598
5,218,599
Returning object as null returns what?
<p>I have a class and a function that returns an object of that class, if i return NULL what exactly gets returned?</p> <p>Example:</p> <pre><code>class someclass { int a; int b; someclass::someclass(int a, int b) { this-&gt;a = a; this-&gt;b = b; } }; someclass functionname() { return NULL; } someclass foo = functionname(); </code></pre> <p>Since I dont have a default constructor for the class what gets returned? Is it an actual usable object? Or just gibberish? Why cant I check like this?</p> <pre><code>if (foo == NULL) { something } </code></pre>
c++
[6]
94,195
94,196
Continue statement not working
<p>I am new to java </p> <pre><code>int nop=o; BufferedReader scan = new BufferedReader( new InputStreamReader(System.in)); come_here: System.out.println("Enter length"); try{ int n=Integer.parseInt(scan.readLine()); nop=n; }catch(Exception sandy){ System.out.println("Please Enter Numericals only"); continue come_here; } </code></pre> <p>If user entered any string instead of numericals Exceptions occurs and prints "Please Enter Numericals only" and compiler executes next statements, here am loosing user input to overcome that I have used label (<code>come here:</code>), if an Exception occurs it says "Please Enter Numericals only" after that I want program to take user input again, I used continue <code>come_here;</code> but its not working?</p> <p>any anybody tell where I have done mistake? and how to resolve that</p> <p>thank you</p>
java
[1]
519,492
519,493
parsing html file using jquery
<p>Hi I have extracted the html source code from a website using jquery. I am trying to extract link under a specific tag which is of the form <code>&lt;p class="title"&gt; &lt;a href="some link "&gt;</code> I am trying to extract the link under a href. To extract the html i did</p> <pre><code>$.get("link",function(data){ alert($data('p').attr('title')); } </code></pre> <p>data contains the html source code. The alert box shows as undefined. Is it not possible to extract the <p> tag with data in this format? I am not able to get how to extract the link under the href tag. Please help </p>
jquery
[5]
5,410,038
5,410,039
string to binary
<p>I convert a character to binary using <code>std::bitset&lt;CHAR_BIT&gt; binary('c');</code> but this doesn't work for a string,</p> <pre><code>std::string str = "MyString"; std::bitset&lt;SIZE_OF_STRING_IN_BITS&gt; binary(str); //Error Exception </code></pre> <p>what should be the alternative?</p>
c++
[6]
2,757,623
2,757,624
Handling file reading and multiple values to a key in dictionary
<p>How can I code to read the first line from a file and put it as a key value of a dictionary and keep reading next values in a iterative manner and put them as the values to the particular key they fall into in the file. Like example:</p> <p><strong><code>Item Quality Cost Place</code></strong></p> <pre><code>Ball 1 $12 TX Umbrella 5 $35 NY sweater 89 $100 LA </code></pre> <p>So here, the representation is my file. When I read, I want the dictionary to be created as in the things in bold go as keys and when i keep reading lines below that, I would have them going as multiple values in the respective keys.</p> <p>thanks</p>
python
[7]
3,487,234
3,487,235
issue with a code received within an iframe to run a function
<p><img src="http://i.stack.imgur.com/I0Oqk.png" alt="enter image description here"></p> <p>this code has been recieved within <code>iframe</code> in order to run a function called <code>uploadingData(x,y)</code> in the main window but there is a problem as you can see. I cant get what is wrong!!</p>
javascript
[3]
201,159
201,160
strcmp(x, str) is wrong?
<p>As a beginner of C++, I feel so puzzled on this point for a long time, the program is to tell the appearing times of each word in a string.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;vector&gt; using namespace std; int main() { string x; vector&lt;string&gt; str; vector&lt;int&gt; t; while (cin &gt;&gt; x) { int k = 0; for (int j = 0; j != str.size(); j++) { if (strcmp(x,str[j]) == 0) t[j]++; k = 1; } if (k == 0) { str.push_back(x); t.push_back(1); } } for (int i = 0; i != str.size(); i++ ) { cout &lt;&lt; str[i] &lt;&lt; " " &lt;&lt; t[i] &lt;&lt; endl; } return 0; } </code></pre> <p>Here is the error:</p> <pre><code>C++\code\3.3.cpp(17) : error C2664: 'strcmp' : cannot convert parameter 1 from 'class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;' to 'const char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called </code></pre> <p>I find no result on the Internet after a long-time searching. How can I fix this?</p>
c++
[6]
4,222,781
4,222,782
File operations [.txt normal file] in javascript?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/585234/how-to-read-and-write-into-file-using-javascript">How to read and write into file using JavaScript</a> </p> </blockquote> <p>javascript functions for file manipulations like reading &amp; writing ? Im looking for word by word file reading &amp; appending each word in an array of strings.</p>
javascript
[3]
3,705,449
3,705,450
How can we add button in custom cell?
<p>I am working in a app and need to add button in cell by customcell. Can any one help me for this? Thanks in advance</p>
iphone
[8]
5,889,240
5,889,241
javascript add data to table cell
<pre><code>&lt;table border='1' id='output'&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>my javascript code</p> <pre><code> document.getElementById("output").childNodes[0].childNodes[0].nodeValue = ajaxRequest.responseText; </code></pre> <p>Doesnt work please help</p>
javascript
[3]
4,274,423
4,274,424
Why do I get an error in python saying that a method cannot be found even though I previously defined the method?
<pre><code>index = 0 def changeColor(): global index if index%2==0: label.configure(bg = "purple") else: label.configure(bg = "blue") index+=1 label.after(1000, changeColor) def Start (self): # command when start button is clicked in GUI self.root = Tk() self.root.geometry("500x300") mainContainer = Frame (self.root) label = Label(mainContainer, text = "") label.pack(side = LEFT, ipadx = 5, ipady = 5) mainContainer.pack() label.after(1000, changeColor) self.root.mainloop() </code></pre> <p>I get an error saying: NameError: global name 'changeColor' is not defined. Why does this occur and how would I fix it?</p>
python
[7]
341,370
341,371
global and $_SESSION variables with the same name are the same
<p>I got a piece of code:</p> <pre><code>$_SESSION['cms_lang'] = 2; global $cms_lang; $cms_lang[1] = 'en'; </code></pre> <p>Error:</p> <pre><code>Cannot use a scalar value as an array </code></pre> <p>Problem is that, I really don't know why server sees my global variable as the same as $_SESSION variable. I used this piece of code a couple of times and never had problem with that. I guess it must depends of settings on server. Can anyone know <strong>how to force server to not take global and session variables with the same name as the same</strong>?</p>
php
[2]
4,201,239
4,201,240
PHP code not creating new line in rtf template
<p>I reduced a php script to the exact code necessary to solve a perplexing problem (at least to me!). All the script below is supposed to do is replace '++name' in an rtf template with a hard coded variable that will print 'me' on one line, and 'you' on the next line. Besides trying "\r\n" to create the new line, I've also tried "\par" to no avail. The below code replaces '++name' with "meyou" on one line. I have found a number of "solutions" on stackoverflow and other forums, but none have worked for me. </p> <p>Any help is much appreciated.</p> <pre><code> &lt;?php $name = "me" . "\r\n" . "you"; header('Content-type: application/msword'); header('Content-Disposition: inline, filename=filenot.rtf'); $filename = 'rtfnotice.rtf'; $fp = fopen ($filename, 'r'); $output = fread( $fp, filesize($filename)); fclose ($fp); $output = str_replace('++name', $name, $output); echo $output; ?&gt; </code></pre>
php
[2]
5,821,189
5,821,190
Multiple instances of class with static constructor
<p>I have existing design of sort of "singleton" implementation with static constructor. I want to be able to destroy and recreate new instance. </p> <p>Can this be done without changing the base design?</p> <p>This is simplified prototype: </p> <pre><code>public static void main(String[] args) { ClassA.doWork(); ClassA.destruct(); ClassA.doWork(); // &lt;--I need new instance here } public class ClassA { private static ClassA inst = new ClassA(); protected ClassA() { //init } public static void doWork(){ //do work } public static void destruct(){ inst = null; } } </code></pre>
java
[1]
4,103,534
4,103,535
Android Tab Activity
<ol> <li>I have 4 tabs in activity group. </li> <li>In Each tab(Separate Activity group) there are around 5 activities and I'm switching between the activities without any problem. </li> <li>My problem is with the device Emulator device back button.</li> <li>Suppose I'm on 4th tab when application launches. and when I click on back button I'm showing dialog box to exit app. and it showing me the dialog box as well. But when I move to some other activities in 4th tab I'm not able to maintain the stack of activities and whenever I press back button then my app is minimizing. this problem is occurring in all tabs.</li> </ol>
android
[4]
1,405,829
1,405,830
making a pyramide
<p>Trying to make a pyramide here, but I'm new to java and a little stuck.</p> <p>The pyramide figure I am trying to make have three parameters: one that show how many lines the pyramide should have, one that choose the symbol that should be used and one that shows if the peak should be down.</p> <p>The pyramide have used those methods: 5, x and false.</p> <p>And that should print at this pyramide:</p> <pre><code> x x x x x x x x x x x x x x x </code></pre> <p>Anyone that know a solution?</p> <p>I have tried making a pyramide with some googling, but I am only getting this output: X XX XXX XXXX XXXXX</p> <p>And not the false part to the decide if the peak should be down.</p>
java
[1]
5,418,190
5,418,191
Replace multi UTF-8 chars with one same acs ii char by preg_replace()
<p>I have to convert a UTF-8 string to non UTF-8 string, I want to replace:</p> <p><strong>Ậ,Ẫ,Ẩ,Ầ,Ấ,Â,Ặ,Ẵ,Ẳ,Ằ,Ắ,Ă,Ạ,Ã,Ả,À,Á</strong> to <strong>A</strong>,</p> <p><strong>Ự,Ữ,Ử,Ừ,Ứ,Ư,Ụ,Ũ,Ủ,Ù,Ú</strong> to <strong>U</strong>,</p> <p><strong>Ợ,Ỡ,Ở,Ờ,Ớ,Ơ,Ộ,Ỗ,Ổ,Ồ,Ố,Ô,Ọ,Õ,Ỏ,Ò,Ó</strong> to <strong>O</strong>... and much more with same case</p> <p>By php <code>preg_replace()</code> ?</p> <p>May I use ?:</p> <pre><code>$string = preg_replace('/Ậ,Ẫ,Ẩ,Ầ,Ấ,Â,Ặ,Ẵ,Ẳ,Ằ,Ắ,Ă,Ạ,Ã,Ả,À,Á/', 'A', $string); $string = preg_replace('/Ợ,Ỡ,Ở,Ờ,Ớ,Ơ,Ộ,Ỗ,Ổ,Ồ,Ố,Ô,Ọ,Õ,Ỏ,Ò,Ó/', 'O', $string); $string = preg_replace('/Ự,Ữ,Ử,Ừ,Ứ,Ư,Ụ,Ũ,Ủ,Ù,Ú/', 'U', $string); </code></pre>
php
[2]
4,225,020
4,225,021
Char/String comparison
<p>I'm trying to have a suggestion feature for the search function in my program eg I type janw doe in the search section and it will output NO MATCH - did you mean jane doe? I'm not sure what the problem is, maybe something to do with char/string comparison..I've tried comparing both variables as type char eg char temp -->temp.Contains ...etc but an error appears (char does not contain a definition for Contains). Would love any help on this! 8)</p> <pre><code>if (found == false) { Console.WriteLine("\n\nMATCH NOT FOUND"); int charMatch = 0, charCount = 0; string[] checkArray = new string[26]; //construction site ///////////////////////////////////////////////////////////////////////////////////////////////////////////// for (int controlLoop = 0; controlLoop &lt; contPeople.Length; controlLoop++) { foreach (char i in userContChange) { charCount = charCount + 1; } for (int i = 0; i &lt; userContChange.Length; ) { string temp = contPeople[controlLoop].name; string check=Convert.ToString(userContChange[i]); if (temp.Contains(check)) { charMatch = charMatch + 1; } } int half = charCount / 2; if (charMatch &gt;= half) { checkArray[controlLoop] = contPeople[controlLoop].name; } } /////////////////////////////////////////////////////////////////////////////////////////////////////////// Console.WriteLine("Did you mean: "); for (int a = 0; a &lt; checkArray.Length; a++) { Console.WriteLine(checkArray[a]); } /////////////////////////////////////////////////////////////////////////////////////////////////// </code></pre>
c#
[0]
5,923,862
5,923,863
how can I set the margin of a EditText using xml?
<p>hi all i have created layout using following code</p> <p> <pre><code> android:layout_height="wrap_content"&gt;&lt;/TextView&gt; &lt;EditText android:layout_height="wrap_content" android:padding="12dip" android:layout_width="wrap_content" android:text="EditText" android:id="@+id/editText1"&gt;&lt;/EditText&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; &lt;TableRow android:layout_width="match_parent" android:id="@+id/tableRow2" android:layout_height="wrap_content"&gt; &lt;TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView2"&gt;&lt;/TextView&gt; &lt;EditText android:text="EditText" android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/EditText&gt; &lt;/TableRow&gt; &lt;TableRow android:layout_width="match_parent" android:id="@+id/tableRow3" android:layout_height="wrap_content"&gt; &lt;Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/Button&gt; &lt;Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/Button&gt; &lt;/TableRow&gt; </code></pre> <p> but now i want to set the margin.how can I do this using XML?</p>
android
[4]
4,094,829
4,094,830
how to use Quaternions in android opengl?
<p>I studied about that Quaternion in android OPENGL ES2.0.</p> <pre><code>some what i understood about that. but, i did not get any clear idea about that Quaternion. can anyone give suggest any example for theoretically and android pro grammatically. Thanks Advance... </code></pre>
android
[4]
5,621,568
5,621,569
newline question
<p>I want to detect a carriage return or a newline character when a user enters data into a textarea. What is the best way to handle this? I've tried str_replace with escape characters but carriage returns and newlines are not detected.</p> <hr> <p>OK, say I type the following into a textarea:</p> <pre><code>The summer was hot this year but next year is supposed to be cooler. </code></pre> <p>I want to detect the CRs. In this case, there is one.</p>
php
[2]
2,396,351
2,396,352
Jquery Page Timer
<p>Is this possible using jQuery/PHP? I am looking to have my webpage automatically go to a different web page at a certain time of day. For example, i have a 'breakfast' page that is supposed to auto-redirect to the 'Lunch' (www.mylunchpage.com) page at noon. Then the lunch page go to 'Dinner' (www.mydinnerpage.com) page at 5pm. I want it all based on time of day on not on a timer.</p> <p>Yes, the browser will be open all day...</p> <p>Any idea on how to make this work? Any advise will be greatly appreciated.</p>
jquery
[5]
4,342,144
4,342,145
JQuery test value coming back from select
<p>It has options with values <code>true</code> and <code>false</code>.</p> <p>I have some jQuery here:</p> <pre><code>$("#myselect").change(function () { var accepted = $(this)[0].value; alert(accepted); if(accepted == false) { alert("Hi"); } }); </code></pre> <p>What I don't understand is why the Hi message is never shown.</p> <p>The condition in the <code>if</code> is always coming through <code>false</code>.</p> <p>Could someone please help me with this I'm fairly new to jQuery.</p>
jquery
[5]
4,762,573
4,762,574
Is there a browser on android accepting extensions?
<p>I know how to make java programs on android, and I've yet included Browsers in my programs, but I'm more looking for the kind of extension system (with code in javascript) that we have on our desktop versions of Firefox and Chrome.</p> <p>Is there something similar on Android ?</p> <p>My goal would be to port one of my Chrome extensions to Android. Do the Chrome team make something for Android ?</p>
android
[4]
2,943,356
2,943,357
Reading from file in c++
<p>Im trying to learn a bit about c++ and have run in to some trouble.</p> <p>I have the following code:</p> <pre><code>char board[5][5]; ifstream myReadFile; myReadFile.open("c:/test.txt"); for(int i=0; i&lt;5; i++) { for(int j=0; j&lt;5; j++) { while (myReadFile.good()) { board[i][j] = myReadFile.get(); cout &lt;&lt; board[i][j]; } } } myReadFile.close(); for(int x=0; x&lt;5; x++) { for(int y=0; y&lt;5; y++) { cout &lt;&lt; board[x][y]; } cout &lt;&lt; endl; } </code></pre> <p>Now i was expecting the first loop to read the chars from the txt file and this works, so yeah! But the second loop, i was expecting to print the same char back to cout. However this was not the case, so i add the line</p> <pre><code>cout &lt;&lt; board[i][j] </code></pre> <p>to the first loop to see if they where loading correctly. This is the result i get</p> <p><img src="http://tbmilena.dk/test.png" alt="results"></p> <p>Can someone explain why the second loop isn't printing the same as the first.</p>
c++
[6]
2,503,769
2,503,770
How to select more than one checkbox in gridview and show the details in another Gridview in asp.net with c#
<p>In my project i have a need to select some check boxes in a GridView and show the details in another gridview. I use an arraylist to keep all the values of the checkbox using the foreach loop, but i can't able to display the records in another Grid view. Any help will be highly appreciated.</p>
asp.net
[9]
2,744,778
2,744,779
Jquery Plus/Minus Incrementer
<p>I want to have a client side Plus / Minus system where a user can click the plus and a value is incremented by 1, minus and the value is decreased by 1, the value should never go below zero and should start on 0. Is there a way to do this simply in jquery? All the jquery plugins look at bit OTT for this operation.</p> <p>Any help appreciated, ta.</p>
jquery
[5]
4,723,156
4,723,157
Use Function in Javascript
<p>in the following javascript code I see there's a use of the command function, but it didn't specify the name of the function. What's this all about?</p> <pre><code>var getReview = function(movie) { switch (movie) { case "Matrix": return "good trip out"; break; case "Princess Bride": return "awesome date night movie"; break; case "Welcome to America": return "Amjad's favorite"; break; case "Remember the Titans": return "love the sports"; break; case "Why do I look like I'm 12?": return "The Ryan and Zach story"; break; case "Fighting Kangaroos in the wild": return "Token Australian movie for Leng"; break; default: return "I don't know!"; } };​ </code></pre>
javascript
[3]
2,014,785
2,014,786
Force inclusion of a header in project
<p>I have a header with a particular set of rules that the user must follow. If the user does not want to follow the rules, they must define a preprocessor macro which will disable the checks. If the user is using the library, the user must include the header in every one of their classes that uses any code from the library or explicitly state otherwise by the above mentioned preprocessor (in this case, the header may be included implicitly [using one of the library's classes] which is fine):</p> <pre><code>// User using my library, they must include the BaseHeader.h or otherwise use the following define // #define NOT_USING_BASE_HEADER //(can of course be defined project wide) #include &lt;BaseHeader.h&gt; // ... other includes (not necessarily from my library) class Foo { //... }; </code></pre> <p>Is there a way to accomplish this? Keep in mind that the base header is also being included </p>
c++
[6]
3,540,493
3,540,494
How to type π (pi) in Java?
<p>Is there a character within the Math API that allows for representing the character <code>π</code>?</p>
java
[1]
1,230,932
1,230,933
C# Compile a class other than DLL
<p>I am new to <strong>C#</strong>. I am not a good programmer but I have worked on some projects which were in <strong>Delphi7</strong>. In Delphi there is one option; compile the class files to create <strong>.dcu</strong>. Those <strong>.dcu</strong> can be used without having the actual code with any other project in Delphi and after build <strong>.dcu</strong> files need not no given to end user.</p> <p>Now my actual Question,</p> <p><em>Is there any way where I can create some compiled file from my C# class and use that compiled unit with some other project in C# ?</em></p> <p>I already tried to create dll and use. Nice Idea, but I don't want to give any other file than Configuration File and Executable file. Since, I created dll that needs to give with application.</p> <p>I also tried to create a setup of application which build executable, configuration file and dll together. while executing, it extract itself in %temp% folder and executes from there only. So, In this case I am not able to set the configuration file's values.</p> <p>Again the same question,</p> <p><em>Is there any way where I can create some compiled file from my C# class and use that compiled unit with some other project in C# ?</em> <br> <br> <br> Please suggest the solution</p> <p>Thanks</p>
c#
[0]
2,309,743
2,309,744
Notify User when the installed app is
<p>I want to notify user in an alert dialog that if my app is updated in the market when the app launched by user. </p> <p>Is there any service to call and get the updates from market of particular app?.</p>
android
[4]
5,917,982
5,917,983
why does my 'join' function run wrong
<pre><code>b=','.join([1,2,3,4,5]) print b </code></pre> <p>I want it to print the string: <code>'1,2,3,4,5'</code></p> <p>In your answers, please try to use code examples rather than text, because my English is not very good. Thank you.</p>
python
[7]
5,700,028
5,700,029
Pass a dict to a function in python
<p>I have the following function:</p> <pre><code>def create_dict(dict={}): # build the dict receiver(dict) def receiver(dict): item_1 = dict[item_1] ... </code></pre> <p>How would I correctly pass the dict to the receiver function such that I can easily retrieve the values from the keys?</p>
python
[7]
1,405,786
1,405,787
How do I access a method in the root view controller from a different class?
<p>I apologize if this is an easy one.</p> <p>I have my root view controller NB_ViewController. I have another class named ShowScreen. How can ShowScreen access a method in NB_ViewController?</p> <p>Thank you so much in advance.</p>
iphone
[8]
1,851,910
1,851,911
How to make "int" parse blank strings?
<p>I have a parsing system for fixed-length text records based on a layout table:</p> <pre><code>parse_table = [\ ('name', type, length), .... ('numeric_field', int, 10), # int example ('textc_field', str, 100), # string example ... ] </code></pre> <p>The idea is that given a table for a message type, I just go through the string, and reconstruct a dictionary out of it, according to entries in the table.</p> <p>Now, I can handle strings and proper integers, but <code>int()</code> will not parse all-spaces fields (for a good reason, of course).</p> <p>I wanted to handle it by defining a subclass of <code>int</code> that handles blank strings. This way I could go and change the type of appropriate table entries without introducing additional kludges in the parsing code (like filters), and it would "just work".</p> <p>But I can't figure out how to override the constructor of a build-in type in a sub-type, as defining constructor in the subclass does not seem to help. I feel I'm missing something fundamental here about how Python built-in types work.</p> <p>How should I approach this? I'm also open to alternatives that don't add too much complexity.</p>
python
[7]
1,201,044
1,201,045
Can i create message box which will be seen/popup on current screen/home screen in Android?
<p>i want to create message box which must be seen on current screen(Ex i am playing song or creating message on that screen also that message must got pop-up/seen)like notification.. so.please help me to achieve this.....</p> <p>Thanks in Advance--</p>
android
[4]
3,574,090
3,574,091
Can I use these PHP functions together?
<p>Can I use these PHP functions below:</p> <pre><code>$user = mysql_escape_string($user); $user = filter_var($user, FILTER_SANITIZE_STRING); $user = stripslashes($user); $user = trim($user); </code></pre> <p>together like this:</p> <pre><code>$user = mysql_escape_string(stripslashes(trim(filter_var($user, FILTER_SANITIZE_STRING)))); </code></pre> <p>sorry if this is a stupid question.</p>
php
[2]
4,510,470
4,510,471
error while moving an uploaded image
<p>Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phptMeFd4' to './photogallery/4bf2806a0d80c4ad68aa5e4e20dscn6842.jpg' in /some path/addsplashphoto.php on line 49</p> <p>am trying to upload photo to a destination folder in my server but each and every time an error like above is appearing..same code is working quite well at localhost(i have set changed the file permissions of my server folder but still have the same problem )</p> <p>somebody please tell me the reason of this error...</p>
php
[2]
3,990,016
3,990,017
How can I execute dynamic SQL in c#?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4629/c-eval-equivalent">C# eval equivalent?</a> </p> </blockquote> <p>how can i execute A command from some string on windows forms application like this:</p> <pre><code>string s=" MessageBox.Show(\"Hello World !\"); " //and then execute s like a dynamic string in sql //execute(s) </code></pre> <p>//does it mean that there is no command that executes string in c#?</p>
c#
[0]
2,717,485
2,717,486
C++: how to add int to current string in C++?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/191757/c-concatenate-string-and-int">C++ concatenate string and int</a> </p> </blockquote> <p>Hi,</p> <p>In C# I can write like this:</p> <pre><code>int i = 0; string text = "out.jpg"; while(true) { i++; Object.write(i+text, stream); } </code></pre> <p>But this is not true for C++. the problem is at: i + default.</p> <p>How could I fix this in C++?</p> <p>Thanks in advance. Your help is much appreciated!</p>
c++
[6]
2,948,003
2,948,004
How can I make it really difficult to bot a multiply tetris game?
<p>I thought about making a multiplayer tetris game using web technologies. However, as the source code is very public when writing a web-based JavaScript/HTML5 game, it would be fairly simple to program a bot to play a near perfect game. So, how could one make it really difficult to bot a tetris game?</p> <p>I figured, that I could do something fancy like running the game entirely on a server and stream the game as a video using HTML canvas, but this will still be fairly simple to write a bot for, I would presume.</p> <p>What sort of thing could I do to make it difficult to write a bot for this game, multiplayer tetris?</p>
javascript
[3]
2,779,726
2,779,727
Java Disable OSX Force Quit
<p>How can I disable force quit from within my java application? Either that, or how about disabling it from .plist?</p>
java
[1]
4,185,363
4,185,364
Typecasting method pointer to parent class method
<p>What i'm trying to do is somewhat obscure, so let me show on an example (this is not the actual code):</p> <pre><code>template &lt;class T&gt; class ArrayStorage { protected: void processStuff(void (ArrayStorage&lt;T&gt;::*procedure)(T *)) { for (int i = 0; i &lt; count; i++) (this-&gt;*procedure)(content[i]); } // No method of type void (ArrayStorage&lt;T&gt;::*)(T *) private: T **content; int count; }; class DrawableStorage : public ArrayStorage&lt;Drawable&gt; { public: void drawStuff() { processStuff((void (ArrayStorage&lt;Drawable&gt;::*)(Drawable *)) &amp;DrawableStorage::drawOne); } private: void drawOne(Drawable *item) { item-&gt;draw(); } }; </code></pre> <p>Basically, there is a generic container that is able to iterate through its items and use a method on each of them (whose pointer is in the parameter). This method however does not exist in this class, but only in its subclasses. You can see that in the subclass "drawStuff" method, i supply a method pointer of the sublass, but typecasted as a method of the base class.</p> <p>Suprisingly enough, this has successfully compiled and works just fine.</p> <p>My question is, is it just a coincidence that my particular compiler was able to handle it while in fact it is completely invalid and i should get rid of it, or is it correct usage of method pointers?</p> <p>Thank you.</p>
c++
[6]
2,409,518
2,409,519
Debugging the EXEC_BAD_ACCESS on Iphone using Performance Tool, Allocations
<p>An error is caught, using Zombie CFString Foundation Library<br> caller {NSPlaceholderMutableString int] Malloc</p> <p>CFString Foundation Library<br> caller {NSPlaceholderString initWithFormat:locale} Zombie</p> <p>well it didn't drop to where I declared. I have no idea where that NSMutablestring is called and which variable it is</p>
iphone
[8]
3,545,841
3,545,842
What does it mean to be a daemon thread?
<p>I'm fully aware of the impact of flagging a thread as a daemon thread on JVM exit (if all non-daemon threads exit, the JVM will exit.)</p> <p>Are there other side-effects to setting a thread as a daemon?</p> <p>(as a complete aside, which is really irrelevant except for semantics, is the meaning of a daemon thread not backwards in this case: shouldn't a daemon thread keep the JVM alive...for instance, if I wrote my own HTTP daemon and started it running, wouldn't I want the JVM to remain alive as long as that thread is alive? Or is there some other semantic for the term 'daemon'?)</p>
java
[1]
5,883,012
5,883,013
Include if file exists
<p>I need an <code>include</code> function / statement that will include a file only if it exists. Is there one in PHP?</p> <p>You might suggest using <code>@include</code> but there is an issue with that approach - in case the file to be included exists, PHP will not output warnings if the parser find something wrong in the included file.</p>
php
[2]
1,398,495
1,398,496
jQuery find() function current element
<p>I'm trying to move strings from name attributes to the src of each img. I'm using jQuery to do this:</p> <pre><code>$("#one").find("img").attr("src",$(this).attr("name"); </code></pre> <p>Now the problem is that $(this) is not the current manipulated element. So how do I get the current element that find() has found?</p>
jquery
[5]
4,226,783
4,226,784
running a function when another is clicked using jquery
<p>When i run this <code>$btns.first().click();</code> in the first function it doesnt action it where as if i click it (as per second function it works perfectly. The result is the slides all show when i click on a tab instead of just one. And then when i click one of the inner buttons the slides all disapear leaving just one. Which is correct. </p> <p><a href="http://jsfiddle.net/p259x/" rel="nofollow">http://jsfiddle.net/p259x/</a></p> <p>I know this is hard to understand so hopefully the link helps.</p>
jquery
[5]
3,965,601
3,965,602
What is the better approach to convert primitive data type into String
<p>I can convert an integer into string using</p> <pre><code>String s = "" + 4; // correct, but poor style or String u = Integer.toString(4); // this is good </code></pre> <p>I can convert a double into string using</p> <pre><code>String s = "" + 4.5; // correct, but poor style or String u = Double.toString(4.5); // this is good </code></pre> <p>I can use <code>String s = "" + data</code>approach to convert either an int or double into String. While If I wants to use the other approach using <code>toString()</code> I have to use the Wrapper class of each data type. Then why in <a href="http://ww0.java3.datastructures.net/contents/supplement2.pdf" rel="nofollow"><strong>some books</strong></a> it is mentioned that the first approach is poor one while the second one is the better. <strong>Which one is the better approach and why?</strong></p>
java
[1]
5,838,126
5,838,127
Identifying each table row using SQl
<p>I have created a table using HTML that retrieves data from my database. At the end of each row, I have manually added a submit button which is inside the while loop as the data is retireved from the database. Once the button is clicked, the session username is inserted into a table in the database. I also want it to enter other data of only the specific row. With what I have right now, no matter which button you click on any row, the data from the first row is only inserted.</p> <p>Thanks for all your help.</p> <p>In simpler words, on button click how do I select the data from that row where the button is present and insert it into the db?</p> <pre><code>mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM Persons"); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;Firstname&lt;/th&gt; &lt;th&gt;Lastname&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['FirstName'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['LastName'] . "&lt;/td&gt;"; echo "&lt;td&gt;"; include "button.php"; echo "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; </code></pre> <p>Button.php checks for the session_username and adds it to the database. I want it to also insert the "firstname" .</p>
php
[2]
5,418,796
5,418,797
Sorting a dictionary by value then by key
<p>This seems like it has to be a dupe but my SO-searching-fu is poor today...</p> <p>Say I have a dictionary of integer key/values, how can I sort the dictionary by the values descending, then by the key descending (for common values).</p> <p>Input:</p> <pre><code>{12:2, 9:1, 14:2} {100:1, 90:4, 99:3, 92:1, 101:1} </code></pre> <p>Output:</p> <pre><code>[(14,2), (12,2), (9,1)] # output from print [(90,4), (99,3), (101,1), (100,1), (92,1)] </code></pre>
python
[7]
1,751,099
1,751,100
Calculate date/time difference in java
<p>I want to calculate difference between 2 dates in hours/minutes/seconds. I have a slight problem with my code here it is :</p> <pre><code>String dateStart = "11/03/14 09:29:58"; String dateStop = "11/03/14 09:33:43"; // Custom date format SimpleDateFormat format = new SimpleDateFormat("yy/MM/dd HH:mm:ss"); Date d1 = null; Date d2 = null; try { d1 = format.parse(dateStart); d2 = format.parse(dateStop); } catch (ParseException e) { e.printStackTrace(); } // Get msec from each, and subtract. long diff = d2.getTime() - d1.getTime(); long diffSeconds = diff / 1000; long diffMinutes = diff / (60 * 1000); long diffHours = diff / (60 * 60 * 1000); System.out.println("Time in seconds: " + diffSeconds + " seconds."); System.out.println("Time in minutes: " + diffMinutes + " minutes."); System.out.println("Time in hours: " + diffHours + " hours."); </code></pre> <p>This should produce :</p> <pre><code>Time in seconds: 45 seconds. Time in minutes: 3 minutes. Time in hours: 0 hours. </code></pre> <p>However I get this result :</p> <pre><code>Time in seconds: 225 seconds. Time in minutes: 3 minutes. Time in hours: 0 hours. </code></pre> <p>Can anyone see what I'm doing wrong here ?</p>
java
[1]
4,899,236
4,899,237
Using print_r in ob_start
<p>As mentioned in the manual it's not working. i tried var_dump it too suffers from the same problem. </p> <pre><code>ob_start() $debugdata=print_r ($var,true) </code></pre> <p>This prints the result on screen than storing to a variable </p>
php
[2]
2,796,747
2,796,748
Only variables should be passed by reference
<pre><code>// Other variables $MAX_FILENAME_LENGTH = 260; $file_name = $_FILES[$upload_name]['name']; //echo "testing-".$file_name."&lt;br&gt;"; //$file_name = strtolower($file_name); $file_extension = end(explode('.', $file_name)); //ERROR ON THIS LINE $uploadErrors = array( 0=&gt;'There is no error, the file uploaded with success', 1=&gt;'The uploaded file exceeds the upload max filesize allowed.', 2=&gt;'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 3=&gt;'The uploaded file was only partially uploaded', 4=&gt;'No file was uploaded', 6=&gt;'Missing a temporary folder' ); </code></pre> <p>Any ideas? After 2 days still stuck</p>
php
[2]
4,430,539
4,430,540
How do I directly access a PHP file located in my themes folder?
<p>I have a file in my theme's folder called "test.php".</p> <p>If I go to www.mysite.com/wp-content/themes/my-theme/folder/test.php the theme loads which I assume is a 404 error handled by WP. If I change the file name to be test.html I can access it no problem.</p> <p>I tried adding the following code to my functions.php file (to add a rewrite rule):</p> <pre><code>add_rewrite_rule( 'test.php$', $relative_directory . '/folder/test.php [L]', 'top' ); </code></pre> <p>but even having the htaccess rule didn't seem to do anything.</p> <p>Any idea what could be causing this?</p>
php
[2]
379,175
379,176
Is there a function to find the absolute root path in php?
<p>for example:</p> <p>/home/mydomain.co.uk/public_html/</p> <p>Something generic for windows or linux? Id like it to produce the root path only regardless of where i call the script from. So not the absolute root path to my script.</p> <p>Sorry is this is hard to understand.</p>
php
[2]
3,005,794
3,005,795
How to deploy a website to internet.(ASP.NET and SQL Server )
<p>I am new to the web development.I have built my website in visual studio 2008 using Sql server 2008 as backend.Now I want to know the whole process of deploying the website in some web domains and as well as my database to some database domain.I didn't purchase any domain till now.I want to know about web hosting as well.</p> <p>Please help me.I have googled but did not find anything which give me complete idea about this.Please refer me some documents which i can go through or something else. Thanks</p>
asp.net
[9]
3,775,932
3,775,933
Programing exercise
<p>Hi I have been doing the Javabat exercises and I have found myself in a bit of a snag with this problem:</p> <p>We'll say that a String is xy-balanced if for all the 'x' chars in the string, there exists a 'y' char somewhere later in the string. So "xxy" is balanced, but "xyx" is not. One 'y' can balance multiple 'x's. Return true if the given string is xy-balanced. </p> <pre><code>xyBalance("aaxbby") → true xyBalance("aaxbb") → false xyBalance("yaaxbb") → false </code></pre> <hr> <pre><code>public boolean xyBalance(String str) { if(str.length() &lt; 2){ if(str == "x"){ return false; } return true; } for (int i = 0 ; i &lt; str.length()- 1;i++){ if (str.charAt(i)=='x' &amp;&amp; str.charAt(i + 1) == 'y'){ return true; } } return false; } </code></pre>
java
[1]
1,325,890
1,325,891
simple asp.net webforms ul li menu with selected class
<p>I have a simple unordered list with links in it.</p> <pre><code>&lt;body&gt; &lt;div id="topMenu"&gt; &lt;ul&gt; &lt;li&gt;&lt;a class="selected" href="../Default.aspx"&gt;Start&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="../Category/ShowAll.aspx"&gt;Categories&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="../Elements/ShowAll.aspx"&gt;Elements&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="../Articles/ShowAll.aspx"&gt;Articles&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;asp:ContentPlaceHolder ID="MainContentPlaceholder" runat="server"&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;/body&gt; </code></pre> <p>I want to change the class of the link i click to the "selected" class, which is the easiest way to do this. I thought about making it into linkbuttons and saving the info in the session, but that seems overkill, there has to be an easier approach?</p>
asp.net
[9]
4,848
4,849
Manually Remove and Change WordPress Page/Post Title
<p>I have added custom metaboxes into the wp-admin page and post editors. There is a metabox with the ability to enter in a person's first name (ex. "John") and last name (ex. "Doe"). </p> <p>I want to set that particular post's/page's title to the combined values of those form entries (ex. "John Doe") without having to enter it in the top page/post title bar. This would, thus allow the post/page to behave like a contact card. Preferably, I would like this to work with permalinks too.</p> <p><em>I must include any non-native and new code into the functions.php file of my child theme <strong>only</strong>.</em></p> <p>For Reference: I am using the Genesis Framework.</p> <p>Any suggestions?</p>
php
[2]