Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
3,685,986 | 3,685,987 | sorting is not working | <p>when i m trying to sort in grid view without ispostback property then sorintg is done, but when i m using ispoastback property on page_load then it is not working. please suggest me some solution...here is my code</p>
<pre><code> private string ConvertSortDirection(SortDirection sortDirection)
{
string newSortDirection = String.Empty;
switch (sortDirection)
{
case SortDirection.Ascending:
newSortDirection = "ASC";
break;
case SortDirection.Descending:
newSortDirection = "DESC";
break;
}
return newSortDirection;
}
protected void grd_productMaster_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable dataTable = grd_productMaster.DataSource as DataTable;
if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
dataView = (DataView)Session["dataview"];
if (Session["dataview"] != null)
{
dataView.Sort = e.SortExpression + " " + ConvertSortDirection(e.SortDirection);
grd_productMaster.DataSource = dataView;
grd_productMaster.DataBind();
}
else
Response.Write("Dataview is null");
}
}
</code></pre>
| asp.net | [9] |
1,280,058 | 1,280,059 | PHP Filter Input Escape Output | <p>Will it be better if i add to mysql_real_escape_string also addslashes like that:</p>
<pre><code>$username = mysql_real_escape_string(trim(addslashes($_POST['username'])));
</code></pre>
<p>And is there any need in this in password var:</p>
<pre><code>$password = md5(mysql_real_escape_string(trim($_POST['password'])));
</code></pre>
<p>Also i read some topics about safe retrieving data from db...
it says that it would be better to retrieve data like that:</p>
<pre><code>htmlentities(stripslashes($v))
</code></pre>
<p>Is it really necessary for safety?</p>
| php | [2] |
2,664,830 | 2,664,831 | Javascript Popup Text Limit in IE8 | <p>Is there any limit to the amount of text that can be called via a Popup in javascript/jquery?</p>
<p>I have a popup that works fine in IE9, FF etc BUT does NOT work in IE8</p>
<p>The word count is 2667, is there any limitations in IE8 and can it be fixed via code?</p>
<p>Update: When I edit the text, the popup works. Still curios why IE8 would not load </p>
<p>Thanks</p>
<p>RG</p>
| javascript | [3] |
3,370,664 | 3,370,665 | Put contents of Set<Object> into Array | <p>I'm sure this is an easy one. I just want to dump the set after the for loop in to the array of type <code>Role</code></p>
<p>This is what I got:</p>
<pre><code>Role[] hotPartRoles;
Set <Role> roles = profile.getRoles(Section.MMC);
for (Role role : roles )
{
if( role.getName().contains("HOT_PART") && !role.getName().contains("READ_ONLY") )
{
System.out.println("Role: " + role.getName());
}
}
</code></pre>
<p>I want to put the vaues that come back from the for loop into <code>hotPartRoles</code></p>
<p>thanks.......</p>
| java | [1] |
4,857,730 | 4,857,731 | How to open the default browser in background and get the source code of a web page? | <p>I'm using Dev-C++ and i'm looking for a mode to open(...or better...i need to load a browser intance in the background) the default browser (Example I.E.) and send a request to get the source code of the page I requested.</p>
<p>Can I do something like this in C++?</p>
<p>Thank you!</p>
<p>P.S. I need this for Windows</p>
| c++ | [6] |
788,233 | 788,234 | Search Bar automatically becomes first responder after resigning text fields first responder | <p>i have a UITableViewController with a search bar and a textfield. When i resign the textfields first responder it seems like the search bar becomes the first responder as it goes into "search-modus". Is anyone familiar with this problem or does anyone know how to prevent the search bar from becoming the first responder after i resign the textfields first responder.</p>
| iphone | [8] |
908,650 | 908,651 | Accessing a variable outside of an 'if' statement | <p>How can I make <code>insuranceCost</code> available outside the <code>if</code> statement?</p>
<pre><code>if (this.comboBox5.Text == "Third Party Fire and Theft")
{
double insuranceCost = 1;
}
</code></pre>
| c# | [0] |
2,041,849 | 2,041,850 | Display GIF Image using movie in android | <p>i want to display Gif image in android.i tried using Movie but it not succeed.
anyone can help me i am new to android.i search alot but not find proper code.
plz can share working coding sample.</p>
| android | [4] |
2,300,405 | 2,300,406 | javascript and this | <pre><code>function distance(r,t){
this.rate = r,
this.time = t,
this.calculate = function() {return rate * time ;};
return this;
}
var trip1 = distance(2,4);
var trip2 = distance(5,7);
var trip3 = distance(3,10);
document.write("<br>trip1: " + trip1.calculate());
document.write("<br>trip2: " + trip2.calculate());
document.write("<br>trip3: " + trip3.calculate());
</code></pre>
<p><strong>ouput</strong></p>
<pre><code>trip1: 30
trip2: 30
trip3: 30
</code></pre>
<p>Shouldn't the output be</p>
<pre><code>trip1: 8
trip2: 35
trip3: 30
</code></pre>
| javascript | [3] |
5,710,369 | 5,710,370 | Javascript: Check if server is online? | <p>What's the fastest way to check if my server is online via javascript?</p>
<p>I'm trying the following AJAX..</p>
<pre><code> function isonline(){
var uri = 'MYURL'
var xhr = new XMLHttpRequest();
xhr.open("GET",uri,false);
xhr.send(null);
if(xhr.status == 200)
{
//is online
return xhr.responseText;
}
else
{
//is offline
return null;
}
}
</code></pre>
<p>The problem is it never returns if it's offline.. how would I set a timeout so that if it doesn't return after a certain amount of time I assume offline?</p>
| javascript | [3] |
163,220 | 163,221 | SMS type TEXT or MMS or other? | <p>How to capture incoming MESSAGE type whether it is Text or MMS or something else in Android programmatic ally?</p>
| android | [4] |
781,200 | 781,201 | Java: Casting Object to Array type | <p>I am using a web service that returns a plain object of the type "Object". Debug shows clearly that there is some sort of Array in this object (see the image below) so I was wondering how I can cast this "Object" to an Array (or similar)?</p>
<p><a href="http://img269.imageshack.us/img269/8439/objectdebug.png" rel="nofollow">Debug Image</a></p>
<p>I tried the following:</p>
<pre><code>Collection<String> arr = (Collection<String>) values;
Vector<String> arr = (Vector<String>) values;
ArrayList<String> arr = (ArrayList<String>) values;
</code></pre>
<p>But nothing worked. I always get an InvocationTargetException.</p>
<p>What am I doing wrong?</p>
| java | [1] |
1,168,983 | 1,168,984 | Android Video and Audio Output | <p>Is it possible in android to capture the screen image and any playing audio file? I have done some searches but didn't find anything. </p>
| android | [4] |
2,928,717 | 2,928,718 | Beginner: Javascript must be on header to run? Does the declaration order of the functions matter? | <p>I have this function in my head:</p>
<pre><code><head>
window.onload = function(){
var x = new Array(0,2,3,4,5,6,7,8);
var y = new Array(20,10,40,30,60,50,70,10);
drawGraph(y,x);
}
</head>
</code></pre>
<p>Can I declare the function drawGraph() somewhere in the body? Do I need to declare it before it is called?</p>
| javascript | [3] |
4,231,378 | 4,231,379 | Android- Create a list with names of all image folders only | <p>I am stuck at a point where my activity generates a list containing an thumb image and name of all folders that contain images from SD card..
1. How do i filter only those folders with the images?
2. How do i get the thumb images from the first image in the folder? </p>
| android | [4] |
1,922,916 | 1,922,917 | Functions vs OOP question | <p>I have just started studying OOP and I am a little confused of the benefits of doing either functions or OOP. I understand OOP is much more versatile in organizing your code, but for example, I have 50 lines of code, that occur on 7/10 pages of my site. Is it better to create a file and put a function in the file, and then use an include, or do the same with a class? Furthermore, is it better, to mass classes into one file and include it? If anyone has a bit of insight that may help clear up my confusion, I would really appreciate it.</p>
| php | [2] |
4,884,997 | 4,884,998 | NSUserDefaults and NSMutableArray | <p>When saving an array in the userdefaults using the <code>setObject</code> method, is it then ok to just <code>setObject:myMutableArray</code> or do I need to wrap it in<br>
<code>[NSArray arrayWithArray:myMutableArray];</code> ? The first one should work right? Since it is a subclass of NSArray, and it wont affect other things?</p>
| iphone | [8] |
812,099 | 812,100 | Using ordinary stream writers/readers with piped streams | <p>Consider the following test code. </p>
<p>I am trying to find out if I can use piped streams like "normal" I/O streams, together with the commonly used Reader and Writer implementations (specifically, another part of the code base I am working on demands that I use OutputStreamWriter).</p>
<p>The problem here is that nothing appears to show up on the read end. The program at least appears to correctly write the message to the write-end of the pipe, but when trying to read from the other end I block indefinetly, or if I (as in this case) check for available bytes, the call returns 0.</p>
<p>What am I doing wrong?</p>
<pre><code>public class PipeTest {
private InputStream input;
private OutputStream output;
public PipeTest() throws IOException {
input = new PipedInputStream();
output = new PipedOutputStream((PipedInputStream)input);
}
public void start() {
Stuff1 stuff1 = new Stuff1(input);
Stuff2 stuff2 = new Stuff2(output);
Thread thread = new Thread(stuff1);
thread.start();
Thread thread2 = new Thread(stuff2);
thread2.start();
}
public static void main(String[] args) throws IOException {
new PipeTest().start();
}
private static class Stuff1 implements Runnable {
InputStream inputStream;
public Stuff1(InputStream inputStream) {
this.inputStream = inputStream;
}
@Override
public void run() {
String message;
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
try {
//message = reader.readLine();
System.out.println("Got message!");
System.out.println(inputStream.available());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private static class Stuff2 implements Runnable {
OutputStream outputStream;
public Stuff2(OutputStream outputStream) {
this.outputStream = outputStream;
}
@Override
public void run() {
String message = "Hej!!\n";
OutputStreamWriter writer = new OutputStreamWriter(outputStream);
try {
writer.write(message);
System.out.println("Wrote message!");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
</code></pre>
| java | [1] |
1,983,603 | 1,983,604 | How to turn on my computer through python? | <p>I am using ubuntu10.04.I am trying to turn on my system at particular date automatically.Is there any chance to turn on my computer through python code?</p>
| python | [7] |
4,256,184 | 4,256,185 | Syntax Error, unexpected $end | <p>Been trying for hours this php embedding in html but something is wrong as i get a error:</p>
<p>Parse error: syntax error, unexpected $end in C:\Program Files\xampp\htdocs\profile.php on line 678</p>
<pre><code><select value='$pays' name='pays' id='pays' style='width: 204px;margin-bottom: 5px; outline-width:0;'>
<?php
$result = mysql_query("SELECT pays_az, pays_zz, pays_or FROM in_lays WHERE pays_flush = '1' ORDER BY pays_nom ASC");
while ($row = mysql_fetch_array ($result) )
{ ?>
<option value="<?php echo $row['dd']; ?>"
<?php if($row['dd_id'] == $pays)
{
echo 'selected="selected" ' ;
}
else
{
if($row['dd_id'] == "61")
{
echo 'selected="selected"' ;
}
}
?>><?php echo $row['lala']; ?></option>
<?php}?>
</select>
</code></pre>
<p>dont pay attention to the names in the sql request.</p>
| php | [2] |
758,059 | 758,060 | How to pass paramerters to custom selector from a NSTimer object? | <p>How to use the <code>userInfo</code> object in an <code>NSTimer</code> call such as</p>
<pre><code>+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;
</code></pre>
<p>I want to send certain parameters to my custom selector.</p>
| iphone | [8] |
4,193,787 | 4,193,788 | preg_replace syntax | <p>I have an existing piece of code that successfully from what I can tell replace empty form values for a text field called your-subject. I need to do the same thing for another field called Bcc. I cannot seem to get my syntax correct when I try to add the name="Bcc" field. Can someone show me the proper syntax? The page just simply fails to load so I'm guessing I missed a quote or escape character somewhere?</p>
<p>Works fine:</p>
<pre><code>echo preg_replace('!<input type="text" name="your-subject" value=""!'
,'<input type="text" name="your-subject" value="MLS# '.$row['mlnum'].'"'
,do_shortcode( '[contact-form-7 id="17" title="Contact Form"]' )
);
</code></pre>
<p>Broken:</p>
<pre><code>echo preg_replace('!<input type="text" name="your-subject" value=""!'
,'<input type="text" name="your-subject" value="MLS# '.$row['mlnum']
.'"''!<input type="text" name="bcc" value=""!'
,'<input type="text" name="your-subject" value="test@test.com"'
,do_shortcode( '[contact-form-7 id="17" title="Contact Form"]' )
);
</code></pre>
| php | [2] |
4,277,142 | 4,277,143 | How to set a textview's background color to be holo green light via XML? | <p>I've got a textview and I'd let to set its background color to be holo green light as mentioned here: <a href="http://developer.android.com/reference/android/R.color.html" rel="nofollow">http://developer.android.com/reference/android/R.color.html</a></p>
<p>However, I can't figure out how to do this via XML. Is it possible? I currently have:</p>
<pre><code> <TextView
android:text="2"
android:textSize="200sp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/textView2"
android:background="#00FF00"
android:gravity="center"
android:textColor="#EEEEEE"
android:layout_alignParentRight="true" />
</code></pre>
<p>However, I'm unable to change android:background to somehow reference holo green light.</p>
<p>Does anyone have any suggestions? I've tried "@android:color/" but no dice.</p>
<p>Thanks,</p>
<p>Gabe</p>
| android | [4] |
1,890,481 | 1,890,482 | Android: republishing a .apk file to the store | <p>I submited an .apk file to the Android app store yesterday, and now submitted another one.</p>
<p>It created a second apk file which I activated and then I de-activated the previous one.</p>
<p>Is that the right procedure? Now I have 2 apk files showing up. Is that what is supposed to happen? Or is one supposed to delete the previous file?</p>
<p>Thanks!</p>
| android | [4] |
1,479,401 | 1,479,402 | How do I reapply a jQuery selector? | <p>I have a javascript function that selects several elements, and then performs some DOM manipulation. When the DOM manipulation involves adding more elements that match the initial selectors, I'd like to re-apply them to include the new elements.</p>
<pre><code>var row1 = table.find("tr.row1 td");
var row2 = table.find("tr.row2 td");
var row3 = table.find("tr.row3 td");
for(...) {
if() {//Some condition is met
table.children().each(function(row) {
row.append(row.children().eq(5).clone());
});
row1.refresh(); // I'd like something here like refresh, rather than row1 = table.find("tr.row1 td");
}
//Code that uses row1, row2, and row3
}
</code></pre>
<p>Is there a function that does what I'm looking for on the <code>refresh()</code> line?</p>
| jquery | [5] |
181,423 | 181,424 | Get changed value from <select> using jQuery | <p>I am trying to get the changed value of a <code><select></code> input using <strong>jQuery</strong>.</p>
<p><strong>Before change</strong></p>
<pre><code><select class="input" multiple="multiple" name="inputUserRoles[]">
<option value="Administrator">Administrator</option>
<option value="Faculty" selected="selected">Faculty</option>
<option value="Head of Department">Head of Department</option>
<option value="Faculty Coordinator" selected="selected">Faculty Coordinator</option>
</select>
</code></pre>
<p><strong>After change</strong></p>
<pre><code><select class="input" multiple="multiple" name="inputUserRoles[]">
<option value="Administrator">Administrator</option>
<option value="Faculty" selected="selected">Faculty</option>
<option value="Head of Department">Head of Department</option>
<option value="Faculty Coordinator">Faculty Coordinator</option>
</select>
</code></pre>
<p>If you notice, after the change event, the option 'Faculty Coordinator' is not <code>selected</code>.</p>
<p>I wish to get the value 'Faculty Coordinator'.</p>
<p><strong>My javascript code</strong></p>
<pre><code>$('select[name="inputUserRoles[]"]').change(function(e) {
// this line gives me the value after the change event.
var inputUserRoles = $(this).val();
});
</code></pre>
<h2>Possible Solutions?</h2>
<p>I was thinking that the event <strong>(e)</strong> should be containing the changed data but I have no idea how to get it. The project I am working on is in its final phase and I just need to figure out this part to complete the similar remaining modules.</p>
<p>The other way to get this done is by getting the old input and comparing.</p>
| jquery | [5] |
5,701,955 | 5,701,956 | How to send predefined email template in vb.net? | <p>I am now developing one web application in vb.net. In that application I have one requirement. i.e. I have to send predefined email template to registered users. In that template I have to add some text messages like greeting messages or welcome messages. How to send predefined email templates in vb.net?</p>
| asp.net | [9] |
1,681,180 | 1,681,181 | If people recommend I shouldn't use .innerHTML, what then should I instead use? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/737307/javascript-is-it-better-to-use-innerhtml-or-lots-of-createelement-calls-to-add">JavaScript: Is it better to use innerHTML or (lots of) createElement calls to add a complex div structure?</a> </p>
</blockquote>
<p>What should I use instead of <code>.innerHTML</code>? All advice is appreciated.</p>
| javascript | [3] |
2,192,785 | 2,192,786 | Offset Timer starts | <p>Hi new to the site so I apologize if my question is not properly formatted</p>
<p>If i have two events that need to alternate every 2 seconds (one is ON the other is OFF), how can i delay the start of one of the timers for the 2 second offset?</p>
<pre><code> static void Main(string[] args)
{
Timer aTimer = new Timer();
Timer bTimer = new Timer();
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
bTimer.Elapsed += new ElapsedEventHandler(OnTimedEventb);
// Set the Interval to 4 seconds
aTimer.Interval = 4000;
aTimer.Enabled = true;
bTimer.Interval = 4000;
bTimer.Enabled = true;
Console.WriteLine("Press the Enter key to exit the program.");
Console.ReadLine();
}
// Specify what you want to happen when the Elapsed event is
// raised.
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
Console.WriteLine("The status is on {0}", e.SignalTime);
}
private static void OnTimedEventb(object source, ElapsedEventArgs b)
{
Console.WriteLine("The state is off {0}", b.SignalTime);
}
</code></pre>
<p>So I basically want the ON event to happen when the program starts, then 2 seconds later have the OFF event fire and so on</p>
<p>using vs 2012 console app but I will be using in windows forms program</p>
| c# | [0] |
5,715,005 | 5,715,006 | How to convert month name array to number array | <p>Here i have defined my month name array</p>
<pre><code>$months = array(1 => 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
</code></pre>
<p>Below is the code i loop throgh it for getting the month names in a dropdown.</p>
<pre><code><tr>
<td>Period From:<span id="star">*</span>
<select name="monthfrom" id="monthfrom" style="width:60px">
<option value="Month">Month</option>
<?php
foreach ($months as $value) {
echo '<option value="' . $value . '">' . $value . '</option>\n';
}
?>
</select>
</td>
</tr>
</code></pre>
<p>After excuting i want month names in the dropdown but value should be a two-digit month number (with leading zeroes).</p>
| php | [2] |
5,817,364 | 5,817,365 | How do I enter line breaks in HTML link titles? | <p><strong>PHP code:</strong></p>
<pre><code>foreach( )
{
if()
{
$title = $title . $sub['TITLE']."<br />";
}
}
echo '<a title="$title"> </a>';
</code></pre>
<p>when I place the cursor in anchor tag, the title should show one by one</p>
<pre><code>i.e A
b
c
</code></pre>
<p>but it showing now as</p>
<pre><code>A <br />
B <br />
C <br />
</code></pre>
<p>Why the break tag showing here??</p>
<p>and also I need to know how to remove <code><br/></code> i.e only the last <code><br/></code> tag in the string?</p>
| php | [2] |
1,321,295 | 1,321,296 | Web.Config Issues | <p>I have an ASP.NET web application that has a web.config file in the website's parent directory. I have another folder in the website which has another asp.net application. The folder also has a web.config directory for itself. When I run the application within the sub folder, it throws error and somehow these errors are related to references in root level application. </p>
<p>Initially it threw this error: code sub directory doesnt exist, . I added a dummy folder for this within the application in the sub folder but it seems to be looking for more references. is there a way to resolve this issue. </p>
<p>Parent application has it's own config and the application within Sub folder has it's own web.config. Whe i run the appl within sub folder, it is trying to use the web.config from parent application not it's own. </p>
<p>Thanks
Jay </p>
| asp.net | [9] |
5,281,177 | 5,281,178 | Can't disable screen compatibility mode in android | <p>I am developing an App for all screen sizes and dpi. </p>
<p>The problem is that for large/smaller screen than normal the UI is being scaled, meaning I think screen compatibility mode is enabled.</p>
<p>This is my goal: I have an image button that is 90 pixels in height, so I think it is 90 dp in normal-mdpi device and I want it to remain 90 dp in larger and smaller screen sizes. So to the eye, the size remains the same.</p>
<p>The problem I am having is that is looks good (90 dp) in normal-mdpi device, but it looks much bigger and with scaling artifacts in a large-mdpi device.</p>
<p>I am targeting min android OS of 2.3.3, therefore I have the following manifest:</p>
<pre><code><uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="16" />
<!--
If not set explictly, screen compatibility mode would be enabled for
large screen, which is scaling of normal
-->
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
</code></pre>
<p>According to the android documentation, if targeting 10 or below, you mush specify supports-screens otherwise compatibility mode is enabled by default. Problem is that I am specifying it but I am still getting the compatibility mode enabled.</p>
<p>Any ideas? Please let me know if my understanding is wrong.</p>
<p>Thanks</p>
| android | [4] |
333,963 | 333,964 | how to set focus for last added ctrl in TableLayoutPanel | <p>am using TableLayoutPanel to show the images.. here dynamically i ll add lot image into TableLayoutPanel .. here i need to focus the last added image .... i don't know how to do this please help me....</p>
| c# | [0] |
1,012,724 | 1,012,725 | How do I open a new tab/window using JavaScript? | <h1>Objective</h1>
<p>I want to open a URL in a new tab/window in the <strong>EXACT</strong> same manner as target="_blank" would. </p>
<h1>Code</h1>
<p>I'm using a PHP condition which triggers the following JavaScript:</p>
<pre><code><script type="text/javascript">
window.open ("http://www.google.com/","_blank", "status=1,toolbar=1");
</script>
</code></pre>
<h1>My problem</h1>
<p>window.open is <strong>NOT THE SAME</strong> as target="_blank" hyperlinks.</p>
<ol>
<li>It presents an issue with pop-up blockers.</li>
<li>The window requires parameters to look like what target="_blank" would have produced.</li>
<li>Once the JavaScript runs, certain font colors of the containing document are lost.</li>
</ol>
<h1>My question</h1>
<p>How do I EXACTLY simulate what's produced by target="_blank"?</p>
| javascript | [3] |
3,404,137 | 3,404,138 | jquery each() function not working as intended | <p>I'm trying to loop through all the inputs in my form and if the input does not contain a value, then do a couple of things. </p>
<p>Here's my code so far,</p>
<pre><code>$('input').each(function() {
if($(this+'[value!=""]')) {
$('.requiredMark').hide();
$(this).after(checkMark);
}
});
</code></pre>
<p>What am I doing wrong? Thank you </p>
| jquery | [5] |
5,465,729 | 5,465,730 | javascript: anonymous function expose functions (how frameworks really works) | <p>i was exploring in the last few days how big frameworks works , how they assign their function name and it can't(?) be override , i pretty much know how framework work with anonymous function , for example they do it this way or similar version :</p>
<pre><code>(function(){
var Sizzle = function (){
var x;
};
Sizzle.f = function(){
alert("!");
};
window.Sizzle = Sizzle;
})();
</code></pre>
<p>i still don't get few things about those huge frameworks and i hope i can find answer :</p>
<ol>
<li>how do they assign function name and the name can't be override?</li>
<li>in the code above to call the function i need to write Sizzle.f() to get the function to work , but when i use jquery i don't write Jquery.show() , just show() , how do they vanish the "jquery" from "jquery.show()" function call?</li>
</ol>
<p>by saying the name can't be override i mean , if i create function with one of the jquery functions names , the jquery function will work.</p>
<p>thanks in advance.</p>
| javascript | [3] |
3,547,523 | 3,547,524 | 'import module' vs. 'from module import function' | <p>I have always been using this method:</p>
<pre><code>from sys import argv
</code></pre>
<p>and use <code>argv</code> with just <strong>argv</strong>. But there is a convention of using this:</p>
<pre><code>import sys
</code></pre>
<p>and using the argv by <code>sys.argv</code></p>
<p>The second method makes the code self documented and I <em>(really)</em> adhere to it. But the reason I prefer first method is it is fast because we are importing only the function that is needed rather than import the whole module (which contains more useless functions which python will waste time importing them). Note that I need just argv and all other functions from sys are useless to me.</p>
<p>So my questions are. Does the first method really makes the script fast? Which method is preferred most? Why?</p>
| python | [7] |
1,597,855 | 1,597,856 | where can I find websites with good java source codes that work? | <p>HI. I am a beginner/intermediate java programmer.I'd like to see codes of useful applications used in the real world. Could anyone tell me where to look for such source codes? thanks.</p>
| java | [1] |
2,768,509 | 2,768,510 | Figure out crash reason for a same project which crashes under certain target | <p>I am targeting my application to be able run across Android 1.5 till 2.3. I create 2 AVDs </p>
<pre><code>Android 2.3.3 (API Level 10)
Android 1.5 (API Level 3)
</code></pre>
<p>I found out my application able to launch in Android 2.3, but not 1.5. It crashes even before the application able to show up. I try to find out the root cause using the following way. Here is what I did.</p>
<p><strong>I made the build target pointed to Android 1.5</strong>
<img src="http://i.stack.imgur.com/tUP7V.png" alt="enter image description here"></p>
<p><strong>I Debug As -> 1 Android Application</strong>
<img src="http://i.stack.imgur.com/HkKvH.png" alt="enter image description here"></p>
<p>The crash breakpoint is pointing to Android code, and not my application code.</p>
<p><strong>If I just Run As -> 1 Android Application, I will get the following</strong>
<img src="http://i.stack.imgur.com/32mbR.png" alt="enter image description here"></p>
<p><strong>If I run the same source code, by targeting Android 2.3.3, the application can be launched without problem.</strong></p>
<p><img src="http://i.stack.imgur.com/82frh.png" alt="enter image description here"></p>
<p>What is the correct way, for me to figure out, why the same project can crash under certain target, but run well under another target.</p>
| android | [4] |
749,599 | 749,600 | issues with writing test case in java | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4744146/how-to-write-test-case-in-java">how to write test case in java</a> </p>
</blockquote>
<p>hi
I created one class in which I have one constructor as follows:</p>
<pre><code>public class ABC {
private static String host;
private static String port;
private static String browser;
private static String url;
private static String fullurl;
public ABC(){
try {
File file = new File("Element.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
</code></pre>
<h2> doc.getDocumentElement().normalize();</h2>
<p>please tell me test case for constructor:</p>
| java | [1] |
1,909,601 | 1,909,602 | Double ternary in JavaScript | <p>I was going through some stuff in the jQuery source, specifically the <code>inArray</code> method and I found this line of code:</p>
<pre><code>i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
</code></pre>
<p>What I am seeing is two ternary operators, but I have no idea how this is used. I understand how the ternary operator works, but I have never seen it used like this before. How does this piece of code work??</p>
| javascript | [3] |
1,448,480 | 1,448,481 | Adding element to existing XML node | <p>Where am i going wrong???</p>
<p>I have an xml file with OppDetails as a tag already as shown below</p>
<pre><code><OppDetails>
<OMID>245414</OMID>
<ClientName>Best Buy</ClientName>
<OppName>International Rate Card</OppName>
<CTALinkType>AO,IO,MC,TC</CTALinkType>
</OppDetails>
</OppFact>
</code></pre>
<p>Now i am trying to add another element to it but getting an error in AppendChild method please help</p>
<pre><code>XmlNode rootNode = xmlDoc.SelectSingleNode("OppDetails");
XmlElement xmlEle = xmlDoc.CreateElement("CTAStartDate");
xmlEle.InnerText = ExcelUtility.GetCTAStartDate();
rootNode.AppendChild(xmlEle);
xmlDoc.Save("C:\\test.xml");
</code></pre>
| c# | [0] |
4,751,421 | 4,751,422 | ImageView not showing up on Android | <p>When I try to show an image using ImageView on my emulator, it shows up.
Once I add a button, the image doesn't show up.</p>
<p>I don't know if this helps, but my XML when it's working:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/ImageView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
</LinearLayout>
</code></pre>
<p>and not working:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:id="@+id/backbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back"/>
<ImageView android:id="@+id/ImageView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
</LinearLayout>
</code></pre>
| android | [4] |
5,369,597 | 5,369,598 | ABPersonviewController | <p>Can we add any label to display some message on the info screen after using ABPersonviewController. it display a inbuilt info screen i need to display a label for custom message how to do it</p>
| iphone | [8] |
48,852 | 48,853 | android: How to hide group indicator in BaseExpandableListAdapter when child count = 0 | <p>Please help me hide the group indicator in BaseExpandableListAdapter when child count is zero. I have a list of groups with various dynamic child counts and I would like to hide the icon only for those groups that do not have any children. What is the proper way to do this?</p>
| android | [4] |
5,251,529 | 5,251,530 | Detect lack of earpiece (speakerphone only) on an Android device | <p>I've got an app which displays a speakerphone toggle button when used on a phone. The toggle switches audio routing between the phone's earpiece and the speakerphone. However, when the app is run on a tablet (or any device which lacks an earpiece), I'd like to remove the toggle, since all audio is routed through the speakerphone.</p>
<p>Ideally, I'd like to use some kind of <code>isEarpiecePresent()</code> call, or maybe check a flag on some configuration object to find this information, but I can't find anything of the sort in the API.</p>
<p>I attempted to work around the issue by calling <code>AudioManager.setSpeakerphoneOn(false)</code>, then checking <code>AudioManager.isSpeakerphoneOn()</code>, hoping that it would still return true and I could key off of that. The system returned <code>false</code>, even though audio is still routing through the speaker.</p>
<p>I'm currently thinking of checking for telephony capability, even though that doesn't exactly fit. Any other ideas?</p>
| android | [4] |
4,968,035 | 4,968,036 | compilation error in java "stray '@' in program" | <p>i am trying to submit a java program in <a href="http://www.codechef.com" rel="nofollow">codechef</a>. I successfully compiled it and ran it using netbeans. But when i submit the code by uploading the corresponding .java file... it comes up like this...</p>
<p><code>
prog.cpp:41: error: stray '@' in program prog.cpp:4: error: 'import' does not name a type prog.cpp:7: error: expected unqualified-id before 'public'
</code></p>
<p>my java program starts like this....</p>
<pre><code>import java.util.Scanner;
</code></pre>
<p><code>public class jewels{
static int CNT=0;
static String q,qq;
</code></p>
<p>and so on....</p>
<p>@Jon Skeet... u were ... I got the error... Sorry for that.. I was submitting it as a C++ file.
but now i am getting the new one...</p>
<p><code>Main.java:7: class jewels is public, should be declared in a file named jewels.java public class jewels{ ^ 1 error
</code></p>
<p>although i uploaded the jewels.java file...
please help...</p>
| java | [1] |
504,541 | 504,542 | How to pass parameters to a function in a file using Java? | <p>I have a function written in clearbasic code in a clearbasic file. Is it possible for a JAVA program to access this file and send parameters to the function to get desired result?</p>
| java | [1] |
2,126,885 | 2,126,886 | how to clear the unneccessary input stream in C++ | <p>I would like to make the user input a center number of character, e.g. 10, however, the user might input more than 10. </p>
<pre><code>for(int i = 0 ; i< 10 ; i++)
cin>>x;
</code></pre>
<p>The extra character could make my code crash since I will ask for input later. </p>
<p>How can I clear the input at this moment when the user input more than 10?</p>
<p>Thanks so much!</p>
| c++ | [6] |
915,724 | 915,725 | PHP get value of array by position | <p>I am pulling the latest 3 news articles from my database and I need to access them by the order they were pulled from, so first position in the array, second position and so on to display them in order in random sections of my web page. I came across accessing the array key but that is not working, where am I going wrong? Thanks in advance!</p>
<pre><code>$value = array_slice($blog, 0, 1);
echo $value;
</code></pre>
| php | [2] |
4,842,305 | 4,842,306 | Simulate change option in a select with JavaScript? | <p>In <a href="http://www.crucial.com/index.aspx" rel="nofollow">this</a> site, for example, there are 3 SELECT elements (Step 1, Step 2 and Step 3). I'm able to change the value of the first one with <code>selectElement.value = selectElement.options[i].value;</code>, but when I change it the Step 2 doesn't update it's options as it would if I would select it with the mouse. Is there any way to force it to update? </p>
| javascript | [3] |
4,085,944 | 4,085,945 | jQuery fly out | <p>I wrote this jQuery script.
It works somewhat OK. I want this fly out to close when the user mouse goes outside the fly out. How would I do that?</p>
<p>Here is the code below:</p>
<pre><code> <script language="javascript">
$(document).ready(function() {
$('#slick-box').hide();
$('a#slick-toggle').mouseover(function() {
$('#slick-box').toggle(400);
}).mouseout(function(){
$('#slick-toggle').hide();});
});
</script>
<style>
</style>
</head>
<body>
<a id="slick-toggle" href="#"> toggle the box </a>
<div style="position:relative;outline:1px dashed green;padding:10px;">
<div id="slick-box" style="position:absolute;outline: 1px dashed hotpink; color:#fff; background-color:#000; opacity:0.8; filter:80;top:0px; left:0px ;">
<h2>music name </h2>
<p> This will be shown and hidden</p>
</div>
</div>
<p>lorem ip sum loerm ip lorem ip sum lorem ipsum</p>
<p>lorem ip sum loerm ip lorem ip sum lorem ipsum</p>
<p>lorem ip sum loerm ip lorem ip sum lorem ipsum</p>
<p>lorem ip sum loerm ip lorem ip sum lorem ipsum</p>
<p>lorem ip sum loerm ip lorem ip sum lorem ipsum</p>
<p>lorem ip sum loerm ip lorem ip sum lorem ipsum</p>
<p>lorem ip sum loerm ip lorem ip sum lorem ipsum</p>
</body>
</code></pre>
| jquery | [5] |
118,999 | 119,000 | Strange behaviour of onResume() - Thread already started | <p>I've got a class which replicates the Bluetooth OBEX Protocol. This class is based on the Bluetooth Chat Example. An instance of this class is constructed in my <code>onCreate()</code> method</p>
<pre><code>bluetoothCommunicator = new BluetoothCommunicator(BaseClass.this);
</code></pre>
<p>This <code>BluetoothCommunicator</code> class has two inner classes which extends Thread</p>
<p><code>AcceptThread</code> and <code>ReadInputThread</code></p>
<p>From my baseClass where the communication socket is initialized, I also have the <code>onResume()</code> and the <code>onPaused()</code> methods. </p>
<pre><code>@Override
public void onResume() {
bluetoothCommunicator.resumeCommunicator();
}
</code></pre>
<p>This will call the resumeCommunicator method: </p>
<pre><code>public void resumeCommunicator() {
Log.i("RESUME COMMUNICATOR: ", "COMMUNICATOR IS RESUMED");
if(server == null)
Log.i("Server: ", "IS NULL");
if (server == null) {
AcceptThread server = new AcceptThread();
server.start();
}
if(!server.isAlive()) {
server.start();
}
}
</code></pre>
<p>In this method, <code>server</code> is an instance of <code>AcceptThread</code></p>
<p>But this <code>onResume</code> method will cause some problems for me. When I put my application in the background, and tries to open it again, the <code>onResume</code> method is called, but it says that the Thread already has started, and throws an exception. It sounds pretty strange that this would happend, by just looking at the code in the <code>resumeCommunicator</code> method. </p>
| android | [4] |
5,351,778 | 5,351,779 | "Unable to start activity" after onStop? | <p>I have a problem with life cycle of my code.</p>
<p>It runs well without noticeable errors, but when I stop the program (ie loading home screen) and return to the program again, it stops running showing error ("unable to start activity").
The log also shows this message: "java.lang.OutOfMemoryError: bitmap size exceeds VM budget"</p>
<p>I guess that this means my frame-to-frame bitmap animation. Is there a way to resolve this error? Please help.</p>
<p>Thanks in advance.</p>
| android | [4] |
2,545,930 | 2,545,931 | how to get the application running time - iphone | <p>I want to calculate the running time of application that is when the application was started and then when it was closed.</p>
<p>Starting can be logged in application did finish launching but application will terminate is not working for me as when home button is pressed the application fires event "applicationWillResignActive" but user may start the application again or user can quit the application. When I try to quit the application application will terminate event is not occurring.</p>
<p>How can I then find out the application running time ?</p>
<p>Many Thanks,<br>
Naveed Butt</p>
| iphone | [8] |
5,450,997 | 5,450,998 | JQuery - Call the jquery button click event based on name property | <p>I have one HTML button like,</p>
<pre><code><input type="button" id="btnSubmit" name="btnName" class="btnclass" value="Click Me" />
</code></pre>
<p>I want to call jquery button click event based on "id" property means,
we use the code like,</p>
<pre><code>$("#btnSubmit").click(function(){
////////
});
</code></pre>
<p>as well as call button click event based on "class" property means,
we use the code like,</p>
<pre><code>$(".btnclass").click(function(){
/////////
});
</code></pre>
<p>and My question is, I want to call the button click event based on "name" property means, How to do this?</p>
| jquery | [5] |
950,034 | 950,035 | Trying to get a string that represents a class heirachy | <pre><code>class Base
{
}
class A: Base
{
}
class B:A
{
}
</code></pre>
<p>I want to be able to get for an instance of B the string "Base.A.B"</p>
<p>Of course I could simply do</p>
<pre><code>class B:A
{
const string NAME = "Base.A.B";
}
</code></pre>
<p>But thats kind of fragile, if I change things I have to change it in many places</p>
<p>I started out with</p>
<pre><code>class Base
{
protected string Name {get{return typeof(Base).Name;}};
}
</code></pre>
<p>With the dea of each class hierarchy level calling its base.Name method. But again I have now had to name Base twice (admittedly it will fail at compile time if I forget) but it still seems fragile.</p>
| c# | [0] |
3,769,725 | 3,769,726 | How to Set Paging in DataList control in asp.net? | <p>Actually Datalist not contain allowpaging property. so how can i set paging in datalist.</p>
| asp.net | [9] |
1,418,101 | 1,418,102 | using default constructor to initialize types C# | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/24551/best-practice-initialize-class-fields-in-constructor-or-at-declaration">Best Practice: Initialize class fields in constructor or at declaration?</a> </p>
</blockquote>
<p>Please do you have any advantage for doing</p>
<pre><code>public class MyClass
{
List<string> list;
public MyClass
{
list = new List<string>();
}
}
</code></pre>
<p>over doing this</p>
<pre><code>public class MyClass
{
List<string> list = new List<string>();
public MyClass
{
}
}
</code></pre>
<p>I guess its all the same. Thus constructors are more important than these simple cases</p>
| c# | [0] |
3,389,974 | 3,389,975 | Jquery .on() method | <p>I want to allow to click on my buttons on conditions. So I use the .on() method to allow to click just when the class "clickable" is present. :</p>
<pre><code>$(".button").on("click", ".clickable", function () {
alert("click");
});
$("#stop").click( function () {
$(".button").removeClass('clickable');
});
</code></pre>
<p>But I can't click on my buttons from the beginning.
Is my .on() method not correct ?</p>
<p>this my html structure :</p>
<pre><code><div class="button clickable">1</div>
<div class="button clickable">2</div>
<div class="button clickable">3</div>
</code></pre>
<p>Thank you</p>
| jquery | [5] |
1,125,518 | 1,125,519 | iPhone app will push view controller in simulator but not on device | <p>I am using a UIButton to call the following IBAction to show a view controller, as far as I am aware this is a normal way of doing this? it works perfectly in the 4.3 simulator but when I run it on a 4.3 iPod the button presses, the code below is called but nothing happens, no error, no feedback, …any ideas?</p>
<pre><code>-(void)showAddNewUserView{
AddNewUserViewController *AddNewUserView = [[AddNewUserViewController alloc]init];
[AddNewUserView setHidesBottomBarWhenPushed:YES];
[self.navigationController pushViewController:AddNewUserView animated:NO];
}
</code></pre>
| iphone | [8] |
571,644 | 571,645 | Why does any social site like Reddit use this method? | <p>See what <a href="http://en.wikipedia.org/wiki/Reddit" rel="nofollow">Reddit</a> uses to add one of its buttons:</p>
<pre><code><script type="text/javascript" src="http://www.reddit.com/button.js?t=2"></script>
</code></pre>
<p>This JavaScript adds an <code><iframe></code> to the page, then the <code><iframe></code> adds the HTML code.</p>
<p>Why doesn’t the JavaScript add the HTML directly?</p>
| javascript | [3] |
561,572 | 561,573 | How can I sort the results of a LINQ query | <p>I have the following query. Is there an easy way that I could sort the results in numeric order
of RowKey. Currently RowKey is a string. I would like to sort _rowData and NOT modify this query as I want to try some different sort orders and I'm looking for one line changes and not to redo the query.</p>
<pre><code>var _rowData = (from qu in _que.GetAll(
u => u.PartitionKey == partitionKey )
select new {
qu.PartitionKey,
qu.RowKey,
qu.Style,
qu.ShortTitle,
ModifiedToString = String.Format("{0:MM/dd/yyyy HH:mm}", qu.Modified)
});
</code></pre>
<p>I want to do the sorting outside of the LINQ query. The reason is that actually I want to be able to let the user choose a sort of RowKey, ModifiedToString and ShortTitle.</p>
| c# | [0] |
2,565,890 | 2,565,891 | Are Anonymous Classes a bad idea? | <p>After using them a while I can't help but feel that the hoops you're forced to jump through when using anonymous classes are not worth it.</p>
<p>You end up with <code>final</code> all over the place and no matter what the code is more difficult to read than if you'd used a well named inner class.</p>
<p>So what are the advantages of using them? I must be missing something.</p>
| java | [1] |
2,928,194 | 2,928,195 | button.setOnClickListener is giving me errors | <pre><code> Button myButton = new Button(this);
myButton.setText("Change View");
myButton.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
myButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
});
</code></pre>
<p>What exactly is wrong with this code? It gives me an error where I set the onClickListener. I also had to remove the @override above public void despite the fact that other examples have them.</p>
| android | [4] |
2,306,668 | 2,306,669 | Can I have a part of a scrollable Listview (implemented using hashmap) non-scrollable? | <p>Im trying to make a list to enter the marks of students.
I have an xml layout file which has the name of student as a textview and marks of 5 subjects as edittexts.
Then I have another xml layout file which has a listview which is horizontally scrollable.
Now in the java file Im using Hashmap to duplicate this layout for multiple students.
I have the entire list horizontally scrollable.
If I scroll left or right, I want all the rows to be scrolled together with the names being static horizontally.
But I want only the marks to be scrollable. I want the name of student to be static.
I tried to make the textview used 4 name as horizontallyscrollable="false". Doesn't help.
Need help.</p>
| android | [4] |
5,250,751 | 5,250,752 | image preloading problem (using $("img").load()) | <p>I use the load function to preload Images before applying a hover effect.</p>
<pre><code>$("img").load(function(){ //image preloading
//some function & variable setting
$listingItems.hover(
function(){
//effect
},
function(){
//effect back
}
)
}) // load
</code></pre>
<p>the problem i have i that the effects only works if i reload the page. When i first come to the page, the images are loaded but there is no hover effect.</p>
<p>You can take a look at the source here:
<a href="http://meodai.ch/rundum/shop.html" rel="nofollow">http://meodai.ch/rundum/shop.html</a></p>
<p>What have i done wrong? Can anyone help? Is there an other simple way to preload images before executing a function?</p>
| jquery | [5] |
1,240,549 | 1,240,550 | How do I extend a class? | <p>I have a class: <code>Model</code>, with many functions, such as <code>draw()</code>, <code>rotate()</code> etc.</p>
<p>now i have another class called <code>Cube</code> that i want to be able to work the same way as Model.</p>
<p>I have this in my <code>Cube</code> class constructor: </p>
<pre><code>Model m3d = new Model();
m3d.build(obj);
</code></pre>
<p>So what i want is to be able to in another class call something like:</p>
<pre><code>mCube.draw();
</code></pre>
<p>and <code>m3d</code> will perform <code>draw()</code>.</p>
| java | [1] |
1,544,102 | 1,544,103 | iphone developer program gap | <p>I have a client that has around 200 employees. They don't qualify for the enterprise account, but need more devices than the standard business account (currently 100).</p>
<p>Does anyone know how to handle the middle ground? Are you allowed to have multiple accounts to handle this?</p>
<p>Thanks!</p>
<p>Rob</p>
| iphone | [8] |
2,453,835 | 2,453,836 | webpage caching | <p>I am looking for a best solution for caching my webpages example http:/www.website.com/test.php?d=2011-11-01 which has url rewrite rule to become http:/www.website.com/testd-2011-11-01.html</p>
<p>the scripts below does not work for dynamic web page it give the same page regardless of the query.</p>
<pre><code><?php
$cachefile = "cache/".$reqfilename.".html";
$cachetime = 240 * 60; // 5 minutes
// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && (time() - $cachetime
< filemtime($cachefile)))
{
include($cachefile);
echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))."
-->";
exit;
}
ob_start(); // start the output buffer?>
my website content here
<?php
// open the cache file for writing
$fp = fopen($cachefile, 'w');
// save the contents of output buffer to the file
fwrite($fp, ob_get_contents());
// close the file
fclose($fp);
// Send the output to the browser
ob_end_flush(); ?>
</code></pre>
| php | [2] |
396,137 | 396,138 | Nested function: am I creating 10 functions here? | <p>I'm working on a function that is too complicated (processor) so I embedded part of the functionality in a nested "utility function" inside it (print). A simplified version of it looks like this:</p>
<pre><code>var out = document.getElementById( "output" );
function processor ( n ) {
function print( msg ) {
out.innerHTML += msg;
}
while ( n > 0 ) {
print( n-- );
print( ", " );
}
print( "<br/>" );
}
for ( var i = 0; i < 10; i++ ) {
processor( i );
}
</code></pre>
<p>You can see it in action in <a href="http://jsfiddle.net/kVb99/3/" rel="nofollow">this JSfiddle</a>.</p>
<p>The question is: am I really creating 10 instances of the utility function <code>print()</code>? If yes, what is a more efficient way to write this code without putting the utility function outside the <code>processor()</code> function? I want the <code>print()</code> function to only be accessible in <code>processor()</code> and nowhere else. One solution is namespace.</p>
<p>I've read this question and even though it's related but it's not directly my answer:
<a href="http://stackoverflow.com/questions/10709439/efficiency-of-creating-an-event-handler-in-a-nested-loop-am-i-creating-1440-fun">Efficiency of creating an event handler in a nested loop: am I creating 1440 functions here?</a></p>
| javascript | [3] |
1,417,535 | 1,417,536 | Insert html between the head tags using JavaScript | <p>In previous quests we looked at how we could insert code into a tag and with multiple attributes, and before the first tag (doctype), but what about inserting code between the head tags such as new CSS style sheets and JavaScript inserts.</p>
<p>I did searched here and found some related posts, but no examples that work.</p>
<p>For example, how to add the following lines of code using JavaScript only...</p>
<pre><code><link rel="stylesheet" type="text/css" href="chrome.css" />
<script type="text/javascript" src="chrome.js"></script>
</code></pre>
<p>One suggestion below looked promising, but when tested it didn't actually work, for example...</p>
<pre><code>var refScript = "<SCRIPT>alert('OK');</SCRIPT>";
document.getElementsByTagName("head")[0].innerHTML += refScript;
</code></pre>
| javascript | [3] |
5,796,104 | 5,796,105 | How to prevent deletion and modification of file in java | <p>I am stuck with this problem and can't find the solution basically i want to secure the files which i have selected from JFileChooser i want that the user can't delete or modify a file.
Please help me i am very thankful to you.</p>
| java | [1] |
2,081,406 | 2,081,407 | Android: How to do something after user clicks on my EditText | <p>I have an EditText that shows time. After user clicks the EditText I want to show a TimePickerDialog, so I set a View.OnClickListener to my EditText. But the OnClickListener is behaving wierdly - I touch the EditText and then software keyboard appears (which I don't want). When I touch again, OnClickListener.onClick() is finally called and the dialog appears.</p>
<p>What should I do if I want the dialog to appear immediately?</p>
| android | [4] |
1,140,555 | 1,140,556 | How to control or override the Client Side Naming of a Server Side Control in ASP.net 3.5? | <p>Is there a way to control the client side name that is assigned to a Server Side Control in ASP.Net 3.5.</p>
<p>I currently the following in an ASP.Net Repeater that just presents a list of a bunch of Yes No Questions.</p>
<pre><code> <asp:RadioButtonList RepeatDirection="Horizontal" CssClass="YesNo" ID="YesNo" runat="server">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" Text="No" />
</asp:RadioButtonList>
</code></pre>
<p>On the Client Side the following is what is rendered.</p>
<pre><code><input id="Repeater1_ctl00_YesNo_0" type="radio" value="Yes" name="Repeater1$ctl00$YesNo">
<label for="Repeater1_ctl00_YesNo_0">Yes</label>
</code></pre>
<p>I would like to be able to have the Client Side Name of the control be something like </p>
<pre><code>name = <%# DataBinder.Eval(Container.DataItem, "QuestionNumber") %>YesNo
</code></pre>
<p>So when the form data is posted I can easily Identify the QuestionNumber and type of Question. </p>
<p>Is there a way to override the naming scheme that asp.net using so instead of seeing
Repeater1$ctl00$YesNo I will see 4YesNo when the form is posted?</p>
| asp.net | [9] |
1,404,685 | 1,404,686 | ASP.Net - send email with page contents | <p>I have an Asp.Net page containing one GridView and a couple of images (google charts - pngs).
I need to email the contents of my page. How can I do that? The grid can be an html table in the email body or the whole thing could be an image; it doesn't matter.<br>
Thanks for your help!</p>
| asp.net | [9] |
2,840,006 | 2,840,007 | In Java, how can I implement my own ThreadLocal from scratch? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1202444/how-is-javas-threadlocal-implemented-under-the-hood">How is Java’s ThreadLocal implemented under the hood?</a> </p>
</blockquote>
<p>It's been a while since I programmed in Java, and I want to freshen up on some theory. </p>
<p>How can I implement my own ThreadLocal from scratch?</p>
| java | [1] |
4,320,352 | 4,320,353 | Create a page that accepts a birth date and birth time of the user in php | <p>Create a page that accepts a birth date and birth time of the user. The script will compute the time elapsed(age) from the given date and time until the current date and time.</p>
<p>Ex.</p>
<p>Given:</p>
<p>Birth Date: January 5, 2000</p>
<p>Birth Time: 10:00 am</p>
<pre><code> Elapse time from January 5, 2000 10:00 am
</code></pre>
<p>to present date and time:</p>
<pre><code> ______ year
______ months
</code></pre>
<p><em><strong></em></strong> days</p>
<pre><code> ______ hours
______ minutes
______ seconds
</code></pre>
| php | [2] |
5,363,253 | 5,363,254 | java hashtable with collision resolution | <p>I want to get all the values(multiple) of a particular key.But i m getting only one value?I dont know how to print all the values.Great help if someone correct the code..did not get any help from google search.. </p>
<pre><code>import java.util.*;
public class hashing
{
public static void main(String args[])
{
String[] ary=new String[4];
String key;
char[] chrary;
ary[0]=new String("abcdef");
ary[1]=new String("defabc");
ary[2]=new String("ghijkl");
ary[3]=new String("jklghi");
Hashtable<String, String> hasht = new Hashtable<String, String>();
for(int i=0;i<4;i++){
chrary=ary[i].toCharArray();
Arrays.sort(chrary);
key=new String(chrary);
hasht.put(key,ary[i]);
}
Enumeration iterator = hasht.elements();
while(iterator.hasMoreElements()) {
String temp = (String)iterator.nextElement();
System.out.println(temp);
}
}
}
</code></pre>
<p><strong>PS:output is defabc jklghi.I want abcdef defabc ghijkl jklghi.</strong></p>
| java | [1] |
3,944,542 | 3,944,543 | Modifying .class file | <p>I wanted to know which of the below solutions is better:
I want to modify some .class files and as I have realized there is two ways to do that:</p>
<ul>
<li>Decomplile the .class file, modify it and finally compile it again. - </li>
<li>Directly modify it with a hex editor.</li>
</ul>
<p>Thanks</p>
| java | [1] |
3,374,608 | 3,374,609 | how to create help system in java | <p>We are developing new web application and we must integrate help in it. Does anyone know any good opensource help application that we can integrate it in our system or is better to develop help center from scratch? We are using java 1.6. Help must be related to articles, forms,...</p>
<p>Thx</p>
| java | [1] |
3,433,989 | 3,433,990 | Virtual mouse click c# | <p>I have an multithreaded application that needs to be able to preform multiple mouse click at the same time.</p>
<p>I have an <code>IntPtr intptr</code> to a process on which i need to send a mouse click to.
I have tried to find this information on the web and there are some examples which i have tried. But I have not got any of them to work.</p>
<p>As I understand the correct way to solv my issue is to use the function
<code>SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);</code></p>
<p>hWnd is the IntPtr to the process.
Msg is the wanted action, which I want a left click, <code>int WM_LBUTTONDBLCLK = 0x0203;</code>
IntPtr wParam is of no intrest to this problem ( as I understand)
And the coordinates to the click is in lParam.
I construct lParam like,</p>
<pre><code>Int32 word = MakeLParam(x, y);
private int MakeLParam(int LoWord, int HiWord)
{
return ((HiWord << 16) | (LoWord & 0xffff));
}
</code></pre>
<p>But as you might understand, I cant get this to work.
My first question is, the coordinates are they within the window of this process or are
the absolut screen coordinates?
And my second question, what am I doing wrong?</p>
| c# | [0] |
2,786,916 | 2,786,917 | ListBox instantly deselects when I click it in ASP.NET | <p>It's inside an updatepanel, as it gets updated in response to another drop down box.</p>
<p>I suspect when I click it, it is posting back or something, which is causing it to de-select. Do you know how I can stop it from doing this, as the selecteditemchanged event is a trigger for another update panel, and when it triggers it errors because selectedindex is -1 (because it deselects instantly when I click it)</p>
<p>Edit: Turning off autopostback fixes it, but then it no longer works as a trigger...</p>
| asp.net | [9] |
2,953,047 | 2,953,048 | Visual C#: How to add controls to a form created with code? | <p>I'm new to Visual C# and I'm currently stuck on how to create a new form (with code, not design) and add things (namely labels and textboxes) to this new form. Here's what I have right now:</p>
<pre><code>namespace AccountInfo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
profileForm profile = new profileForm(); // Make new form
profile.Name = "newProfile";
profile.Text = "Add a new profile";
profile.LabelText = "test";
profile.Show(); // Display form
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
public class profileForm : Form
{
// Controls
Label label1 = new Label();
public profileForm()
{
}
public string LabelText
{
set { label1.Text = value; }
}
private void profileForm_Load(object sender, EventArgs e)
{
}
}
}
</code></pre>
<p>When I run this code, I get the default form and I click button1. It brings up a new form, but with nothing on it. I expect a label to show up but it won't. I've tried this multiple different ways (this being my most recent method) and I can't get anything to show up. I've looked around StackOverflow and one other topic came up, but its solution didn't work for me. I'd appreciate any insight into this :) Thanks a ton!</p>
<p>Edit: I've also tried this using the constructor instead. It didn't help.</p>
| c# | [0] |
3,927,101 | 3,927,102 | Translate class function to lambda function | <p>I'm trying to pull of something like this:</p>
<pre><code>class helper {
.. some class variables ..
public function somehelper ($somevar)
{
.. some action ..
}
}
</code></pre>
<p>to - <code>$somehelper('somevar!')</code> </p>
<p>i want it to be a lambda function without me declaring a new lambda function. I want the code to be created automatically. I want to create this lambda function autamatically via a core class that will create to each helper function - lambda function with the functions name. I dont want to specify it. I have a template file included, and an instance of a class helper. <code><a href..><?= $makeSeo($url); ?></a></code> this will lead to - public function <code>makeSeo($url)</code> in a helper class. autmatically.</p>
<p>Thanks in advanced! </p>
| php | [2] |
2,387,882 | 2,387,883 | Why are Integer.parseInt(String s, 2) and Integer.toBinaryString(int i) incompatible? | <p>Why are this two methods using two different approaches while processing binary numbers? String which represents negative binary number in <code>Integer.parseInt(String s, 2)</code> method should start with <code>-</code> character, but <code>Integer.toBinaryString(int i)</code> returns string with additional 1 ahead. So, this code</p>
<pre><code>Integer.parseInt(Integer.toBinaryString(-1), 2);
</code></pre>
<p>throws <code>java.lang.NumberFormatException</code>. What is the reason of such behavior? </p>
| java | [1] |
4,935,932 | 4,935,933 | How to know whether user has changed the state of toggle button? | <p>I have ten toggle button .I want to save the states of 5 buttons when clicking the home button.But I want to save it only if the user has made a change in any of the buttons state.Is there any way to know the change in states without using setOnClickListner.</p>
| android | [4] |
2,064,238 | 2,064,239 | If module `example` contains both function `run` and submodule `run`, can I count on `from example import run` to always import the former? | <p>If I have a Python module implemented as a directory (i.e. package) that has both a top level function <code>run</code> and a submodule <code>run</code>, can I count on <code>from example import run</code> to always import the function? Based on my tests that is the case at least with Python 2.6 and Jython 2.5 on Linux, but can I count on this generally? I tried to search information about the import priorities but couldn't find anything.</p>
<p>Background:</p>
<p>I have a pretty large package that people generally run as a tool from the command line but also sometimes use programmatically. I would like to have simple entry points for both usages and consider to implement them like this:</p>
<p><code>example/__init__.py</code>:</p>
<pre><code>def run(*args):
print args # real application code belongs here
</code></pre>
<p><code>example/run.py</code>:</p>
<pre><code>import sys
from example import run
run(*sys.argv[1:])
</code></pre>
<p>The first entry point allows users to access the module from Python like this:</p>
<pre><code>from example import run
run(args)
</code></pre>
<p>The latter entry point allows users to execute the module from the command line using both of the approaches below:</p>
<pre><code>python -m example.run args
python path/to/example/run.py args
</code></pre>
<p>This both works great and covers everything I need. Before taking this into real use, I would like to know is this a sound approach that I can expect to work with all Python implementations on all operating systems.</p>
| python | [7] |
5,505,246 | 5,505,247 | Representing alphabets as numbers | <p>can someone help please? I'm completely new to Java Programming and I need to represent alphabets as numbers such that I can perform operations (like matching two numbers) with numbers instead of alphabets.E.g. A = 1; B = 2; c = 3;... Many thanks</p>
| java | [1] |
231,121 | 231,122 | Disable "history.go(-1)" on certain pages | <p>I want to be able to disable "history.go(-1)" on certain pages.
I'm thinking if is there a way to clean up the Javascript's history object. Ideas?
"history.go()" seen to be not functioning too well on certain browsers such as IE. Is that true? Any solution for that?</p>
| javascript | [3] |
2,745,330 | 2,745,331 | How to verify that a variable is of 'file' type | <p>It used to be in Python (2.6) that one could ask:</p>
<pre><code>isinstance(f, file)
</code></pre>
<p>but now "file" is undefined (using Python 3.0)</p>
<p>What is the proper method for checking to see if a variable is a file now? The What'sNew docs didn't mention this...</p>
| python | [7] |
5,027,818 | 5,027,819 | Locationlistener and Timers | <p>Does anyone know why i'm not able to get any coordinates when registeren a locationlistener via a Timertask (tried both NETWORK_PROVIDER and GPS_PROVIDER)
but when i register them manually i get coordinates just fine. </p>
<p>this is how i register my listener:</p>
<pre><code>Looper.myLooper().prepare();
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0,0,locationListener);
Looper.myLooper().loop();
</code></pre>
<p>my location listener looks like this:</p>
<pre><code>LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
lat = location.getLatitude();
longt = location.getLongitude();
if(lat !=0 && longt!=0)
{Log.e(LOG_TAG, "getting coords");
locationManager.removeUpdates(locationListener);
Toast.makeText(getApplicationContext(), "got coords!!!", 2000).show();
reqlat.add(String.valueOf(lat));
reqlon.add(String.valueOf(longt));
DateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
Date now = new Date();
Date date = new Date();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
reqtime.add(String.valueOf(timeformat.format(now)));
reqdate.add(String.valueOf(dateFormat.format(date)));
savemyData();
lastlongt = longt;
lastlat = lat;
logging=false;
coords = false;
CancelGpsTimer();
Looper.myLooper().quit();
}
}
</code></pre>
<p>i suspect it has something to do with the looper.prepare() but i can't figure out what. If i don't have a looper.prepare() i get an exception saying i can't create a handler insisde a thread that has not called looper.prepare().</p>
| android | [4] |
4,473,770 | 4,473,771 | How to change web sphere settings in RAD Administrative console | <p>I have web sphere server integrated to RAD(rational application developer).When i stop the server from the server view,I can see the server stopped but when start it again the server does not start many times, since the java process still runs I can see that in the task manager. so i have to go to task manager and have to kill the java process and restart my Rad and have to stop the server again.
I know we can change the server settings in Administrative console to stop the server when ever we close the work space etc.But i could not find where exactly it is. </p>
<p>Please help me where and how we can change these settings in administrative console</p>
| java | [1] |
1,300,383 | 1,300,384 | A second XMLHttpRequest gives NS_ERROR_FAILURE | <p>with JavaScript I request a File with XMLHttpRequest and it works. But when i want to request a file (no matter if it is the same or not) the second time, I get a NS_ERROR_FAILURE at the line with req.open...</p>
<pre><code>function readfile(file) {
var req = new XMLHttpRequest();
alert(file);
req.open('GET', file, false);
req.send();
return req.responseText;
}
</code></pre>
<p>The files are in the same folder.
1-2 months ago (with an older Firefox) it worked, but now (with Firefox 14) I get this error.</p>
| javascript | [3] |
3,752,283 | 3,752,284 | Important topics/APIs list for Java interview | <p>This is little different from what already been asked for <a href="http://stackoverflow.com/questions/706190/java-books-for-preparing-for-interviews">here</a> </p>
<p>I would like to know what topics/APIs are most important for Java interviews. for example - </p>
<ul>
<li><strong>Concurrency</strong>, </li>
<li><strong>Collections</strong><br>
.....and like that. </li>
</ul>
<p>The reason is because implementations like <code>ConcurrentHashMap</code> (read <a href="http://www.ibm.com/developerworks/java/library/j-jtp08223/" rel="nofollow">here</a>) have so much details in them, that one would like to discuss about them as it covers many important aspects</p>
| java | [1] |
1,008,444 | 1,008,445 | How to select random 5 value from array value of 100 in jquery? | <p>I have 100 values in an array but I need to select 5 value randomly on every click one button and I have one value e.g a=10 this a value shouldn't come in the 5 selected value. </p>
<p>I tried in different way but I am not able to do it in jquery. please any help me.</p>
| jquery | [5] |
3,589,915 | 3,589,916 | JavaScript code compression | <p>Is there is way to compress JavaScript code?</p>
<p>e.g.</p>
<pre><code>function test(){
// some code here
}
</code></pre>
<p>after compression it should be </p>
<pre><code>function test(){//some code here}
</code></pre>
<p>Also, I need vise versa at the time of editing the code.</p>
| javascript | [3] |
4,336,451 | 4,336,452 | How to dismiss the progress bar | <p>In my app there is a button that onClick moves you to a new activity with rss news.<br/>I want to use a progress bar until the news are downloaded to the device...<br/>I have make some tries but unfortunately the progress bar is starting until the rss load,when they present it stops but when i return to the previous activity with the android back button, the progress bar starts again and never stops..</p>
<p>I have entered the progress bar in the onClick of the button in my first activity:</p>
<pre><code>Button nea = (Button) findViewById(R.id.nea);
nea.setOnClickListener(new View.OnClickListener() {
public void onClick (View view) {
Thread thread = new Thread(null, null, "MagentoBackground");
thread.start();
m_ProgressDialog = ProgressDialog.show(main.this,
"Please wait...", "Retrieving data ...", true);
Intent myIntent = new Intent(view.getContext(), nea.class);
startActivityForResult(myIntent, 0);
}
});
</code></pre>
<p>Where should I put something like <code>m_ProgressDialog.dismiss();</code></p>
| android | [4] |
928,417 | 928,418 | Java technologies learning path | <p>I need to learn fairly quickly the following Java related technologies:</p>
<ul>
<li>XML(JAXP, JAXB)</li>
<li>Web Services (JAX-WS, JAX-RPC)</li>
<li>Web (Servlet, JSP, JSF)</li>
<li>JDBC, JPA, Hibernate, Spring Framework including Spring AOP </li>
</ul>
<p>What is the best order for learning?</p>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.