Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,705,296
1,705,297
Inheriting a class with constructor arguments in java
<p>The situation is I want to inherit an object to have a cleaner constructor interface:</p> <pre><code>class BaseClass { public BaseClass(SomeObject object){ ... } } class SubClass extends BaseClass{ private SubObject subObject = new SubObject(); public SubClass(){ super(new SomeObject(subObject)); // doesn't compile } } </code></pre> <p>But to do that I need to do stuff before the constructor like in the example above but can't because Java doesn't allow that. Is there any way around this? I'm starting to feel that if your class is designed to be subclassed it should always implement default constructor and provide setters for the values it needs... Sometimes you can get away with this if you create a new object straight into the super constructor as an argument but if you need a reference to the object you created then you are hosed.</p>
java
[1]
2,949,497
2,949,498
Dispay printer dialog
<p>I use this line to have Adobe Reader print my generated pdf :</p> <pre><code>desktop.print(new File("temp.pdf")); </code></pre> <p>It always uses the standard printer. Is there a way to display the "choose printer" dialog instead?</p>
java
[1]
260,243
260,244
Why is <asp:ListItem> not allowed inside <asp:RadioButtonList>?
<p>I went to compile my asp.net website (.Net 2.0, VS 2008) and got some strange errors from the compiler.</p> <pre><code>Literal content ('&lt;asp:ListItem "1" Text="Yes"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem "0" Text="No"&gt;&lt;/asp:ListItem&gt;') is not allowed within a 'System.Web.UI.WebControls.ListItemCollection'. </code></pre> <p>This is the "offending" code:</p> <pre><code>&lt;td align="center" class="tournamentformtext"&gt; &lt;asp:RadioButtonList ID="rblTrueORFalse" runat="server" RepeatDirection="Horizontal"&gt; &lt;asp:ListItem "1" Text="Yes"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem "0" Text="No"&gt;&lt;/asp:ListItem&gt; &lt;/asp:RadioButtonList&gt; &lt;/td&gt; </code></pre> <p>The wierdest thing about this is that this page has not been touched in quite some time and all of a sudden it starts blowing up. </p> <p>Does anyone have any clue what is going on? If you need more info, ask and I'll be happy to provide what I can.</p>
asp.net
[9]
3,284,277
3,284,278
Problem with indexOf on JavaScript array
<pre><code>var allProductIDs = [5410, 8362, 6638, 6758, 7795, 5775, 1004, 1008, 1013, 1014, 1015, 1072, 1076, 1086, 1111, 1112, 1140]; lastProductID = 6758; </code></pre> <p>for some reason I get a -1 or I guess which is equivalent to not found for this:</p> <pre><code>alert(allProductIDs[allProductIDs.indexOf(lastProductID)); </code></pre> <p>I can't figure out for the life of my why because it should find 6758 and that would be index 3. If it's index 3 then I should get back 6758 I would think.</p>
javascript
[3]
2,405,349
2,405,350
jQuery exclude elements with certain class in selector
<p>I want to setup a click event trigger in jQuery for certain anchor tags.</p> <p>I want to open certain links in a new tab while ignoring ones with a certain class (before you ask I cannot put classes on the links I am trying to catch as they come from a CMS).</p> <p>I want to exclude links with class "button" OR "generic_link"</p> <p>I have tried</p> <pre><code>$(".content_box a[class!=button]").click(function (e) { e.preventDefault(); window.open($(this).attr('href')); }); </code></pre> <p>But that doesn't seem to work, also how do I do an OR statement to include "generic_link" in the exclusion?</p> <p>Many thanks</p>
jquery
[5]
2,102,485
2,102,486
Python: Convert list of ints to one number?
<p>I have a list of integers that I would like to convert to one number like:</p> <pre><code>numList = [1,2,3] num = magic(numList) print num, type(num) &gt;&gt;&gt; 123, &lt;type 'int'&gt; </code></pre> <p>What is the best way to implement the <i>magic</i> function?</p> <p>Thanks for your help.</p> <p><b>EDIT</b> <br> I did find <a href="http://bytes.com/groups/python/722951-int-str-list-elements" rel="nofollow">this</a>, but it seems like there has to be a better way.</p> <p><b>EDIT 2</b> <br> Let's give some credit to <a href="http://stackoverflow.com/questions/489999/python-convert-list-of-ints-to-one-number#490020">Triptych</a> and <a href="http://stackoverflow.com/questions/489999/python-convert-list-of-ints-to-one-number#490031">cdleary</a> for their great answers! Thanks guys.</p>
python
[7]
3,098,014
3,098,015
How to use Marshal.getActiveObject() to get 2 instance of of a running process that has two processes open
<p>Currently my code uses </p> <pre><code>SurferApp = Marshal.GetActiveObject("Surfer.Application") as Surfer.Application </code></pre> <p>to get the running instance of a software called surfer, for the sake of simplicity we can replace Surfer to Word that everyone knows about. Now let's say I have 2 MS word application running and I want to get both of them using <code>Marshal.GetActiveObject()</code>, how can I get both the running instances and associate each with a separate object?</p>
c#
[0]
3,379,822
3,379,823
Why do I have to specify namespace when choosing startup form?
<p>I wasn't able to set my new form as a startup form, it complained about it not existing. But after some minutes I tried with typing "Namespace.NewForm" and that worked.</p> <p>In my other project, The startup is set as this:</p> <pre><code> Application.Run(new MyForm()); </code></pre> <p>Why did I have to specify namespace when changing startup form in this project?</p>
c#
[0]
2,606,345
2,606,346
jQuery example for val() of input box
<p>The <a href="http://api.jquery.com/val/" rel="nofollow">example</a> for finding the value of an input box in jQuery is below.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; p { color:blue; margin:8px; } &lt;/style&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" value="some text"/&gt; &lt;p&gt;&lt;/p&gt; &lt;script&gt; $("input").keyup(function () { var value = $(this).val(); $("p").text(value); }).keyup(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I have 2 questions.</p> <ol> <li>Why is the script inside the body? (I tried putting it between the head tags and it <em>does not</em> work).</li> <li>Why are there two different keyup() methods, one directly after $("input") and the other after the function?</li> </ol>
jquery
[5]
946,021
946,022
alert dialog size varies based on list view
<p>I have created a alert dialog in oncreate dialog method of dialog fragment. I am populating the alert dialog with array adapter. My problem is the alert dialog size varies depending on the text in the adapter. I want the alert dialog to be fixed in default size. pls help.</p>
android
[4]
4,450,545
4,450,546
How To Create Folders Based on a Range of Numbers in Python
<p>I want to create a few folders based on a given range of numbers. For example, I want to create folders 500 through 520. Is there a way to create these folders using the <code>range(500, 520)</code> ?</p> <p>Am I heading down the right path with this code?</p> <pre><code> import os for i in range(500, 520): os.mkdir(r'C:\Dir' + i) </code></pre> <p>I know this is wrong since <code>i</code> is an integer, but can someone guide me to the right direction? </p>
python
[7]
2,111,449
2,111,450
BroadcastReceiver with permissions
<p>There are some BroadcastReceiver. I want establish permission for BroadcastReceiver:</p> <pre><code> &lt;receiver android:name=".BR1" android:permission="testbr.pac.TestBR_MY_ACCESS"&gt; &lt;intent-filter&gt; &lt;action android:name="testbr.pac.TestBR"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;receiver android:name=".BR2" android:permission="testbr.pac.TestBR_MY_ACCESS"&gt; &lt;intent-filter&gt; &lt;action android:name="testbr.pac.TestBR"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;receiver android:name=".BR3"&gt; &lt;intent-filter&gt; &lt;action android:name="testbr.pac.TestBR"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; </code></pre> <p>When I want send message:</p> <pre><code> public static final String RECEIVER = "testbr.pac.TestBR"; public static final String RECEIVER_PERMISSION = "testbr.pac.TestBR_MY_ACCESS"; .......... Intent broadcast = new Intent(); broadcast.setAction(RECEIVER); sendOrderedBroadcast(broadcast, RECEIVER_PERMISSION); </code></pre> <p>I get errors: "Permission Denial: broadcasting Intent" and "Permission Denial: receiving Intent"</p>
android
[4]
3,122,538
3,122,539
How to open front face camera and record video in android
<p>How to open front face camera using surface view and record video in android 3.1.can anybody provide code</p> <p>Thanks</p>
android
[4]
5,434,965
5,434,966
using jquery mousemove and setTimeout and clearTimeout to reveal/hide a menu
<p>I pasted some code below of what seems to be a common approach to reveal a menu on mousemove. It seems that as the mouse continues to move, the duration of the timeout increases. What's up with that? Is there a reason why the cleartimeout would not be working?</p> <pre><code>var timer; $(document).mousemove(function() { if (timer) { clearTimeout(timer); timer = 0; } $('.navi a, a.left, a.right').animate({top:'0px'},'fast'); timer = setTimeout(function() { $('.navi a, a.left, a.right').animate({top:'50px'},'fast'); }, 1000) }); </code></pre>
jquery
[5]
4,624,750
4,624,751
Website structure / Newbie
<p>I created a website using php, passing values from page to page either with POST or GET.</p> <p>Though there is some cons, I dont know how to track specifically what data has been viewed in GoogleAnalytics as it just shows the name of the page (xxxx.php)</p> <p>On the other side, I see websites structured differently with a bunch of subdirectories created : www.xxx.com/xxxxxx/xxxxx/xxx</p> <p>This looks like pretty manual for me , compared to the .php?xxxx=xxxx way of structuring. </p> <p>Do you know how this subdirectory style structuring can be automatically obtained?</p>
php
[2]
1,745,982
1,745,983
Atrribute Error in Python 2.73 when creating random string
<p>I'm using the following function (which I think is pretty straight-forward) to generate a random string:</p> <pre><code>import sys import string import random def random(size=16): lst = [random.choice(string.ascii_letters + string.digits) for n in xrange(size)] str = "".join(lst) return str </code></pre> <p>However, I keep getting the following error:</p> <pre><code>AttributeError: 'function' object has no attribute 'choice' </code></pre> <p>Can someone tell me what's wrong with my code? Google doesn't seem to help, and I'm too new to Python to troubleshoot it effectively myself.</p>
python
[7]
403,118
403,119
Sanitise or validate email php
<p>I am using <code>filter_var</code></p> <p>and a function to check if the email is valid</p> <pre><code>function checkEmail($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); } </code></pre> <p>This is only thing I do. In registration for example i validate email with this function then insert in database (prepared statement used ofc) <strong>But is it essential to use sanitisation in this function as well?</strong> Is there any "VALID" but "DANGEROUS" email that could cause problem...?</p>
php
[2]
753,964
753,965
Scroll fixed div to certain point
<p>I have seen a few examples of these, but mine is a little different and can't figure this out.</p> <p>I'm using a piece of jQuery found on these forums, to scroll a fixed div to certain point then stopping, using 'scrollTop'.</p> <pre><code>var windw = this; $.fn.followTo = function ( pos ) { var $this = this, $window = $(windw); $window.scroll(function(e){ if ($window.scrollTop() &gt; pos) { $this.css({ position: 'absolute', top: pos }); } else { $this.css({ position: 'fixed', top: 40 }); } }); }; $('#scrollto-menu-nav').followTo(250); </code></pre> <p>However, I need it to stop scrolling when it reaches a height from the <strong>bottom</strong> not from the <strong>top</strong>. Any ideas?</p> <p>Thanks, R</p>
jquery
[5]
5,009,641
5,009,642
How to pass decimal values over serialport in C#?
<p>how to pass decimal values over serialport control?</p>
c#
[0]
1,857,477
1,857,478
Data container for fast lookup and retrieval
<p>Actually I need a data structure that helps me in reducing time for look-ups and retrieval of values of the respective keys.</p> <p>Right now I am using a map container with key as structure and want to retrieve its values as fast as possible. </p> <p>I am using gcc on fedora 12. I tried unordered map also, but it is not working with my compiler.</p> <p>Also, Hash map is not available in namespace <code>std</code>.</p>
c++
[6]
4,867,760
4,867,761
How to use the NSUrlConnection for getting the data from web?
<p>iam developing one application.In that i want to use the usurlconnection class.SO please tell me how to use this one.This contain the lot of delegate methods.So please tell me how to use them.</p>
iphone
[8]
555,607
555,608
why type $this = $(this) in jquery
<p>I'm new to jQuery and have noticed someone go:</p> <pre><code>var $this = $(this); </code></pre> <p>Why do this? Is it to save typing? Does it help performance? Is it fairly standard practice?</p> <p>Also I've started doing things such as:</p> <pre><code>var minus_button = $('#minus_button'); </code></pre> <p>Should this instead be <code>var $minus_button = $('#minus_button');</code> to signal it's a jquery object?</p> <p>I read <a href="http://docs.jquery.com/JQuery_Core_Style_Guidelines" rel="nofollow">http://docs.jquery.com/JQuery_Core_Style_Guidelines</a> but couldn't find any suggestions.</p>
jquery
[5]
5,386,008
5,386,009
Is there a tool for signing all jars in a folder and subfolders?
<p>Is there a tool for signing all jars in a folder and subfolders?</p>
java
[1]
5,325,809
5,325,810
Parse timestamps in plain text file and count them per 5 minute intervals
<p>My Input is a plain text file containing 6,000 timestamps, looks like this</p> <pre><code>2011-06-21 13:17:05,905 2011-06-21 13:17:11,371 2011-06-21 13:17:16,380 2011-06-21 13:17:20,074 2011-06-21 13:17:20,174 2011-06-21 13:17:24,749 2011-06-21 13:17:27,210 2011-06-21 13:17:27,354 2011-06-21 13:17:29,231 2011-06-21 13:17:29,965 2011-06-21 13:17:32,100 2011-06-21 13:17:32,250 2011-06-21 13:17:45,482 2011-06-21 13:17:51,998 2011-06-21 13:18:03,037 2011-06-21 13:18:04,504 2011-06-21 13:18:10,019 2011-06-21 13:18:27,434 2011-06-21 13:18:29,960 2011-06-21 13:18:30,525 ... </code></pre> <p>My output should be a CSV file counting how many lines are found between each 5 minute slot starting at the "whole hour"</p> <p>Example Output:</p> <pre><code>From, To, Count 13:00:00, 13:04:59, 0 13:05:00, 13:09:59, 0 13:10:00, 13:14:59, 19 13:15:00, 13:19:59, 24 ... </code></pre> <p>Thanks!</p>
python
[7]
2,290,507
2,290,508
Problem with unique html() jQuery
<p>I have jQuery function, that if it will hit specific class is wrapping it with some oter divs.</p> <pre><code>(document).ready(function(){ var Text = $('.bd_box_cont').html(); $('.bd_box_cont').html(" &lt;div class='bd_box_tl'&gt;&lt;div class='bd_box_rt'&gt;" + Text +"&lt;/div&gt;&lt;/div&gt; "); )} </code></pre> <p>Only problem is that I have more then one container on my site, and it is putting this same html to every one of them.</p> <p>How can I return var Text for specific container?</p> <p>Thank you for your help in advance </p>
jquery
[5]
681,969
681,970
How to Send MMS Pro-grammatically without using Intent.ACTION_SEND
<p>I have gone to various blog and tutorial<code>(http://stackoverflow.com/questions/2972845/how-to-send-image-via-mms-in-android)</code> and unable to get solution.</p> <p>I want the solution to send Image with SMS (i.e MMS) pro grammatically without using Intent.</p> <p>There is no documentation in this regard.Please suggest an alternative to do that without ACTION_SEND.</p>
android
[4]
2,253,949
2,253,950
Sql lite vs mysql db
<p>In android development, and when is it good to use sql lite vs Web server db? If a person delete the app or upgrade my app then will the db get deleted if i use sql lite? </p> <p>Thank you very much</p>
android
[4]
5,831,873
5,831,874
retrieve gmail account details configured in android
<p>In my application, I have to send a mail when a button is clicked. I have all details for sending the mail except the "from address". This "from address" should be the gmail account configured in the android phone. How can I fetch those details? Can anyone please help?</p>
android
[4]
2,088,087
2,088,088
I'm new to python, and trying to program a sales tax button for a calculator
<p>I just started programming in python not long ago, and I'm having trouble figuring out the rounding issue when it comes to tax and money. I can't seem to get decimals to always round up to the nearest hundredths place. for instance, in our state, sales takes is 9.5%, so a purchase of 5 dollars would make tax $.48, but in reality its $.475. I've tried math.ceil, but it seems like that only works to the nearest integer. Is there a simple way to enable a round up on any thousands digit? (ex .471 would round to .48)</p> <p>Thanks</p>
python
[7]
5,943,088
5,943,089
switch user to site url
<p>I had to check about data retrieve from data base in DDL and if this data equal specific value user will redirect to specific site (URL) .I tried to make this with if statement but it did not work please anyone help me.</p> <pre><code>protected void IMGSite_Click(object sender, ImageClickEventArgs e) { if (DDLBrand.SelectedItem.Text="Sharp") { Response.Redirect("http://toshiba.elarabygroup.com/"); } if (DDLBrand.SelectedItem.Text = "Seiko") { Response.Redirect("http://Seiko.elarabygroup.com/"); } } </code></pre>
c#
[0]
4,943,560
4,943,561
Make an android activity method thread safe
<p>I have a method updateFoo() of an activity called both from a Handler thread every 5 seconds and from a button when user want to press it... updateFoo update the interface of my activity... to make this method thread safe I declared it "synchronized" ... Is that the right way???</p> <p>Thanks in advance for any help..</p> <p>.4S.</p>
android
[4]
4,949,063
4,949,064
Java removing unicode characters
<p>I get user input including unicode characters like </p> <pre><code>\xc2d \xa0 \xe7 \xc3\ufffdd \xc3\ufffdd \xc2\xa0 \xc3\xa7 \xa0\xa0 </code></pre> <p>for example:</p> <pre><code>email : [email protected]\xa0\xa0 street : 123 Main St.\xc2\xa0 </code></pre> <p>desired output:</p> <pre><code> email : [email protected] street : 123 Main St. </code></pre> <p>What is the best way to removing them using Java? </p> <p><strong>Update</strong>: I tried the following, but doesn't seem to work</p> <pre><code>public static void main(String args[]) throws UnsupportedEncodingException { String s = "abc@gmail\\xe9.com"; String email = "[email protected]\\xa0\\xa0"; System.out.println(s.replaceAll("\\P{Print}", "")); System.out.println(email.replaceAll("\\P{Print}", "")); } </code></pre> <p>Output</p> <pre><code>abc@gmail\xe9.com [email protected]\xa0\xa0 </code></pre>
java
[1]
2,026,962
2,026,963
PHP: Find largest value from results of two MySQL database queries
<p><strong>I have the following two <code>mysql_queries</code>:</strong></p> <p><strong>1.</strong></p> <pre><code>$primary_img_query = "SELECT imgWidth, imgHeight FROM primary_images WHERE imgId=$imgId"; $primary_img_data = mysql_query($primary_img_query) or die('MySql Error' . mysql_error()); </code></pre> <p><strong>2.</strong></p> <pre><code>$secondary_img_query = "SELECT imgWidth, imgHeight FROM secondary_images WHERE primaryId=$imgId"; $secondary_img_data = mysql_query($secondary_img_query) or die('MySql Error' . mysql_error()); </code></pre> <p>What I need to do is find the largest value of both <code>imgWidth</code> and <code>imgHeight</code> from each query, and then find the largest value between the two found values. I need both said largest values to end up in variables.</p> <p>All values in <code>imgWidth</code> and <code>imgHeight</code> are positive integers greater than zero.</p> <p>Thanks for any help you can provide.</p> <hr> <p>I was thinking I could put the results from both <code>imgWidth</code> and <code>imgHeight</code> in each query in separate arrays, then combine the arrays, and use <code>max()</code> to find the largest(highest) value. Would that work?</p>
php
[2]
2,618,831
2,618,832
How to avoid warning of Unreachable code
<p>I have the below</p> <pre><code>string currency = string.Empty; Regex r = new Regex(@"~(\w*[a-zA-Z0-9$£~%]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); for (Match m = r.Match(expression); m.Success; m = m.NextMatch()) { currency = (m.Groups[1].Value); break; } return currency; </code></pre> <p>The intension is that, after the first match in the loop it should break.</p> <p>The warning messge(Unreachable code) is happening <strong>m = m.NextMatch()</strong> of the loop.</p> <p>How to overcome this?</p> <p>Thanks</p>
c#
[0]
432,765
432,766
PHP, adding to a database
<p>When filling in the fields in the browser and presing add product it returns Column count doesn't match value count at row 1 instead of adding it to the database.</p> <pre><code>&lt;?php if (isset($_POST['name'])) { $name = mysql_real_escape_string($_POST['name']); $price = mysql_real_escape_string($_POST['price']); $shipping = mysql_real_escape_string($_POST['shipping']); $quantity = mysql_real_escape_string($_POST['quantity']); $description = mysql_real_escape_string($_POST['description']); $keywords = mysql_real_escape_string($_POST['keywords']); $category = mysql_real_escape_string($_POST['category']); $sql = mysql_query("SELECT id FROM products WHERE name='$name'"); $productMatch = mysql_num_rows($sql); if($productMatch &gt; 0){ echo'sorry name of film is already in database'; exit(); } $sql = mysql_query("INSERT INTO products (name,price,shipping,quantity,description,keywords,category)VALUES ('$name','$price','$shipping','$quantity','$description','$keywords','$category',now)") or die(mysql_error()); $id = mysql_insert_id(); $newname = "$id.jpg"; move_uploaded_file($_FILES['fileField']['tmp_name'], "./images/$newname"); } ?&gt; &lt;?php $product_list = ""; $sql = mysql_query("SELECT * FROM products"); $productCount = mysql_num_rows($sql); if($productCount &gt; 0){ while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $name = $row["name"]; $catagory = $row["catagory"]; $price = $row["price"]; $product_list .=""; } } else { $product_list = "You have no products"; } ?&gt; &lt;?php echo $product_list; ?&gt; &lt;here is a form that contains all required data &lt;?php include 'includes/overall/footer.php' ; ?&gt; </code></pre> <p>any ideas cheers this is to be used so we can add products to the database as an admin</p>
php
[2]
79,053
79,054
How do I reference a function's variable from another class? - C#
<p>I am having a hell of a time getting a variable from the function of another class usable in my Game1 (main) class. Specifically, I want to take width and height from the function SaveData in SetWindowSize.cs and use it in ReadSettings in Game1.cs.</p> <p>I get the error </p> <blockquote> <p>'ShovelShovel.SetWindowSize' does not contain a definition for 'height'. Same for 'width'.</p> </blockquote> <p>Game1.cs (the function only)</p> <pre><code>protected void ReadSettings() { try { if (File.Exists(SetWindowSize.savePath)) { using (FileStream fileStream = new FileStream(SetWindowSize.savePath, FileMode.Open)) { using (BinaryReader binaryReader = new BinaryReader(fileStream)) { SetWindowSize.width = binaryReader.ReadInt32(); SetWindowSize.height = binaryReader.ReadInt32(); } } } } catch { } } </code></pre> <p>SetWindowSize.cs</p> <pre><code>namespace ShovelShovel { protected void ReadSettings() { try { if (File.Exists(savePath)) { using (FileStream fileStream = new FileStream(savePath, FileMode.Open)) { using (BinaryReader binaryReader = new BinaryReader(fileStream)) { var windowSize = WindowSizeStorage.ReadSettings(); WindowSize.Width = windowSize.Width; WindowSize.Height = windowSize.Height; } } } } catch { } } </code></pre> <p>Thank you so much to anyone and everyone that can help me, I really appreciate it.</p>
c#
[0]
1,166,290
1,166,291
ASP.NET Membership API Equivalent for PHP
<p>Are there any good schemas/models for roles and membership for PHP/MySQL, apart from rolling a custom one? I like the way ASP.NET's membership and roles work and was wondering of there was an equivalent in PHP.</p>
php
[2]
5,667,039
5,667,040
Printing all static content in a .java file
<p>I have to print all the static content in l the .java files in my workspace. Can anyone suggest any tool or code to do that?</p> <p>By static means SIB's static constants, methods and all.</p>
java
[1]
4,853,251
4,853,252
is it possible to get function name in which given closure is running?
<pre><code>function MyFunction() { closure = function() { alert('my parent function name is: '/* now what here ? */); } closure(); } MyFunction(); </code></pre> <p>Result should be <code>my parent function name is: MyFunction</code></p> <p>(To moderators: I do not know why stackoverflow is preventing me from sending this question claiming it doesn't meet quality standards. Do I must type some superfluous text to be allowed to send this.)</p>
javascript
[3]
1,702,185
1,702,186
Can we use ignore_user_abort() on any line of code?
<p>Can we use ignore_user_abort on any line of PHP like:</p> <pre><code>&lt;?php // Process Codes if($_GET['nonstop']) { ignore_user_abort(1); // Background process }else{ // Nonbackground process } // Other Codes ?&gt; </code></pre> <p>Or we need to use on only after <code>&lt;?php</code> (first line)?</p> <p>Thanks.</p>
php
[2]
5,696,783
5,696,784
(solved) JQuery: Getting data from child elements
<p>Markup:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a href="#" class="item-list" data-id="1"&gt;Link 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" class="item-list" data-id="2"&gt;Link 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" class="item-list" data-id="3"&gt;Link 3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>In JQuery, i would select link 1 and it should be able to fetch the data-id of link1. I tried</p> <pre><code>$('.item-list').click(function(){ var link = $(this); alert($(this).data('id')); }); </code></pre> <p>It doesn't have any result. </p> <p>Oh. the list gets generated after the page is loaded. I am querying the DB to get the list. Also, it is also possible for the list to change, depending on how the user filters the dB.</p> <p>Thanks.</p>
jquery
[5]
5,045,761
5,045,762
What is the E-mail Attachment limitation in android?
<p>I wanted to know what is the maximum size of the file that we can attach with e-mail in android? Or is the attachment limit completely dependent on E-mail that we have configured ???</p>
android
[4]
5,056,513
5,056,514
Customized Grid in wxPython?
<p>How can I implement the grid(black border) in the following image in wxPython?</p> <p><img src="http://i.stack.imgur.com/yYRZn.png" alt="alt text"></p>
python
[7]
4,107,330
4,107,331
How do I set an absolute include path in PHP?
<p>In HTML, I can find a file starting from the <strong>web server's</strong> root folder by beginning the filepath with "/". Like:</p> <pre><code>/images/some_image.jpg </code></pre> <p>I can put that path in any file in any subdirectory, and it will point to the right image.</p> <p>With PHP, I tried something similar:</p> <pre><code>include("/includes/header.php"); </code></pre> <p>...but that doesn't work.</p> <p>I think that that <a href="http://us2.php.net/manual/en/ini.core.php#ini.include-path" rel="nofollow">this page</a> is saying that I can set <code>include_path</code> once and after that, it will be assumed. But I don't quite get the syntax. Both examples start with a period, and it says:</p> <blockquote>Using a . in the include path allows for relative includes as it means the current directory.</blockquote> <p>Relative includes are exactly what I <strong>don't</strong> want.</p> <p><strong>How do I make sure that all my includes point to the <code>root/includes</code> folder?</strong> (Bonus: what if I want to place that folder outside the public directory?)</p> <h2>Clarification</h2> <p>My development files are currently being served by XAMPP/Apache. Does that affect the absolute path? (I'm not sure yet what the production server will be.)</p> <h2>Update</h2> <p>I don't know what my problem was here. The <code>include_path</code> thing I referenced above was exactly what I was looking for, and the syntax isn't really confusing. I just tried it and it works great.</p> <p>One thing that occurs to me is that some people may have thought that "/some/path" was an "absolute path" because they assumed the OS was Linux. This server is Windows, so an absolute path would have to start with the drive name.</p> <p>Anyway, problem solved! :)</p>
php
[2]
5,487,210
5,487,211
getting a row value from an "id" column
<p>in the following code, i would like to get the row result for column "id" as a result for $selectedmovieid. The 'commenid' is the primary key attribute. Sorry for not knowing how to use mysql_fetch_assoc properly.</p> <pre><code>&lt;?php require ("connect-comment.php"); $deleteid=$_GET['commentid']; $query1=mysql_query("SELECT id FROM comment WHERE commentid='$deleteid'"); $selectedmovieid= mysql_fetch_assoc($query1); $query2=mysql_query("DELETE FROM comment WHERE commentid='$deleteid'"); header("Location: reload.php?id=$selectedmovieid"); ?&gt; </code></pre> <p>EDIT 1: I will do up the security injection much later, just need to get the syntax right and get the right result. So this is what i have done so far:</p> <pre><code>&lt;?php require ("connect-comment.php"); $deleteid=$_GET['commentid']; $query1=mysql_query("SELECT id FROM comment WHERE commentid='$deleteid'"); while ($selectedmovieid= mysql_fetch_assoc($query1)) {echo $selectedmovieid['id'];}; $query2=mysql_query("DELETE FROM comment WHERE commentid='$deleteid'"); header("Location: reload.php?id=$selectedmovieid"); ?&gt; </code></pre> <p>Now this doesn't make much sense to me cos i am not parsing the correct <code>$selectedmovieid</code> value into the <code>reload.php?id=</code></p>
php
[2]
4,587,692
4,587,693
Bringing up SoftKeyboard on android
<p>I want to pop up the software keyboard when the user presses the search hardware search key.</p> <p>At the moment I use the following function with doesn't seem to work for the search key but which does work for the back key: The logging doesn't get even tiggered through the search key.</p> <pre><code>@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_BACK){ Log.v(TAG, "On back key press"); renderPrevious(); return false; } if(keyCode == KeyEvent.KEYCODE_SEARCH){ Log.v(TAG, "On search key press"); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); return false; } return true; } </code></pre> <p>I have no text field but want to handle the input directly myself if that matters.</p>
android
[4]
5,703,012
5,703,013
Image Scroll in Firefox on Button click
<p>Please help On (Button onclick = "scroll_Ex('up');") the javascript is not working. I want to scroll image on button click Its working in IE but not in Firefox .Any altrenate code so that its works in Firefox and IFPrev is id of a file.htm </p> <p>The code is given below </p> <pre><code>function scroll_Ex(dirc) { var IFPrev = document.getElementById('IFPrev'); IFPrev.Document.all.myBody.doScroll('scrollbarPage'+ dirc); } </code></pre>
javascript
[3]
1,913,381
1,913,382
Asp.net export in excel
<p>Iam doing export functionality in asp.net1.1... I used to passed a dataset to excel and export that records in excel... Now i want on certain condtion some records should highlight in red colors... So plz tell me how to do this.</p>
asp.net
[9]
4,167,559
4,167,560
Remove a child from parent and add it as Sibling to Parent
<p>I have a Bullet Region like</p> <ul><li>Hello</li><li>How</li><li>are</li><li>you</li></ul> <p>No i am selecting <li>are</li> and changing to Number Bullet. so my list should change like </p> <p><ul><li>Hello</li><li>How</li></ul><ol><li>are</li></ol><ul><li>you</li></ul></p> <ol> <li>want to end the Disc bullet after second child.</li> <li>want to add Third child as sibling to parent.</li> <li>Want to again make Disc bullet to fourth child and add it as sibling to parent.</li> </ol> <p>How can i do this.</p>
javascript
[3]
4,680,837
4,680,838
passing value to other module python
<p>i have two script name is A.py and B.py</p> <p>i want to know how to send value from A.py to B.py.</p> <p>for more detail,when run finished A.py script at the end of script ,A.py call B.py.</p> <p>my question is i have to send some value from A.py to B.py.</p> <p>anybody some help me how to send value A.py to B.py,so i can use some value in B.py.</p> <p>"Do I assume correctly that you want to have B.py to use all the variables with values </p> <p>that exist when A.py finishes?"</p> <p>this is what i want exactly. i was upload my A.py and B.py to pastebin site.</p> <p><a href="http://elca.pastebin.com/m618fa852" rel="nofollow">http://elca.pastebin.com/m618fa852</a> &lt;- A.py</p> <p><a href="http://elca.pastebin.com/m50e7d527" rel="nofollow">http://elca.pastebin.com/m50e7d527</a> &lt;- B.py</p> <p>i want to use B.py 's xx value, xx value is come from A.py .</p> <p>sorry my english </p>
python
[7]
1,375,581
1,375,582
Adding new input using jQuery
<p>I have a drop down called roomfac1 on my form and I would like <em>roomfac2</em>, <em>roomfac3</em>... (duplicate dropdowns) to be added when the user clicks on the <strong>Add</strong> button. How do I accomplish this using jQuery? In addition to this, I would also like the user to dynamically remove the newly created inputs as well.</p> <p>I've uploaded my code here: <a href="http://jsfiddle.net/ecRXP/2/" rel="nofollow">http://jsfiddle.net/ecRXP/2/</a></p> <pre><code>&lt;select name="roomFac1" id="roomFac1"&gt; &lt;option selected="selected"&gt;Any&lt;/option&gt; &lt;/select&gt; &lt;input type="button" value="Add" class="pmbtn" id="addFac"/&gt; &lt;input type="button" value="Remove" class="pmbtn" id="removeFac"/&gt; </code></pre>
jquery
[5]
1,696,351
1,696,352
C# refine method code for query
<p>i am trying to create a method to access an access2010 .accdb database simply by calling the method with the SQL statement. this method currently works after my many hours of "trial and error". Are there any ways to refine this piece of code to make it more robust yet simpler because of the many steps involved. (new connection, then new command, then new reader etc seems to be too many of a steps in just executing one SQL command?)</p> <p>btw this code is to query a database and return a string.</p> <pre><code>public static string getString(string SQL) { using (var connection = new OleDbConnection(connectionString)) using (var command = connection.CreateCommand()) { command.CommandText = SQL; command.CommandType = CommandType.Text; connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { return reader.GetString(0).ToString(); } } return null; } } } </code></pre>
c#
[0]
1,277,927
1,277,928
Beginner object references question
<p>If I instantiate an object in a main class, say:</p> <pre><code>SomeObject aRef = new SomeObject(); </code></pre> <p>Then I instantiate another object from the main class, say:</p> <pre><code>AnotherObject xRef = new AnotherObject(); </code></pre> <p>How can the instance of AnotherObject make use of the aRef reference to access the methods in SomeObject? (To use the same instance of SomeObject)</p>
java
[1]
598,851
598,852
jquery: get values of all children of a div
<p>I am trying to use jquery to get the values of all children element of a div.</p> <pre><code>&lt;div class='parent'&gt; &lt;input type='text' value='1' class='child' /&gt; &lt;input type='text' value='2' class='child' /&gt; &lt;input type='text' value='3' class='child' /&gt; &lt;input type='text' value='4' class='child' /&gt; &lt;/div&gt; </code></pre> <p>The child inputs are generated with php from db. Their number varies.</p> <p>I am trying to get something like:</p> <pre><code>variable = (child1_value + child2_value + child3_value + child4_value + ... + "childX_value"); </code></pre> <p>how can I make this work for whatever number of children?</p>
jquery
[5]
505,049
505,050
Store and recall button in calculator application (iPhone)
<p>I'm new in iPhone development. I made a calculator in which I need to put 2 more buttons:</p> <ol> <li><code>Store</code>: Stores the current value of the display into a memory location.</li> <li><code>Recall</code>: Recalls the value in memory.</li> </ol> <p>But I don't know how.</p>
iphone
[8]
3,179,162
3,179,163
how to run asp.net project on iis real server windows 2008
<p>HI,</p> <p>i developed application in Visual Studio... ASP.NET project with master.page. I do it on my notebook and now I want put it on my server... i copy all files and give it to wwwroot directori in iis7 on my windows server 2008, but when i try start ist it wrote:</p> <hr> <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 remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.</p> <p>Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".</p> <p> </p> <p>Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.</p> <p> </p> <hr> <p>maybe it is stupit question becouse, all what i do is only copy files from project.. So please How can i put my asp.net project (web page) on server????</p> <p>Thanks lot</p> <p>PS: sorry for my englis i will work on it. :)</p> <p>Eddy</p>
asp.net
[9]
2,801,688
2,801,689
Response Keyword not Recognized
<p>i am trying to use commands like <code>Response.ClearContent()</code> and <code>Response.Write()</code> to export a datatable to Excel however visual studio is not recognizing the <code>Response</code> keyword. is there a <code>using</code> statment associated with these commands? Because i'm obviously missing something. thanks</p>
c#
[0]
2,865,822
2,865,823
Set up parameter not recognized from parse request
<p>This has been playing on my mind for a while, I need to check that the user has entered the correct parameters, how do I do check this in an if statement in php? Users enters as follows;</p> <pre><code>www.domain.com/?amnt=100&amp;from=AAA&amp;to=BBB </code></pre> <p>so I need to check if they enter something as follows;</p> <pre><code>www.domain.com/?xxx=100&amp;yyy=AAA&amp;to=BBB </code></pre> <p>/////// Code is now as follows;</p> <pre><code> //1000 Required parameter is missing if ($amnt == null || $from==null || $to==null) { $error_code = 1000; $returnXML = new XML(); $returnXML-&gt;CreateError($error_code,$error_msg[$error_code]); echo '&lt;META HTTP-EQUIV="Refresh" Content="0; URL=error.xml"&gt;'; exit; } //1100 Parameter not recognized if(!isset($_GET['amnt'], $_GET['from'], $_GET['to'])) { $error_code = 1100; $returnXML = new XML(); $returnXML-&gt;CreateError($error_code,$error_msg[$error_code]); echo '&lt;META HTTP-EQUIV="Refresh" Content="0; URL=error.xml"&gt;'; exit; } </code></pre> <p>it returns the first IF when I request ../?xxx=100&amp;yyy=GBP&amp;to=USD, it makes logical sense, but how do I get it to return the second IF, if the parameters are not entered?</p>
php
[2]
5,812,913
5,812,914
Export data elements to text file in Python
<p>How could I alter the following code to get a table of data elements in a text file to be plotted in excel?</p> <pre><code> x = z = vz = vy = ax = ay = time = 0.0 y = 50 #Initial Height: 50 meters vx = 25 #Initial velocity in the x direction: 25 m/s az = -9.8 #Constant acceleration in the z direction: -9.8 m/s^2 deltaTime = 1 #Initializes a matrix with 3 columns and 1000 rows for each column: Will hold the corresponding x,y,z coordinate of the particle at time t positionMatrix = [[None]*1000 for x in range(3)] posArray = [x, y, z] velArray = [vx, vy, vz] accArray = [ax, ay, az] timeArray = [i*deltaTime for i in range(1000)] #print(timeArray) for j in range (1000): #j is the time increment for i in range (3): #i is each component (x, y, z) #x = x + vx*time + .5*ax*(time*time); #y = y + vy*time + .5*ay*(time*time); #z = z + vz*time + .5*az*(time*time) positionMatrix[i][j] = posArray[i] + velArray[i] * timeArray[j] + 1/2*accArray[i] * timeArray[j] * timeArray[j] print(positionMatrix) </code></pre>
python
[7]
275,462
275,463
Targeting Google APIs
<p>I'm new to Android Development and Eclipse and I'm going through the various tutorials. </p> <p>When setting up Eclipse I installed Android 2.3.3 SDK Platform along with Google APIs for that platform.</p> <p>When I create new projects for most all of the tutorial programs I select Android 2.3.3 as my target.</p> <p>However, when going through the Google Map Views tutorial I am told to select Google APIs instead of Android 2.3.3 when creating the project. I did this and the map view program works just fine.</p> <p>But this seems like a binary OR decision; I'm allowed to select one or the other. Does the Google APIs include all that's in the Android 2.3.3 platform? In other words could I just always select Google APIs target for the platform level that I want and it would work? Thanks, Dean</p>
android
[4]
5,599,278
5,599,279
How to capture the href attribute of an internal link in jQuery and use the value of # for selecting a div tag Id
<p>I have an a navigation which contains links such as:</p> <pre><code>&lt;a href="#div1"&gt;DIV 1&lt;/a&gt; &lt;a href="#div2"&gt;DIV 2&lt;/a&gt; &lt;a href="#div3"&gt;DIV 3&lt;/a&gt; </code></pre> <p>Also I have three div tags as follow</p> <pre><code>&lt;div id="div1"&gt; SOME CONTENT &lt;/div&gt; &lt;div id="div2"&gt; SOME CONTENT &lt;/div&gt; &lt;div id="div3"&gt; SOME CONTENT &lt;/div&gt; </code></pre> <p>I want that when I click on </p> <pre><code>&lt;a href="#div1"&gt;DIV 1&lt;/a&gt; </code></pre> <p>then it shows the content of </p> <pre><code>&lt;div id="div1"&gt; SOME CONTENT &lt;/div&gt; </code></pre> <p>and hide all other DIV tags and so on..</p>
jquery
[5]
648,558
648,559
C++ version of CopyOnWriteArrayList
<p>Java has <a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/CopyOnWriteArrayList.html" rel="nofollow">CopyOnWriteArrayList</a>, which enables me to iterate and mutate using 2 different threads simultaneously, without having any external locking.</p> <p>Do we have any similar thread safety data structure for C++?</p>
c++
[6]
698,665
698,666
Newbie query on dynamic addition of properties
<p>This is a follow-up to my previous <a href="http://stackoverflow.com/questions/12172119/javascript-how-to-avoid-addition-of-a-new-property-in-a-function/12172186">query</a>. I have been trying some code since then :</p> <pre><code>var myFunc = function(){ this.int1=1; var int2=2; }; myFunc.int1=3; myFunc.int3=4; for(var name in myFunc){ console.log('myFunc...'+name+'='+myFunc[name]); }; var myFuncImpl = new myFunc(); myFuncImpl.int1=5; for(var name in myFuncImpl){ console.log('myFuncImpl...'+name+'='+myFuncImpl[name]); }; </code></pre> <p>And I get output as :</p> <pre><code>myFunc...int1=3 myFunc...int3=4 myFuncImpl...int1=5 </code></pre> <p>I can't answer the following questions :</p> <ol> <li><p>Why isn't <strong>int2</strong> visible as a property to myFunc ? It's still in myFunc's scope, right ? Where does this definition disappear ?</p></li> <li><p>Why I am I able to over-write <strong>int1</strong>'s value outside function scope ? What if someone accidentally deletes my values outside code ? For "objects", I understand "Object.freeze()" can help over myFuncImpl - but what about function definitions like myFunc ?</p></li> <li><p>Why can't I access <strong>int3</strong> from myFuncImpl ? Where did the prior definition (while defining myFunc) go ?</p></li> </ol> <p>I guess my doubts are due to my thinking of myFunc as a "class" (as in Java) and myFuncImpl as an object. Perhaps I am straying too far ?</p> <p>Thanks !</p>
javascript
[3]
1,974,358
1,974,359
How to avoid repeatedly calling a function in this case?
<p>I wrote a function to display an object on each wordpress post:</p> <pre><code>function pod(){ global $post,$pod; $id = get_the_ID(); $pod = new WP_POD( $id ); return $pod; } </code></pre> <p>I thought $pod is global, so, I can use $pod->stuffs when need, but it doesn't work. So, in each function I need to use stuffs in the object, I have to add one line:</p> <pre><code>$pod = pod() </code></pre> <p>I think repeatedly calling this function might not good for performence. Is there a way to make this global and accessable by other functions?</p>
php
[2]
4,718,836
4,718,837
How to implement fluent interface with a base class, in C++
<p>How can I implement this fluent interface in C++:</p> <pre><code>class Base { public: Base&amp; add(int x) { return *this; } } class Derived : public Base { public: Derived&amp; minus(int x) { return *this; } } Derived d; d.add(1).minus(2).add(3).minus(4); </code></pre> <p>Current code doesn't work since Base class doesn't know anything about Derived class, etc. I would be very thankful for a hint/suggestion.</p>
c++
[6]
5,337,552
5,337,553
iphone refresh json data from other class
<p>I am displaying json data in tableview </p> <pre><code>-(void)getJsonDataFromNet{ //retrieves the json data and display in tableview } </code></pre> <p>And For one of Selected row i am displaying multiselect alert tableview which i used the code from below link</p> <p><a href="http://starterstep.wordpress.com/2009/03/24/custom-uialertview-with-uitableview" rel="nofollow">http://starterstep.wordpress.com/2009/03/24/custom-uialertview-with-uitableview</a></p> <p>Now, after dismiss of alert tableview i need to refresh the json data and calling [self getJsonDataFromNet] method to refresh.</p> <p>I can able to refresh json data but the view is not loading the data and displays the same old data </p>
iphone
[8]
3,466,512
3,466,513
Moving the object on desired path using Accelerometer
<p>I want to move the ball image on the desired path lets say a road with a "V" turn with the help of Accelerometer values.I have taken separate image for track with alpha non zero on track. Using alpha values i am calculating next point for the ball. This works fine for the part of the track parallel to X or Y axis.</p> <p>But i am facing issues when moving the ball on slanted edges as shown below. Ball sometimes stuck up or gives jerks or moves out of the track. </p> <pre><code>------------------------------------------ O / ------------------------------------- / / / / / / / / / / / </code></pre> <p>or (if image is not visible) please consider number seven image as track "7". Want to move the ball on track similar to like "7"</p> <p>Help is needed in urgent.</p> <p>Thanks in advance. Regards, Vishal Mali</p>
iphone
[8]
5,286,124
5,286,125
why string.matches and pattern.matches get different results?
<pre><code> // pattern 20xx/xx/xx, e.g. 2012/2/22 String Regex_Date_1 = "20\\d\\d/\\d{1,2}/\\d{1,2}"; String cell = "from 2011/7/31 to 2011/8/15 15:10-17:40,18:30-21:00"; System.out.println(cell); System.out.println("--- a ---"); System.out.println( cell.matches(Regex_Date_1) ); System.out.println("--- b ---"); Pattern p = Pattern.compile(Regex_Date_1); Matcher m = p.matcher(cell); while(m.find()){ System.out.println( m.group(0) ); } </code></pre> <p>results:</p> <pre><code> from 2011/7/31 to 2011/8/15 15:10-17:40,18:30-21:00 --- a --- false --- b --- 2011/7/31 2011/8/15 </code></pre> <p>Why string.matches return false? but pattern.matches can get matches?</p>
android
[4]
4,706,655
4,706,656
Javascript "Uncaught TypeError: object is not a function" associativity question
<p>Code is as follows:</p> <pre><code>&lt;body&gt; &lt;a href="javascript:;" id="test"&gt;hello&lt;/a&gt; &lt;/body&gt; &lt;script type="text/javascript"&gt; document.getElementById("test").addEventListener("click", function () { test() }, false) function test() { var postTypes = new Array('hello', 'there') (function() { alert('hello there') })() } &lt;/script&gt; </code></pre> <p>This will throw an "Uncaught TypeError: object is not a function". If I wrap the anonymous function call/invocation in another set of parentheses it will execute the alert, but still give me an error. If I put a semi-colon after the "var postTypes" definition then it will completely fine.</p> <p>I was led to believe that javascript does not require semi-colons, so I'm making a guess that there is some weird associativity rules of function application that I am not fully understanding. I hope someone can give me the answer to why I am getting this error.</p> <p>Thanks.</p>
javascript
[3]
5,239,592
5,239,593
How to implement Search More button how in google images
<p>How to implement Search More button how in google images? In google images search results saved, if I click on any link on the page and then press on the back button.</p>
javascript
[3]
4,270,900
4,270,901
C# how to get the name (in string) of a class property?
<pre><code>public class TimeZone { public int Id { get; set; } public string DisplayName{ get; set; } } </code></pre> <p>In some other class I've:</p> <pre><code> var gmtList = new SelectList( repository.GetSystemTimeZones(), "Id", "DisplayName"); </code></pre> <p><em>Note: System.Web.Mvc.SelectList</em></p> <p>I do not like to have to write the property name with "Id" and "DisplayName". Later in time, maybe the property name will change and the compiler will not detect this error. C# how to get property name in a string?</p> <p><strong>UPDATE 1</strong></p> <p>With the help of Christian Hayter, I can use:</p> <pre><code>var tz = new TimeZone(); var gmtList = new SelectList( repository.GetSystemTimeZones(), NameOf(() =&gt; tz.Id), NameOf(() =&gt; tz.TranslatedName)); </code></pre> <p>OR</p> <pre><code>var gmtList = new SelectList( repository.GetSystemTimeZones(), NameOf(() =&gt; new TimeZone().Id), NameOf(() =&gt; new TimeZone().TranslatedName)); </code></pre> <p>If someone has other idea without the need of creating a new object. Feel free to share it :) thank you.</p>
c#
[0]
4,142,724
4,142,725
Windows Services
<p>I have to create a service in .net 1.1 and to install that service using setup project and successfuly installed that service but didn't show the service list</p>
c#
[0]
5,926,921
5,926,922
Update android application remotely
<p>how to update an android third party application on mobile with user permission?<br> We are developing one product.client installed it from our company website.<br> How to update it remotely?</p> <p>Thanks in advance</p>
android
[4]
1,606,024
1,606,025
How to write a function to rearrange a list according to the dictionary of index
<p>How to write a function to rearrange a list according to the dictionary of index in python?</p> <p>for example,</p> <pre><code> L=[('b',3),('a',2),('c',1)] dict_index={'a':0,'b':1,'c':2} </code></pre> <p>I want a list of :</p> <pre><code> [2,3,1] </code></pre> <p>where 2 is from 'a',3 is from 'b' and 1 is from 'c', but rearrange only the number in L according to the dict_index</p>
python
[7]
4,652,999
4,653,000
Conditional loop
<pre><code> static bool BoxDiscovery(h) { ... //I've acquired bmp by this point in the ellipses above for (int v = 211; v &lt; 661; v++) { Color c = bmp.GetPixel(h, v); if (c.R &gt; 221 &amp;&amp; c.G &lt; 153) //if c.r &gt; 221 &amp;&amp; c.G &lt; 153 get me out of this crazy // thing Jane and return true, else false without the // compiler throwing an 'Unreachable code detected'. // Use break or anything you want. ... } } } </code></pre> <p>I'm feeling especially stupid today.</p>
c#
[0]
1,217,186
1,217,187
How to split domain info from username in PHP
<p>PHP is pulling the user id as <code>"domain\username"</code> through <code>$_SERVER['AUTH_USER']</code> I am looking to be able to echo just the username in the html.</p>
php
[2]
5,669,273
5,669,274
Do you have to include a false value in a ternary operator PHP?
<p>I need to add append data to a string if a certain variable is true, if not, I don't need to append anything. Currently I'm doing:</p> <pre><code>$string = (condition()) ? 'something'.$string.'something' : $string; </code></pre> <p>Is there a way to skip adding the false option in a ternary operator? It seems wasteful to say $string = $string if the condition is false.</p>
php
[2]
3,279,312
3,279,313
ArrayList not reading in properly
<p>I have an ArrayList &amp; I Want it to read in &amp; Total the numbers within the file, but it is only outputting the last number within the file, they are all on different lines etc.</p> <pre><code>Here is my code, thanks in advance: import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class ArrayListOfNumbers { public static void main(String[] args) throws FileNotFoundException { ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;(); list.add(1); Scanner Scan = new Scanner (new File("numbers.txt")); int sumOf = 0; for(int i=0; i &lt; list.size(); i++){ sumOf = sumOf + list.get(i); } //while scanning add sum to ArrayList List while (Scan.hasNext()) { sumOf = Scan.nextInt(); list.add(sumOf); } //print the array list System.out.println(sumOf); Scan.close(); } } </code></pre>
java
[1]
4,920,196
4,920,197
Android Device chooser does not offer real Galaxy tab 10.1 device
<p>Running eclipse + android sdk on Windows XP<br> Have got "hello Android" application running in emulator OK.<br> Want it to run on Samsung Galaxy tab 10.1.<br> Android Device chooser does not see real device.<br> Have install usb drivers on XP from Samsung.<br> XP device manager shows: Samsung Mobile USB Modem, Samsung Android ADB Interface. Samsung Mobile USB Composite Device.<br> On Tab have enabled USB debuging. Have run 'adb devices' and it shows no devices.</p> <p>Any help greatly appreciated in progressing this next step of my learning the android environment.</p>
android
[4]
3,589,699
3,589,700
Howto start a windows form in c#
<p>i have a simple programm, and i added a windows form, what must i make top start the form from the programm?</p>
c#
[0]
198,954
198,955
Difference between load vs DOMContentLoaded
<p>Whats the difference between</p> <pre><code>window.addEventListener("load", load, false); </code></pre> <p>and</p> <pre><code>document.addEventListener("DOMContentLoaded", load, false); </code></pre> <p>?</p>
javascript
[3]
4,410,430
4,410,431
jQuery appendTo problem on IE
<p>The code below works fine on Firefox, Safari etc with no errors at all. But won't work on any IE, also reports errors. Can someone help please?</p> <p>HTML</p> <pre><code>&lt;p class="tooltip-ent"&gt;...&lt;/p&gt; </code></pre> <p>jQuery</p> <pre><code>$('&lt;span class="tt-icon-ent"&gt;Something&lt;/span&gt;').appendTo('.tooltip-ent'); $('&lt;span class="tt-popup-ent"&gt;PopupContent&lt;/span&gt;').appendTo('.tt-icon-ent'); $('.tt-icon-ent').mouseover(function() { $('.tt-popup-ent', this).addClass('tt-popup-show'); }); $('.tt-icon-ent').mouseout(function() { $('.tt-popup-ent', this).removeClass('tt-popup-show'); }); </code></pre> <p>CSS</p> <p>for "tt-popup-show" basically display block and position absolute </p>
jquery
[5]
3,449,682
3,449,683
How do I change the full background color of the console window in C#?
<p>In C#, the console has properties:</p> <pre><code>Console.BackgroundColor // the background color Console.ForegroundColor // the foreground/text color </code></pre> <p>These can be used to change the background color of the console, and the foreground, or text, color of the console.</p> <p>The issue is, when I do something like:</p> <pre><code>Console.BackgroundColor = ConsoleColor.White; // background color is white Console.ForegroundColor = ConsoleColor.Blue; // text color is blue </code></pre> <p>Now, with the above code, it does indeed turn the text blue and the background white, but it only turns the background of the text white, instead of the entire background white.</p> <p>Here's an example of what I mean: <img src="http://i.stack.imgur.com/LGC6i.png" alt="The background only covers the background of the text, not of the entire console window"></p> <p>As you can see, the white background only displays behind the text, and does not change the color of the entire console window.</p> <p>So, how do I change the color of the entire console window?</p>
c#
[0]
2,050,034
2,050,035
python: pass string instead of file as function parameter
<p>I am beginner in python, and I need to use some thirdparty function which basically has one input - name of a file on a hard drive. This function parses file and then proceses it.</p> <p>I am generating file contents in my code (it's CSV file which I generate from a list) and want to skip actual file creation. Is there any way I can achieve this and "hack" the thirdparty function to accept my string without creating a file? </p> <p>After some googling I found StringIO, and created a file object in it, now I am stuck on passing this object to a function (again, it accepts not a file object but a file name).</p>
python
[7]
1,783,749
1,783,750
jQuery .each callback error
<p>I am currently messing with the <code>.each()</code> function in jQuery and I am trying to count all <code>div</code>'s with the the <code>id</code> of item and add them to a string.</p> <p>The problem is, I get a callback error from my jQuery source, which I load from jquery.com's website.</p> <pre><code>var items = ""; $('div.item').each(function(){ items += $('this').data('id'); }); </code></pre> <p>The error, as seen on firebug;</p> <pre><code>callback is undefined if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { </code></pre>
jquery
[5]
2,686,816
2,686,817
ListView not responding to Click or KeyPress
<p>I have a simple ListView in my layout.xml file.</p> <pre><code>&lt;ListView android:id="@+id/action_list" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; </code></pre> <p>And in my javacode, I add a setOnItemClickListener() to my listview:</p> <pre><code>listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { System.out.println ("get onItem Click position= "+position); } }); </code></pre> <p>But when I run on G1. I don't see any print out when I click an item on the ListView on the phone. Or when I select an item using track ball and press CENTER.</p> <p>Can you please tell me why to resolve my problem?</p> <p>Thanks in advance.</p>
android
[4]
628,388
628,389
Issue with scrolling
<p>My scroll view scrolls down extra... what could be the possible reason? It works fine in first go but when I edit my textfield in the scrollview, it starts scrolling extra down. Any clue?</p>
iphone
[8]
5,383,868
5,383,869
Arrays not getting values
<p>I have been working on this yahtzee project and have run into a problem. The dice_number array doesn't seem to be getting the randomly generated values. The oneScore TextView always displays "--". I'm posting my code. Thanks in advance for any help given. Also if you need to see anymore of the code let me know. </p> <pre><code> switch (v.getId()) { case R.id.rollBtn: for(i = 0; i &lt; 5; i++){ randnum = random.nextInt(5); if(i == 0){ images[i].setImageResource(image_array[randnum]); dice_number[i] = randnum; } else if(i == 1){ images[i].setImageResource(image_array[randnum]); dice_number[i] = randnum; } else if(i == 2){ images[i].setImageResource(image_array[randnum]); dice_number[i] = randnum; } else if(i == 3){ images[i].setImageResource(image_array[randnum]); dice_number[i] = randnum; } else if(i == 4){ images[i].setImageResource(image_array[randnum]); dice_number[i] = randnum; } else if(i == 5){ images[i].setImageResource(image_array[randnum]); dice_number[i] = randnum; } } break; case R.id.onesBtn: for (i = 0; i &lt; 5; i++) { if (dice_number[i] == 1) { dice_count[0] += 1; oneScore.setText(Integer.toString(dice_count[0])); } else oneScore.setText("--"); } </code></pre>
android
[4]
4,195,202
4,195,203
How do you create a frozen/non scrolling window region using javascript?
<p>Am curious to know how you create a frozen/non-scrolling regions on a webpage using javascript! like the one used by Stackoverflow when they alert you of the badge you have earned with a "X" close button!</p> <p>Gath</p>
javascript
[3]
2,996,115
2,996,116
JQuery + HttpHandler returning whole html page instead of the expected data
<p>I have a design of JQuery calling a .ashx file returning a small table, which was working fine all this time. However, suddenly the http handler seems to be returning the whole html page instead, not everytime though.</p> <p>Not sure why this is happening! Any clues?</p> <p>Thanks in advance</p>
jquery
[5]
3,453,932
3,453,933
Handler vs AsyncTask
<p>I'm confused as to when one would choose AsyncTask over a Handler. Say I have some code I want to run every n seconds which will update the UI. Why would I choose one over the other? </p>
android
[4]
3,692,774
3,692,775
jQuery: When clicking on checkbox, input box below will be visible
<p>I am not very good at jQuery, so I have a question; is there a quick way to code so when you click on a checkbox (equally to 1), there will appear a text box below. </p> <p>I am currently learning jQuery, so this would be a great example.</p> <p>Thanks in advance!</p>
jquery
[5]
1,793,438
1,793,439
jQuery - Click call function and click function
<p>Basically when I click a button I want to call a function and run the button click function:</p> <p>This jQuery runs when the page loads:</p> <pre><code>jQuery( document ).ready( function ( $ ) { $('ul li:first-child').addClass( 'first_item' ); className = $('.first_item').attr('id'); alert('Date is:'+ className +'.'); }); </code></pre> <p>And this jQuery runs when the a button is clicked:</p> <pre><code>jQuery( document ).ready( function ( $ ) { $('.button').click(function() { $('.tweets ul').prepend($('.refreshMe').html()); }); }); </code></pre> <p>I want to do both when the button is clicked, how can i combine the two?</p> <p>P.P:</p> <p>What If i wanted to add another function into the mix, all to run together:</p> <pre><code> $(".refreshMe").everyTime(5000,function(i){ $.ajax({ url: "test.php?latest="+className+"", cache: false, success: function(html){ $(".refreshMe").html(html); } }) }) </code></pre>
jquery
[5]
3,313,544
3,313,545
Selecting all checkboxes and passing it to another page on click of a button
<p>HI,</p> <p>I have multiple checkboxes in my report. I am using two buttons Select All and Deselect All for selecting all checkboxes and deselecting all checkboxes. But am not able to pass the checked values to another report. Only if I manually select the checkboxes then only those values are getting passed in the report.</p> <p>Can anyone help me out with this?</p>
javascript
[3]
435,015
435,016
What to do with multiple Android apps that share about 90% of source code?
<p>I have a public transport app for one country and I want to create a separate app for another country. Most of the code will be shared, but I need some classes to have different implementations for example TransitProvider.</p> <p>Is it possible to share code using Android Library Project? Can I do the following?</p> <ol> <li>Have TransitProvider (that extends AbstractTransitProvider) in the library project. The class has methods left unimplemented.</li> <li>In application project > AndroidManifest.xml I have different package name than in library's manifest. I have also TransitProvider in this project, that is in the same package as the library's TransitProvider.</li> <li>When I use TP in library project code, the implementation from app. project should be used (ie application project's TP overrides library's TP).</li> </ol>
android
[4]
2,464,681
2,464,682
Retrieve table id with jQuery
<p>I have some tables that are generated with automatic id, so I didn't know the table id before to do some stuff on it.</p> <p>To retrieve my id, I use this jQuery light code </p> <pre><code> $('table').each(function(){ alert(this.id); }); </code></pre> <p>Idea of the html code generated:</p> <pre><code>&lt;table id="table1"&gt;...&lt;/table&gt;&lt;table id="table2"&gt;...&lt;/table&gt; </code></pre> <p>This jQuery code give me all table ids.<br> My tables have some button to add rows, so if I click on the add button for the 2nd table, that only add the row for the 2nd table (the code upside give me all table id on my web page)</p> <p>How can I retrieve the curent table id? (I have try to play with prev() but I think I don't play as well as I must do)</p> <p>Note: I didn't need code to append a row, I could do that ;)</p>
jquery
[5]
2,465,269
2,465,270
Online radio streaming
<p>I need to create a application for online radio streaming for a link(The path of the mp3 file) can somebody please provide me a link to go about it.The user then should be able to play the song and also stop playing the music.Please please its urgent any help will be appreciated.Thank you.</p>
android
[4]
1,708,884
1,708,885
Load XML content in javascript application
<p>I develop a javascript application which display data from xml with charts and lists. For now I put some sample files onto the server's directory that I load with :</p> <pre><code>$.ajax({ type: 'GET', url: 'data/default.xml', dataType: 'xml', ...}) </code></pre> <p>The Xml files can be very heavy so when one of them is loaded I put the data in an IndexedDB.</p> <p>In a second time I would like to let the visitor loads its own xml file by giving the filepath of the xml (f.i. : /home/user/sample.xml). I do not want to upload this file onto the server because I do not need it and it could be too big. But I do want to load those data in the IndexedDB and let the app displays data without any call to the server.</p> <p>I do not know if browsers could work this way? If they could, how can I do such a trick?</p>
javascript
[3]
5,092,840
5,092,841
IPhone EventKit Discrepancy with NSDate ( Time is off by 1 hour )
<p>I was creating an <code>EKEvent</code> for iCal but the time was coming out incorrectly. </p> <p>When I created the <code>NSDate</code> and used a dateformatter to read it, the date was as I would expect it. But, when I would add the date as the <code>startDate</code> to the <code>EkEvent</code> and would add the event to the calendar it would mysteriously change to 1 hour later.</p> <p>I checked through the documentation on Timezones and offsets thinking that was the root cause.</p>
iphone
[8]
2,425,949
2,425,950
How to hide the Div at the Click of the Button in MVC
<p>My application is in MVC3.I want a particular Div in my View to Hide at the click of the button. Below is my Code that i tried.</p> <pre><code> $(document).ready(function () { $("#btnCompare").click(function () { if(MyCondition) { for(MyLoop) { } } } }); </code></pre> <p>My this code is not working.As well as i want to Div to Hide after the Click is called. Please suggest</p>
jquery
[5]