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,493,308
5,493,309
Trouble using onPause() method
<p>I have an activity.. when it is calls <code>onPause()</code> it starts a new activity.. Problem is when I lock screen of my phone..It calls the <code>onPause</code> which cause it to go back to the main activity but I want to stay in that activity.. Is there a way to fix this ?</p> <p>This is the code snippet if it helps.. </p> <pre><code>@Override protected void onPause() { super.onPause(); call_next_activity(call_next_act); } private void call_next_activity(Boolean call_next) { if (!call_next) return; Intent select_one; if (program_id) { select_one = new Intent("c.theworld.com.nikhil.MENU"); } else { select_one = new Intent("c.theworld.com.nikhil.CHAPTER"); Chapter.call_menu = true; } startActivity(select_one); } </code></pre>
android
[4]
1,909,193
1,909,194
Using regex to avoid if elifs
<p>I'm new to Python, which I'm using to do an ugly little put-this-tabular-data-into-a-db conversion. The program looks at the data, creates a table in MySQL, and then reads the data into the table. In this section, header row text is checked to make some decision about data typing. I had an idea that I could be clever and do this with a single regex rather than if/elifs. My solution works for this case at least, where I don't have to worry about multiple matches. What I'm asking is, is there any real merit to this approach in terms of efficiency?</p> <pre><code>def _typeMe(self, header_txt): # data typing colspecs = { 'id':'SMALLINT(10)', 'date':'DATE', 'comments':'TEXT(4000)', 'flag':'BIT(1)', 'def':'VARCHAR(255)' } # regex to match on header text e.g. 'Provisioner ID' r = re.search(re.compile('(ID$)|(Date)|(Comments$)|(FLAG$)', re.IGNORECASE), header_txt) checktype = lambda m: max(m.groups()).lower() if m else 'def' return colspecs[checktype(r)] </code></pre>
python
[7]
2,405,090
2,405,091
Android Frame Animation
<p>I would like to know if it is possible to remove one of the frames I added using addFrame in Android?</p> <p>Thanks</p> <p>Kelvin</p>
android
[4]
5,117,228
5,117,229
Proper reuse of ContactHeaderWidget
<p>I am trying to reuse the header layout for contact details display view.</p> <p>I was able to add the widget of ContactHeaderWidget to my XML file as it is in this <a href="http://android.git.kernel.org/?p=platform/packages/apps/Contacts.git;a=blob;f=res/layout-finger/contact_card_layout.xml;h=6e7056134a5167e7b7cf4981ca21f8e6f8059190;hb=HEAD" rel="nofollow">file</a> and it shows up empty when I run the apk.</p> <p><strong>But now how do I set the name of the contact, and the image of the contact?</strong></p> <p>I've tried the method in line 197 <a href="http://android.git.kernel.org/?p=platform/packages/apps/Contacts.git;a=blob;f=src/com/android/contacts/ViewContactActivity.java;h=ca3c08a4f010e9f6d7623c5eeda5f216f141d198;hb=HEAD" rel="nofollow">here</a> but I couldn't import the necessary files as that would be line 28, which is not available for me.</p> <pre><code>import com.android.internal.widget.ContactHeaderWidget; </code></pre>
android
[4]
561,127
561,128
Why is this method "undefined" in Firefox once the page has loaded?
<pre><code>"use strict"; Math.isNumber = function(number) { return (number &gt;= 0 || number &lt; 0); }; </code></pre> <p>I have placed the above in a clean HTML file within <code>&lt;script&gt;</code> tags within the <code>&lt;head&gt;</code>. Before the page has fully loaded, I can use <code>alert(Math.isNumber("blah"))</code> and I get a value. But once the page has loaded, typing <code>Math.isNumber</code> into Firefox's web console yields <code>undefined</code>. In Chrome, it returns the function I set above. Why?</p>
javascript
[3]
812,073
812,074
Random card generation
<p>I need to randomly generate three cards from array i have the array of 52 cards names from card1 to card52</p> <pre><code>String rank[]=new String[52]; for(int i=0;i&lt;rank.length;i++) { rank[i]= "card"+i; } </code></pre> <p>Now i need to select three cards from the array and it should not be repetable.</p> <p>can anybody help me. actually i m doing this bt cards are repeting. pls provide me the sollution.</p> <p>Thanks in Advance.</p>
java
[1]
4,690,362
4,690,363
Python: Get relative path from comparing two absolute paths
<p>Say, I have two absolute paths. I need to check if the location referring to by one of the paths is a descendant of the other. If true, I need to find out the relative path of the descendant from the ancestor. What's a good way to implement this in Python? Any library that I can benefit from? Thanks.</p>
python
[7]
3,433,667
3,433,668
Message sent using invalid number of digits. Please resend using 10 digit number or valid short code android 9230 in android
<p>I am creating application in which we reply to sender of the text message automatically from our android device. I had check that number has only digits not letters for validation but some times while sending message it gives me error as:</p> <p>Message sent using invalid number of digits. Please resend using 10 digit number or valid short code android</p> <p>like that how can i avoid number formatting in android. or is there another way avoid this error. If any one knows solution about this please let me know.</p> <p>Thank You. Vikram </p>
android
[4]
2,803,577
2,803,578
Create a function and assign its return to a variable
<p>Is there a one line way of doing this? Eg: </p> <pre><code>var myVare = function(params){ if(param.condition){ return 'a'; }else{ return 'b'; } }(param:{condition:'abc'}); console.log(myVare);//I would like it to be == to 'a' </code></pre>
javascript
[3]
467,115
467,116
Delete Remote file With @get_file_contents - PHP
<p>I have been trying to delete images from a remote server. I don't want to use a direct link because the server changes depending on the location of the file. I have code like this.</p> <pre><code>$photo["server"] = "http://img1.myserver.com"; $call = @file_get_contents( $photo["server"]."/delete.php?pho_id=".$pho_id."&amp;pag_id=".$pag_id ); </code></pre> <p>Is there some reason why this wont work? I send the vars and grab them in the php file. It works fine with a direct browser call but I want to do it from the script. Any ideas why this wont execute the script? And fopen is enabled on my server.</p>
php
[2]
4,245,123
4,245,124
Is there any reason to use this->
<p>I programmed in C++ for many years and I still have doubt about one thing. In many places in other people code I see something like:</p> <pre><code>void Classx::memberfunction() { this-&gt;doSomething(); } </code></pre> <p>If I need to import/use that code, I simply remove the <strong>this-></strong> part, and I have never seen anything broken or having some side-effects.</p> <pre><code>void Classx::memberfunction() { doSomething(); } </code></pre> <p>So, do you know of any reason to use such construct?</p> <p>EDIT: Please note that I'm talking about member functions here, not variables. I understand it can be used when you want to make a distinction between a member variable and function parameter.</p> <p>EDIT: apparent duplicate: <a href="http://stackoverflow.com/questions/333291/are-there-any-reasons-not-to-use-this-self-me">http://stackoverflow.com/questions/333291/are-there-any-reasons-not-to-use-this-self-me</a></p>
c++
[6]
1,527,265
1,527,266
thumbs.db messing up my upload routine
<p>I'm getting the following error while uploading a zip archive.</p> <pre><code>Warning: ZipArchive::extractTo(C:\xampplite\htdocs\testsite/wp-content/themes/mytheme//styles\mytheme/Thumbs.db) [ziparchive.extractto]: failed to open stream: Permission denied in C:\xampplite\htdocs\testsite\wp-content\themes\mythem\uploader.php on line 17 </code></pre> <p>The thing I can't quite figure is that I don't see a thumbs.db file in either the zip archive or the destination folder that was created (the upload still processes, I just get these errors).</p> <p>The function is below, line 17 is commented...</p> <pre><code>function openZip($file_to_open) { global $target; $zip = new ZipArchive(); $x = $zip-&gt;open($file_to_open); if($x === true) { $zip-&gt;extractTo($target); //this is line 17 $zip-&gt;close(); unlink($file_to_open); } else { die("There was a problem. Please try again!"); } } </code></pre>
php
[2]
5,465,828
5,465,829
Can't convert Javascript array to object properly
<p>I have been struggling with this problem the entire day. I feel like it's super solvable, and I'm not sure where I'm going wrong. Each time I go to post this, I feel like I come up with a different solution that doesn't end up working.</p> <p>I'm looking to do the following:</p> <pre><code>var someObj = {}; // @param key - string - in the form of "foo-bar-baz" or "foo-bar". // (i won't know the number of segments ahead of time.) // @param value - string - standard, don't need to act on it function buildObject( key, value ) { var allKeys = key.split("-"); // do stuff here to build someObj } </code></pre> <p>Essentially the key will always take the format of key-key-key where i want to build <code>someObj[key1][key2][key3] = value</code>.</p> <p><a href="http://jsfiddle.net/BMJjW/4/" rel="nofollow">This JSFiddle</a> contains a longer example with a sample layout of the data structure I want to walk away with.</p> <p>Thanks so much for any help you can give.</p>
javascript
[3]
2,781,792
2,781,793
Use jquery to display div based on form value selected
<p>I want to display a div if a certain radio button in a form is selected, but hide that div if any other radio button in the form is selected, using jquery.</p> <p>This is the code I have that isn't working:</p> <pre><code>$("select").change(function(){ if($("#radio1").is(":selected")){ $("#grid_9 omega").slideDown("slow"); } else { $("#grid_9 omega").slideUp("slow"); } }); </code></pre> <p>where the id for the radio button I want to have display the div "gid_9 omega" is "radio1".</p> <p>Thanks for your help!</p>
jquery
[5]
812,490
812,491
What are the wise and allowed ways to add advertisement to iPhone App?
<p>I will be publishing an App in a few days. Initially I don't want to add advertisements, but can change my mind anytime, so I've thought this. Add a WebView to application and set its image to a dynamic web content. If no ads; I will display a simple logo, but when ads are available, replace the content with them. So there will be no modification to iPhone compiled binary.</p> <p>Do you think it is allowed by Apple, and a good approach?</p>
iphone
[8]
871,293
871,294
How to reboot android device
<p>How to shutdown and restart android device in my application. please give me a suggestion if is possible or not. I search a lot but no code work for me.</p>
android
[4]
2,473,151
2,473,152
javascript odd syntax: c.name=i+ +new Date;
<p>colorbox v1.3.15 from colorpowered.com has this javascript in it's minified code:</p> <pre><code>c.name=i+ +new Date; </code></pre> <p>this seems to run perfectly, should it?</p>
javascript
[3]
4,022,023
4,022,024
Does checking against null for 'success' count as "Double use of variables"?
<p>I have read that a variable should never do more than one thing. Overloading a variable to do more than one thing is bad. </p> <p>Because of that I end up writing code like this: (With the <code>customerFound</code> variable)</p> <pre><code>bool customerFound = false; Customer foundCustomer = null; if (currentCustomer.IsLoaded) { if (customerIDToFind = currentCustomer.ID) { foundCustomer = currentCustomer; customerFound = true; } } else { foreach (Customer customer in allCustomers) { if (customerIDToFind = customer.ID) { foundCustomer = customer; customerFound = true; } } } if (customerFound) { // Do something } </code></pre> <p>But deep down inside, I sometimes want to write my code like this: (Without the <code>customerFound</code> variable)</p> <pre><code>Customer foundCustomer = null; if (currentCustomer.IsLoaded) { if (customerIDToFind = currentCustomer.ID) { foundCustomer = currentCustomer; } } else { foreach (Customer customer in allCustomers) { if (customerIDToFind = customer.ID) { foundCustomer = customer; } } } if (foundCustomer != null) { // Do something } </code></pre> <p>Does this secret desires make me an evil programmer?</p> <p>(i.e. is the second case really bad coding practice?)</p>
c#
[0]
3,616,104
3,616,105
query error on content provider user dictionary
<pre><code> String[] mProjection = { // UserDictionary.Words._ID, // Contract class constant for the _ID column name UserDictionary.Words.WORD, // Contract class constant for the word column name UserDictionary.Words.LOCALE // Contract class constant for the locale column name }; searchvalue = (EditText) findViewById(R.id.editText); mSelectionClause = UserDictionary.Words.WORD + " LIKE ?"; mSelectionArgs[0] = searchvalue.getText().toString(); Cursor mCursor = getContentResolver().query( UserDictionary.Words.CONTENT_URI, mProjection, mSelectionClause, mSelectionArgs, null); </code></pre> <p>Any ideas why I am getting bind or column index out of range on this query?</p>
android
[4]
262,209
262,210
how to change php encoding in database?
<p>I have got mysql database in utf8_general_ci and php page with utf-8 charset. Why in php page i have got some text with bad encoding (which takes from data)? <a href="http://likebox.ru/fbtn/" rel="nofollow">http://likebox.ru/fbtn/</a></p>
php
[2]
5,398,199
5,398,200
Which is the best way to fetch/retrieve data from server in android? Is it Xml or Json
<p>I am trying to upload &amp; retrieve data with the server.</p> <p>Which is the best way to retrieve data using xml or json ?</p> <p>Thank you</p>
android
[4]
2,903,823
2,903,824
Event bubbling or failed bubbling on click event in javascript
<p>My basic issue is that I have a click event that i have attach to my container, i am trying to delgate that click event just to the buttons in that container. All of that is easy, the issue i have is the event.target in webkit is hitting the spans in the button instead of the button its self. How do i stop the click event from bubbling down wards to the span in the button. I want my targ to be the butto. here is a quick demo showing the issue <a href="http://jsfiddle.net/jVeMw/" rel="nofollow">fiddle of the issue</a></p>
javascript
[3]
5,941,505
5,941,506
Use different name in asp:hiddenfield
<p>I have a for which is built within an ASP.net usercontrol. This form is then used within a CMS as part of integration with a merchant gateway. The gateway requires that a number of hiddenfields be passed in which is fine in the main however one of these needs to be called Profile. The CMS I am using also defines a global variable called Profile and as such when I try and add a hidden field with this ID I get errors. </p> <p>Is there a way of setting the 'name' property to Profile, and the ID to something different?</p>
asp.net
[9]
5,638,910
5,638,911
In case of an Atomic classes, how does Java manage the call by value?
<p>I am currently working on atomic classes and I am unable to track whether it is "call by value" or "call by reference". I understand that Java does not allow call by reference and that it is only and only call by value. But in case of atomic classes, it seems to be call by reference. Can you share your thoughts with me?</p>
java
[1]
4,826,113
4,826,114
C++, please explain Classes to a Python user?
<p>I'm trying to learn C++, Thanks to this article I find many similarity between C++ and Python and Javascript: <a href="http://www.cse.msu.edu/~cse231/python2Cpp.html" rel="nofollow">http://www.cse.msu.edu/~cse231/python2Cpp.html</a></p> <p>But I can't understand C++ Classes at all, they looks like Javascript prototypes, but not that easy.</p> <p>For example:</p> <pre><code>//CLxLogMessage defined in header class myLOG: public CLxLogMessage{ public: virtual const char * GetFormat (){ return "Wavefront Object"; } void Error (const std::string &amp;msg){ CLxLogMessage::Error (msg.c_str ()); } void Info (const std::string &amp;msg){ CLxLogMessage::Info (msg.c_str ()); } private: std::string authoringTool; }; </code></pre> <p>Question: What is this Public/Private stuff at all!?</p> <p>Edit: To be honest, I more enjoy C++ than Python, because I can learn truth meaning of everything, not simple automated commands, for example I preferred to use "int X" rather than "X" alone.</p> <p>Thanks</p>
c++
[6]
2,473,480
2,473,481
AlarmManager and WakeLock example
<p>I try this wakefull example:https://github.com/commonsguy/cw-omnibus/tree/master/AlarmManager/Wakeful</p> <p>but I have few questions.</p> <p>Do I need <code>&lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;</code>? becouse intent is always null as I tested.</p> <p>And inScheduledService is example: </p> <pre><code>@Override protected void doWakefulWork(Intent intent) { Log.d(getClass().getSimpleName(), "I ran!"); } </code></pre> <p>but this method is never fired.</p> <p>in WakefulintentService is this method which is also never fired:</p> <pre><code> @Override final protected void onHandleIntent(Intent intent) { try { doWakefulWork(intent); } finally { PowerManager.WakeLock lock = getLock(this.getApplicationContext()); if (lock.isHeld()) { lock.release(); } } } </code></pre> <p>What to change that i will get <code>I ran</code> as output?</p>
android
[4]
5,084,384
5,084,385
set datasource for combobox
<p>how to set datasoure of combobox by jquery</p> <p><code>data={"a","b","c","d"}</code>. and <code>ComboBox.datasource=data;</code>==>by jquery</p>
jquery
[5]
4,418,518
4,418,519
SensorEvent.timestamp to absolute (utc) timestamp?
<p>I question myself what the timestamp in SensorEvent.timestamp means. Numbers like 3548712982000 occur. It is not plausible for anything: nanoseconds/milliseconds since 1970 etc. Is this maybe some overflow error? It seems as it is different on different devices at the same time!!!</p>
android
[4]
2,400,093
2,400,094
Writing 4 arguments with the write function to a file
<p>I would like to write this to a file <code>f.write("add unit at-wc 0 0 0 %s" % x ,y, z, "0.000 0.000 0.000 ")</code> but when I do that I get an error saying <code>function takes exactly 1 argument (4 given).</code></p>
python
[7]
4,568,070
4,568,071
Deep text file processing
<p>When dealing with text files in java, is there any way to achieve this results:</p> <p>Assuming that my text file contains the data below(User number, first name, last name, username, user type)</p> <pre><code>Num010101 James Jackson JJ123 Normal_User </code></pre> <p>Now I have another file that contains login info (user, password)</p> <pre><code>JJ123 abc </code></pre> <p>When the the user logs in to the system I'd like to check the first file using .contains(username), now if the username is found within a line then I want to print the first and last name which are separated by a tab character. </p> <p>I prefer not to use mapping here I want to print the line without the first, third and forth value.</p> <p>In c++ I normally do it using the map library or iterator (for example &lt; First_value, Second_Value > and i->first , i->second) but since I'm new to java I am kind of stuck.</p> <p>I'd like to skip the first, third and forth value in printing, that is what I am looking for not mapping.</p>
java
[1]
2,865,047
2,865,048
capturing jquery Radiobutton list selected values
<p>I am trying to get value of selected item using JQuery in a radio button list. I have 2 radio button lists and I am getting value from 1st radio button list with out any issues. But When I select 2nd dropdown, It shows the same first dropdown result in alert.</p> <p>Please suggest </p> <pre><code> $("#&lt;%=RBLTechnology.ClientID%&gt; input").change(function () { var ProjectArchitecture = $("input[@name=RBLTechnology]:checked").val(); alert("Selected Project Architecture Layer is " + ProjectArchitecture ); }); $("#&lt;%=RBLforService.ClientID%&gt; input").change(function () { var ServiceLayer = $("input[@name=RBLforService]:checked").val(); alert("Selected Service Layer is " + ServiceLayer); }); &lt;asp:RadioButtonList ID="RBLTechnology" runat="server" RepeatDirection="Horizontal"&gt; &lt;asp:ListItem Selected="True" Value="ASP.NET webforms"&gt;ASP.NET webforms&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="ASP.NET MVC"&gt;ASP.NET MVC&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="SilverLight"&gt;SilverLight&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="WPF"&gt;WPF&lt;/asp:ListItem&gt; &lt;/asp:RadioButtonList&gt; &lt;asp:RadioButtonList ID="RBLforService" runat="server" RepeatDirection="Horizontal"&gt; &lt;asp:ListItem Selected="True" Value="Class Library Service"&gt;Class Library Service&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="Web Service"&gt;Web Service&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="WCF Service"&gt;WCF Service&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="WCF RIA Service"&gt;WCF RIA Service&lt;/asp:ListItem&gt; &lt;/asp:RadioButtonList&gt; </code></pre>
jquery
[5]
124,550
124,551
How to create named lock in java?
<p><strong> We can achive it in c# as follows- </strong></p> <pre> void readFile(File file) { Mutex mutexForFile = null; bool mutexCreateFlag; // Return true/false based on whether mutext is already exist or it is created as part of current call mutexForFile = new Mutex(false, file.FullName.GetHashCode().ToString(), out mutexCreateFlag); if (!mutexCreateFlag) throw new Exception("File UsedByOtherProcess"); else { mutexForFile .WaitOne(); // synchronized access to resource ProcessFile(fileInfo: file); mutexForFile .ReleaseMutex(); } } </pre> <p>Don't think about relevance of the code, just for example i have given</p> <p>will somthing like this be possible in Java?</p>
java
[1]
4,426,077
4,426,078
php script to generate checksum from md5
<p>In order to calculate the checksum i need following things. these parameters are concatenated in a constant (no spaces) string made up of the values of the following parameters in the exact order listed below: o Secret Key o Merchant id o Currency o Total amount o Item list (item_name_1, Item_amount_1, item_quantity_1 to item_name_N, Item_amount_N, item_quantity_N) o Timestamp</p> <p>e.g In that case the string befor hash will be: pLAZdfhdfdNh57583USD69.99Tier2 item69.9912010-06-14.14:34:33</p> <p>And using the MD5 hash function the result is: ghvsaf764t3w784tbjkegbjhdbgf</p> <p>i want to know how can i create a php script that will call md5 hash function with the inputs given above and based on that it will generate the hash function value that will be the checksum value for my coding..</p>
php
[2]
655,176
655,177
JavaScript API | JS API
<p>If you want to search the library API of the following, you go to their respective links:</p> <p><a href="http://api.jquery.com/" rel="nofollow">Jquery</a></p> <p><a href="http://nodejs.org/docs/latest/api/" rel="nofollow">nodejs</a></p> <p><a href="http://dev.mysql.com/doc/refman/5.0/en/c.html" rel="nofollow">mySQL (C)</a></p> <p>Where is <strong>THE</strong> API for Javascript itself?</p>
javascript
[3]
4,255,340
4,255,341
Global Class to access Variables
<p>We like to have a global instance of a class and would like to access across the application (in different forms etc)</p> <p>What are the different possiblities? (other than static class).</p>
c#
[0]
3,658,813
3,658,814
Why? about PHP array and php foreach loop
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2645499/why-does-php-overwrite-values-when-i-iterate-through-this-array-twice-by-referen">Why does PHP overwrite values when I iterate through this array twice (by reference, by value)</a> </p> </blockquote> <pre><code>$arr=array('a','b','c'); foreach($arr as &amp;$v){ echo $v; } foreach($arr as $v){ echo $v; } </code></pre> <p>the result is abcabb, not abcabc, why?</p>
php
[2]
2,001,544
2,001,545
Microsoft Expression SDK
<p>I'm converting mp3 to wma with expression encoder sdk 4 with the code below</p> <p>A wma file is produced but it is missing the thumbnail / image / cover from the mp3 file.</p> <pre><code>using (var job = new Job()) { var mediaItem = new MediaItem(input.FullName) { OutputFileName = outputFileName, OutputFormat = { AudioProfile = { Codec = AudioCodec.Wma, Bitrate = BitRate ?? BitRate, Channels = 1 } } }; job.MediaItems.Add(mediaItem); job.OutputDirectory = OutputDirectory; job.CreateSubfolder = false; job.Encode(); } </code></pre> <p>I have tried the following:</p> <p>1)</p> <pre><code>mediaItem.MarkerThumbnailCodec = ImageFormat.Jpeg; mediaItem.MarkerThumbnailJpegCompression = 0; mediaItem.MarkerThumbnailSize = new Size(50, 50); </code></pre> <p>2)</p> <pre><code>mediaItem.ThumbnailCodec = ImageFormat.Jpeg; mediaItem.ThumbnailEmbed = true; mediaItem.ThumbnailJpegCompression = 50; mediaItem.ThumbnailMode = ThumbnailMode.BestFrame; mediaItem.ThumbnailSize = new Size(50, 50); mediaItem.ThumbnailTime = TimeSpan.FromSeconds(0); </code></pre> <p>3)</p> <pre><code>mediaItem.OverlayFileName = @"c:\Chrysanthemum.jpg"; mediaItem.OverlayStartTime = TimeSpan.FromSeconds(0); </code></pre> <p>..but it doesn't help.</p> <p>Please help me :)</p>
c#
[0]
3,595,471
3,595,472
How to extract the text from PDF document
<p>I have one pdf document which has links. I need to get link title.</p> <p>Please help me to solve this issue.</p> <p>Thanks in advance.</p> <p>Sow</p>
c#
[0]
3,760,052
3,760,053
converting decimal to int in c#
<p>why percentage returns 0 when rate = 0.085 for example ?</p> <pre><code>int percentage = (int)rate*100; </code></pre>
c#
[0]
5,010,733
5,010,734
Argument exception for Image.FromStream
<p>So I have a byte array "sorted" that holds grayscale values and is 14080 bytes long. I'm trying to render this as an image so I thought it would be a good idea to try to convert it to an image object and then use the save function for images to save the image to a path on my computer. However, every time I run it I get an argument exception error. Before I was catching the error it said my parameter was invalid, but I don't understand how that's the case because I'm pretty sure my syntax is right and I filled my "sorted" byte array in the program so I don't get how it could be invalid... Any help would be appreciated- Plus I haven't even gotten to my save method yet because it keeps on breaking so I don't know if this works at all!</p> <pre><code>try { MemoryStream ms = new MemoryStream(sorted); Image returnImage = Image.FromStream(ms); returnImage.Save("C:/Users/ttannin/downloads/silouete.jpg"); } catch (ArgumentException aex) { throw new Exception("Something is broken...", aex); } </code></pre> <p>PS. I was trying to mimic an example found <a href="http://www.codeproject.com/Articles/15460/C-Image-to-Byte-Array-and-Byte-Array-to-Image-Conv" rel="nofollow">here</a>.</p>
c#
[0]
2,204,762
2,204,763
How to change programmatically a global setting like 'haptic feedback'?
<p>How can I change programmatically a global setting like 'haptic feedback'?<br> (Manually you can change this setting in 'Sound &amp; Display Settings')</p> <p>Changing e.g. the airplane mode can be done with the following code:</p> <pre><code>private void setAirplaneMode(boolean bOn) { Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, bOn ? 1 : 0); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", bOn ? 1 : 0); sendBroadcast(intent); } </code></pre> <p>However, for 'haptic feedback' this does not work because I don't find a corresponding intent.</p> <p>Simply</p> <pre><code>private void setHapticFeedbackMode(boolean bOn) { Settings.System.putInt(getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, bOn ? 1 : 0); } </code></pre> <p>does not work (I guess a broadcast of an intent is really necessary).</p> <p>I am not interested in things like <code>setHapticFeedbackEnabled</code>, because in that way you are only changing the way how the calling app/view is handling haptic feedback. I am looking for a way to change the global setting. (Like if you were checking/unchecking the checkbox in 'Sound &amp; Display Settings' manually.)</p>
android
[4]
4,771,106
4,771,107
selecting a select list in jquery
<p>There has to be something really simple that I am overlooking, but for some reason I cannot find any information about this and it keeps coming up so..</p> <p>I am trying to select a select element in jquery. Right now I don't care about it's options, I just want the select element. If I have the following element:</p> <pre><code>&lt;select id="testSelect"&gt;&lt;option&gt;1&lt;/option&gt;&lt;/select&gt; </code></pre> <p>and I use jquery to select it:</p> <pre><code>var selectElement = $("#testSelect"); </code></pre> <p>I get an array of all the options in the select list, but not the select element itself. What am I missing?</p>
jquery
[5]
4,440,162
4,440,163
jQuery adding a function to a link question
<p>I have a dynamically created table which in the last <code>&lt;td&gt;</code> there is a hidden <code>&lt;div&gt;</code> which is shown when the user hovers over a link in the <code>&lt;td&gt;</code>. That all works fine but there are several links in the div that I want to fire a function based on the id of the link concat'd with an string captured from a <code>&lt;td&gt;</code> from the parent row. I can capture the the variables I need from the id and <code>&lt;td&gt;</code> but something is wrong with the click function I have created. </p> <p>I monitored the function in FireBug and the function appears to be firing on all of the links instead of the one that is clicked. Here is my working code:</p> <pre><code>function fixLink() { $('a.batchMatchLink').click( function() { var r = $(this).parent().parent().parent().parent().parent(); var x = $(this).attr("id"); var a = $(r).find('td:nth-child(6)').text(); var st = x + "." + a; fireLink(st); } ); } function fireLink(st) { $.ajax({ type: "POST", url: "AjaxWcf.svc/MatchBatch", contentType: "application/json; charset=utf-8", data: st, dataType: "json", success: function(msg) { alert("Entry has been updated"); }, error: AjaxFailed }); </code></pre> <p>Why are all of the links firing?</p> <p>Thanks!!!</p>
jquery
[5]
4,011,653
4,011,654
append url with a session id jquery
<p>I have a static session ID i'm using and need to add it to a url when clicked, but can't seem to get it right. If you go to <a href="http://www.mysite.com/test.php" rel="nofollow">http://www.mysite.com/test.php</a> you get redirected, the session id XYX needs to be added, so the correct url to hit the page would be <a href="http://www.mysite.com/test.php?sessionid=XYX" rel="nofollow">http://www.mysite.com/test.php?sessionid=XYX</a></p> <pre><code>&lt;a href="http://www.mysite.com/test.php" class="foo"&gt;link here&lt;/a&gt; $('.foo').click(function(){ (this).append(?sessionid=XYX');' }); </code></pre> <p>I know this is wrong, all documentation Ive found is much more complex than my needs. thanks!</p>
jquery
[5]
6,010,363
6,010,364
Check if Activity is running from Service
<p>How can a Service check if one of it's application's Activity is running in foreground?</p>
android
[4]
1,059,952
1,059,953
reading specific line in a text file
<p>I have a text file that I am reading from it and writing to it using c++. the file is like a table that has 4 fields: id,title,year,price. something like this:</p> <p>1;c++ how to program;1990;50$</p> <p>2;java how to program;1996;70$</p> <p>the id is entered at the console, and then I have to search for this id in the text file and displays all the record of this id. further more, the user should be able to update a specific line in the text file. can any one help me please ? Thanks</p>
c++
[6]
3,461,650
3,461,651
Spacing Between String and Hiding String
<p>I have tried everything now what i need to do is place a space between a $results</p> <pre><code> echo "&lt;p&gt;&lt;h3&gt;".$results['cname'].$results['csurname']."&lt;/h3&gt;" .$results['msisdn']."&lt;/p&gt;" </code></pre> <p>Betweeb cname and csurnname I need a spacing, Also i need to hide the msisdn not to display on the screen but it is required to work my page</p> <p>Any suggestions would be greatly appreciated</p>
php
[2]
2,201,957
2,201,958
Android app signing mechanism
<p>To prevent frauds I have to verify server side, that application connecting to my server is not a fake. I was wondering If I can use built in android signing mechanism? Maybe there is some kind of <em>unique</em> (different for each device) magic number that I can verify on each request?</p> <p>Thank you for any suggestions.</p> <p>m.</p>
android
[4]
2,654,221
2,654,222
Hiding elements with javascript
<p>On button click, I want to hide the div. How do i do it?</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;/head&gt; &lt;script language="javascript" type="text/javascript"&gt; function button() { var a = document.getElementById('approve'); document.getElementById('p').innerHTML= 'Fred Flinstone'; } &lt;/script&gt; &lt;body&gt; &lt;div id="hide"&gt; &lt;form&gt; &lt;p id="p"&gt;heya&lt;/p&gt; &lt;input type="button" id='approve' value="approve" onclick="button()"/&gt; &lt;input type="button" id="reject" value="reject"/&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>SORRY FOR ASKING AGAIN...BUT COULDN'T FIND A BETTER METHOD. THANKS</p>
javascript
[3]
1,566,211
1,566,212
C++ -- Which one is supposed to use "new Car" or "new Car()"?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/620137/do-the-parentheses-after-the-type-name-make-a-difference-with-new">Do the parentheses after the type name make a difference with new?</a> </p> </blockquote> <p>Hello all,</p> <pre><code>class Car { public: Car() : m_iPrice(0) {} Car(int iPrice) : m_iPrice(iPrice) {} private: int m_iPrice; }; int _tmain(int argc, _TCHAR* argv[]) { Car car1; // Line 1 Car car2(); // Line 2, this statement declares a function instead. Car* pCar = new Car; // Line 3 Car* pCar2 = new Car(); // Line 4 return 0; } </code></pre> <p>Here is my question:</p> <p>When we define an object of Car, we should use Line 1 rather than Line 2. When we new an object, both Line 3 and Line 4 can pass the compiler of VC8.0. However, what is the better way Line 3 or Line 4? Or, Line 3 is equal to Line 4.</p> <p>Thank you</p>
c++
[6]
3,335,337
3,335,338
Can a class instantiate another class? (PHP)
<p>I tried this and I get an error when I try to instantiate class "first" inside of class "second".</p> <p>The commented sections inside of class "second" cause errors.</p> <pre><code>class first { public $a; function __construct() { $this-&gt;a = 'a'; } } class second { //$fst = new first(); //public showfirst() { //$firsta = $this-&gt;first-&gt;a; // echo "Here is first \$a: " . $firsta; //} } </code></pre> <p>EDIT:</p> <p>This results in a server error even though all I have in class "second" is the instantiation of class "first".</p> <pre><code>class second { $fst = new first(); //public showfirsta() { // $firsta = $this-&gt;fst-&gt;a; // echo "Here is first \$a: " . $firsta; //} } </code></pre>
php
[2]
674,931
674,932
How to get Activity's content view?
<p>Tell me, what method should I call to get know if Activity has it's contentView, I mean method <strong>setContentView()</strong> has been done?</p>
android
[4]
2,925,223
2,925,224
how to declare variables in class?
<p>I have following code:</p> <pre><code>class one { public: typedef int (*funPtr) (void); one() { // here I'm using map variable which is private. } ~one(){} private: typedef map&lt;int, funPtr&gt; mMap; mMap mapVar; }; </code></pre> <p>In this case class constructor gives that error that map is not declared. Can anyone help me?</p>
c++
[6]
4,949,518
4,949,519
Is this a safe way to reference objects in JavaScript?
<p>If I were to define two objects myDataStore and myDrawer something like this:</p> <pre><code>var myDataStore = function(myObjectRef) { this.myInternalObject = myObjectRef; }; var myDrawer = function(myObjRef) { this.myInternalObject = myObjectRef; }; </code></pre> <p>And if I were to create an object like so:</p> <p>[[EDIT - Adjusted Object Creation to Ensure 'this' is being mapped to myObject, not the global window object]]</p> <pre><code>(function(){ var myObject = window.myObject = function(){ this.dataStore = new myDataStore(this); this.drawer = new myDrawer(this); } })(); </code></pre> <p>Then myObject.dataStore.myInternalObject, and myObject.drawer.myInternalObject, would simply be pointers back to the original 'myObject' - not taking up any additional memory in the browser. Yes?</p> <p>I am interested in implementing techniques like this - as it makes it easy for objects to communicate with each other.</p>
javascript
[3]
1,538,441
1,538,442
How to make histogram with python?
<p>I have some difficulties to solve this problem :<br/> Write a function word_graph that takes three arguments -(1) <strong>in_grame</strong> sptipulating thr name of a pickle file containing an index of descriptions, (2)<strong>gr_frm</strong> stipulating a file name on which to store the output graph and (3) <strong>wo_r</strong> stipulating a word to generate the graph for and generates a histogram of word frequency for <strong>wo_r</strong> and <strong>in_grame</strong>. </p>
python
[7]
5,715,894
5,715,895
Can an external Javascript file be called and executed depending on a conditional?
<p>I know that I can run an external Javascript file from within HTML with the following syntax:</p> <pre><code>&lt;script type="text/javascript" src="http://somesite.com/location/of/javascript.js"&gt; &lt;/script&gt; </code></pre> <p>This will result in <code>http://somesite.com/location/of/javascript.js</code> being run the moment the browser reads that line of the HTML.</p> <p>But is there a way I can run an external Javascript file from within Javascript? Something like:</p> <pre><code>if (x == 1) { run this! -&gt; http://somesite.com/location/of/javascript.js; } </code></pre> <p>Obviously that's not valid code. But I can't find any example of what might be the right way to do this (if it exists), because all the help text I find with Google searches tell me how to run Javascript from within HTML</p> <p>I know that I can include a Javascript file and then call functions within it. However, in this situation, I do not have any control over <code>http://somesite.com/location/of/javascript.js</code>, and it is designed to execute the moment it is called. I can't change how it works, so I need to figure out how to call it at the right time in the right way.</p> <p>Is there a way I can get it to be called and executed immediately depending on a conditional statement?</p>
javascript
[3]
917,450
917,451
Passing a Session.Item to a MySQL query
<p>I have a aspx web page that has a session variable:</p> <pre><code>Dim UserName As String = CType(Session.Item("UserName"), String) </code></pre> <p>I am attempting to include this variable in the <code>MySQL</code> query of a <code>SqldataSource</code> for a Databound <code>GridView</code> control:</p> <pre><code>Dim Sql As String = "SELECT DeviceDescription, DeviceType, DeviceID FROM validate WHERE ClientID='" &amp; UserName &amp; "'" </code></pre> <p>However, this does not work.</p> <p>How do you pass/include this <code>session</code> variable in the <code>DataSource</code> of the <code>GridView</code>?</p>
asp.net
[9]
2,030,851
2,030,852
jQuery after 4 img add some tag
<p>I have list of pictures and i want after every 4 pictures add li tag. some like this.</p> <p>I have this.</p> <pre><code>&lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; </code></pre> <p>that looks like this</p> <pre><code>&lt;li&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;/li&gt; &lt;li&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;img src="#" /&gt; &lt;/li&gt; </code></pre> <p>it may be possible !? thanks anyway.</p>
jquery
[5]
5,941,966
5,941,967
how to create multi choice list view with search box in android
<p>I m having a list of around more than 100 items that i m building a multi choice list, out of which user can select as many items he need, I created the list view with multi choice selection but scrolling the 100 items is too complex for user so is there any way to put the search box at the top of list view so upon typing the text in search box user will see only related items and can make a multi choice selection out of that</p> <p>any help is appreciated</p>
android
[4]
3,105,823
3,105,824
Launch android app on screen unlock
<p>I want to build a lock screen replacement application. Is there any way to create a listener/service that would launch my app whenever the user wakes up/unlocks the screen? </p>
android
[4]
3,986,354
3,986,355
Python Program, while loop not executing?
<pre><code>Names=[0,1,2,3,4] Names[1]=='Ben' Names[2]=='Thor' Names[3]=='Zoe' Names[4]=='Katie' Max=4 Current=1 Found=False PlayerName=input('What player are you looking for?') while Found==False and Current==Max: if Names[Current]==PlayerName: Found=True else: Current+=1 if Found==True: print('Yes, they have a top score') else: print('No, they do not have a top score') </code></pre> <p>This is the program. When any of the 4 names at the top are entered, the program should print, 'Yes, they have a top score', but when anything else is entered it should print,'No, they do not have a top score'.</p> <p>However whatever name is entered it returns the 'No, they do not have a top score' message. I think it may have something to do with the loop but not sure what. </p>
python
[7]
2,709,229
2,709,230
jQuery. Prepend with fadeIn (error)
<p>I've used code from here <a href="http://stackoverflow.com/questions/1906066/jquery-prepend-fadein">jquery prepend + fadeIn</a></p> <p>Without <code>fadeIn</code> it works</p> <pre><code>function updateResult(data) { $('#test').prepend( html ); } </code></pre> <p>But with <code>fadeIn</code> works only when data contains one <code>div</code> tag, </p> <pre><code>$('#test').prepend( $(html).hide().fadeIn('slow') ); </code></pre> <p>otherwise FireFox returns error </p> <pre><code>uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://code.jquery.com/jquery-latest.min.js :: &lt;TOP_LEVEL&gt; :: line 16" data: no] </code></pre> <p>How it possible rewrite this code?</p> <p><strong>Upd.</strong> In my situation I've solved it this way </p> <pre><code>data = data.replace(/(?:(?:\r\n|\r|\n)\s*)/gi, ''); $(data).hide().prependTo('#test').fadeIn('slow'); </code></pre> <p>After removing line breaks works as should</p>
jquery
[5]
1,626,474
1,626,475
php login script error
<p>I have this login script working just fine on one server but not on other and coudn't figure out why.</p> <pre><code>include_once 'include/processes.php'; $Login_Process = new Login_Process; $Login_Process-&gt;check_status($_SERVER['SCRIPT_NAME']); </code></pre> <p>and the third line won't display the server status, the code display on my web page, and didn't go to main page. any idea may cause the issue.</p> <p>thanks.</p>
php
[2]
4,968,946
4,968,947
OutOfMemoryError: bitmap size exceeds VM budget (Convert Drawable to Bitmap)
<p>I have out of memory error when i am trying to convert drawable in to Bitmap images. I have past my code and stack trace if its possible plz help.</p> <pre><code>public static Bitmap convertDrawableToBitmap(Drawable dwb, int width, int height){ if (dwb == null || width == 0 || height == 0) return null; Bitmap bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888); //line 23 Canvas canvas = new Canvas(bmp); dwb.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); dwb.draw(canvas); return bmp; } //--------------- va.lang.OutOfMemoryError: bitmap size exceeds VM budget 1at android.graphics.Bitmap.nativeCreate(Native Method) 2at android.graphics.Bitmap.createBitmap(Bitmap.java:477) 3at com.app.downloadmanager.utils.DrawableBitmapUtils.convertDrawableToBitmap(DrawableBitmapUtils.java:23) </code></pre>
android
[4]
4,219,044
4,219,045
How to implement double tab for surface view in android
<p>can anybody tell How to implement double tab for surface view in android using gesture detector can anybody provide code</p> <p>Thanks</p>
android
[4]
1,197,178
1,197,179
Issue with SlidingDrawer
<p>I have a layout with 2 components: a <code>SlidingDrawer</code> which uses a Button and a <code>LinearLayout</code> (when the Button is clicked ou dragged, the <code>LinearLayout</code> appears or disappears); and one List, which is below the <code>SlidingDrawer</code>. </p> <p>I need this List to "stretch". So, when the Button of the <code>SlidingDrawer</code> had focus (the Button has 30dp os size), the List needs to be bigger. But when the <code>LinearLayout</code> has focus (this Layout has 150dp of size), the List needs to be smaller.</p> <p>How can I do this behavior in real time, like the Notification screen of Android works?</p>
android
[4]
916,719
916,720
Javascript switch statement with months
<p>I have a assignment where the user puts in a number inside a prompt box and the month comes out. Here is code so far:</p> <pre><code>&lt;script type="text/javascript"&gt; var a = prompt("enter a month number please."); var b = ""; switch(a){ case 1: b = "January"; break; case 2: b = "February"; break; case 3: b = "March"; break; case 4: b = "April"; break; case 5: b = "May"; break; case 6: b = "June"; break; case 7: b = "July"; break; case 8: b = "August"; break; case 9: b = "September"; break; case 10: b = "October"; break; case 11: b = "November"; break; case 12: b = "December"; break; } if((a==12) || (a==1) || (a==2)){ document.write(" It is " + a + ", which is in winter.") } if((a==3) || (a==4) || (a==5)){ document.write(" It is " + a + ", which is in spring.") } if((a==6) || (a==7) || (a==8)){ document.write(" It is " + a + ", which is in summer.") } if((a==9) || (a==10) || (a==11)){ document.write(" It is " + a + ", which is in fall.") } &lt;/script&gt; </code></pre> <p>My months are not the output. Instead, the number is my output. It seems my switch statement is being ignored and only doing the if statements. I am lost at what i'm doing wrong.</p>
javascript
[3]
5,757,141
5,757,142
Static variables in ASP.NET
<p>There is <a href="http://support.microsoft.com/kb/312607#4" rel="nofollow">an article</a> that recommends to store ASP.NET application state in static members of <em>HttpApplication</em> class (in Global.asax.cs).</p> <p>What about storing application state in static members of <strong>other classes</strong>?</p> <p>I tried to do so and it seems that there are several instances of these variables can exist (single instance per AppDomain?). Is it true and should we always use only <em>Application</em> class's static fields? Or it doesn't matter?</p>
asp.net
[9]
4,556,407
4,556,408
UIViewController issue
<p>I want to get objects values from a UIViewController.</p> <p>I am using this </p> <blockquote> <p>SecondViewController *newObject=[[SecondViewController alloc] init];</p> </blockquote> <p>But newobject has textview, its value is zero. How can I access the textview?</p>
iphone
[8]
452,435
452,436
catch & save outging sms to my app & the native app
<p>iv`e created an SMS app with a db that saves almost all of the messages.</p> <p>the problem starts when i want to save (1) my app outgoing messages to the native SMS app - the mmssms.db &amp; the (2) outging native SMS messages to my app db.</p> <p>i searched all over and failed to find a proper example for that question,especially for the second one.</p> <p>iv`e found that its all about the ContentResolver like this:</p> <p><a href="http://stackoverflow.com/questions/2735571/detecting-sms-incoming-and-outgoing">Detecting SMS incoming and outgoing</a></p> <p>but i cant figure how.</p> <p>please help me :)</p> <p>tanks!</p> <p>EDIT: </p> <p>the aswer for the (1) question is : <a href="http://stackoverflow.com/questions/7763575/android-updating-the-sent-box-afer-sending-an-sms">Android: Updating the sent box afer sending an sms</a></p> <p>still searching for the (2) answer.</p>
android
[4]
1,231,156
1,231,157
Trying to send mail using yahoo smtp in php
<p>Please can some one suggest me codes to send mails using yahoo smatp, and php.. </p> <pre><code>require("class.phpmailer.php"); // be sure to change this to your location! $mail = new PHPMailer(); $mail-&gt;IsSMTP(); $mail-&gt;SMTPAuth = true; // enable SMTP authentication $mail-&gt;SMTPSecure = "ssl"; // sets the prefix to the servier $mail-&gt;Host = "smtp.mail.yahoo.com"; // sets yahoo as the SMTP server $mail-&gt;Port = 25; // set the SMTP port $mail-&gt;Username = "sumthing@yahoo.com"; // yahoo username $mail-&gt;Password = "password"; // yahoo password $mail-&gt;From = "sumthing@yahoo.com"; $mail-&gt;FromName = "myname"; $mail-&gt;AddAddress("you@example.com"); $mail-&gt;Subject = "Test PHPMailer Message"; $mail-&gt;Body = "Hi! \n\n This was sent with phpMailer_example3.php."; if(!$mail-&gt;Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail-&gt;ErrorInfo; } else { echo 'Message has been sent.'; } </code></pre> <p>This code is giving me errrors 'Could not connect to SMTP host". </p>
php
[2]
3,547,106
3,547,107
number of parse calls allowed in trial version of jep jar
<p>I am using jep for evaluating expressions but getting following exception</p> <pre><code>15:01:00,819 ERROR [stderr] (http--0.0.0.0-8443-3) com.singularsys.jep.ParseException: Trial version limitation: Number of parse calls exceeded 15:01:00,819 ERROR [stderr] (http--0.0.0.0-8443-3) at com.singularsys.jep.Jep.parse(Unknown Source) 15:01:00,819 ERROR [stderr] (http--0.0.0.0-8443-3) at com.singularsys.jep.Jep.parse(Unknown Source) </code></pre> <p>from above it is clear that the number of parse calls are exceeding than the allowed limit. For now i have 28 expressions. Does any one have idea of what is the maximum number of parse calls does jep allows in trial version. Any help or pointers would be much appreciated.</p>
java
[1]
408,727
408,728
python create a class with complex numbers
<p>i have done this in c++ but i am trying it to python and have difficulties.I did this code:</p> <pre><code>class mycomplex: def __init__(self,real=None,imag=None): self.real=real self.imag=imag def read_data(self): self.real=input("Give the real part :") self.imag=input("Give the imag part :") def addition(self,complex): return mycomplex(self.real+complex.real,self.imag+complex.imag) def __str__(self): return ("{0} {1} {2} {3}{4}".format("The complex is : ",self.real,"+",self.imag,"j")) if __name__=="__main__": a=mycomplex() b=mycomplex() a.read_data() b.read_data() print(a) print(b) c=a.addition(b) print(c) </code></pre> <p>1) First of all it doesn't work because i have in the init method 2 arguments and when i try to create an instance with a=mycomplex() it gives me an error of course.Can i handle this in some way without changing the init ?</p> <p>2) In order for me to understand i want to use the addition method with 2 ways like i say in the code.It will help me i think.It's different to say a.addition() and c=a.addition(b).</p> <p>3) If you have any better suggestions from implementing the above,please say it.I think you understand what i am trying to show you.</p> <p>Thank you!</p>
python
[7]
4,831,622
4,831,623
Quoting a Python function in order to apply it later
<p>Given an object Foo, which has a set of methods Bar, Baz, Quux, and Close.</p> <p>I want to wrap calls into Foo as follows</p> <pre><code>def wrapper(method_symbol, *args): object = Foo() apply(object.method_symbol, args) object.Close() </code></pre> <p>So later on, I can call <code>wrapper(Bar, MySweetArgs)</code> and have wrapper correctly dispatch.</p> <p>Obviously in Lisp this would be simple, simply <code>QUOTE method_symbol</code> and away you go.</p> <p>The goal is to properly allocate/deallocate resources in a text-efficient fashion. I would prefer not wrap all of Foo with a SafeFoo class.</p>
python
[7]
5,580,669
5,580,670
Can I repeat same tasks in buttonclick C#
<pre><code>private void button1_Click(object sender, EventArgs e) { for (int iter = 0; iter &lt; 3; ++iter) { //...code for defining some matrix elements and cell id try { var firstTask = new Task(() =&gt; invokedisplaymatrix(MatrixInfoValues)); var secondTask = firstTask.ContinueWith((t) =&gt; invokedisplayblankmatrix(MatrixInfoValues)); var thirdTask = secondTask.ContinueWith((t) =&gt; invokedisplayanswermatrix(MatrixInfoValues)); firstTask.Start(); } catch (AggregateException error) { Console.WriteLine(error.Message); } } } </code></pre> <p>I have a number of tasks to be performed in my code, which is activated when a button is pressed in windows form application. I need to repeat the same procedures for n number of iterations. But When I debug the program, I can see that control goes to increment 'iter' after tasks and only tasks for the final 'iter' are performed. Can anyone help to fix the issue?</p>
c#
[0]
4,818,063
4,818,064
Database.Script Method Throwing - ArgumentOutOfRangeException
<p><strong>Hello, I'm running the following code:</strong></p> <pre><code>database.UserDefinedFunctions[name, schema].Script(dropstoredProcOptions); </code></pre> <p>With this as dropstoreProcOptions:</p> <pre><code> ScriptingOptions dropstoreProcOptions = new ScriptingOptions(); dropstoreProcOptions.IncludeIfNotExists = true; dropstoreProcOptions.ScriptDrops = true; dropstoreProcOptions.IncludeDatabaseContext = false; </code></pre> <p>If you run the .Script() function without any parameters no errors are thrown, however once you pass ScriptingOpstions as a parameter the following error is thrown: <strong>ArgumentOutOfRangeException</strong></p> <p>Any help or suggestions on how I could better debug it would be appreciated. Thank you.</p>
c#
[0]
5,783,551
5,783,552
JQuery - Get attribute of higher-level item
<p>I am trying to get the ID of <code>item1</code> but it does not return the ID in the code below. Is there a ways to get the ID of a higher-level function?</p> <p>I assume that the code is trying to get the ID of <code>popup</code> but that is both not needed and does not exist. Can I get the higher-level function's ID or can I pass it down to the lower function as a parameter?</p> <pre><code>$(".item1").live ("click" ,function(){ $('.popup_pre_loading').css('display','none'); $('.popup').fadeIn( 800, function(){ alert((this).attr('id'));//need this for URL param }); return false; }); </code></pre> <p>Please note that this code works when the the alert box is directly within the <code>item</code>'s function.</p>
jquery
[5]
1,231,324
1,231,325
how do I convert an integer to binary in javascript?
<p>I'd like to see integers, positive or negative, in binary.</p> <p>Rather like this question, but for javascript. <a href="http://stackoverflow.com/questions/5263187/how-can-i-print-a-integer-in-binary-format-in-java">How can i print a integer in binary format in java</a></p> <p>Added- Answers given so far, using toString(2), don't work for -1</p>
javascript
[3]
4,421,005
4,421,006
How Can I validate form and sending form via ajax to the another php page?
<p>I have this code between <code>&lt;head&gt;&lt;/head&gt;</code></p> <pre><code>&lt;script&gt; $(document).ready(function() { $("#test1").validate({ jQuery.extend(jQuery.validator.messages, { required: "Bez vyplnění této položky nelze objednávku odeslat!", email: "Prosím zadejte platnou e-mailovou adresu!", number: "Zadané znaky mohou obsahovat pouze číslice od 0 - 9.", }); }); }); &lt;/script&gt; </code></pre> <p>I need to have ajax function validate form and after the validation i want redirect the page to another php file, where will be proceed my another php code. thanks for help </p>
jquery
[5]
5,983,932
5,983,933
When does ActivityManagerSerivces dump out the content of 'procrank'
<p>When i looked at teh ActivityManagerService.java, it said it will dump out the content of 'procrank' when it is low on memory and there is no background service?</p> <p>Here is 1 instance of procrank dumped out by ActivityManagerService: It has '84884K' free. So why ActivityManager thinks it is 'low on memory'?</p> <pre><code>10-05 16:39:19.143 I/ActivityManager( 368): Total PSS by OOM adjustment: 10-05 16:39:19.143 I/ActivityManager( 368): 25249 kB: System 10-05 16:39:19.143 I/ActivityManager( 368): 25249 kB: system (pid 368) 10-05 16:39:19.143 I/ActivityManager( 368): 38258 kB: Persistent 10-05 16:39:19.143 I/ActivityManager( 368): 21451 kB: com.android.systemui (pid 467) 10-05 16:39:19.143 I/ActivityManager( 368): 8319 kB: com.android.phone (pid 537) 10-05 16:39:19.143 I/ActivityManager( 368): 4861 kB: com.android.nfc (pid 568) 10-05 16:39:19.143 I/ActivityManager( 368): 3627 kB: com.android.setting (pid 549) ... 10-05 16:39:19.143 I/ActivityManager( 368): ------ ------ ------ 10-05 16:39:19.143 I/ActivityManager( 368): 598802K 585888K TOTAL 10-05 16:39:19.143 I/ActivityManager( 368): RAM: 848196K total, 84884K free, 1044K buffers, 43508K cached, 3556K shmem, 27380K slab </code></pre>
android
[4]
4,258,509
4,258,510
Connect to as400 using sql
<p>I would think this would be a fairly common thing, and easy to find in google, but so far I haven't had much luck. I would like my application to connect to the i-series AS400 system using some method, run an SQL statement over an AS400 physical file, return a result set, and then have my visual c# program process the result set. I've heard of ADODB, ODBC, DB2, and OLEDB. Can someone show me an example of the syntax for getting one of these methods to work? I'd prefer to use a method that isn't dependent on having certain software such as client access, and am trying to avoid using something like ODBC due to the fact you have to configure the DSN. I've searched and searched, but the most code I can find is what the connection string should look like. Any help is appreciated!</p> <p>Thanks!</p>
c#
[0]
3,316,216
3,316,217
Is there a way to force specific order on extenders added to the same control?
<p>I wrote two control extenders that need to be placed always in the same order. Is there any way to make VS always place them in the correct order?</p> <p>The only solution i found was to place them in a central repository keyed on the target control ID on their init stage - and then have each of them perform its work through that repository rather then directly. but this looks like an overly complex solution for me.</p> <p>Anyone has a better idea?</p>
asp.net
[9]
3,769,437
3,769,438
Java Scanner multiple delimiter
<p>I know this is a very asked question but I can't find and apropiate answer for my problem. Thing is I have to program and aplication that reads from a .TXT file like this</p> <pre><code>Real:Atelti Alcorcon:getafe Barcelona:Sporting </code></pre> <p>My question is how what can I do to tell Java that I want String before : in one ArrayList and Strings after : in another ArrayList?? I guess It's using delimeter method but I don't know how use it in this case. </p> <p>Sorry for my poor english, I've to improve It i guess. Thanks</p>
java
[1]
1,943,986
1,943,987
SygicActivity finish() closes the entire application
<p>I am developing an app that uses Sygic navigation API. I have my main menu activity which calls the sygic activity but then if I call finish on the sygic activity, it closes the entire application.</p> <p>I spoke to the developers of Sygic and they told me this is the expected result for the activity (obviously not the expected behavior of an android activity) and they do not seem very willing to change this (I suspect its bad programming on their part).</p> <p>What I have been trying to do all day is figure out a way where I can either override the finish() method, I have tried casting to Activity and calling finish but that didnt seem to work.</p> <p>I have looked at instead of calling finish, starting the main menu activity from within the sygic activity with a number of flags set, but I think android is still calling finish on the sygic activity.</p> <p>So does anyone know how to override the finish method, or "minimize" an activity so that it doesn't ever actually close.</p> <p>Thanks for reading, Kevin</p>
android
[4]
798,714
798,715
how to hide a complete asp.net webform
<p>I want a page to run in the background in my Asp .Net web application. That page should not be visible to the user. </p> <p>The exact use of this page: the user will schedule a mail, that is to be send later. After he scheduled, the page should be hidden.</p> <p>Can we do it?</p> <p>Platform version (.NET 4)</p>
asp.net
[9]
2,569,551
2,569,552
Reason for The local variable may not have been initialized?
<p>This is what my method looks like</p> <pre><code>public int abc() { int x; if(x &gt; 100) { //Say ok return x;//Causes compiler error } //if something more, x = some number return x;//Causes compiler error } </code></pre> <p>I saw an answer at SO - <a href="http://stackoverflow.com/questions/12661417/java-local-variable-may-not-have-been-initialized-not-intelligent-enough">Java: &quot;Local variable may not have been initialized&quot; not intelligent enough?</a></p> <p>But, I am still not sure why this error happens. Its a compiler error and not a warning. So, the problem must be something more serious than "taking a safe route".</p>
java
[1]
197,024
197,025
android honeycomb list menus
<p>I feel stupid for asking: What are the drop menus on honeycomb apps called? I'd like to use them in my app but i don't even know where to start.</p> <p>An Example from Google Music, notice the triangle in the corner:</p> <p><img src="http://i.stack.imgur.com/WUxEh.png" alt="unopened menu"></p> <p>Here it is opened:</p> <p><img src="http://i.stack.imgur.com/gMdZc.png" alt="opened menu"></p> <p>I found the Menu, which appears in the top right. I don't think they are context menus which you usually see associated with long holding touches.</p> <p>(I realize these images are from the website, but they are all over honeycomb apps too)</p>
android
[4]
5,816,134
5,816,135
python, create a filtered list from a text document
<p>Every time I try to run this program, Python IDLE responds by telling me that it is not responding and has to close. Any suggestions on how to improve this code to make it work the way I want?</p> <pre><code>#open text document #filter out words in the document by appending to an empty list #get rid of words that show up more than once #get rid of words that aren't all lowercase #get rid of words that end in substring 'xx' #get rid of words that are less than 5 characters #print list fin = open('example.txt') L = [] for word in fin: if len(word) &gt;= 5: L.append(word) if word != word: L.append(word) if word[-2:-1] != 'xx': L.append(word) if word == word.lower(): L.append(word) print L </code></pre>
python
[7]
2,326,305
2,326,306
How do I put a javascript variable inside javascript array?
<p>I'm sure this is a simple question, but I couldn't find the answer.</p> <p>I've included the code as well as my explanation.</p> <pre><code>var dates = "'2012-07-22','2012-07-26','2012-07-28'"; </code></pre> <p>i have this JavaScript variable and i need to pass it the below <code>filterDates</code> array...something like this </p> <pre><code>filterDates = [dates]; </code></pre> <p>or </p> <pre><code>filterDates = [document.write(dates)]; var filterDates = []; </code></pre> <p>I really don't know how to do it with JavaScript...for example we can do it in php like this</p> <pre><code>filterDates = [&lt;?php echo $thatVariable; ?&gt;]; </code></pre> <p>How do I do this in JavaScript?</p>
javascript
[3]
5,860,830
5,860,831
Deciphering object oriented programming concepts in Java
<p>I've been reading about object oriented concepts, and I'm getting really lost. Conceptually, all I understand is that a method "does" something and that a class is a "blueprint". I've read all the analogies, but the only thing that really makes sense to me so far is: Loops,if then, variable assignments, primitive data types, and the basic syntax.</p> <p>To me, a program is a program is a program. You type in instructions, and the computer executes. I guess I don't really see big picture. </p>
java
[1]
2,843,913
2,843,914
Mutally exclusive constraints on two methods with the same signature
<p>So these two methods have the same signature but different constraints</p> <pre><code>public static void Method&lt;T&gt;(ref T variable) where T : struct { } public static void Method&lt;T&gt;(ref T variable) where T : class { } </code></pre> <p>But they cannot be defined in a single class because they have the same signatures. But in this particular case they're mutually exclusive. (Unless I'm wrong about that)</p> <p>I understand you can put additional constraints besides <code>class</code> and <code>struct</code> but you can't specify both <code>struct</code> and <code>class</code> on the same method. So why would this fail to compile?</p>
c#
[0]
1,484,213
1,484,214
jQuery callback function issue
<p>I am a bit new to programming in jQuery/Javascript and am having some issues showing/hiding a series of headers in a div tag (container). The script code with attempted callback is:</p> <pre><code>$(document).ready(function(){ $('&lt;h1&gt;Text1&lt;/h1&gt;').hide().prependTo("#container").fadeIn(2000, function(){ $("#container h1").fadeOut(2000, function(){ $('&lt;h1&gt;Text2&lt;/h1&gt;').hide().prependTo("#container").fadeIn(2000, function(){ $("#container h1").fadeOut(2000, function(){ $('&lt;h1&gt;Text3&lt;/h1&gt;').hide().prependTo("#container").fadeIn(2000, function(){ $("#container h1").fadeOut(2000, function(){ $('&lt;h1&gt;Text4&lt;/h1&gt;').hide().prependTo("#container").fadeIn(2000); }); }); }); }); }); }); }); </code></pre> <p>I basically want it to dislay Tesxt1 header with a fadein, then fadeout, then desplay text2 with a fadein and fadeout. Text4 is the last one and should only have a fadein without fadeout. Without the callback functions, everything is executed simultaneously and when they are added (incorrectly) above, later texts are prepended multiple times. </p> <p>Thank you very much for your time.</p>
jquery
[5]
5,957,845
5,957,846
How to save list items on disk instead of memory in Java
<p>I'm looking for a data structure same as ArrayList in Java that saves items on disk instead of memory. Does java have such a data structure? Thanks</p> <p>I want to have a dynamic structure that saves items on memory and when its size exceeds some value, save new items on disk until the size goes below the value.</p>
java
[1]
5,842,731
5,842,732
How do i set a variable using conditional statements?
<p>This does not work, even though putting a simple print ("foo") in the function block does work. </p> <pre><code>&lt;script&gt; var viewportHeight = $(window).height(); var X; $(function() { if (viewportHeight &gt;= 600) { var X = 100; } }); &lt;/script&gt; </code></pre>
jquery
[5]
2,993,524
2,993,525
Javascript function to get the color name from RGB value or Hexadecimal value
<p>Need a javascript method to get color name.</p> <p>Hoping javascript function should look like as follows </p> <pre><code>function (r,g,b) { .... return &lt;color name&gt;; // like blue, cyan, magneta etc etc } </code></pre>
javascript
[3]
2,602,918
2,602,919
How to generate short filenames for uploaded photos?
<p>While uploading new photos to a linux server with PHP, I'm having to give them unique names (using it's file name is ruled out). There's no interaction with a DB so getting unique IDs is also not possible. </p> <p>I thought of using <strong>DATE+TIME.jpg</strong>, but that's just too long. </p> <p>So what is the best method to create the shortest possible unique names with PHP? </p>
php
[2]
3,352,950
3,352,951
Need help on Bar Chart Plot
<p>I need help on plotting the bar chart to show daily based statistics like below attached image<img src="http://i.stack.imgur.com/Zpkc9.png" alt="enter image description here"> shown on iPhone App to android, can you any suggest the corresponding api for this one.</p>
android
[4]
2,192,539
2,192,540
href attribute of <a> not being set
<p>In my application, I send an AJAX request to a server, and based on some data, I have to change the <strong>href</strong> attribute of element. Here's my code:</p> <pre><code>$('#unclaimed_codes_list li').map(function(){ $(this).children("a:first").text(fname + ' ' + lname + '(' + key + ')'); } $.get('/accs/get_val/' + key, function(data){ var edit_href = '/ak_access_levels/' + id + '/edit'; alert(edit_href); $(this).children("a:first").attr('href', 'edit_href'); }); </code></pre> <p>But its not working. I can see that my edit_href value is correct, but still, the href attribute is not being set. Am I missing something? Thanks.</p>
jquery
[5]
551,996
551,997
FTP implement in android issue
<p>i have refer <a href="http://stackoverflow.com/questions/1567601/android-ftp-library">Android FTP Library</a> for implement ftp upload file fundamental in android but when i click on <a href="http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html" rel="nofollow">http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html</a> it get nothing. so how can i get jar file first?</p> <p>after some time i got jar file name is "<strong>commons-net.jar</strong>" &amp; "<strong>org.apache.commons.net_2.0.0.v200905272248.jar</strong>" but not get sucess to import <code>import org.apache.commons.net.ftp.*;</code> class.</p> <p>i have also refer site form :: <a href="http://androiddev.orkitra.com/?p=28" rel="nofollow"><strong>This Example</strong></a> which recommended jar filen &amp; also download but got same problem for me.</p> <p><strong>Screen short</strong> <img src="http://i.stack.imgur.com/rZSRB.png" alt="enter image description here"></p>
android
[4]
4,206,781
4,206,782
window.location.href javascript does not trigger shouldOverrideUrlLoading
<p>My tested on nexous one (compiled with android 2.2) shows that shouldOverrideUrlLoading is not triggered when the page is redirected via window.location.href. The onPageFinished is trigger as usual.</p> <p>Could anyone advise how to intercept javascript page redirect? Any other way to redirect the page in javascript so shouldOverrideUrlLoading is triggered? Is this a bug for shouldOverrideUrlLoading? </p> <p>Thanks,</p> <p>June</p>
android
[4]