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,678,262 | 3,678,263 | virtual keyword internals | <p>I heard lots of times virtual function is usually implemented using a vtable. But I actually don't know actually how its implemented and how it works.</p>
<p><em>edit</em></p>
<p>I didn't actually get this code: How can it be rewritten. Can someone explain this in detail please.</p>
<p>Finally, let's see how the compiler implements a call to a virtual function. Your code might look like this:</p>
<pre><code> // Your original C++ code
void mycode(Base* p)
{
p->virt3();
}
</code></pre>
<p>The compiler has no idea whether this is going to call <code>Base::virt3()</code> or <code>Der::virt3()</code> or perhaps the <code>virt3()</code> method of another derived class that doesn't even exist yet. It only knows for sure that you are calling <code>virt3()</code> which happens to be the function in slot #3 of the v-table. It rewrites that call into something like this:</p>
<pre><code> // Pseudo-code that the compiler generates from your C++
void mycode(Base* p)
{
p->__vptr[3](p);
}
</code></pre>
| c++ | [6] |
2,273,467 | 2,273,468 | How to make auto casting between list item? | <p>I define 2 object: </p>
<pre><code> public sealed class obj1
{
public int i1;
public string str1
}
public sealed class obj2
{
public int i2;
public string str2
public static explicit operator obj2( obj1 e )
{
return new obj2()
{
i2 = e.i1;
str2 = e.str;
}
}
</code></pre>
<p>}</p>
<p>Now, i define 2 list that contain object </p>
<pre><code>List<obj1> obj1item;
List<obj2> obj2item = new List<obj2>();
obj2item.add(o1);
obj2item.add(o2);
</code></pre>
<p>And now, I want to add the object from <code>obj2item</code> to <code>obj1item</code>;</p>
<p>That mean that i want to do </p>
<pre><code> obj1Item = obj2Item
</code></pre>
<p>I used the linq to do it </p>
<pre><code> var v = from t in obj2item
select (obj1) t;
foreach (var item in v)
{
obj1item.Add(item);
}
</code></pre>
<p><em><strong>My question:</em></strong></p>
<p>Is there some other way to do add the obj2Item items to obj1Item ? </p>
| c# | [0] |
3,828,513 | 3,828,514 | Problem with asp.net custom hander | <p>ive written a custom http handler and its in app_code. It's just a website so code is not being compiled into a dll. I've written the handler and its signature looks like this...</p>
<pre><code>namespace MicrotanksWebsite
{
public class RssHandler : IHttpHandler
{
}
}
</code></pre>
<p>The error i'm getting is:</p>
<blockquote>
<p>Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. </p>
<p>Parser Error Message: Could not load type 'MicrotanksWebsite.RssHandler'.</p>
</blockquote>
<p>the web config looks like this</p>
<pre><code><httpHandlers>
<add verb="*" type="MicrotanksWebsite.RssHandler" path="*.rss" />
</httpHandlers>
</code></pre>
<p>any ideas?</p>
| asp.net | [9] |
176,591 | 176,592 | Convert timezone in php | <p>I have these timezones. I want to get the current datetime depends on the given timezone. The user will select either one timezone. so need to return current time.</p>
<p><strong>ASKT<br/>
CDT<br/>
EDT<br/>
HST<br/>
MDT<br/>
MST<br/>
PDT<br/></strong></p>
<p>How can i convert? Please help</p>
| php | [2] |
3,611,343 | 3,611,344 | Using Java to get OS-level system information | <p>I'm currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows.</p>
<p>Has anyone been able to successfully extract information such as the current disk space used, CPU utilisation and memory used in the underlying OS? What about just what the Java app itself is consuming?</p>
<p>Preferrably I'd like to get this information without using JNI.</p>
| java | [1] |
3,387,031 | 3,387,032 | What's the most efficient way to empty an element with jQuery | <p>All these do it, but what is the most efficient way?</p>
<pre><code>$(selector).html('');
$(selector).text('');
$(selector).children().remove();
</code></pre>
| jquery | [5] |
3,229,414 | 3,229,415 | tablesorter works on all except one | <p>I have a tablesorter that works on all except one column.
See <a href="http://www.dbno.us/finance/beta/old.php?index=sp100" rel="nofollow">http://www.dbno.us/finance/beta/old.php?index=sp100</a></p>
<p>When you click on P/E, it sorts incorrectly. On ascending order, it will put 223.68 ahead of 23.30. On descending order, it will put 9.22 ahead of 86.85.</p>
| jquery | [5] |
892,705 | 892,706 | Execute multiple batch files c# | <p>I hope that you can help me. When I want to execute those .bat files, I can see that the files are executed but I can get only the first one, the second one or the others I can't get them, I have no problem with my batch files, I've tried to executed them one by one and it works.</p>
<pre><code> string str_Path = Server.MapPath(".") + "\\execute.bat";
string str_PathN= Server.MapPath(".") +"\\executeN.bat";
string str_PathHD = Server.MapPath(".") + "\\executeHD.bat";
string str_PathFHD = Server.MapPath(".") + "\\executeFHD.bat";
ProcessStartInfo processInfo = new ProcessStartInfo(str_Path);
processInfo.UseShellExecute = false;
Process batchProcess = new Process();
batchProcess.StartInfo = processInfo;
batchProcess.Start();
Thread.Sleep(3000);
ProcessStartInfo hd = new ProcessStartInfo(str_PathHD);
hd.UseShellExecute = false;
Process batchProcessHD = new Process();
batchProcessHD.StartInfo = processInfo;
batchProcessHD.Start();
Thread.Sleep(3000);
...
</code></pre>
| c# | [0] |
4,982,028 | 4,982,029 | FadeIn appended div with jQuery | <p>I load some divs with append. Works, but I'd like to fade it in. Fade Out works but not fade in...</p>
<pre><code>$("#click").click(function() {
var overlay = $('<div id="overlay1">'),
overlayBox = $('<div id="overlay2">');
$('body').append(overlay1, overlay2).fadeIn(500);
});
</code></pre>
| jquery | [5] |
48,310 | 48,311 | Ninject Func clarification | <p>Could someone please help me to understand the statement below please:</p>
<pre><code>kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => ctx.Kernel)
</code></pre>
<ol>
<li>What does above code do?</li>
<li>What is Func?</li>
<li>Is it trying to bind and Interface IKernel to something...? This part really confuses me:
<code><Func<IKernel>>().ToMethod(ctx => () => ctx.Kernel</code>)</li>
</ol>
<p>I'm aware that kernel.bind is used to bind the Interface to Concrete type but not sure about the above as there's no concrete type given.</p>
<p>How does it fits in to the real world scenario. Basically why and when do I use this function</p>
<p>Thanks</p>
| c# | [0] |
805,420 | 805,421 | Hide and Show same div using Jquery | <p>Hi im trying to figure out how to hide and show content using multiple links. Ex.</p>
<pre><code><a href="#">Content 1</a>
<a href="#">Content 2</a>
<a href="#">Content 3</a>
<div class="show">content #1</div>
<div class="hidden">content #2</div>
<div class="hidden">content #3</div>
</code></pre>
<p>So when someone clicks Content #2, it shows content #2 and hides content #1</p>
| jquery | [5] |
3,187,237 | 3,187,238 | Compile a .cs file which is located in different folder of the disk from another .cs program | <p>i want to compile a .cs program which exist in some other folder on the disk and generate a .dll of it, using another .cs program or a console application or a window application. i tried using the following </p>
<pre><code>using (StreamReader textReader = new StreamReader(@"path\Filename.cs"))
{
textFile = textReader.ReadToEnd();
Console.WriteLine(textFile);
}
CodeDomProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler compiler = codeProvider.CreateCompiler();
// add compiler parameters
CompilerParameters compilerParams = new CompilerParameters();
compilerParams.CompilerOptions = "/target:library /optimize";
compilerParams.GenerateExecutable = false;
compilerParams.GenerateInMemory = true;
compilerParams.IncludeDebugInformation = false;
compilerParams.ReferencedAssemblies.Add("mscorlib.dll");
compilerParams.ReferencedAssemblies.Add("System.dll");
// compile the code
CompilerResults results = compiler.CompileAssemblyFromSource(compilerParams, textFile);
</code></pre>
| c# | [0] |
1,622,955 | 1,622,956 | Add to Dictionary<string, string> using foreach | <p>what is the best way to ensure that optionValue is always unique in the following scenario? </p>
<pre><code>public Dictionary<string, string> Dict = new Dictionary<string, string>();
foreach (string optionKey in i.options.Keys)
{
string optionValue = i.options.Values.ToString();
Dict.Add(optionKey, optionValue);
}
</code></pre>
<p><strong>EDIT</strong>: i.options contains a key and a value pair. I need to ensure that for each key the corresponding value is added to the dictionary</p>
<p><strong>EDIT2</strong>: corrected order of Dict.Add(optionKey, optionValue)</p>
| c# | [0] |
1,403,215 | 1,403,216 | Remove console.assert in production code | <p>I'm using console.assert to test/debug but I'd like to remove this in production code. I'm basically overwriting console.assert to be a noop function right now but wondering if there's a better way. It would be ideal if there was some javascript preprocessor to remove this.</p>
| javascript | [3] |
1,523,117 | 1,523,118 | What does threadid bogus mon mean? | <p>I am using a <code>ScheduledThreadPoolExecutor</code> and when I have multiple scheduled threads running I am getting <code>threadid=xx: bogus mon 1+0>0; adjusting</code> in LogCat.</p>
<p>Can anyone shed any light on what this means, is it bad and if so how do I stop it?
Thanks.</p>
| android | [4] |
4,388,346 | 4,388,347 | how to acess excel cell value and set it | <p>need to open an excel sheet and then go an to cell range like A 4, B5
<strong>set A4= " India" and set B5="Report name"</strong></p>
<p>in the excel sheet i do not have any headers like.i have few data dump in excel sheet
above that data i need to write 2 value "India" and "Report name " in the cell range</p>
<p><strong>A4=" India" and set B5="Report name</strong></p>
<p>please let me know how to do it.</p>
<p>any help would be great, please let me know how to go ahead here any code will help me</p>
| c# | [0] |
3,006,532 | 3,006,533 | What is the best way to learn jQuery? | <p>I am new to <a href="http://en.wikipedia.org/wiki/ASP.NET_MVC_Framework">ASP.NET MVC</a> and <a href="http://en.wikipedia.org/wiki/JQuery">jQuery</a>. What is the best way to learn jQuery? Are there any good links, blogs, and screencasts?</p>
| jquery | [5] |
4,954,481 | 4,954,482 | php function with Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '$' | <p>The PHP function below is producing this error: Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '$', on this line that contens this code:<code>$obj = new ( );</code></p>
<p>Does anyone know what's wrong?</p>
<pre><code>function createContextAwareObjectOfClass($className) {
$className;
$obj = new ( );
IApplicationContextAware;
if (!( $obj instanceof null )) {
Exception;
throw new ( '' . 'Non-context aware class "' . $className . '" passed to createContextAwareObjectOfClass' );
}
$obj->setAppContext( $this );
return $obj;
}
</code></pre>
| php | [2] |
1,501,951 | 1,501,952 | Highlight the tabbaritem with image | <p>I have three TabBarItem in a TabBar . And each tabbar item has normal image. I want to highlight the TabBarItem image instead of the normal image.</p>
<p>Can i achieve it?</p>
<p>Thanks in advance</p>
| iphone | [8] |
4,864,564 | 4,864,565 | How to get all option values with jQuery? | <pre><code><select>
<option>test</option>
<option>test1</option>
</select>
</code></pre>
<p>In fact I'm going to retrieve the innertext of <code><option></code>,but these two jobs are similar.</p>
| jquery | [5] |
3,021,663 | 3,021,664 | How do I hide the navigation bar for popups in javascript? | <p>How do I hide the navigation bar for popups in javascript?</p>
| javascript | [3] |
3,967,613 | 3,967,614 | How do I call static method for a generic type in a class? | <pre><code>interface TerminationCondition
{
static bool IsSatisfied(some parameters);
}
</code></pre>
<p>Let's say some classes A and B implement this interface. </p>
<p>Some other class C has a generic type:</p>
<pre><code>class C<termCondition> where termCondition : TerminationCondition
</code></pre>
<p>I need to call IsSatisfied from C accordingly, whether I have passed A or B for the generic type. For some reason it is not possible termCondition.IsSatisfied().</p>
<p>To summarize, the question is How do I call static method for a generic type in a class?</p>
| c# | [0] |
1,111,423 | 1,111,424 | How to prevent "MainActivity screen "display | <p>I have an Android app in which the first screen is a menu display. Before it gets to the menu display though it displays a page with the launcher icon and "Main Activity" at the top. How do I prevent this display? Manifest file has this:</p>
<pre><code><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.menu"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</code></pre>
<p>--- edit</p>
<p>So the class that displayed the menu was called MainActivity.java. Maybe not a good idea, if only because it is not a good practice. So I renamed it to MenuActivity.java and changed the manifest accordingly(below). But the behavior is still the same.</p>
<pre><code><application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MenuActivity"
android:label="@string/menu_activity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</code></pre>
| android | [4] |
1,461,973 | 1,461,974 | go back to the previous activity when clicked on back button in android | <p>I am designing a login based application.i have applied on click on the submit button to go to next view.In the nextview i have back button.I want that when i click on back button view should go back to previous activity</p>
<p>Thanks in advance
Tushar</p>
| android | [4] |
3,621,981 | 3,621,982 | Echo a comma on all but the last value? (result from mysql_fetch_array) | <p>How do I echo a comma on all but the last value? Here's my code:</p>
<pre><code>while ($servdescarrayrow = mysql_fetch_array($servdescarray)) {
ECHO $servdescarrayrow['serv_desc'].",";
}
</code></pre>
<p>Shouldn't this work:</p>
<pre><code>$i = 0;
while ($servdescarrayrow = mysql_fetch_array($servdescarray)) {
$count = count($servdescarrayrow);
if ($i < $count) {
echo $servdescarrayrow['serv_desc'].",";
$i++;
}
else {
break;
}
}
</code></pre>
| php | [2] |
3,850,172 | 3,850,173 | Force Calculate using UIAcceleration values in iphone | <p>How to calculate force value of iphone using UIAcceleration values....</p>
<p>Can anyone help me?</p>
<p>What i want is ? When user moves slowly from one region to other i want to do some task or they move faster i want to do some other task ....</p>
<p>Can anyone help me ?</p>
<p>Thanks in advance.....</p>
| iphone | [8] |
5,975,858 | 5,975,859 | How to replace " and \ from text files using Java? | <p>I'm using <code>replace</code> and <code>replaceAll</code> Java functions to replace strings in text files.</p>
<p>I've some issues with some symbols occurring in my text file, such as <code>"</code> and <code>\</code></p>
<p>Let's say I have to remove the " from "blablabla", what should i use ? I'm currently using this line but it doesn't work:</p>
<pre><code>fields[i] = fields[i].replaceAll("\\"blablabla\\"", "");
</code></pre>
<p>thanks</p>
| java | [1] |
5,042,722 | 5,042,723 | compile error: cannot find symbol: In, StdIn and StdOut | <p>The code is from
<a href="http://algs4.cs.princeton.edu/11model/BinarySearch.java.html" rel="nofollow">http://algs4.cs.princeton.edu/11model/BinarySearch.java.html</a> for Algorithms textbook.</p>
<pre class="lang-java prettyprint-override"><code>import java.util.Arrays;
public class BinarySearch {
// precondition: array a[] is sorted
public static int rank(int key, int[] a) {
int lo = 0;
int hi = a.length - 1;
while (lo <= hi) {
// Key is in a[lo..hi] or not present.
int mid = lo + (hi - lo) / 2;
if (key < a[mid]) hi = mid - 1;
else if (key > a[mid]) lo = mid + 1;
else return mid;
}
return -1;
}
public static void main(String[] args) {
int[] whitelist = In.readInts(args[0]);
Arrays.sort(whitelist);
// read key; print if not in whitelist
while (!StdIn.isEmpty()) {
int key = StdIn.readInt();
if (rank(key, whitelist) == -1)
StdOut.println(key);
}
}
}
</code></pre>
<p>I get this error</p>
<pre><code>$ javac BinarySearch.java
BinarySearch.java:44: cannot find symbol
symbol : variable In
location: class BinarySearch
int[] whitelist = In.readInts(args[0]);
^
BinarySearch.java:49: cannot find symbol
symbol : variable StdIn
location: class BinarySearch
while (!StdIn.isEmpty()) {
^
BinarySearch.java:50: cannot find symbol
symbol : variable StdIn
location: class BinarySearch
int key = StdIn.readInt();
^
BinarySearch.java:52: cannot find symbol
symbol : variable StdOut
location: class BinarySearch
StdOut.println(key);
^
4 errors
</code></pre>
| java | [1] |
186,602 | 186,603 | picker view in iphone | <p>i am new developer in iphone application
how to length decreases of the picker view in iphone application </p>
| iphone | [8] |
5,931,253 | 5,931,254 | jQuery append while slideToggle | <p>I am appending new data - $('#posts').append(data);<br>
But I want this new data to .slideToggle() while appending.</p>
<p>How can it be done?</p>
| jquery | [5] |
5,779,721 | 5,779,722 | Tableview scrolling and header views | <p>My application has a header (like toolbar) which contains some button controllers,and just below the header view there is a tableview which contains some datas from sqlite.</p>
<p>When the tableview starts scrolling, I need the top header to hide and another header to pop out in place of the main header view.</p>
<p>Is it possible to this? But I didnt want this in a tap function.</p>
<pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if(scrollView == table)
{
tab.contentOffset = table.contentOffset;
headerview.hidden=YES;
}
else
{
table.contentOffset = tab.contentOffset;
headerview.hidden=YES;
}
}
</code></pre>
<p>it hides the headerview ,but my problem is when the scrolling of tableview stops headerview need to be appear again.</p>
| iphone | [8] |
4,759,204 | 4,759,205 | How to sort table rows using class names? | <p>Hi i have the bellow code i want to sort table rows based on the class name ..here each row contains two classes one is "sprint1" and second one is "cls*" ..i want to sort the rows bassed on the second class...thanks in advance</p>
<p></p>
<pre><code> <tr class="sprint1 cls5">
<tr class="sprint1 cls4">
<tr class="sprint1 cls3">
<tr class="sprint1 cls1">
<tr class="sprint1 cls2">
</code></pre>
<p></p>
| jquery | [5] |
5,747,196 | 5,747,197 | Describe an algorithm to perform depth first (preorder) traversals on a quadtree and implement in python | <p>Let's assume that a given object occupies a 2D space, which can be decomposed into N cells. These N cells can, in turn, be stored in an n X n square matrix M, where n is a power of 2 and n = sqrt(N). If a cell is occupied by any portion of the object, then the corresponding matrix entry M[i][j] = 1, otherwise M[i][j] = 0. Implement an algorithm to perform depth first traversal on quadtree in python
sample input is
a = [[0, 0, 1, 1], [0, 0, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]]
n = MyNode.MyNode(a) #"n" is the root of a quadtree based on "a"
n.depthFirst()
output is
P P E F F E F E P E F F F</p>
| python | [7] |
3,072,856 | 3,072,857 | My asp.net site has stopped giving me control not found error | <p>I work in an asp.net website, Earlier if I remove any control from my page and it has references in javascript something like this</p>
<pre><code>$('#<%= txtName.ClientID %>') // just an example of use
</code></pre>
<p>it used to give me the error saying something like "txtName does not exist", showing the exact line where the problem is, which helps me figure out the cause and rectify it easily.</p>
<p>But from last many days it has stopped giving me above type of error but it just shows </p>
<pre><code>XML parsing error: no element found
Location:
Line number 1: ...
</code></pre>
<p>That's make it hard to find the problem. Any idea why it has stopped this behavior?</p>
<p><strong>Edit</strong></p>
<p>Today I just added two Title elements by mistake in <%@ Page directive and it started giving me the XML parsing error, earlier it used to give me error something like "Title cannot be defined multiple times" !!!</p>
| asp.net | [9] |
2,156,138 | 2,156,139 | Issue with clickable links when running jquery | <p>We've set up some fun jquery additions in two places:
<a href="http://artsygeek.com.s141242.gridserver.com/565" rel="nofollow">http://artsygeek.com.s141242.gridserver.com/565</a> (the 404 error page)
<a href="http://artsygeek.com.s141242.gridserver.com/services/magic" rel="nofollow">http://artsygeek.com.s141242.gridserver.com/services/magic</a></p>
<p>The top menu is still functioning normally, but the links in the content and the footer are not showing up as clickable!</p>
<p>The last sentence on the magic page is a link, and the ul on the 404 error page should all be clickable links.</p>
<p>We're totally baffled. Any help would be appreciated!</p>
<p>Thanks,
Jennifer </p>
| jquery | [5] |
5,380,556 | 5,380,557 | PHP: Skipping to a position given by strpos() | <p>If I have a string position that I derived with STRPOS(), how would I skip to that position? I am using a function that needs to start at the position, or at the start of the next line.</p>
<p>How would I do this? Speed is a factor.</p>
| php | [2] |
3,191,716 | 3,191,717 | Iphone SDK how to save my score? | <p>i have a integer called HighScore which is connected to highscorelabel . i have made it so when the user gets a high score it puts the score they got onto the label but i would now like to know how i can save it so that when the app is opened again it will still have the high score : this is my code for detecting when a high score is made</p>
<ul>
<li>(void) submitScore {
if (lives > HighScore){
HighScore = lives;
}
highscorelabel.text = [NSString stringWithFormat:@"%i" , HighScore];
}</li>
</ul>
<p>can anyone help me please
thankyou
dave</p>
| iphone | [8] |
3,054,013 | 3,054,014 | Looping through with double variables | <p>I have two arrays with two sets of values in ($a[] and $b[])
I want to do something like the following:</p>
<p>$a[0] - $b[0]
$a[0] - $b[1]</p>
<p>$a[1] - $b[0]
$a[1] - $b[1]</p>
<p>This will continue until the arrays reach the end.
So i want a hyphen to seperate the two arrays, with the first array staying the same until the second array has looped through.</p>
<p>I am trying to get this in a dropdown with option value.</p>
<p>How could i achieve this?
I never tried doing any loops with two varaibles like that before, I literally have no idea at all!
Thankyou</p>
| php | [2] |
3,987,661 | 3,987,662 | How to pass an array of C-Strings to a function | <p>Normally I would just pass an array into a function, however, I am doing a homework assignment and my professor says to use an array of C-Strings and I want to use a function. However, I can not think of how to send this to a function. Any help would be great.</p>
| c++ | [6] |
5,271,450 | 5,271,451 | A better way of finding out if any running process was launched from a given file? | <p>I have to check whether another process is running, based only on the name of the EXE file.</p>
<p>Currently I get the process list and then query the <code>MainModule.FileName</code> property, however some processes throw <code>Win32Exception</code> "Unable to enumerate the process modules" when you access the <code>MainModule</code> property.
Currently I am filtering to a 'safe list' by catching these access exceptions thus:</p>
<pre><code>List<Process> processes = new List<Process>(Process.GetProcesses());
// Slow, but failsafe. As we are dealing with core system
// data which we cannot filter easily, we have to use the absense of
// exceptions as a logic flow control.
List<Process> safeProcesses = new List<Process>();
foreach (Process p in processes)
{
try
{
ProcessModule pm = p.MainModule;
// Some system processes (like System and Idle)
// will throw an exception when accessing the main module.
// So if we got this far, we can add to the safe list
safeProcesses.Add(p);
}
catch { } // Exception for logic flow only.
}
</code></pre>
<p>Needless to say I really don't like having to use exceptions like this.</p>
<p>Is there a better way to get the process list for which I can access the <code>MainModule</code> property, or even a better method of checking if any process was spawned from a given file?</p>
| c# | [0] |
4,729,622 | 4,729,623 | Launching an application (3rd party, closed source) | <p>I am trying to interface with 3rd party software, trawling for ideas and suggestions:</p>
<p>There is a COMPANY file, shared among an entire user group, which just contains text, say</p>
<pre><code>H:\Vin2010.L50
H:\NewVat.L50
H:\Vatchange.L50
H:\WES009\L50Data
H:\SOF001\L50Data
</code></pre>
<p>Now in my app, I've got icons for those up on the screen and if a user clicks on one, say
NewVat.L50, then I have to launch (the closed source) sage.exe which launches SBDDesktop.exe
(also closed source) which reads that file. For experimentation purposes I overwrote that
file with just the one directory and it then does exactly what I want.</p>
<p>What I really want to happen is that for this user and one-shot only, intercept that read so it thinks there is only the one line, whereas everyone else and this user the next time they open this file sees the lot.</p>
<p>Just to complicate matters, C:\ProgramData\Sage is already redirected to H:\SageData.sys
(we use a miniFilter Driver; and H:\ is a network share) so when SBDDesktop.exe tries to
open (eg) C:\ProgramData\Sage\Accounts\2012\company what it actually gets back is from
H:\SageData.sys\Accounts\2012\company (and similar for 10 other versions).</p>
<p>Most everything I've read about Folder Redirection seems to be about getting individual
user data off the desktop onto a server, but it would be almost the exact opposite of that,
and much more of a temporary thing, to get what I'm after.</p>
<p>Everything I can think of dies because you cannot put a reparse point on a network share.</p>
<p>Ideally the final solution will be in C++, but at this point anything will be considered.</p>
| c++ | [6] |
1,615,499 | 1,615,500 | Error: variable might not have been initialised | <p>I am doing a book exercise regarding the Ackermann function.</p>
<p>I have one question though. If I declare result but do not initialise it, the compiler complains that "variable result might not have been initialised". </p>
<pre><code>int result;
</code></pre>
<p>When I set it to default to 0, it does not complain.</p>
<pre><code>int result = 0;
</code></pre>
<p>I thought that when one declares a variable with type int it defaults to 0 automatically.</p>
<p>Here's the complete code:</p>
<pre><code>public class Ackermann {
public static int ack(int m, int n) {
int result = 0;
//int result;
if (m == 0)
result = n + 1;
else if(m > 0 && n == 0)
result = ack(m-1, 1);
else if(m > 0 && n > 0)
result = ack(m-1, ack(m, n-1));
return result;
}
public static void main(String[] args) {
System.out.println(ack(3, 3));
}
}
</code></pre>
| java | [1] |
3,920,738 | 3,920,739 | Why does the radix for JavaScript's parseInt default to 8? | <p>Defaulting the radix to 8 (if the string starts with a 0) in JavaScript's parseInt function annoys me, only because I continue to forgot to pass the optional second argument as 10. I'm looking for an answer telling me why it makes sense to have it default to 8.</p>
| javascript | [3] |
1,282,143 | 1,282,144 | How to convert number to next higher multiple of five? | <p>I am coding a program where a form opens for a certain period of time before closing. I am giving the users to specify the time in seconds. But i'd like this to be in mutliples of five. Or the number gets rounded off to the nearest multiple. </p>
<p>if they enter 1 - 4, then the value is automatically set to 5.
If they enter 6 - 10 then the value is automatically set to 10. </p>
<p>max value is 60, min is 0.</p>
<p>what i have, but i am not happy with this logic since it resets it to 10 seconds.</p>
<pre><code> if (Convert.ToInt32(maskedTextBox1.Text) >= 60 || Convert.ToInt32(maskedTextBox1.Text) <= 0)
mySettings.ToastFormTimer = 10000;
else
mySettings.ToastFormTimer = Convert.ToInt32 (maskedTextBox1.Text) * 1000;
</code></pre>
| c# | [0] |
3,865,340 | 3,865,341 | Get 3 most common Point from List<Point> | <p>I have a quick question that I haven't found out how to do efficiently (in C#).</p>
<p>I have a list array of Points (X,Y). I need to find which 3 points are the tightest cluster. It's for a mapping project.</p>
<p>What would the best way to do this be? There's only about 6 to 9 items in the list.</p>
<p>Thanks in advance.</p>
<p>Cheers!</p>
| c# | [0] |
4,752,450 | 4,752,451 | Date format and Array which used menu based progarm | <p>How to make hindi lanuage date format which is use a locale class in java language? and second question how to make bank account use array for loop in menu based program in java ?</p>
| java | [1] |
2,325,989 | 2,325,990 | Elegant way to express shift left OR right in template | <p>I currently have a template function which, depending on its template parameters A and B, may shift a value either left or right:</p>
<pre><code>template <int A, int B> void f(X) {
// ...
if (A >= B)
{
SetValue(X << (A-B));
}
else // (A < B)
{
SetValue(X >> (B-A));
}
</code></pre>
<p>When I instantiate the template for <code>A<B</code>, I get a warning for a negative shift right on the (unreachable) first branch, and else I get a warning for a negative shift left on the first branch. Our codebase is warning-free so this isn't acceptable. Is there a concise, readable alternative to these two shift statements?</p>
<p>Similar questions (e.g. <a href="http://stackoverflow.com/questions/8009040/dynamically-shift-left-or-right">Dynamically shift left OR right</a>) don't have this spurious warning as the shift distance is a runtime variable there.</p>
| c++ | [6] |
1,272,246 | 1,272,247 | How to layout view right aligned and bottom of an LinearLayout | <p>I am trying to layout 1 textview (upText) left aligned and 1 textview (downText) and an image view (image) both on the same line and right aligned.</p>
<p>how can I do that? I tried that, but both 'textview' and image view at left aligned.</p>
<p></p>
<pre><code> <TextView
android:id="@+id/uptext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"/>
<TextView
android:id="@+id/downtext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:gravity="right|bottom"/>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right|bottom"/>
</LinearLayout>
</code></pre>
| android | [4] |
3,370,177 | 3,370,178 | javascript: shortcut build-in object function (setInterval) | <p>I was doing something similar to this few days ago and it worked perfectly , now i try to write it same as it was and it's not working , somehow.</p>
<p>what's the problem here?</p>
<pre><code>var win = window ,
setInter = "setInterval";
win[setInter](function(){alert();}, 1000);
</code></pre>
<p>as i mention before , it was written 2 days ago and it work perfectly , now i tried to rewrite it and somehow it not working , am i missing here something?</p>
<p>thank you in advance.</p>
| javascript | [3] |
2,593,650 | 2,593,651 | Converting VB.NET Web Form to C# and wiring up events | <p>In My VB.NET web page, I have this standard event. Note the "Handles" clause on teh event declaration.</p>
<pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
</code></pre>
<p>In my C# web app, I have this:</p>
<pre><code>protected void Page_Load(object sender, System.EventArgs e)
{
</code></pre>
<p>Since C# doesn't have a "Handles" equivalent and from what I've seen, event handlers are wired up using delegate += syntax, I was looking for this, but I could not foind it in the aspx page, aspx.cs file or the aspx.designer.cs file.</p>
<p>In VB, I would have two drop down lists at the top of the Code Editor window and I could select any object on the web form or the web form itself and see the possible events for the object. Selecting the event would either take me to the event handler or if it didn't exists, it would create the stub for me.</p>
<p>I know that the Properties window in C# (and I think in VB, too) has an Event tab that shows the list of events for the selected object GUI object, but "Page" doesn't appear as an object that can be selected.</p>
<ol>
<li><p>Where does C# define the hooking up of the event to the handler? </p></li>
<li><p>How do I generate a stub for the Page event handler routine? I know that the handle appears by default, but what if it is deleted or I want to add a Page_initialize code? Is there an easy way to get the stub or do I need to go to the Object Browser for the syntax?</p></li>
</ol>
| c# | [0] |
4,688,466 | 4,688,467 | How to create my own java library(API)? | <p>I created a program in java and I designed it so that methods that I want them to be appear(Getters methods) in the main, I can call them easily after initiate the class that holds these methods...</p>
<p>The question is that, I need to make this application(that holds the getters methods) be like an API... So, that I can give my application for developers to use my function(The getters method) if they needs them, and only what they need is to add this file(I think the API after is done shown as jar file)...</p>
<p>How can I do that ??? So that, I can make my code reusable with other application, Similar to the DLL I think...</p>
<p>Thanks alot;)</p>
| java | [1] |
2,912,984 | 2,912,985 | PHP Associative Array Duplicate Key? | <p>I have an associative array, however when I add values to it using the below function it seems to overwrite the same keys. Is there a way to have multiple of the same keys with different values? Or is there another form of array that has the same format?</p>
<p>I want to have
42=>56
42=>86
42=>97
51=>64
51=>52
etc etc</p>
<pre><code> function array_push_associative(&$arr) {
$args = func_get_args();
foreach ($args as $arg) {
if (is_array($arg)) {
foreach ($arg as $key => $value) {
$arr[$key] = $value;
$ret++;
}
}else{
$arr[$arg] = "";
}
}
return $ret;
}
</code></pre>
| php | [2] |
1,486,086 | 1,486,087 | jquery popup is not working | <p>i want to open a pop in my mvc3 razor application for that i am witting following code .
When i click button .nothing happen . and i see a error in Error console " $(#dialog).dialog is not a function ". I am new to jquery , can any one help me what mistake i am doing.</p>
<pre><code> $(function () {
$('#dialog').dialog({
autoOpen: false,
width: 400,
resizable: false,
title: 'hi there',
modal: true,
open: function(event, ui) {
//Load the Edit action which will return
// the partial view _Edit
$(this).load("@Url.Action("Edit")");
},
buttons: {
"Close": function () {
$(this).dialog("close");
}
}
});
$('#Button1').click(function () {
$('#dialog').dialog('open');
});
});
</code></pre>
| jquery | [5] |
1,162,608 | 1,162,609 | List Item Selected Behavior | <p>When I change the background color of a list item it no longer flashes green when selected. Is there a way to retain this default behavior when the background is changed?</p>
| android | [4] |
1,458,495 | 1,458,496 | Location manager does not detect location correctly even we are moving miles away in android | <p>In my application I have to fetch the current location. First it correctly fetches the location. But we are moving from the current location to some other location. It shows the previous address. It is not updating the location. My code is:</p>
<pre><code>locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locListener = new MyLocationListener();
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locListener);
location = locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(location != null)
{
latitude = location.getLatitude();
longitude = location.getLongitude();
}
//My location listener is as follows
public void onLocationChanged(Location loc) {
if (loc != null) {
//Toast.makeText(this.getBaseContext(),
//"Location changed : Lat: " + loc.getLatitude() +
//" Lng: " + loc.getLongitude(),
//Toast.LENGTH_LONG).show();
double lat = loc.getLatitude();
double lon = loc.getLongitude();
}
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO Auto-generated method stub
}
</code></pre>
<p>Please find the mistake and when i launch first time it is not working on second time itself it is working....so check this thing also.....</p>
| android | [4] |
1,437,263 | 1,437,264 | App can report it's own memory usage? | <p>I have a console app that watches a folder (Manual code... not using the .Net classes) for file changes, and then does some moving of files based on rules.</p>
<p>However, it seems to shut down by it's self. Crashes, I guess. Now, it's a home project, and I have a 'Hit a key to end' option. I also have a 3 year old walking around. So, it might not be code issue related. However, as a learning exercise, is there a way to get the memory usage of the app? So, I want to know the total amount of memory being used by my app.</p>
| c# | [0] |
817,444 | 817,445 | JavaScript object method name for setTimeout | <p>my object has a function that i want to call recurseively.
my problem is how do i use setTimeout to point to the method of that instance of the object?</p>
<pre><code>MyObject.prototype.Play = function() {
// do some stuff
setTimeout(thecurrentmethodnameHERE, 1000);
}
var test = new MyObject();
test.Play();
</code></pre>
| javascript | [3] |
2,966,264 | 2,966,265 | Variable in PHP http link | <p>I'm trying to get the cureent url and send that through in a link and I'm stuck. The link displays but it's missing the url that I want to include (content in the code sample here)</p>
<pre><code>'href' => ( "http://chart.apis.google.com/chart?cht=qr&chs=300x300&choe=UTF-8&chld=H&chl='.$content .'")
</code></pre>
| php | [2] |
2,160,880 | 2,160,881 | PHP fopen forloops | <p>I'm not exactly sure why this isn't working I tried googling it to see if there was a answer a lot of them came up with a foreachloop instead of regular for loops can someone explain to me why this isn't working.</p>
<pre><code><?php
$list = array("GOOG", "AAP", "MSFT");
for($i=0; $i<3; $i++)
{
echo "why isn't this working <br>";
$fp = fopen ("http://finance.yahoo.com/d/quotes.csv?s=GOOG&f=sl1ve1x&e=.csv","r");
$data = fgetcsv ($fp, 1000, ",");
$exit = str_replace('"',"",$data[3]);
$exchange = str_replace('"',"",$data[4]);
echo "$data[0] <br>";
echo "$data[1] <br>";
echo "$data[2] <br>";
}
?>
</code></pre>
<p>I expected it to print google info 3 times it doesn't if I take fopen out by itself once it works but if I do it multiple times it just doesn't do anything what I expected is </p>
<p>output ex </p>
<pre><code>why isn't this work
Goog
8398
789
why isn't this work
Goog
8398
789
why isn't this work
Goog
8398
789
</code></pre>
| php | [2] |
1,859,470 | 1,859,471 | Asp:table bordercolor different html rendered for 1.1 and 2.0 | <p>I have the following markup .NET 1.1 app.</p>
<p>I want the grid lines of the table to be darkgray this is the goal here.</p>
<pre><code><asp:table id="tbl" Runat="server" CellSpacing="0" BorderColor="darkgray" GridLines="Both"></asp:table>
</code></pre>
<p>I have the app in IIS set as ver 1.1 in my dev box
and 2.0 in production for various reasons.</p>
<p>The page source in 1.1 renders this</p>
<pre><code><table id="ctlTimesheetMonthly_tbl" cellspacing="0" rules="all" bordercolor="DarkGray" border="1" style="border-color:DarkGray;border-collapse:collapse;">`
</code></pre>
<p>2.0 renders this</p>
<pre><code><table id="ctlTimesheetMonthly_tbl" cellspacing="0" rules="all" border="1" style="border-color:DarkGray;border-collapse:collapse;">
</code></pre>
<p>Which is wrong as it produces a white border for some reason.</p>
<p>Any idea how to get both the same??</p>
<p>Malcolm</p>
| asp.net | [9] |
4,500,395 | 4,500,396 | link to automatically open my App? | <p>1) Is it possible for an iPhone (iOS device) to automatically open an App (that they already have installed) when the user taps on a link (for example a link they received via email)? I'm thinking of using emails for notifications and all the email would have is some text about the notification and then a link that would automatically open the App - it doesn't have to pass any data to the App. If this is possible, sample code (or a URL that explains this) would be much appreciated.</p>
<p>2) In addition, if the user did not have the App, it would be nice if the link could open up the App Store directly to my App so they could download/purchase.</p>
<p>Thanks in advance.</p>
<p>BCB</p>
| iphone | [8] |
2,089,375 | 2,089,376 | php combat system: issue with loops | <p>Folks at gamedev shot me down so I'd like to try here. </p>
<p>Here's my problem. Two users have a speed variable, based on who has the faster speed is who hits the most, and first. So here are some imaginary stats:</p>
<blockquote>
<p>UserA has 2,000 speed</p>
<p>UserB has 4,000 speed</p>
</blockquote>
<p>UserB has 2x the amount of speed, thus would hit first, and would get two hits before UserA gets a shot, so the battle would go as follows:</p>
<pre><code>UserB hits UserA
UserB hits UserA
***UserA hits UserB
UserB hits UserA
UserB hits UserA
***UserA hits UserB
</code></pre>
<p>In that pattern. The concept itself is simple, but I'm having big problems with the execution. I need to loop this so I can do the damage calculations and insert battle events into the database, but how can I - within the loop - tell php who gets to hit this round and how many more hits they get, and so on? </p>
<p>Any ideas?</p>
| php | [2] |
1,957,201 | 1,957,202 | How Can i get data from the file in the documents folder | <p>i am new to xcode and objective c.</p>
<p>firstly i have created a file in documents directory and it is created and now what i need is how can i read the data from that file like whether the file is containing a particular string or not</p>
<p>How can i get that</p>
| iphone | [8] |
2,172,393 | 2,172,394 | How to navigate the user from floor to floor using android application | <p>I have the requirment to navigate the user from floor to floor using wifi and gps. If user have have android tablet with wifi connection and walking to get lattitude and longitude .I have to draw or voice recognition to go left or right to tell to the user.Is it possible? if it is can anybody tell how to dO?</p>
<p>Thanks </p>
| android | [4] |
5,948,885 | 5,948,886 | Function that accepts variable arguments of different datatypes in c++ | <p>I have been searching for this in stackoverflow but i was unable to understand most of the solutions proposed. The problem is that i need to write a function that may accept any datatype and the number of arguments to the function also vary..For now i would just like to print those arguments in the function.</p>
<pre><code>void printVariableArgs(){
//print all variables that are passed to this function
}
</code></pre>
<p>Is it possible to do this in c++, If so how is it done?</p>
| c++ | [6] |
5,631,550 | 5,631,551 | Javascript mailto function loading issue | <p>I'm using JavaScript <code>mailto</code> function and when clicking on the button the mail loads in the same tab. How can I load the mail in a new tab? </p>
<p>Here's my code:</p>
<pre><code><input type="button" value="Apply" name="apply" onclick="mailJob('Sample');">
</code></pre>
<pre><code>function mailJob(code)
{
window.location="mailto:example@gmail.com?subject="+code;
}
</code></pre>
| javascript | [3] |
1,295,964 | 1,295,965 | Jquery .unbind and .html not working | <p>the code below is suppose to remove #approve and #deny and echo what the user has pressed when one of the links are pressed. </p>
<pre><code><html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('#approve').click(function(){
$('#approve').unbind('click');
$('#deny').unbind('click');
$('.rare').html('Approved!');
});
return false;
});
$('#deny').click(function(){
$('#approve').unbind('click');
$('#deny').unbind('click');
$('.rare').html('Denied!');
});
return false;
});
})
</script>
</head>
<body>
<div class="rare">
<a href id="approve">Approve</a>
<a href id="deny">Deny</a>
</div>
</body>
</html>
</code></pre>
<p>but it doesnt seem to work, i am new to jquery so i dont understand why it doesnt work. jquery is hosted my google</p>
| jquery | [5] |
3,283,440 | 3,283,441 | Why is this jQuery code not getting parsed? | <p>Can someone take a look inside <a href="http://www.tapet-online.ro/skin/frontend/default/acumen/js/manatln.js" rel="nofollow">this script</a> and tell me why isn't it parsed, triggered and active?
I mean, everything I put after <code>(function($) {</code> has no effect.</p>
<p>That script should've dropped down a filtering menu's elements from a category page. ( ie: <a href="http://www.tapet-online.ro/catalog/fototapet.html" rel="nofollow">this one</a> )</p>
<p>I really don't know what to do here. I've tried several things and I haven't found a solution.</p>
<p>Thanks!</p>
| jquery | [5] |
3,938,989 | 3,938,990 | How to add one extra field to contact database? | <p>I want to add one field(column) to contact fields,that i can set value for that field in code and mobile user can not see that field in contact properties.In this way i can use contact information without create another database to copy contact database.
Is this possible?
please help me</p>
| android | [4] |
992,520 | 992,521 | Image into the UITextView | <p>Is this possible to insert the image into the UITextView from the Gallery. If this is possible then how this can be done? Is there any default method of the UITextView? Please suggest me.</p>
| iphone | [8] |
1,543,871 | 1,543,872 | Method calling from 2 diffferent classes | <p>I am new to java. I have 2 methods form 2 different classes. I would like to return the methods into 1 class. An error is occuring to me. Could someone see the code and help me pls?</p>
<pre><code>public int getHeight () {
if (nd.leftNode == null && nd.rightNode== null) {
return 0;
} else {
int leftH = 0;
int rightH = 0;
if (nd.leftNode != null) {
leftH++;
leftH += nd.getLeftNode().getHeight();
}
if (nd.rightNode != null) {
rightH++;
rightH += nd.getRightNode().getHeight();
}
return Math.max(leftH,rightH);
}
}
public int getLeftHeight() {
if (nd.leftNode == null) {
return 0;
} else {
return nd.getLeftNode().getHeight() + 1; //error here cannot find symbol getHeight()
}
public class Node {
public Node getLeftNode(){
return leftNode;
}
</code></pre>
<p>I appreciate any help.</p>
| java | [1] |
5,452,494 | 5,452,495 | Deployment of website | <p>I deployed my website into IIS..I created virtual directory and gave an alias 'a'..but when I open the site in IE or Mozilla, it says 'Access is denied'..i write <a href="http://localhost/a/Login.aspx" rel="nofollow">http://localhost/a/Login.aspx</a>
Server Error in '/a' Application.
Where is the problem?</p>
| asp.net | [9] |
2,855,677 | 2,855,678 | Do I need to delete all the children of a DOM element , when I delete the parent itself? | <p>If I delete a parent element, do the child elements remain in the browser's memory?</p>
<pre><code><div id="parent">
<ul>
<li>one</li>
<li>two</li>
<li>one</li>
</ul>
</div>
<script>
var element = document.getElementById("parent");
element.parent.removeChild(element);
</script>
</code></pre>
| javascript | [3] |
287,976 | 287,977 | Using mysql to query a table with a product code which is part of a filename | <p>I am trying to query a table which has a column called "filename".</p>
<p>The actual filename is made up of "productcode-category.jpg"</p>
<p>If i have the product code posted to a php page, how could i then take the value and search in the filename column where it equals the product code?</p>
<p>It would be great if it wasnt case sensitive as well. </p>
| php | [2] |
5,309,327 | 5,309,328 | Using reflection - how to get all fields and methods | <p>Using Java reflection:</p>
<ul>
<li>How can I get all the methods of a given object (private, protected, public etc)</li>
<li>And perhaps create a structural representation of the class</li>
<li>And finally, serialize the object into String or byte array</li>
</ul>
<p>Does this idea look sound? or this won't get me anywhere? </p>
<p>What I'm trying to achieve is to be able to:</p>
<ul>
<li>Serialize any <code>java.lang.Object</code> into byte array or String</li>
<li>Class / Objects that don't implement <code>Serializable</code> will be thrown into my application for serialization</li>
</ul>
| java | [1] |
3,243,260 | 3,243,261 | Update tableView with AccessoryCheckmark when switching back to that TabView | <p>My app has 3 tabs, and the array that populates a tableView in third tab can be changed in the other two tabs. When I switch to the third tab, I need the tableView to be updated. I know how to do this, the only problem is that the table view is a check list.</p>
<p>When I tick some of the rows in the third tab, switch to another tab and update the 3rd tab's array, when I want to switch back to the third tab the table is updated with the new data but the checkmarks are removed from the table.</p>
<p>Is there a way to update the table without removing the checkmarks?</p>
| iphone | [8] |
2,583,756 | 2,583,757 | Is there any way to know if connected device is a specific one? | <p>I want to let just specific DOK device something-
is there way to know that the specific DOK is connected to my machine??-
like MAC address or something else?- and if so- how do I do it through the code? </p>
| c# | [0] |
96,212 | 96,213 | Java: store to memory + numbers | <p>Im having a function:</p>
<pre><code>private void fixTurn(int turn)
</code></pre>
<p>And then I have:</p>
<pre><code> memory1 = memory1 + count;
</code></pre>
<p>Now, I would like to make, if turn is 2 it should:</p>
<pre><code> memory2 = memory2 + count;
</code></pre>
<p>I tried this:</p>
<pre><code> memory + turn = memory+turn + count;
</code></pre>
<p>But will it will not work, should i just go with an if statement?</p>
| java | [1] |
2,168,687 | 2,168,688 | Make jQuery works for element created with "insertAfter" etc | <p>Hello<br>
I have some elements like <code><a class='link'>click</a></code> which are created after clicking on another div ...<br>
Is there any chance to make jQuery works for <code><a class='link'>click</a></code> ? </p>
<p>For now I'm forced to use <code><a onclick='func()' class='link'>click</a></code> ... and it's not possible to make something like <code>alert($(this).html())</code> (which must pop-up the text "click").</p>
<p>Thanks</p>
| jquery | [5] |
5,054,075 | 5,054,076 | custom datagridview | <p>Can you please help to create a proper custom datagrid of which, if I select any of the cell only that cell will be in edit mode and all others are in read only mode and that cell should have a data source to bind with it.</p>
| c# | [0] |
2,253,027 | 2,253,028 | make div appear on only 1 of many image rollovers | <p>I have a hidden div with class <code>hidden_thing</code> that is positioned in the center of an image and then hidden using CSS visibility. I can switch it to visible with the following jQuery, but I have many images on the page with the same class <code>cat_image_table</code>. So how do I select on the currently rolled over image?</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
$('.cat_image_table').on("mouseenter", function(){
$('.hidden_thing').fadeIn(300)
});
$('.cat_image_table').on("mouseleave", function(){
$('.hidden_thing').fadeOut('slow')
});
});
</script>
</code></pre>
<p>CSS:</p>
<pre><code>.cat_image_table {
border-top-left-radius: 5px;
border-top-right-radius: 5px;
width:255px;
margin:0;
padding:0;
border-spacing:0;
border:none;
height:300px;
overflow:hidden;
}
.hidden_thing {
position: absolute;
top: 130px;
left: 50px;
width:150px;
height:30px;
background: #EE1B2C;
padding-top:5px;
color:white;
font-family:allerBold;
font-size:20px;
visibility:hidden;
}
</code></pre>
<p>PHP:</p>
<pre><code><div class="cat_image_table">
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES_CAT . $listing['products_image'], $listing['products_name'], 255, 340, 'class="cat_image_round"') . '</a>
</div>
<div class="hidden_thing">Click to View</div>
</div>
</code></pre>
| jquery | [5] |
4,631,152 | 4,631,153 | android and camera flash | <p>I want to write application which will be used camera flash. I want the light to blink. For now I have this code:</p>
<pre><code>void ledon() {
cam = Camera.open();
Parameters params = cam.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_ON);
cam.setParameters(params);
cam.startPreview();
cam.autoFocus(new AutoFocusCallback() {
public void onAutoFocus(boolean success, Camera camera) {
}
});
}
</code></pre>
<p>this part:</p>
<pre><code> cam.autoFocus(new AutoFocusCallback() {
public void onAutoFocus(boolean success, Camera camera) {
}
});
</code></pre>
<p>I dont know why its necessary but it wont work without it.</p>
<p>This code turn on led and turn off automaticly for about 2 seconds. I want to led will turn on e.g. for 5 sec then 3 sec led off and then again on for 4 seconds. How I can manually set periods of time in which led will be on and off. Is this possible? Thanks for any help.</p>
<p>PS. I have samsung galaxy ace.</p>
| android | [4] |
1,966,532 | 1,966,533 | Just declaring a variable in Python? | <p>Is it possible to just declaring a variable in Python, like so?:</p>
<p>var</p>
<p>so that it's gonna be initialized to None?</p>
<p>It seems like python allows this, but as soon as you access it, it crashes.</p>
<p>Is this possible? If not, why?</p>
<p>EDIT: I wanna do this for cases like this:</p>
<pre><code>value
for index in sequence:
if value == None and conditionMet:
value = index
break
</code></pre>
<h3>Duplicate</h3>
<ul>
<li><a href="http://stackoverflow.com/questions/664219/uninitialized-value-in-python">Uninitialised value in python</a> (by same author)</li>
<li><a href="http://stackoverflow.com/questions/571514/are-there-any-declaration-keywords-in-python">Are there any declaration keywords in Python?</a> (by the same author)</li>
</ul>
<h3>Related</h3>
<ul>
<li><a href="http://stackoverflow.com/questions/575196/python-variable-scope-and-function-calls">Python: variable scope and function calls</a></li>
<li><a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables">Other languages have "variables"</a></li>
</ul>
| python | [7] |
2,424,245 | 2,424,246 | How to carry textbox values from one webpage to another webpage using JavaScript? | <p>I'm quite new to JavaScript andI'm trying to do the following:</p>
<p>I've two webpages Page1.html and Page2.html
On Page1.html I've one textbox and a button.
After a user puts in some text in the textbox and clicks the button, I want Page2.html be opened and the text of the textbox appearing in the body of the newly opened Page2.html as follows:</p>
<p>"You wrote" + "[text from the textbox on Page1.html]"</p>
<p>I've tried the getElementById thing. But because of my very obvious green horns, I am missing something very basic in here. Can anybody please elabourate as to how I should proceed?</p>
| javascript | [3] |
692,133 | 692,134 | Code to launch external app explicitly | <p>From one of my apps, I'm trying to launch another. I want to use an explicit intent.</p>
<pre><code>ComponentName cn = new ComponentName("com.myOtherApp", "OtherAppActivity");
Intent intent = new Intent();
intent.setComponent(cn);
context.startActivity(intent);
</code></pre>
<p>When I run that code, however, it asks if I've declared that activity in my manifest. However, when I put the following into the manifest, I get the same error:</p>
<pre><code><activity android:name="com.myOtherApp.OtherAppActivity">
</activity>
</code></pre>
<p>What am I doing wrong?</p>
<p>Thanks</p>
| android | [4] |
4,887,287 | 4,887,288 | Serialized string to array in PHP | <p>I receive a string from jQuery UI Sortable plugin, it gives me a string like this one</p>
<pre><code>items[]=1&items[]=2&items[]=3
</code></pre>
<p>How can I trun it into a real array?</p>
<p>I was thinking replacing <code>&</code> with <code>;</code> and asserting it. Any better suggestions?</p>
| php | [2] |
299,147 | 299,148 | C# virtual keyword | <p>Is a virtual method compulsory to override by its subclass?</p>
| c# | [0] |
5,343,730 | 5,343,731 | how to set listview with multiple fonts | <p>My application have listview with friends name in Marathi and Hindi fonts.
But names in Marathi and Hindi fonts are displayed as block.</p>
<p>I also have <code>.ttf</code> file for Marathi and Hindi fonts and i also added that in <code>assets->fonts</code> folder. </p>
| android | [4] |
4,711,271 | 4,711,272 | how to print the mysql shell output table | <p>in mysql shell print a table like this </p>
<p>[code][1] </p>
<pre><code>mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| PROXY |
| bbs_bj |
| bbs_bj_copy |
| mysql |
| octopus |
| octopus_cp |
| spider |
+--------------------+
</code></pre>
<p>i want to print this table to the printer keep right formate<br>
is there any python package lib to hand this<br>
or have some way to change the table to html and pdf ?</p>
| python | [7] |
2,510,861 | 2,510,862 | Android-sharedpreference | <p>Hi
I need simple explanation about shared preference in android and preference data</p>
| android | [4] |
3,286,128 | 3,286,129 | asp.net requiredfieldvalidator clientside validate multiple groups | <p>I have a form with 3 asp textboxes for changing password - old password, new password and confirm password and a submit button on form. Old password is checked first for setting new password. The scenario is if administrator wants to change the password it will not check any old password, while for user it will check old password, if it is correct then set the new password. I have taken two requiredfiledvalidator controls for old password and new password field and comparevalidator control to check confirm password. </p>
<p>I have assigned groupA for old password required field validator, and groupB for new and confirm password. The scenario is for admin login I hides old password as it is not required and for user login I makes it visible. </p>
<p>So problem here is that for user login submit event I want to validate both groupA and groupB. Any Idea? </p>
| asp.net | [9] |
903,941 | 903,942 | If i add element first then if i delete that later dynamically i should get an alert..can u help with idea how to do that? | <pre><code>var a1=document.getElementById("txtbx1");
if(a1.value!="")
{
alert('Enter Name!!!');
var lbl1=document.createElement("label");
var lblTitle1=document.createElement("label");
lblTitle1.innerHTML='Name:';
label.appendChild(lblTitle1);
var txt1=document.getElementById("txtbx1");
var txt11=txt1.value;
lbl1.innerHTML=txt11;
label.appendChild(lbl1);
}
</code></pre>
<p>Here i am comparing if the value of that text box is NULL,but its wrong when its deleted from form by user..so please help that how to write condition to check its deletion..</p>
| javascript | [3] |
4,675,665 | 4,675,666 | Is it necessary to learn about Code Access Security (CAS)? | <p>Is it necessary to learn about Code Access Security (CAS) for desktop application development in C#.</p>
| c# | [0] |
2,835,204 | 2,835,205 | How could you generate an APK from project B programmatically, using a button click from project A? | <p>I have a project A that should use a wizard to create a project B. Project B is based on a template. Project A should send data to that template and generate an APK from this data and template programmatically.</p>
<p>I've read about the APK structure and what it includes, like classes, resources, and manifest files. My question is, what is the best way to achieve this template-based generation of an APK? What could I use for this?</p>
| android | [4] |
6,024,914 | 6,024,915 | IPhone Development on MacBook | <p>Is IPhone development possible on MacBook? Or do I need MacBook Pro?</p>
<p><a href="http://www.apple.com/macbook/" rel="nofollow">http://www.apple.com/macbook/</a></p>
<p>Thanks.</p>
| iphone | [8] |
1,429,403 | 1,429,404 | How to know the position of StackView in Android 3.0..OnItemClick is returning 0 everytime | <p>I m tring to get the position of My views when i click on them in StackView but its always returning zero unlike other ViewGroups like Gallery,ListView and GridView.OnSelectedListener also not working ..can anyone help plz???</p>
| android | [4] |
4,939,725 | 4,939,726 | How to put an image on another Downloaded Image | <p>I have a question that I want to put a small image on left top corner of a downloaded image, showing on my web page. I don't know how to do that? </p>
<p>Please help me out about this problem.</p>
<p>Thanks in advance.</p>
| asp.net | [9] |
3,533,985 | 3,533,986 | Refactoring options - multiple methods in same class or into separate classes | <p>we have some API which will be called either by client A, B, C or D</p>
<p><strong>Current code</strong></p>
<pre><code>doSomething(String client){
if (client.equals("A")){
...
}
else if (client.equals("B")){
...
}
</code></pre>
<p><strong>Proposed refactoring 1</strong></p>
<p>separate into multiple methods and have each client call the dedicated method such as</p>
<pre><code>doSomethingForClientA()
doSomethingForClientB()
</code></pre>
<p>we need this because internally each method will call other private methods defined in the same class</p>
<p><strong>Proposed refactoring 2</strong></p>
<p>Use strategy (or template) pattern and separate into multiple classes for the clients to call</p>
<p>the method call from client remains </p>
<pre><code>doSomething()
</code></pre>
<p>Which approach is better in the long run? Is there any design pattern to help with option 1 ?
or a 3rd option?</p>
| java | [1] |
2,434,744 | 2,434,745 | GridView elements changes their place dynamically when scroll screen | <p><strong>i have a gridview layout, and all items are insert very fine,</strong></p>
<p>now if I check on big screen then all work done is fine, because no scrolling is required</p>
<p>but if I check on small screen then items are changed their position dynamically,</p>
<p>bereif example is given below:-</p>
<p><strong>like I have 28 items and arranged in a grid view 7*4, now if upto 20 items are shown in first screen, now remaining 8 is shown while i scroll screen down, but now some elements of first or second row is aslo put in last row.</strong></p>
<p>code is here</p>
<pre><code>public class ImageAdapter extends BaseAdapter
{
Context mContext;
//public static final int ACTIVITY_CREATE = 10;
public ImageAdapter(Context c)
{
mContext = c;
}
@Override
public int getCount()
{
// TODO Auto-generated method stub
return providers.length;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
View v;
if(convertView==null)
{
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.icontext, null);
TextView tv = (TextView)v.findViewById(R.id.icon_text);
tv.setText(providers[position]);
ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
iv.setImageResource(R.drawable.icon);
}
else
{
v = convertView;
}
return v;
}
</code></pre>
| android | [4] |
3,409,831 | 3,409,832 | Is it possible to fetch the links on the flash part of the web page using php? | <p>I am working to fetch the links on a web page in php.The non-flash part of the web page is done but I am unable to fetch the links on the flash part of the web page.I want to know whether it is possible to fetch that using code?If so please guide me in the right direction.</p>
| php | [2] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.