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 |
|---|---|---|---|---|---|
5,628,962 | 5,628,963 | How to simulate Func<T1, T2, TResult> in C++? | <p>In C#, I use Func to replace Factories. For example:</p>
<pre><code>class SqlDataFetcher
{
public Func<IConnection> CreateConnectionFunc;
public void DoRead()
{
IConnection conn = CreateConnectionFunc(); // call the Func to retrieve a connection
}
}
class Program
{
public void CreateConnection()
{
return new SqlConnection();
}
public void Main()
{
SqlDataFetcher f = new SqlDataFetcher();
f.CreateConnectionFunc = this.CreateConnection;
...
}
}
</code></pre>
<p>How can I simulate the code above in C++?</p>
| c++ | [6] |
5,462,744 | 5,462,745 | Missing Data Using MS Access | <p>I have a c# programm that uses MS Access. I execute the following SQL statement</p>
<pre><code>SELECT * FROM DATA LEFT JOIN LINEITEMS ON DATA.PRI_KEY=LINEITEMS.ID
</code></pre>
<p>Data.Pri_key is always populated as is Lineitems.ID.</p>
<p>I have a very large data file that populates the two tables Data & Lineitems. This is invoice information which is printed out to a PDF using iTextSharp.</p>
<p>Intermittently through out the file some of the line item data for an invoice goes "missing" i.e. it never gets printed. </p>
<p>I have taken one of the invoices that exhibits the problem and have put its data in an input file on its own i.e. it produces one invoice. All the line items are printed from this file. Nothing goes missing.</p>
<p>Does anyone have any ideas? Is this an MS Access bug? If it is that would be a problem because Access is all that the client has.</p>
| c# | [0] |
3,090,049 | 3,090,050 | Android 1.5 api giving wrong output | <p>I am working with android 1.5 api, I know it is deprecated, but its client requirement. I am using following code to read Contacts address but every time it give address count zero. I am not able find out what is the problem</p>
<pre><code>private void getAddress(String _Id)
{
Cursor curAddress=null;
try
{
String addrWhere = Contacts.ContactMethods.PERSON_ID + " = ? AND " + Contacts.ContactMethods.KIND + " = ?";
String[] addrWhereParams = new String[]{_Id, Contacts.ContactMethods.CONTENT_POSTAL_ITEM_TYPE};
curAddress = _resolver.query(Contacts.ContactMethods.CONTENT_URI, null, addrWhere, addrWhereParams, null);
int i=0;
int aCount = curAddress.getCount();
String[] aType = new String[aCount];
String[] aAddrss = new String[aCount];
while(curAddress.moveToNext())
{
aType[i] = curAddress.getString(curAddress.getColumnIndex(Contacts.ContactMethodsColumns.TYPE));
aAddrss[i] = curAddress.getString(curAddress.getColumnIndex(Contacts.ContactMethodsColumns.DATA));
i++;
}
}
catch (Exception e)
{
Log.e(StaticVariables.TAG, "getAddress: " + e.getMessage());
}
finally
{
if(curAddress!=null) curAddress.close();
}
}
</code></pre>
| android | [4] |
4,390,313 | 4,390,314 | get phone number in android | <p>I use this code to get phone no in android2.1.but i don't suceed please help me</p>
<p>public void onCreate(Bundle savedInstanceState)
{</p>
<pre><code> super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String contactId,name,number;
Cursor cursor=getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null,null,null,null);
cursor.moveToFirst();
if(cursor.moveToFirst())
{
do
{
contactId=cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
name=cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
number=cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
int type=cursor.getInt(cursor.getColumnIndex(Phone.TYPE));
switch(type)
{
case Phone.TYPE_HOME :
Toast.makeText(this,"home--"+number+"",Toast.LENGTH_LONG).show();
break;
case Phone.TYPE_MOBILE :
Toast.makeText(this,"mobile--"+number+"",Toast.LENGTH_LONG).show();
break;
}
//Toast.makeText(this,"ID--"+contactId+"name"+name+"number:"+number, Toast.LENGTH_LONG).show();
}while(cursor.moveToNext());
}
// Cursor phone=getContentResolver().query(Phone.CONTENT_URI,null,Phone.CONTACT_ID+"="+contactId,null,null);
//phone.close();
cursor.close();
}
</code></pre>
| android | [4] |
2,944,300 | 2,944,301 | In App Purchase Problem | <p>please help me , i am getting product count 0 in response.product.
i have followed all the steps of in app purchase in documentation .
1.Provisioning profile and i allowed in app purchase.
2.Dummy app binary uploaded to itunes and rejected that by myself.
3.Setup 2 products in itunes in app purchase and app identifier was selected.</p>
<p>All the things seems fine but i am getting product count 0.</p>
<p>Please let me know how can i solve this issue .</p>
<p>Thanks</p>
| iphone | [8] |
4,940,165 | 4,940,166 | How to use a segment to select a value then use that value in a formula | <p>I am trying to simply have a segment when selected pick a factor and use it in a formula. The problem i am having is converting the factor a (float) into a value a (double) and show this on the display. What am I doing wrong here? Seems like an easy fix but I've tried a lot of things to no avail.</p>
<h2>.h</h2>
<p>NSInteger segPicked, var1, var2;</p>
<h2>.m</h2>
<p>var1 = 1100;
var2 = 2.5;</p>
<p><pre><code>
- (void) pickOne:(id)sender { // Selector for twosegment controller
if (checkCondition == properCondition) {
segUnit.text = [twoSegments titleForSegmentAtIndex: [SixSegments selectedSegmentIndex]];
segPicked = [twoSegments selectedSegmentIndex];</p>
<pre><code> float factor = 0;
if (segPicked == 0 ) {
factor = 0.28;
} else if (segPicked == 1 ) {
factor = 0.16;
}
double value = (factor*(var1/var2)); <--- It crashes here..
Result.text = [NSString stringWithFormat:@"Segment with = ", value];
}
</code></pre>
<p>}
</pre></code></p>
| iphone | [8] |
637,070 | 637,071 | Is ther anyway to create a non-type template parameter for a class but not declare using <>? | <p>My original code looks like this:</p>
<pre><code>class a{
...
char buff[10];
}
</code></pre>
<p>and im attempting to make this change to the code:</p>
<pre><code>template <int N = 10>
class a{
...
char buff[N];
}
</code></pre>
<p>Is there any thing I can do to keep my existing code creating instances of class a like this:</p>
<pre><code>a test;
</code></pre>
<p>instead of making the change to:</p>
<pre><code>a<> test;
</code></pre>
<p>to get the default parameter?</p>
| c++ | [6] |
3,159,279 | 3,159,280 | how to use different package for different device in android? | <p>Hi i have develop a application in android which run in every device, i use different layout for different size device's but i have use some code programmatically without xml so, it create a problem in different size device.</p>
<p>so i require to change the package acording to the device resolution so, it can posible in android to programmatically detect and change the package class</p>
<p>plz, give some suggestion.</p>
<p>Thanking you.</p>
<p>i have use android2.2 for my application </p>
| android | [4] |
349,238 | 349,239 | How to periodically poll some value using Java (Swing)? | <p>I am using swing based model.My form contains one Jbutton its called "polling(function name is getvalue())".I have a function name as "getvalue()".This function does retrieve values(this value will change after some span of time) and print it in console. I want code and idea about, that function will call automatically every 5 minutes ( or some span of time interval)and retrieve values and print it in console.I want code using timer concept .</p>
<p>my button function is like</p>
<p>private void ActionPerformed(java.awt.event.ActionEvent evt)
{</p>
<p>}</p>
<p>where will write my Automatic polling code.</p>
| java | [1] |
3,308,031 | 3,308,032 | How to access instance variable and method in main activity from other activity? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables">Android: How to declare global variables?</a> </p>
</blockquote>
<p>I want to access public instance variable in main activity from other activity.
And I want to call public method in main activity.
How can I do that?</p>
<pre><code>class MainActivity extends Activity {
public int i;
public void myMethod() {}
}
class MyActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// How can I access variable i in MainActivity?
// And How can I call myMethod() in MainActivity?
}
}
</code></pre>
| android | [4] |
4,020,809 | 4,020,810 | PHP topic viewing and replying script | <p>I'm working on a small board/forum. I have topic posting done; it's visible in the database and all that jazz. Now I'm working on retrieving the topic list and so that when you click a topic you can view it. That's working fine, except that when I click on it the page goes blank and nothing is being shown. I know the issue is that I can't get the id of the post I clicked on because it's in the if-else statement with a while loop. Here is my code now.</p>
<pre><code><?php
require('init.php');
$get_threads = mysql_query("SELECT * FROM GOT ORDER BY time");
if (!isset($_GET['view_thread'])) {
$get_threads = mysql_query("SELECT * FROM GOT ORDER BY time");
while ($select_threads = mysql_fetch_assoc($get_threads)) {
$title = $select_threads['title'];
$time = $select_threads['time'];
$user = $select_threads['user'];
$id = $select_threads['id'];
$form = '<center>
<form method="get" action="">
<input type="submit" name="view_thread" id="view_thread" value="'.$title.'" />
<input type="hidden" name="thread_id" id="thread_id" value="'.$id.'" />
</form>
</center>';
echo '<div id="post_info">'.$form.'<hr>Posted by: <b>'.$user.'</b> '.$time.'</div>';
}
} else {
$get_posts = mysql_query("SELECT * FROM GOT WHERE id='$id'");
$select_posts = mysql_fetch_assoc($get_posts);
$content = $select_posts['content'];
echo $content;
}
?>
</code></pre>
<p>I need to get that <code>$id</code> so I can grab the post and later all the replies from the database. I'm new to php so I'm probably missing something. Thanks for any help!</p>
| php | [2] |
3,742,329 | 3,742,330 | Android bumping/file sharing technology | <p>There are a number of applications on the market that allow Android phones to exchange files or some other information. Those applications usually rely on two Android devices being in close proximity and detecting each other's presence. I do not think that they use bluetooth communication to send signal to each other since bluetooth can be off and it would take some time to activate it so bumping would take longer than it does in those applications. Thus those apps have to use some other sensors that most of android phones are equipped with.</p>
<p>Do you have any idea of what those sensors are and how the phones become aware of each other's presence?</p>
<p>Thank you in advance</p>
| android | [4] |
1,974,060 | 1,974,061 | Crop the Image and display it | <p>I am getting an image from the Internet and I am showing the image on to the ImageView. Please let me know is there any way in which I can compress the image(to a particular size/dimension) and show it on the Imageview, as the image is user-uploaded image.
Thanks </p>
| android | [4] |
5,010,927 | 5,010,928 | program is stuck on taskbar while shutting down windows | <p>I have built a program with C# and the program keeps running on system tray near the windows clock. When I try to shut down windows, the program is still running and shutting down windows get stuck.</p>
<p>This is not a program with Windows 7.So my question here is how to add 'something magic' to allow windows to shut down?</p>
| c# | [0] |
4,081,719 | 4,081,720 | Why is my function called two times? | <pre><code> $(document).ready(function () {
doSomething(1);
$('#pp').click( doSomething(2) );//why is this called?? I didn't click the button..
});
function doSomething(v) {
alert(v);
}
</script>
<body>
<input type="button" id="pp" value="asdf" />
</code></pre>
<p>I need a function to be called on load and click. But somehow <code>doSomething()</code> is called two times on load. What's going on..??</p>
| jquery | [5] |
2,432,639 | 2,432,640 | Is it possible to check how much size of an image is loaded using JavaScript | <p>It's a perfectly dumb question. But I just wanted to clear my doubt. When a image is loading we can check loading state using <code>onload</code> or <code>oncomplete</code> events. But I just wanted to know how much portion of the images is loaded using JavaScript. Is it really possible? </p>
<p>My question is, Can we get image size from URL? and Can we get how much portion of image is loaded in some interval? </p>
| javascript | [3] |
3,936,152 | 3,936,153 | sorts in python | <p>I am trying to learn python and get good at algorithms. This is my first language.</p>
<p>for example: take "baggage" and sort into "aabeggg"</p>
<pre><code>string = "baggage"
count = [0] * len(string)
for x in string:
num_value = ord(x)
count[num_value] += 1
</code></pre>
<p>I think the above is a start...but I'm not really sort how to go about it.</p>
| python | [7] |
5,920,843 | 5,920,844 | how to update EditTextPreference existing summary when i click ok button | <p>dear i am able to show EditTextPreference with default summary ...now i want to update it when i enter new value in Edit Text box and click ok then it should be upadate the value of summary...but i am unable to do that my code is below pls update in my code which required...v.v thanks in advance..</p>
<pre><code> public class Prefs extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
final EditTextPreference pref = (EditTextPreference)findPreference("username");
pref.setSummary(pref.getText());
pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
final EditTextPreference pref = (EditTextPreference)findPreference("username");
pref.setSummary(pref.getText());
return true;
}
});
</code></pre>
<p>}</p>
<p>xml file is </p>
<pre><code> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference android:title="User Name"
android:key="username" android:summary="Please provide user name"></EditTextPreference>
<EditTextPreference android:title="Password" android:password="true"
android:key="password" android:summary="Please enter your password"> </EditTextPreference>
</code></pre>
<p></p>
<p>actually my code update previous enter value as summary text ...how to show text as summary when i click ok button..thanks</p>
| android | [4] |
27,618 | 27,619 | jQuery: two <button> in one form problem | <p>I have two <code><button></code> elements in one form.
First <code><button></code> have a click handler, which removes the form.
Second <code><button></code> have click handler which submits the form.</p>
<p>Everything is fine, until i press <code>enter</code> inside any input field in the form. It's triggering first <code><button></code> and removes the form instead of submitting it.</p>
<p>Is it possible to fix it somehow?</p>
<p>Thanks ;)</p>
| jquery | [5] |
4,252,276 | 4,252,277 | How can I call a .exe file W/unknown Path? | <p>How can I call a .exe file W/unknown Path which installed on the machine in C#?</p>
<pre><code>Process.Start(?);
</code></pre>
| c# | [0] |
2,637,277 | 2,637,278 | Accessing SMS gateway from php application | <p>I have finally(with stackoverflow's help and Darhazer)..gotten to the final stage of my sms application.The last hurdle is that the gateway api is not sending the sms messages from my application.However when i place it directly on the address bar and call it,it works. I am using cURL in a loop to send it.Please point me in the right direction. My UPDATED code is:</p>
<pre><code> <?php
include 'sms_connect.php';
$sql="select name,number from sms";
$result=mysqli_query($link,$sql) or die("Error in sms".mysqli_error($link));
while($row=mysqli_fetch_assoc($result))
{
$name=$row['name'];
$number=$row['number'];
$url="http://xx1.yyw.wwe.bbb:8912/bulksms/
bulksms?username=qqq&password=zzz&type=0&dlr=Z&destination=".urlencode($number)."&source=bbb&message=".urlencode($name);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
$results = curl_exec($ch);
}
curl_close($ch);
</code></pre>
| php | [2] |
993,815 | 993,816 | Is it possible to print out the size of a C++ class at compile-time? | <p>Is it possible to determine the size of a C++ class at compile-time?</p>
<p>I seem to remember a template meta-programming method, but I could be mistaken...</p>
<hr>
<p>sorry for not being clearer - I want the size to be printed in the build output window</p>
| c++ | [6] |
2,190,466 | 2,190,467 | Cannot get length in array | <p>I could not even get the alert prompt. What wrong did I done on IE9?</p>
<pre><code><script type="text/javascript">
var countrieslist=document.sc.s1
var subjlist=document.sc.s2
var subj=new Array()
subj[0]=""
subj[1]=["New York|newyorkvalue", "Los Angeles|loangelesvalue", "Chicago|chicagovalue", "Houston|houstonvalue", "Austin|austinvalue"]
subj[2]=["Vancouver|vancouvervalue", "Tonronto|torontovalue", "Montreal|montrealvalue", "Calgary|calgaryvalue"]
subj[3]=["London|londonvalue", "Glasgow|glasgowsvalue", "Manchester|manchestervalue", "Edinburgh|edinburghvalue", "Birmingham|birminghamvalue"]
function updateSubj(selectsubj) {
if (selectsubj>0){
for (i=0; i<subj[selectsubj].length; i++) {
alert("ss");
//s2.options[subjlist.options.length]=new Option(subj[selectsubj][i].split("|")[0], subj[selectsubj][i].split("|")[1])
}
}
}
</script>
</code></pre>
| javascript | [3] |
5,984,347 | 5,984,348 | jquery eventually stops working | <p>I am making a dropdown menu with the following script, the dropdown effect works the first few mouse hovers but then stops working, any ideas? thanks!</p>
<pre><code>$(document).ready(function(){
$("ul.topnav li").hover(function() {
$(this).children().fadeIn(800);
},
function() {
$(this).find("ul.subnav").stop().fadeOut(800);
})
});
</code></pre>
| jquery | [5] |
5,640,711 | 5,640,712 | Define variables with "{}object", unexpected TypeError | <p>If <code>{}object</code>, e.g. <code>{}"string"</code>, <code>{}[1, 2, 3]</code>, or <code>{}({})</code> is exactly equal (according to <code>===</code>) to <code>object</code>, e.g. <code>"string"</code>, <code>[1, 2, 3]</code>, or <code>({})</code>, why can you define a variable with the latter but not the former?</p>
<p>To clarify:</p>
<pre><code>{}"string" === "string" // true
var a = "string" // No error
var a = {}"string" // SyntaxError: Unexpected string
var a = ({}"string") // SyntaxError: Unexpected string
var a = {}("string") // TypeError: object is not a function
var a = ({}("string")) // TypeError: object is not a function
</code></pre>
| javascript | [3] |
3,499,430 | 3,499,431 | How do I calculate a random point that is a fixed distance from another point? | <p>I suppose by distance I mean radius, so another way of phrasing it would be "how do I get random points on the circumference of a circle of a given radius, given also the circles centre point".</p>
<p>I don't understand the markdowns. This is a simple C# question that requires a simple C# answer as provided adequately by Daniel DiPaolo below.</p>
<p>Neither the markdowns nor the associated comments are helpful by way of improving the question or providing an answer.</p>
| c# | [0] |
2,709,707 | 2,709,708 | Making some child visible of expandablelistview when a group is collapsed in android | <p>I have make a expandable listview in android. I want to display some child of a group when group is collapsed. Please help me soon. thank's </p>
| android | [4] |
658,869 | 658,870 | Is there a way to know that a custom notification is about to be shown? | <p>I have a custom notification which is always available to the user (not a notification for a specific event) and should present up-to-date data.
Is there a way to know the notifications screen is being shown so I can update my notification data just at this time, instead of polling new data periodically?</p>
<p>Thanks</p>
| android | [4] |
1,118,808 | 1,118,809 | preserve argspec when decorating? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3729378/how-can-i-programmatically-change-the-argspec-of-a-function-in-a-python-decorato">How can I programmatically change the argspec of a function in a python decorator?</a> </p>
</blockquote>
<p>argspec is a great way to get arguments of a function, but it doesn't work when the function has been decorated:</p>
<pre><code>def dec(func):
@wraps(func)
def wrapper(*a, **k)
return func()
return wrapper
@dec
def f(arg1, arg2, arg3=SOME_VALUE):
return
import inspect
print inspect.argspec(f)
-----------
ArgSpec(args=[], varargs='a', keywords='k', defaults=None)
</code></pre>
<p>Argspec should return <code>arg1</code>, <code>arg2</code>, <code>arg3</code>. I think I need to define <code>wrapper</code> differently as to not use <code>*a</code> and <code>**k</code>, but I don't know how.</p>
| python | [7] |
3,866,316 | 3,866,317 | How to compile Python with all externals under Windows? | <p>When I compiled Python using <code>PCBuild\build.bat</code> I discovered that several Python external projects like ssl, bz2, ... were not compiled because the compiler did not find them. </p>
<p>I did run the <code>Tools\Buildbot\external.bat</code> and it did download them inside <code>\Tools\</code> but it looks that the build is not looking for them in this location and the <code>PCBuild\readme.txt</code> does not provide the proper info regarding this.</p>
<p>In case it does matter, I do use VS2008 and VS2010 on this system.</p>
<p>Example:</p>
<pre>
Build log was saved at "file://C:\dev\os\py3k\PCbuild\Win32-temp-Release\_tkinter\BuildLog.htm"
_tkinter - 2 error(s), 0 warning(s)
Build started: Project: bz2, Configuration: Release|Win32
Compiling...
bz2module.c
..\Modules\bz2module.c(12) : fatal error C1083: Cannot open include file: 'bzlib.h': No such file or
directory
</pre>
| python | [7] |
1,793,170 | 1,793,171 | Is there a difference between "private readonly" and "readonly private"? | <p>I was just reviewing some code and noticed someone had marked member as <code>readonly private</code>. Is this different from <code>private readonly</code> in any way?</p>
<p>Example:</p>
<pre><code>readonly private MyClass myInstance = new MyClass();
</code></pre>
<p>I have never seen this before. I always use <code>private</code> then <code>readonly</code>. I could not find anything on MSDN (or even in the C# spec.) that mentions what order the access modifiers can appear in. Is there an article / reference somewhere?</p>
| c# | [0] |
4,398,454 | 4,398,455 | Abstract Functors in C++ | <p>I would like to write an abstract base class</p>
<pre><code>class func_double_double_t : public unary_function<double, double>
{
virtual double operator()(double x) = 0;
};
</code></pre>
<p>and specialize it for several different types</p>
<pre><code>class func_pow_t : public func_double_double_t
{
public:
func_pow_t(double exponent) : exponent_(exponent) {};
virtual double operator()(double x) { return pow(x, exponent_); };
}
class func_exp_t : public func_double_double_t
...
</code></pre>
<p>and pass these to a function when necessary: </p>
<pre><code>double make_some_calculation(double num, func_double_double_t f)
{
return f(x);
}
</code></pre>
<p>But I can't define an object of type <code>func_double_double_t</code> because it's abstract. I can pass a pointer to the function, but using <code>f</code> like <code>f->operator()(num)</code> seems against the spirit of operator overloading in the first place. (<code>(*f)(num)</code> is better, but still.) </p>
<p>Is there way to make operator overloading and such abstraction play nicely together? </p>
| c++ | [6] |
4,248,738 | 4,248,739 | How to marshall void* with platform invoke | <p>I need to call a function from a C api contained in a dll. Function prototype looks as follows....</p>
<pre><code>int func( char* name, void* value );
</code></pre>
<p>where the contents of the pointer value can refer to any type dependent on the passed name. I an unsure how to set up the Dll inport to correctly marshall this void *. Ihave been experimenting with IntPtr which seems to work whe the value is an int but I cannot retrieve values correctly for floats etc.</p>
<p>I am trying to import the function like this...</p>
<pre><code>[DllImport("dllname.dll", CharSet = CharSet.Ansi)]
public static extern int func( string name, ref IntPtr value );
</code></pre>
<p>pls note that value is an output. A pointer to a value of any type, i.e. the address in a global region of memory of a value of a known type (known to the caller). In a c prog the caller would then be expected to cast this void * to the desired type and dereference to get the actual value stored there. The answers given so far seem to be based around an assumption that the function will write the result to pointer location passed in. My fault as I haven't been too specific. Sorry. C# is not my bag, and I don't even know if IntPtr is the way to go here...</p>
| c# | [0] |
1,236,396 | 1,236,397 | How to read Varian hnd files using java | <p>I have these "Varian hnd" files in my computer and I want to know if there is a way that I can open these files using eclipse or netbeans in java?. I think that these files have some images and I want to show them on my computer but I have no idea how to proceed. Also, can anyone explain to me about the format/extension of "Varian hnd" files.
Your help will be much appreciated.</p>
| java | [1] |
1,097,156 | 1,097,157 | Working out the future date with minutes variable | <p>say i have a variable integer of <code>3000</code></p>
<p>Which equates to <code>3000 minutes</code>, how would i work out the date from now, to <code>3000 minutes</code> into the future?</p>
<p>If it helps, i do have some php which has already broken it down into the variables</p>
<pre><code>$days
$hours
$minutes
</code></pre>
<p>Thanks for the help</p>
| php | [2] |
58,157 | 58,158 | SDK.DIR is missing? android update project? | <p>I get this error when I do ant release: sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var</p>
<p>typing in android update project I get another error saying I must specify the path .... to the project. </p>
<p>Then I try cd into the directory of my project and do </p>
<p>android update -p .
android update -path . </p>
<p>etc and it says -p and -path are not globally recognized. </p>
<p>Could someone just give me the exact synax?</p>
| android | [4] |
2,049,376 | 2,049,377 | Expand a DIV only when content overflows? | <p>My concept: So i have a fixed height DIV that containts a variable amount of content. If the content overflows from the box, it is initially hidden (via CSS), but if you mouseover the box, it should expand to the height needed to display the content.</p>
<p>This is what I have so far to accomplish this:
<a href="http://jsfiddle.net/CvhkM/649/" rel="nofollow">http://jsfiddle.net/CvhkM/649/</a></p>
<p>The problem is as you can see, the jquery fires on both of those example DIVs, where it really should only fire on the bottom div (with content that extends beyond the initial div height as defined via CSS). </p>
<p>Also it grows to a defined height (300px), is there a way to detect the exact height it should grow to?</p>
<p>UPDATE: SOLUTION FOUND--> IVE LEFT IT ON JSFIDDLE: <a href="http://jsfiddle.net/hQkFH/3/" rel="nofollow">http://jsfiddle.net/hQkFH/3/</a></p>
| jquery | [5] |
1,264,548 | 1,264,549 | C++ passing a pointer to static function changes value during execution | <p>Here is my code</p>
<pre><code>Node* Node::createNode(int n)
{
Node newNode(n);
Node *temp = &newNode;
return temp;
}
void Node::printNode(Node* node)
{
cout << node->data << "\t" << node->next << endl;
system("pause");
}
</code></pre>
<p>Here is the main function</p>
<pre><code>int main(int argc, char* argv[])
{
Node *head = Node::createNode(10);
Node::printNode(head);
return 0;
}
</code></pre>
<p>Problem, I was expecting to print 10. Instead I get a garbage value of -858993460. I have noticed that until the point, parameter is passed into the function, it retains correct value. But inside the function printNode, the value changes. So I guess something is going wrong in the function call. Any help would be appreciated.</p>
| c++ | [6] |
122,030 | 122,031 | python automatic (or dynamic) import classes in packages | <p>I'm writing some kind of automated test suite and I want to make sure the classes contained in the package 'tests' get imported automatically upon runtime in the main namespace, without adding them to the <code>__init__</code> file of the package.</p>
<p>So here is the script I have so far:</p>
<pre><code>import os
for dirpath, dirnames, filenames in os.walk('tests'):
for filename in filenames:
if filename.lower().endswith(('.pyc', '__init__.py')): continue
module = ".".join([dirpath, filename.split('.')[0]])
print module
</code></pre>
<p>If I use <code>modulename = __import__(module)</code> the classes get added to the module 'modulename' and not the main namespace.</p>
<p>My question is, how do I import them to the current namespace?</p>
<p>So I can do things like:</p>
<pre><code>testcase = TestCase()
testcase.run()
results = testcase.results()
</code></pre>
<p>or whatever in the main script without explicitly importing the classes.</p>
<p>Thanks in advance!</p>
<p>Thank you all for replying and trying to help me out.</p>
| python | [7] |
2,954,565 | 2,954,566 | For loop not behaving as expected without nested do-while | <p>I wrote the following code to shuffle a deck of cards:</p>
<pre><code>int i,j;
for(int x=1;x<53;x++) {
i=rand()%4;
j=rand()%13;
if(deck[i][j]=0)
deck[i][j]=x;
else
x--;
}
</code></pre>
<p>That didn't produce any result, whereas the following code produced results:</p>
<pre><code>int i,j;
for(int x=1;x<53;x++) {
do {
i=rand()%4;
j=rand()%13;
} while(deck[i][j]!=0);
deck[i][j]=x
}
</code></pre>
<p>What difference causes this? </p>
| c++ | [6] |
485,830 | 485,831 | Strange javascript operator: expr >>> 0 | <p>the following function is designed to implement the <code>indexOf</code> property in IE. If you've ever had to do this, I'm sure you've seen it before.</p>
<pre><code>if (!Array.prototype.indexOf){
Array.prototype.indexOf = function(elt, from){
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++){
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
}
</code></pre>
<p>I'm wondering if it's common to use three greater than signs as the author has done in the initial length check? </p>
<p><code>var len = this.length >>> 0</code></p>
<p>Doing this in a console simply returns the length of the object I pass to it, not true or false, which left me pondering the purpose of the syntax. Is this some high-level JavaScript Ninja technique that I don't know about? If so, please enlighten me!</p>
| javascript | [3] |
2,524,443 | 2,524,444 | Iterate JSON object | <p>I have the following JSON Object:</p>
<pre><code>{
"a1_1_on" : "on",
"a1_1_thr" : "",
"a1_2_on" : "on",
"a1_2_thr" : "",
}
</code></pre>
<p>and I want using a for loop to check the fields for example:</p>
<pre><code>for (var i=1; i<2; i++) {
//alarm
var al = 'ai_' + i + '_on';
//alarm threshold
var althr = 'ai_' + i + '_thr'
//console.log(form_infos.al);
if(form_infos.al == "on" && form_infos.althr == "") {
alert("Alarm for Analog " + i + "is on and you did not specified a threshold. Please specify a threshold before submittiing");
return false;
}
}
</code></pre>
<p>But it shows <code>undefined</code> if I do <code>console.log(form_infos.al)</code>. Any suggestions?</p>
| javascript | [3] |
4,084,237 | 4,084,238 | How do I traverse in a single linked list to a specific node with name age and height? | <p>Now say theres a linked list with 4 nodes.With name age and height.
Now I want to move the pointer to the second node and 4th node so that I could insert a new node inbetween the 2nd and 3rd node of the linked list.</p>
<p>How will I go about this and how will I add values of name, age and height in the new node to be inserted?</p>
<p>The new node's values has to be inserted by the programmer and not the user.</p>
<p>Help will be much appreciated :(</p>
| c++ | [6] |
2,019,486 | 2,019,487 | Sharing cache between multiple web-sites | <p>We have about 50 web-sites, running in different application pools, that read from a common cache database (using Microsoft Enterprise Library Caching application block). </p>
<p>We currently have a console application which populates the cache at 3AM every morning. However, we want to get rid of this application and get the cache to automatically refresh expired items, using the ICacheItemRefreshAction interface. </p>
<p>We were going to create our cache object in the Global.asax of each of the 50 web-sites. However, my concern is that if we set a cache-expiration policy in Global.asax, that each of the 50 web-sites will trigger a refresh action, causing the data to be re-cached 50 times.</p>
<p>We don't want only 1 web-site to set the expiration policies, as then the 49 other web-sites will have a dependency on that 1 web-site, and that's an architecture no-no.</p>
<p>Given these constraints - any recommendations? </p>
| asp.net | [9] |
224,100 | 224,101 | Can JavaScript retrieve a file that is above the web root? | <p>Is it possible to make JavaScript retrieve a file that is above the web root?</p>
<pre><code>function sendurl(url) {
if(document.images){
(new Image()).src="../recieve_url.php?url="+url;
}
return true;
}
</code></pre>
| javascript | [3] |
1,678,519 | 1,678,520 | Timer not working properly in android mobile | <p>I have developed one application which do some task periodically. For that i have set one timer object with task in it. It works fine in the android emulator but as I deployed the same application on the Android Mobile, it shows 2-6 minutes delay everytime and do not work after day crosses. Can someone please tell me the reason and remedy of the timer behaviour.
Thanks in advance!</p>
<p>Code used </p>
<pre><code>private final Handler timerHandler = new Handler()
{
public void handleMessage(Message msg)
{
// Do main activity
}
};
Timer clockTimer = new Timer();
clockTimer.scheduleAtFixedRate(new Task(public void run()
{
timerHandler.sendEmptyMessage(0);
}), StartTime,INTERVAL);
</code></pre>
| android | [4] |
3,966,016 | 3,966,017 | Android: Using drawArc() with different arc sizes with all the same center | <p>I am trying to draw a pie chart in a slightly different way than the conventional way. The pie has equal pieces no matter what, but then each piece's radius is different. So all the arcs are still centered at one point but have different radiuses.</p>
<p>Here is the simplified code for it.</p>
<pre><code>rect1 = new RectF(0,0,8,8)
rect2 = new RectF(0,0,6,6)
rect3 = new RectF(0,0,4,4)
rect4 = new RectF(0,0,2,2)
canvas.drawArc(rect1,0,90,true, paint)
canvas.drawArc(rect2,90,90,true, paint)
canvas.drawArc(rect3,180,90,true, paint)
canvas.drawArc(rect4,270,90,true, paint)
</code></pre>
<p>This creates all the correct arcs, but the point of all the arcs are not centered at the same place. I understand that this is because of how the RectF class works. </p>
<p>So my question is, can I line up these different Arcs in the center of the canvas? Is there an arc offset somewhere that I can use to do this? </p>
<p>I tried <a href="http://stackoverflow.com/questions/3874424/android-looking-for-a-drawarc-method-with-inner-outer-radius">this solution</a> with paint, but was unsuccessful. Any suggestions would be helpful!</p>
| android | [4] |
4,184,250 | 4,184,251 | class attribute with css in jquery | <p>I need jquery function do this: </p>
<p>First:</p>
<pre><code><a class="MyClass1 Myclass2 {padding-top:10px;height:20px;}"></a>
</code></pre>
<p>After calling function:</p>
<pre><code><a class="MyClass1 Myclass2" style="padding-top:10px;height:20px;"><a/>
</code></pre>
<p>Function must work with all elements</p>
<p><strong>Edit</strong></p>
<p>For example: i'm using on the asp.net mvc. Every Module contains different theme properties. This code is Module <code>partial view</code> section.</p>
<pre><code><div class="<%=Model.Theme.HeaderClass%>">...content goes here
</div>
<div class="<%=Model.Theme.BodyClass%>">...content goes here</div>
<div class="<%=Model.Theme.PagerClass%>">
<a class="<%=Model.Theme.PagerItemClass%>"> </a>
</div>
</code></pre>
| jquery | [5] |
4,078,531 | 4,078,532 | Scan class or jar file in Java | <p>I need to scan class or jar file that implements or extend a specific class.<br>
It's the same mechanism that Eclipse use to scan the plugin presence.
There is a way to do this ?</p>
| java | [1] |
4,090,557 | 4,090,558 | php: massive assignement | <p>I want to do a massive assignement of my protected vars, i used this code:</p>
<pre><code>protected $_productName = '';
protected $_price = 0;
protected $_categoyId = 0;
public function setAttributes($attributes)
{
foreach($attributes as $key => $val)
{
$var = '_' . $key;
$this->$var = $val;
}
}
</code></pre>
<p><code>$attributes = array('productName'=>'some Product', 'price' => 10, 'categoryId' => 5)</code> for exapmle. </p>
<p>the code above works for me but I feel that it's not clean. Is there any better solution to do that? </p>
<p>thanx.</p>
| php | [2] |
1,951,265 | 1,951,266 | Changing public key token, how to redirect assemblies? | <p>One of my customer wants to change the assembly signing policy.</p>
<p>Basically, all code and assemblies will be signed with the same and unique snk file.</p>
<p>Unfortunately, a very large code base is using the old public key token.</p>
<p>Is there a way to "redirect" old name to new name assembly?</p>
<p>I've read <a href="http://msdn.microsoft.com/en-us/library/2fc472t2.aspx" rel="nofollow">Assembly Binding Redirection</a>, but it looks like it can only redirect to new version of the same assembly name/public key token.</p>
<p>While I can recompile code, I have a lot of aspx and ascx referencing the old name. I also have 3rd party database that serialize some objects in binary format. I can't change that easily.</p>
| c# | [0] |
3,320,367 | 3,320,368 | Why isn't this program printing out hex values? | <p>It's been a long time since I've touched C++ and I've never been quite fluent in the language, so forgive my ignorance.</p>
<p>I've written the following little program to mess around with XOR encryption:</p>
<pre><code>#include <iostream>
#include <iomanip>
#include "string.h"
using std::cout;
using std::endl;
using std::hex;
using std::string;
string cipher(string msg, char key);
int main(void)
{
string msg = "Now is the winter of our discontent, made glorious summer by this sun of York.";
char key = 's'; // ASCII 115
string ctext = cipher(msg, key);
cout << "Plaintext: " << msg << endl;
cout << "Ciphertext (hex): ";
for (int i = 0; i < ctext.size(); i++)
cout << hex << ctext[i];
return 0;
}
string cipher(string msg, char key)
/*
Symmetric XOR cipher
*/
{
for(int i = 0; i < msg.size(); i++)
msg[i] ^= key;
return msg;
}
</code></pre>
<p>This code outputs the following:</p>
<pre><code>Plaintext: Now is the winter of our discontent, made glorious summer by this sun of York.
Ciphertext (hex): =SSSSSS_SSSS
SSSS*]
</code></pre>
<p>Why can I not get the hex values to output? What am I doing wrong?</p>
<p>Also, any general advice is appreciated.</p>
| c++ | [6] |
3,838,260 | 3,838,261 | Java import can be slow? | <p>Is import package.* slower than import package.MyClass?
If yes, in which scneario: runtime or compilation?</p>
| java | [1] |
1,423,336 | 1,423,337 | Android Will the CountDownTimer remain counting when device goes to sleep? | <p>I am using a CountDownTimer to log a user out of my app after a specified time. I am wondering if the Timer keeps going even if my app is sent to the background or if the phone locks because the user put their phone down? If anyone thinks I should use a different timer method please let me know.</p>
<p>Thanks</p>
| android | [4] |
3,193,588 | 3,193,589 | Android Dialog Activity | <p>I need help on following:
When i touch on my mainActivity, it should handle onTouch event and start new activity which is dialog activity. I am not able to do it. Can anyone suggest anything.</p>
<p>I add <code>android:theme="@android:style/Theme.Dialog"</code>.
If i design simple Dialog activity then it works fine but if i am trying to open it on touch event then it's not working.<br>
Any help is appreciated.</p>
<pre><code>public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int action = event.getAction();
if(action == MotionEvent.ACTION_DOWN) {
Intent loginIntent = new Intent(this, Login.class);
startActivity(loginIntent);
return true;
}
return true;
}
</code></pre>
| android | [4] |
5,435,814 | 5,435,815 | How to check if a String contains any of some strings | <p>I want to check if a String s, contains "a" or "b" or "c", in C#.
I am looking for a nicer solution than using</p>
<pre><code>if (s.contains("a")||s.contains("b")||s.contains("c"))
</code></pre>
| c# | [0] |
2,174,348 | 2,174,349 | android - How to finishes the all acitivities | <p>My application have 10 activities. Every activity contains one button.if you click on that button then all activities will be finished(it means like Logout in gmail). Here i am using 2 steps. But it's not working.
1. Clear the stack using intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) for every activity calling.
2. this.finish() in button click listener. </p>
<p>How to implement it. Please can anybody help me</p>
<p>thanks</p>
| android | [4] |
5,601,577 | 5,601,578 | which payment gateway or payment methods is better in iphone? | <p>I want to implement payment methods in iphone.I dont know which is better and also don't know which payment methods is supported in iphone.PLease provide me some reference documents so i can get idea about that.Please help me for this query.</p>
<p>Thanks in advance</p>
| iphone | [8] |
2,804,933 | 2,804,934 | encoding of text by using java code | <p>the my code by using servlet language that read the text line by line and fill string buffer each 5000 words in a string buffer then display the content in jsp page and I put in header display text in utf-8 the problem is when the text in utf-8 encoding the code read it in unkown character and I want my code to read text in utf-8 and the text shown to user in utf-8 encoding
here is my code for reading the text</p>
<pre><code> try{
File file = new File(p);
l = (int) file.length();
String s = null,strr=null;
String g = null,m=null;
int i = 0;
Scanner input = new Scanner(file);
s1 = new StringBuffer();
s2 = new StringBuffer();
while (input.hasNextLine()) {
g = input.nextLine();
String[] d = g.split(" ");
int h = d.length;
i = i + h;
if (i > 5000) {
break;
}
s1.append(g).append(System.getProperty("line.separator"));
}
if(i > 5000) {
s2.append(g).append(System.getProperty("line.separator"));
while( input.hasNextLine()) {
s = input.nextLine();
String[] d = s.split(" ");
int h = d.length;
i=0;
i=i+h;
if (i > 5000) {
break;
}
s2.append(s).append(System.getProperty("line.separator"));}
if (input.hasNextLine()) {
s3.append(s).append(System.getProperty("line.separator"));
while(input.hasNextLine()) {
strr = input.nextLine();
s3.append(strr).append(System.getProperty("line.separator"));
}
}
}
input.close();
} catch (Exception e) {
e.getMessage();
}
</code></pre>
| java | [1] |
1,894,580 | 1,894,581 | Stop a javascript function inside a jquery? | <p>I want to cancel/stop a javascript function if some criteria is not matching in jquery</p>
<pre><code><div id="prewrapper">
<ul class="tabs seller">
<li class="active">
<a onclick="adc.FormHandler.goto('user_edit', 0); return false;" href="#"><i data="1" class="icon-tab-num"></i> General Info</a>
</li>
<li class="">
<a onclick="adc.FormHandler.goto('user_edit', 1); return false;" href="#"><i data="2" class="icon-tab-num"></i> Account Details</a>
</li>
<li class="">
<a onclick="adc.FormHandler.goto('user_edit', 2); return false;" href="#"><i data="3" class="icon-tab-num"></i> Roles</a>
</li>
</ul>
</div>
</code></pre>
<p>I check some validation in <code>$('#prewrapper').click(function (e){</code>, and if not valid I don't want to go href onclick function i.e., <code>adc.FormHandler.goto</code></p>
| jquery | [5] |
944,613 | 944,614 | resize a div using onload | <p>I am trying to resize a div onload without having a javascript function in the header. So far my code looks like the code below, and while I am somewhat familiar with javascript, I am very much so a beginner.</p>
<p>What I am wanting to do is take a div that has a height set in the stylesheet of 100%, and subtract 60px of height on load. Am I even close, or am I lost?</p>
<p>EDIT: I would not be opposed to other methods of doing this. I just don't know of any other way.</p>
<pre><code><div id="pageContent" onload="document.this.style.height = clientHeight - '60px';">
</code></pre>
| javascript | [3] |
4,683,054 | 4,683,055 | Custom view with button like behavior on click/touch | <p>I have created a custom View which I usually attach an onClickListener to. I'd like to have some button like behavior: if it is pressed, it should alter its appearance which is defined in the onDraw() method. However, this code does not work:</p>
<pre><code>//In my custom View:
@Override
protected void onDraw(Canvas canvas)
{
boolean pressed = isPressed();
//draw depending on the value of pressed
}
//when creating the view:
MyView.setClickable(true);
</code></pre>
<p>pressed always has the value false. What's wrong?</p>
<p>Thanks a lot!</p>
| android | [4] |
5,554,167 | 5,554,168 | What does a pipe in a macro signify? | <p>How is the following macro definition resolved?</p>
<pre><code>#define EMAIL_SERVER_ADAPTER_FATAL_ERROR MSB_RETURN_TYPE_FATAL_ERROR | 1
</code></pre>
<p>I mean, is it resolved to 1 or to MSB_RETURN_TYPE_FATAL_ERROR and why?</p>
| c++ | [6] |
1,918,743 | 1,918,744 | I can't find the wrong code on line 23 | <p>I can't find the wrong code on line 23.</p>
<pre><code><html>
<head><title>cw5</title></head>
<body>
<form method=post>
Please enter 2 numbers: <br>
The first number: <input type="text" name="num1"><br>
The second number: <input type="text" name="num2"><br>
<input type="submit" value="Submit"></form><hr>
<?php
$num=$_POST["num1"]+$_POST["num2"];
echo $_POST['num1']."+".$_POST['num2']."=".$num."<br>";
$num2=$_POST["num1"]-$_POST["num2"];
echo $_POST['num1']."-".$_POST['num2']."=" .$num2."<br>";
$num3=$_POST["num1"]*$_POST["num2"];
echo $_POST['num1']."x".$_POST['num2']."=" .$num3."<br>";
$num4=$_POST["num1"]/$_POST["num2"];
echo $_POST['num1']."/".$_POST['num2']."=" .$num4."<br>";
$num5=$_POST["num1"]%$_POST["num2"];
**echo "the remains of" $_POST['num1']."/".$_POST['num2']. "is".$num5."<br>";**
?>
<hr>
</body>
</html>
</code></pre>
| php | [2] |
1,425,223 | 1,425,224 | How to Connect to computer on the workgroup? | <p>I am trying to connect to a computer over the workgroup. My code is below: </p>
<pre><code>ConnectionOptions options = new ConnectionOptions();
options.Impersonation = ImpersonationLevel.Impersonate;
options.Username = "testusername";
options.Password = "testpwd";
ManagementScope scope = new ManagementScope(@"\\19x.16x.x.xx\C$\TestFolder", options);
scope.Connect();
if (scope.IsConnected == true)
{
MessageBox.Show("Connection Succeeded", "Alert");
}
else
{
MessageBox.Show("Connection Failed", "Alert");
}
</code></pre>
<p>When I run this, I get the exception : "Invalid parameter"</p>
<p>How to sort this out?</p>
<p>edit:</p>
<p>The error is in this line below:</p>
<pre><code>ManagementScope scope = new ManagementScope(@"\\19x.16x.x.xx\C$\TestFolder", options);
</code></pre>
<p>How do we specify the drive? I think the $ is causing the problem</p>
| c# | [0] |
455,553 | 455,554 | Disable submit button untill any form element change? | <p>Heres what im trying to do. After the form is submitted, i want to disable the submit button until any form element is changed. I already got it almost working using a different question on stackoverflow:</p>
<pre><code>$('#myform').find (':submit').attr ('disabled', 'disabled');
// Re-enable submit
var form = $('#myform');
$(':input', form.get(0)).live ('change', function (e) {
form.find (':submit').removeAttr ('disabled');
});
</code></pre>
<p>One problem is that the if the button is disabled, and the user clicks the button, that counds as a change and its now enabled. So a simple double click of the button re-submits! Any suggestions?</p>
| jquery | [5] |
1,906,833 | 1,906,834 | question related to quit the application | <p>I want to quit the application programatically?
how to do it with code?</p>
<p>generally we do it by pressing home button.</p>
| iphone | [8] |
3,827,529 | 3,827,530 | How to find if there are active downloads using API level 8? | <p>Is there a way to find if there is active downloads programmatically working on API level 8?
I need to do an application for android that turns off wifi if there a no downloads active.</p>
| android | [4] |
4,180,419 | 4,180,420 | Why the output getting differed in hexadecimal integer to character conversion? | <p>Why the output varies in both of the following codes since i am applying the same explicit type conversion.</p>
<pre><code> int hex = (char)0xA;
System.out.println(hex);
int hex = 0xA;
System.out.println((char)hex);
</code></pre>
| java | [1] |
3,128,673 | 3,128,674 | Issue throwing two separate FileNotFoundExceptions Java | <p>I need two separate exceptions, one thrown if the .pro file is missing, the other if the missing file is a .cmd, that current set up has both exceptions being thrown if either one is missing. What am I doing wrong here? </p>
<pre><code>import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import javax.xml.ws.Holder;
public class Inventory {
static String FileSeparator = System.getProperty("file.separator");
public static void main(String[] args) {
String path = args[0];
String name = args[1];
ArrayList<Holder> because = new ArrayList<Holder>();
try {
File product = new File(path + name + ".pro");
Scanner scan = new Scanner(product);
while (scan.hasNext()) {
System.out.print(scan.next());
}
scan.close();
} catch (FileNotFoundException e) {
System.out.println("Usage: java Inventory <path> <filename>");
System.out.println("The products file \"" + name + ".pro\" does not exist.");
}
try {
File command = new File(path + name + ".cmd");
Scanner scan = new Scanner(command);
while (scan.hasNext()) {
System.out.println(scan.next());
}
} catch (FileNotFoundException f) {
System.out.println("Usage: java Inventory <path> <filename>");
System.out.println("The commands file \"" + name + ".cmd\" does not exist.");
}
}
}
</code></pre>
| java | [1] |
4,319,510 | 4,319,511 | c# capture microphone | <p>Can someone tell me how could I capture the microphone and send it over IP? Is there any example of how to capture and put into a buffer in order to send it on UDP socket to another computer and listen the song? I'm working in c#. THX. I would really apprecciate if there is someone who can give me an example:)</p>
| c# | [0] |
4,642,667 | 4,642,668 | When checkbox is checked show message in javascript | <p>I want like this in javascript,when checkbox is visible show message1 else show message2.</p>
| asp.net | [9] |
5,633,601 | 5,633,602 | how to add and remove a class from a list of li elements? | <p>if i have an li list like this:</p>
<pre><code><ul>
<li>first </li>
<li>second</li>
<li>third</li>
<li>fourth</li>
</ul>
</code></pre>
<p>How would i write the code in jquery to add a class to the li element , say , first without the class being added to the others?</p>
<p>i tried this but it of course adds to all li elements.</p>
<pre><code>$(document).ready(function() {
$("ul li").click(function() {
if(!$("ul li").hasClass('active'))
{
$("ul li").addClass('active');
}
});
});
</code></pre>
<p>i want to be able to add the class active to only the li element that was click and remove all other exists who have active added to them. how would i do this? thanks</p>
| jquery | [5] |
2,507,726 | 2,507,727 | Triggering click with jQuery to hit code-behind function not working in 1.4 - Worked fine in 1.3.2 | <p>I have a gridview in an update panel and am using a jQuery dialog for adding entries. </p>
<p>The dialog calls an AJAX/JSON function that adds the entry. On success of that function I have jQuery trigger a button click on a hidden button </p>
<pre><code> ...
success: function(msg) {
$("[id$='_btnUpdateGrid']").trigger('click');
$("#new_dialog").dialog('close');
},
...
</code></pre>
<p>which should hit an event handler in the code behind to update the datasource and refresh the gridview. </p>
<pre><code><asp:Button ID="btnUpdateGrid" runat="server" OnClick="btnUpdateGrid_Click"
Text=" " Width="1px" Height="1px" Style="background-color:#F5F3E5; border:none;" />
</code></pre>
<p>This has worked just fine with 1.3.2. Updated to 1.4.1 and it no longer hits the code-behind. The AJAX still works but I have to manually refresh the page to update the grid. </p>
<p>Also, I can hit client side event handlers (e.g OnClientClick="alert('hello')") so I know the click is still happening just not the code-behind event handler. It's like jquery is somehow blocking the page from doing just that now. I have verified this by just changing the version number in the script reference path and seeing the functionality change.</p>
<p>Is this a bug or s there another way I'm supposed to do this now? </p>
| jquery | [5] |
167,062 | 167,063 | How to have a "no image found" icon if the image used in the function returns an error? | <p>In my application I use timthumb for resizing images. Those images are not controlled by me because I get them from RSS feeds. Sometimes the image are not shown in my page. When I examine the entire link with the timthumb I get this</p>
<blockquote>
<p>Warning: imagecreatefromjpeg(http://www.domain.com/image.jpg)
[function.imagecreatefromjpeg]: failed to open stream: HTTP request
failed! HTTP/1.1 404 Not Found in /timthumb.php on line 193 Unable to
open image : <a href="http://www.domain.com/image.jpg" rel="nofollow">http://www.domain.com/image.jpg</a></p>
</blockquote>
<p>So, I am looking for a way to know when an image returns an error, so that I will not display it on page ( the red X icon).</p>
<p>From my RSS feeds, I use regex to get the first image</p>
<pre><code>if (thumb[0]) { show the image using timthumb }
else { show a no-image icon }
</code></pre>
<p>but the example above falls into the "show the image using timthumb".</p>
<p>This is a paste from my code
<a href="http://codepad.org/7aFXE8ZY" rel="nofollow">http://codepad.org/7aFXE8ZY</a></p>
<p>Thank you.</p>
| php | [2] |
4,450,516 | 4,450,517 | Extract a part from a specific string pattern | <p>how can I get the time difference from the string below, I want to get it with (-3.30)</p>
<pre><code>[UTC - 3:30] Newfoundland Standard Time
</code></pre>
<p>and how to get null from the below string</p>
<pre><code>[UTC] Western European Time, Greenwich Mean Time
</code></pre>
<p>and I want to get +3.30 in below string</p>
<pre><code>[UTC + 3:30] Iran Standard Time
</code></pre>
| c# | [0] |
6,031,114 | 6,031,115 | iphone code not firing | <p>I have a class that im using and cant get the code to fire</p>
<pre><code>WeatherServer.m
----------------------
- (NSArray *)weatherItemsForMapRegion:(MKCoordinateRegion)region maximumCount:(NSInteger)maxCount
{
//code is not firing
}
myviewcontroller.h
-----------------------
@class WeatherServer;
@interface MapView : UIViewController <MKMapViewDelegate, UITextFieldDelegate, CLLocationManagerDelegate, ADBannerViewDelegate> {
WeatherServer *weatherServer;
}
@property(nonatomic, retain) IBOutlet WeatherServer *weatherServer;
@end
myviewcontroller.m
----------------------
#import "WeatherServer.h"
@implementation MapView
@synthesize weatherServer;
- (void)mapView:(MKMapView *)map regionDidChangeAnimated:(BOOL)animated
{
NSArray *weatherItems = [weatherServer weatherItemsForMapRegion:mapView.region maximumCount:300];
[mapView addAnnotations:weatherItems];
}
@end
</code></pre>
<p>regionDidChangeAnimated fires ok however, the code in weatherItemsForMapRegion never gets fired.</p>
| iphone | [8] |
4,322,569 | 4,322,570 | Local variable impact global variable - Javascript variable scoping | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3725546/variable-hoisting">variable hoisting</a> </p>
</blockquote>
<pre><code> var a = "global";
//version 1
function changeGlobal(){
alert(a); //why is 'a' undefined here?
if(a){
var a = "local";
alert(a);
}
}
//version 2
function changeGlobal(){
alert(a); //why is 'a' 'global' here? what diff does 'var a="local"' make?
if(a){
//var a = "local";
alert(a);
}
}
changeGlobal();
</code></pre>
<p>Question are inline. Help me understand variable scoping.</p>
| javascript | [3] |
5,765,541 | 5,765,542 | How to get a data element within one's DIV | <p>I am trying to get the data value within an anchor element in a Div.</p>
<p>The code is as follows:-</p>
<pre><code><div id="value" class="wrapper-dropdown-5" tabindex="1">
<img src="./images/content/value-menu-item-selected.png">
<ul class="dropdown">
<li class="orange">
<a href="#" data-jumpslide="2">
...
</code></pre>
<p>I am trying to get the value of <strong>data-jumpslide</strong> within the <strong>div id="value"</strong></p>
<p>Here is what I tried but clearly, it isn't working.</p>
<pre><code>$("#value").data('jumpslide')
</code></pre>
<p>EDIT 2:</p>
<p>Tried this too. </p>
<pre><code>$("#"+$(this).attr("id")+ " > a.data('jumpslide')").
</code></pre>
<p>Didn't work either :(
Thanks.</p>
| jquery | [5] |
3,494,290 | 3,494,291 | How to perform custom paging | <p>Hy All,</p>
<p>I want to provide Numeric and First/Next/Prev/Last Button pager and DropDown for page size in grid view.</p>
<p>So please give me any link or any example.</p>
| asp.net | [9] |
4,247,819 | 4,247,820 | Select a random set of rows without any duplicates | <p><strong>How can I display a random set of questions (pulled from Wordpress) without any duplicates?</strong></p>
<p>This is what I've tried:</p>
<pre><code><?php
$amount = get_field('select_number_of_questions');
$rand_max = count(get_field('step_by_step_test')) -1;
$rand = rand($amount,$rand_max);
$i = 0;
while(has_sub_field('step_by_step_test')):
if($rand == $i):
echo the_sub_field('question');
endif;
$i++;
endwhile;
?>
</code></pre>
<p>At the moment it just shows 1 random question.</p>
<p>It's all dynamic so for instance there can be a total of 10, 20, 31 questions etc. The total amount of questions to select is defined by <code>get_field('select_number_of_questions');</code></p>
<p><code>count(get_field('step_by_step_test')) -1;</code> is getting the total amount of questions to select from.</p>
<p>So in conclusion I want it to select the amount of questions defined by <code>get_field('select_number_of_questions');</code> from a total of <code>count(get_field('step_by_step_test')) -1;</code> without any duplicates.</p>
| php | [2] |
3,763,001 | 3,763,002 | change the sender number when sending sms | <p>Is it possible to change the sender number when sending an sms from my android program ?</p>
<p>Thanks</p>
| android | [4] |
1,026,616 | 1,026,617 | Getting Error in CreateTableCommand.ExecuteNonQuery(); | <p>This is the query in which i m getting error</p>
<pre><code>CreateTableCommand.CommandText = "BACKUP DATABASE Test" +
"TO DISK = 'C:\backup\t1.bak'" +
"WITH " +
"NOFORMAT, " +
"COMPRESSION," +
"NOINIT, " +
"NAME = N't1-Full Database Backup'," +
"SKIP, " +
"STATS = 10;";
</code></pre>
<p>and the error is "Incorrect syntax near 'DISK'."
but if i run run that query ms sql server 2008 its work fine but when i try to use that in my C# application it gave error pls help me out</p>
| c# | [0] |
5,342,339 | 5,342,340 | How to get online audio streaming from a website with different urls? | <p>I have got a website which shows a list of audio files mp3 format. Each one is having their own URL. I want to know how could I read all the files url into my app and use it for audio streaming? Main emphasis is own how to read the url.</p>
| android | [4] |
5,370,562 | 5,370,563 | Button Click and LinkButton Click | <p>I am having a strange day! I am trying to access values inside the Datagrid control. There are textboxes in each row of the Datagrid control. If I use a asp.net button control outside the datagrid control I can access all the values. But if I use LinkButton outside the datagrid control then I cannot access any value. </p>
<p>I have to use LinkButton.</p>
<p>UPDATE 1: Code </p>
<pre><code> //This works
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim indexes() As Integer = dgReceipts.SelectedIndexNumbers
End Sub
//This does not work and I get 0 items in the SelectedIndexNumbers
Protected Sub LinkButtonUpdateReceipts_Click(sender As Object, e As EventArgs) Handles LinkButtonUpdateReceipts.Click
Dim indexes() As Integer = dgReceipts.SelectedIndexNumbers
End Sub
<asp:Button ID="Button1" runat="server" Text="Button" />
<c1:LinkButton ID="LinkButtonUpdateReceipts" runat="server" Text="Update Totals" Icon="images/go-blue-right.gif"></c1:LinkButton>
</code></pre>
| asp.net | [9] |
303,252 | 303,253 | PriorityQueue with external parameters | <p>I have a project where I have a class Halfedge (olny .class file, so no way to modify it).
I want to create a PriorityQueue.
In order to determine which element is bigger, I need not only the fields inside the Halfedge class, but also a HashMap that I create in my code.</p>
<p>The thing is: when I define the Comparator class specific for the Halfedge, I cannot include any parameters.</p>
<p>My question is: how can I implement a comparator class for my Halfedge class using outside parameters? (or simply, how shoul I construct that PriorityQueue)</p>
<p>Thanks a lot!</p>
| java | [1] |
5,599,059 | 5,599,060 | C sharp array error Windows Form Applicaton | <p>I am trying to figure out what the error in this code is:</p>
<pre><code>private void button2_Click(object sender, EventArgs e)
{
int[] teams = new int[10] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
temp = teams[2];
for (int i = 3; i <= 10; i++)
teams[i-1] = teams[i];
richTextBox1.Text = ("Round 1: "+teams[0]+","+teams[1]+" "+teams[2]+","+teams[9]+" "+teams[3]+","+teams[8]+" "+teams[4]+","+teams[7]+" "+teams[5]+","+teams[6]);
}
</code></pre>
<p>I am not getting any errors in the server explorer, but the program crashes when I debug and I get "IndexOutOfRangeException was unhandled"</p>
<p>The output is supposed to be
Round: 1,2 3,10 4,9 5,8 6,7
Round: 1,3 4,2 5,10 6,9 7,8
Round: 1,4 5,3 6,2 7,10 8,9
etc...
until all teams have played each other exactly once. Team 1 is fixed while the rest of the items in the array iterate. </p>
| c# | [0] |
4,523,704 | 4,523,705 | external xml file integration in android | <p>i am developing one application for displaying images and labels and its sound.i want to get this info from xml .where i need to keep xml file in android project how to get values from that xml file</p>
<p>Thanks in advance</p>
<p>Aswan</p>
| android | [4] |
2,900,562 | 2,900,563 | ASP.NET what is the meaning of AutoEventWireup and Inherits? | <p>Given the following statement,</p>
<pre><code><%@ Page Language="C#" AutoEventWireup="true" CodeFile="XXX.aspx.cs" Inherits="XXX %>
</code></pre>
<ol>
<li>What is the meaning of AutoEventWireup?</li>
<li>What if the value of AutoEventWireup is equal to false</li>
<li>What is the meaning of XXX in the Inherits attribute?</li>
<li>I cannot find the definition of XXX in the auto-created file in ASP.NET 2008. Where is the XXX defined?</li>
</ol>
<p>Thank you</p>
| asp.net | [9] |
4,768,556 | 4,768,557 | copy and paste the file in swt | <p>I am having a zip file in my E:\temp\file.zip. Now I need to copy the whole zip file and paste it to my desktop and the original zip file should not be deleted. This should be done using java SWT lib.</p>
<pre><code>import java.io.*;
import javax.swing.*;
public class MovingFile {
public static void copyStreamToFile() throws IOException {
FileOutputStream foutOutput = null;
String oldDir = "F:/CAF_UPLOAD_04052011.TXT.zip";
System.out.println(oldDir);
String newDir = "F:/New/CAF_UPLOAD_04052011.TXT.zip.zip";
// name the file in destination File f = new File(oldDir);
f.renameTo(new File(newDir));
}
public static void main(String[] args) throws IOException {
copyStreamToFile();
}
}
</code></pre>
| java | [1] |
1,394,572 | 1,394,573 | Anonymous objects on the stack, in C++? | <p>I am working on a logging / tracing unit (and please <strong>don't</strong> point to existing ones, this is for the experience as much as for the result).</p>
<p>To get a run-time calling stack trace, the idea is to construct a <code>TraceObject</code> instance first thing a function is entered, which carries the information of the current class and function. Somewhat akin to:</p>
<pre><code>TraceObject to( "MyClass", "myClassFunction" );
</code></pre>
<p>The constructor of <code>TraceObject</code> pushes <code>this</code> on a per-thread stack, the destructor pops it again. The stack can thus be queried for the call stack.</p>
<p>I got this working to satisfaction. However, there is a small snitch: The object <code>to</code>. It will, by design, <em>never</em> be referred to by that name. Hence, it does not need to <em>have</em> a name, least of all one that might collide with any identifiers used by the client (or, in case of <code>_</code> prefix, the implementation).</p>
<p><strong>tl;dr</strong></p>
<p>Is it possible to create an <em>anonymous</em>, non-temporary object on the stack (i.e. one that will live until the function returns, but doesn't have an identifier), and if yes, how would it be done?</p>
| c++ | [6] |
71,152 | 71,153 | Accessing, and push_back values of a vector from a different class? | <p>I'm overall confused on how to access a vector, and add values to it from a different class.</p>
<p>I would like to add values into the vector (the vector is private) from a different class. I also want to access the vector in my main() and be able to print it out.</p>
<p>Can anyone give me an example of how this is done?</p>
<pre><code>Class A
{
//vector is here - it's a private vector
}
Class B
{
//add values to the vector here
}
main()
{
//access the vector here, and print out the values
}
</code></pre>
| c++ | [6] |
2,055,354 | 2,055,355 | Python 2.7 or Python 3 (for speed)? | <p>I've looked around for answers and much seems to be old or outdated. Has Python 3 been updated yet so that it's decently faster than Python 2.7 or am I still better off sticking with my workable code?</p>
| python | [7] |
5,556,709 | 5,556,710 | How to animate diagrams in android using seeker bar | <p>I am looking for a way to use a seeker bar as a slider to move lines up and down the screen so as to be able to create animated graphs.
At the moment I have got this far:</p>
<p>I have created an activity which uses main layout.
On this main layout is a seeker bar and a custom view called graph.
I have referred to the Graph class by using:</p>
<pre><code><com.mypackagename.Graph
Android:id=”@+id/graph”/>
</code></pre>
<p>I have created a corresponding Graph class which extends View and in it I have drawn a red horizontal line using:</p>
<pre><code>@Override public void onDraw(Canvas canvas){
paint = new Paint();
paint.setARGB(255, 255, 0, 0);
paint.setStrokeWidth(2);
paint.setStyle(Style.STROKE);
canvas.drawLine(0, 200, 200, 200, paint);
}
</code></pre>
<p>My problem is how can I get the seeker bar to update this line?</p>
<p>I have written code for the seeker bar as follows:</p>
<pre><code>my_seekerbar.setOnTouchListener(new SeekBar.OnTouchListener()
{
public boolean onTouch(View v, MotionEvent arg1)
{
View parent = (View)v.getParent();
SeekBar seekBar = (SeekBar)v;
int progress = seekBar.getProgress();
}
return false;
}
});
</code></pre>
<p>I am trying to use the value of progress to set the y-co-ordinate of my line.
I have been wrestling with this problem for a long time.
Am I on the wrong track?</p>
| android | [4] |
1,755,980 | 1,755,981 | How to execute python files separately as a python script? | <p>What I want to do is have a python script (that's a python IRC bot) that can run another python script in the background/separately.</p>
<p>I could do something like this:</p>
<pre><code>#irc codey stuff here...
if x == y:
os.system('s%\stuff.py') % path
</code></pre>
<p>But this would stop <strong>main.py</strong> and it then runs <strong>stuff.py</strong> (in 1 command prompt) which I don't want to do.<br>
So what I am trying to make this script do is when the IRC bot picks up a command via IRC, I want it to run stuff.py separately, like double clicking on <strong>stuff.py</strong> and having <strong>main.py</strong> and <strong>stuff.py</strong> running at the same time.</p>
<p>If there is a separate way of doing this in windows/linux, please, can you show both?</p>
| python | [7] |
2,936,588 | 2,936,589 | Android - WebView findall not working correctly on 4.0.3 | <p>I have a webview. Now when I use <code>WebView.findAll()</code> method to search text in the webview it is not highlighting the matching words.</p>
<p>It works fine in Android 2.2,3.2 but is not working in 4.0.3.</p>
<p>Do you have any ideas how I could implement this? I'd really appreciate your help.</p>
<pre><code>webView.findAll(findString);
try
{
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.setAccessible(true);
m.invoke(webView, true);
}
catch(Exception ignored){}
</code></pre>
| android | [4] |
623,217 | 623,218 | How to get an objects string and add this to a string array | <p>I have an <code>ArrayList</code> of my own class <code>Case</code>. The class case provides the method <code>getCaseNumber()</code> I want to add all of the cases casenumber to a <code>String[] caseNumber</code>. I've tried this</p>
<pre><code>public String[] getCaseNumberToTempList(ArrayList<Case> caseList) {
String[] objectCaseNumber = null;
for(int i = 0; i < caseList.size(); i++) {
objectCaseNumber[i] = caseList.get(i).getCaseNumber();
}
return objectCaseNumber;
}
</code></pre>
<p>But my compiler complaints about that the <code>objectCaseNumber</code> is null at the point insid the for-loop. How can I manage to complete this? </p>
| java | [1] |
3,691,516 | 3,691,517 | How to pass data back from Winform to tabpage | <pre><code> if (!existed_channel.Contains(channel_name))
{
if (x)
{
tabpagex.BackColor = Color.Ivory;
tabControl1.TabPages.Add(tabpagex);
client_chat c = new client_chat(channel_name, owner); //Here the client_chat is my Winform that do all the chatting thing.
c.TopLevel = false;
c.Visible = true;
c.BackColor = Color.Ivory;
c.FormBorderStyle = FormBorderStyle.None;
c.Dock = DockStyle.Fill;
tabControl1.TabPages[tab_index].Controls.Add(c); //Here i fill up the tabpage with client_chat winform
tab_index++; //Increment the index everytime i add an tabpage.
existed_channel.Add(channel_name); //Add the name of the page to an arraylist, to make sure everytime there is no duplicate page
}
}
</code></pre>
<p>As you can see, when i close one of my Winform(on the tabpage), i have to send back data and modify the tab_index.
I am able to close both Winform and tabpage, but struggling how to send the data back.
I know how to send back data from childForm to parentForm, but the situation here is little different.</p>
| c# | [0] |
3,289,822 | 3,289,823 | jquery form on success display message generate from server | <p>I have </p>
<pre><code><div id="infoMessage" class="infoMessage"><?php echo $message;?></div>
</code></pre>
<p>which the $message will generate from the server when POST.</p>
<p>How to I do if I wanted to display the infoMessage once the ajax success</p>
<pre><code> $.ajax({
type: "POST",
url: "the/form",
data: $(\'.target\').serialize(),
success: function() {
alert("done");
// how to show the infoMessage ?
}
});
</code></pre>
| jquery | [5] |
2,207,213 | 2,207,214 | iPhone Popup Confirmation | <p>What pattern or view do you use to get the confirmation popup like in Mail where you are prompted to Reply, Forward or Cancel?
<img src="http://i.stack.imgur.com/vSG6G.png" alt="alt text"></p>
| iphone | [8] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.