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,470,121
5,470,122
Remove first options from the select form
<p>Is there a way to remove the first options from this script:</p> <p><a href="http://javascript.internet.com/navigation/connected-comboxes.html" rel="nofollow">http://javascript.internet.com/navigation/connected-comboxes.html</a></p> <p>I want to remove the <strong>[ Type ]</strong> and <strong>[ Style ]</strong> options from the list and display other options only...</p> <p>Can anyone please help?</p>
javascript
[3]
883,525
883,526
TextView:shadowDx/Dy/Radius in dip?
<p>How can we specify a TextView's shadowDx/Dy/Radius values in dip? Right now I have:</p> <pre><code>&lt;style name="foo"&gt; &lt;item name="android:shadowDx"&gt;-1&lt;/item&gt; &lt;item name="android:shadowDy"&gt;-1&lt;/item&gt; &lt;item name="android:shadowRadius"&gt;1&lt;/item&gt; &lt;/style&gt; </code></pre> <p>I can't seem to specify "1dip" in these places. Is there a way to do it other than setting them in code and doing the device density multiplication ourselves?</p> <p>Thanks</p>
android
[4]
4,129,300
4,129,301
Loading php file and then run function
<p>I am trying to pass some parameters to a php file and then load it on my page. After I do that I need to run a function. My problem is that jQuery runs the function before it loads the php file. I can get it working by adding a delay to my function using </p> <pre><code> setTimeout(function() { addSet(id); }, 500); </code></pre> <p>Instead I want it to run when my load function is done running. I have tried using $('#exer'+id).ready(function() { with no luck.</p> <p>This is my code</p> <pre><code>function addExercise(id, name, type, factor, desc) { $("&lt;div id='exer"+id+"' class='exer'&gt;lala&lt;/div&gt;").insertAfter("#beforeExercises"); var php_file = "modules/ExerciseSearchTest2/addExercise.php?id="+ id + "&amp;name=" + name + "&amp;type=" + type + "&amp;factor=" + factor + "&amp;desc=" + desc; $("#exer"+id).load(encodeURI(php_file)); addSet(id); } </code></pre>
jquery
[5]
3,727,375
3,727,376
android animation glow effect on imageview
<p>I am working on a application, where in my home page i need to give glowing and fading effect animation to a logo (imageview) i tried a lot and could not find how to give glow effect animation and i know glow effect for onclick event please help me with this issue Thanks in advance</p> <pre><code>public class CustomView extends ImageView{ public CustomView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public CustomView(Context context, AttributeSet attrs) { super(context, attrs); } public CustomView(Context context) { super(context); } boolean drawGlow = false; //this is the pixel coordinates of the screen float glowX = 0; float glowY = 0; //this is the radius of the circle we are drawing float radius = 20; //this is the paint object which specifies the color and alpha level //of the circle we draw Paint paint = new Paint(); { paint.setAntiAlias(true); paint.setColor(Color.WHITE); paint.setAlpha(50); }; @Override public void draw(Canvas canvas){ super.draw(canvas); if(drawGlow) canvas.drawCircle(glowX, glowY, radius, paint); } @Override public boolean onTouchEvent(MotionEvent event){ if(event.getAction() == MotionEvent.ACTION_DOWN){ drawGlow = true; }else if(event.getAction() == MotionEvent.ACTION_UP) drawGlow = false; glowX = event.getX(); glowY = event.getY(); this.invalidate(); return true; } } </code></pre> <p>this code is for touch event i want animation</p>
android
[4]
2,935,181
2,935,182
Why do multiple iterations of a block of code increase average running time so much?
<p>For example, I'm running a simple nested loop that finds duplicate elements in two arrays. With a list size of 2000, it takes somewhere around 25 milliseconds on average (a guess) if I run the program several times in a row. However, running the program once within a for loop, the more times I loop it, the faster the average runtime for one iteration is. e.g. 10 times is 5 milliseconds each iteration, 10000 times is 2 milliseconds.</p> <p>I have to measure the running time for a few different types of list intersection (e.g. nested loops, binary search etc.) at various list sizes, so I'm not sure which is more accurate. It becomes more of a problem for the longer ones because it takes too long to run it so many times.</p> <pre><code> for (int i = 0; i &lt; A.length-1; i++) { for (int j = 0; j &lt; B.length-1; j++) { if (A[i] == B[j]) { inter++; } } } </code></pre> <p>How I generate the lists used:</p> <pre><code>public studentList(int size, String course) { int IDrange=2*size; studentID=new int[size]; boolean[] usedID=new boolean[IDrange]; for (int i=0;i&lt;IDrange;i++) usedID[i]=false; for (int i=0;i&lt;size;i++) { int t; do { t=(int)(Math.random()*IDrange); } while (usedID[t]); usedID[t]=true; studentID[i]=t; } courseName=course; numberOfStudents=size; } </code></pre>
java
[1]
2,033,511
2,033,512
Referring to objects inside a list without using references or indices
<p>I'm using python for my shopping cart class which has a list of items. When a customer wants to edit an item, I need to pass the JavaScript front-end some way to refer to the item so that it can call AJAX methods to manipulate it.</p> <p>Basically, I need a simple way to point to a particular item that isn't its index, and isn't a reference to the object itself.</p> <p>I can't use an index, because another item in the list might be added or removed while the identifier is "held" by the front end. If I were to pass the index forward, if an item got deleted from the list then that index wouldn't point to the right object.</p> <p>One solution seems to be to use UUIDs, but that seems particularly heavyweight for a very small list. What's the simplest/best way to do this?</p>
python
[7]
2,373,628
2,373,629
How to get radio button appearance in checkbox?
<p>I'm just trying to use different checkboxes whose appearance should looks like an radio button which is like a round button with a green light inside. I googled this for long time but didn't find a solution, is there any way to do this.</p> <p>Thanks in advance.</p>
android
[4]
3,714,187
3,714,188
Regular expression : neeed help for url rewritting
<p>I am using <a href="http://urlrewriter.net" rel="nofollow">urlrewriter.net</a></p> <p>my intended url is like /articles/3/name_of_article/articles.aspx </p> <p>&amp; actual is articles.aspx?article =3; </p> <p>(3 is just taken, it can be any number)</p> <p>i am using regex like this </p> <pre><code> &lt;rewriter&gt; &lt;rewrite url="^/articles/(.+)/(.+)" to="/articles.aspx?article=$1" /&gt; &lt;/rewriter&gt; </code></pre> <p>it does not work, also if i delete module dll from references then also no exception is thrown.</p> <p>1) how can ensure that module is loaded (via code) ?</p> <p>2) is my regex correct ? </p> <p>my web.config contains this : </p> <pre><code>&lt;configSections&gt; &lt;section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" /&gt; &lt;/configSections&gt; </code></pre> <p>&amp; </p> <pre><code>&lt;httpModules&gt; &lt;add type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" name="UrlRewriter" /&gt; &lt;add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt; &lt;/httpModules&gt; </code></pre> <p>plz help!</p>
asp.net
[9]
3,422,705
3,422,706
Javascript :: How to catch mouse-up event outside of element?
<p>I have simple Javascript code, similar to this one:</p> <pre><code>var mouseIsDown = false; ... function canvasMouseDown(e) { ... mouseIsDown = true; } function canvasMouseUp(e) { mouseIsDown = false; } function canvasMouseMove(e) { if (mouseIsDown) { ... } } </code></pre> <p>with implemention my own user interface for tranformations (translations, scalings and rotations) with canvas.</p> <p>Such implementation within <code>canvasMouseMove()</code> function check <code>mouseIsDown</code> variable. All works fine if user does not release mouse button when the cursor/pointer is outside of the canvas element. If that happen, the variable <code>mouseIsDown</code> stays <code>true</code> and is not turned off by <code>canvasMouseUp</code> function.</p> <p>What is easy fix or solution in pure JavaScript <em>(no jQuery)</em> for this issue?</p>
javascript
[3]
3,012,845
3,012,846
PHP: HTTP_X_REQUESTED_WITH vs HTTP_X_REQUEST_WITH
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2579254/php-does-serverhttp-x-requested-with-exist-or-not">PHP: Does $_SERVER[&#39;HTTP_X_REQUESTED_WITH&#39;] exist or not?</a> </p> </blockquote> <p>Recently came upon a problem where ajax-detection wasn't working.</p> <p>This is a PHP question.</p> <p>It turns out the <code>$_SERVER['X_HTTP_REQUESTED_WITH']</code> didn't contain anything, but <code>$_SERVER['X_HTTP_REQUEST_WITH']</code> did (notice the missing 'ED').</p> <p>I've searched and I haven't yet found anything conclusive in my searches as to whether this has changed recently (currently this particular site is on 5.3.10), or if it's always been the case (which would make other postings concerning the subject concerning as they mostly seem to reference the "ED" version).</p> <p>FYI, this site is on apache 2.2.19, if it makes any difference as well.</p>
php
[2]
3,548,082
3,548,083
Best way to do conditional assignment in python
<p>I tend to use this a lot, but it's ugly:</p> <pre><code>a = (lambda x: x if x else y)(get_something()) </code></pre> <p>So I wrote this function:</p> <pre><code>def either(val, alt): if val: return val else: return alt </code></pre> <p>So you can do:</p> <pre><code>a = either(get_something(), y) </code></pre> <p>Is there a built-in function for this like isnull in T-SQL? Or am I missing something really obvious?</p>
python
[7]
847,428
847,429
Which is faster: if (var == 'value' ) OR if (/value/.test(var))
<p>Which is faster:</p> <pre><code>if (var == 'value') </code></pre> <p>or</p> <pre><code>if (/value/.test(var)) </code></pre>
javascript
[3]
5,458,272
5,458,273
Why it is not possible to use IList<T> in interface definition and List<T> in inplementation?
<p>Why it is not possible to use IList in interface definition and then implement this property using List? Am I missing something here or just C# compiler doesn't allow this?</p> <pre><code>public interface ICategory { IList&lt;Product&gt; Products { get; } } public class Category : ICategory { public List&lt;Product&gt; Products { get { new List&lt;Product&gt;(); } } } </code></pre> <p>compiler says Error 82 'Category' does not implement interface member 'ICategory.Products'. 'Category.Products' cannot implement 'ICategory.Products' because it does not have the matching return type of 'System.Collections.Generic.IList'</p>
c#
[0]
5,205,964
5,205,965
Can't load new url using if / else javascript statement - help?
<p>I've appropriated some code to create a countdown timer for the launch of a new site. The timer itself, which uses a custom typeface, works very well. </p> <p>However, when the if / else statement for <code>timesup</code> is true and goes to 'else', I can't get any other function to work apart from the way you see it below:</p> <pre><code>function formatresults(){ if (this.timesup==false){//if target date/time not yet met var displaystring="&lt;div class='row'&gt;&lt;div class='col'&gt; "+arguments[0]+" &lt;/div&gt; &lt;div class='thincol'&gt;&amp;#149;&lt;/div&gt; &lt;div class='col'&gt; "+arguments[1]+" &lt;/div&gt; &lt;div class='thincol'&gt;&amp;#149;&lt;/div&gt;&lt;div class='col'&gt; "+arguments[2]+" &lt;/div&gt; &lt;div class='thincol'&gt;&amp;#149;&lt;/div&gt; &lt;div class='col'&gt; "+arguments[3]+" &lt;/div&gt; &lt;/div&gt;" } else { var displaystring = "BAR" } return displaystring } </code></pre> <p>if I change <code>var displaystring</code> to <code>window.location</code> (to load the full site at the end of the countdown), the timer ceases to work completely.</p> <p>I know this is due to a fundamental misunderstanding of javascript in a way, but in all honesty I've developed sites using javascript and libraries like jquery and mootools and haven't hit a brick wall like this in a long time.</p> <p>If you have any advice, please do share it with me!</p> <p>Many thanks in advance</p>
javascript
[3]
2,182,010
2,182,011
How to run Java Programs
<p>I am just starting Java but I know Scheme...How do you run java code using emacs and putty? I made a program and saved it as first.java on emacs and when i try to open it in putty i did load "first.java" but nothing happened so how do you do this and can yo write Java code in Dr.Scheme?</p>
java
[1]
5,630,862
5,630,863
GetElementbyID fails to fire
<p>From my reading here I would expect this code to work, but it doesn't. I have tried two ways to add click events to a button called "lonext". Neither work. I'm not sure why this might be?</p> <pre><code>window.onload = function() { var goSC = function() { //go to the sucess criteria section document.getElementsByClassName("guidance1").style.display = "none"; document.getElementsByClassName("guidance2").style.display = ""; alert("button clicked"); //first try document.getElementById("lonext").addEventListener("click", function() { goSC(); }, false); //second try document.getElementById("lonext").onclick = goSC; } </code></pre>
javascript
[3]
2,148,277
2,148,278
Why doesn't the class containing main have to be public?
<p>I declared the following class</p> <pre><code>class A { //not public public static void main(String args[]) { System.out.println("done"); } </code></pre> <p>When I compile and run it, it runs fine and prints the output "done". Same behavior even when I declare it as being in a "package a;"</p> <p>However, if JVM spec mandates that main method should be public since "it can't see main otherwise", shouldn't it apply to the class as well? If the JVM "can't see" A.main() when it is not declared public, how is it able to see the class A itself.</p> <p>Is there any explanation for this other than "because the specification says so"?</p>
java
[1]
2,723,005
2,723,006
Can we restrict to install .apk files in our device?
<p>I am new to android application development.</p> <p>I developed some android applications and i install the .apk files in client devices,these are working properly.</p> <p>But my requirement is ,i have to make the client device ,to support for install the .apk file from my company only.If the client is try to install any outside .apk file,then it has to rise an error.</p> <p>please help me to go forward.</p> <p>thank you, bye.</p>
android
[4]
1,936,468
1,936,469
Android "Share" Submenu
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3059155/android-quick-actions-ui-pattern">Android Quick Actions UI Pattern</a> </p> </blockquote> <p>how can we make submenu like android </p>
android
[4]
3,695,360
3,695,361
Tabbar does not show when i am clicking inside the tab bar class in android
<p>I have tab bar it contains 4 tabs,each one call diff activity.In that class i have list view its item click call another activity.At that time the tab bar was not shown...I want app as, i call any activity in app,it always will show the tab bar.please help me.</p>
android
[4]
939,710
939,711
Merge C++ files into a single source file
<p>I have a c++ project with multiple source files and multiple header files. Sometimes, I wan't to send someone my project (usually for a programming contest) and it would be nice if there was an automated way of collapsing all the files into single .cpp file.</p> <p>So for example if I had a.cpp, a.h, b.cpp, b.h etc., I want to get a main.cpp which will compile and run successfully. If no tool is available, I imagine all you need to do is to merge the header files and append the source files to each other? However are there gotchas with externs, include dependencies and forward declarations?</p>
c++
[6]
840,609
840,610
automatic scroll - a scroll view on Touch of textField - iPhone
<p>I have many textfields in my Application which are in a scrollview.</p> <p>What i need is when user touches on a textfield,</p> <p>scrollview should scroll in such a way, so that that textfield should not be behind the keyboard.</p> <p>i have seen these sample code site. but forgot. And right now I am not able to find it through google.</p> <p>Help me.</p> <p>thanks for your kind help to me.</p>
iphone
[8]
1,734,002
1,734,003
Fetch the drive contents dynamically
<p>Hi friends in my project i have a situation that when i select the drive letter it display the corresponding files with in the share drive will dispaly . for that i find the connected drives with my system using the following code<br /> <code>echo "&lt;select id = 'drives'&gt;&lt;option&gt;Drives&lt;/option&gt;"; for($ii=66;$ii&lt;92;$ii++) { $char = chr($ii); if(opendir($char.":/")) echo "&lt;option&gt;".$char."&lt;/option&gt;"; } echo "&lt;/select&gt;";</code></p> <p>But i select the drive letters the corresponding files are not displayed. Please help me to fetch the files. Thanks in advance</p>
php
[2]
1,705,725
1,705,726
How can I extend Calendar on Android?
<p>I mean, is there any way to</p> <ul> <li>add more functionality</li> <li>add/remove events</li> <li>synchronize with other then Google calendars/formats (authorized)</li> </ul>
android
[4]
3,023,314
3,023,315
How can I read multiple bytes from a file at a time?
<p>I want to read 8byte chunks from a binary file at a time till I reach end of the file. Why doesn't this code work? What are the alternatives?</p> <pre><code>// read a file into memory #include &lt;iostream&gt; #include &lt;fstream&gt; using namespace std; int main () { long long int * buffer; ifstream is; is.open ("test.txt", ios::binary ); // allocate memory: buffer = new long long int; // read data: while(!is.eof()) is.read (buffer,sizeof(long long int)); is.close(); delete[] buffer; return 0; } </code></pre> <p>If I replace all <code>long long int</code> with <code>char</code>, the code works perfectly.</p> <p>Ref: code adapted from <a href="http://www.cplusplus.com/reference/iostream/istream/read/" rel="nofollow">www.cplusplus.com</a></p>
c++
[6]
4,641,796
4,641,797
How to update Android version 2.3.6
<p>I am using eclipse and installed android sdk which contains android 2.3.3 version but I want update my sdk and download android 2.3.6 version. When I am go through AVD SDK Manager and check available package but it doesn't show the package of android version 2.3.6</p> <p>How to update android version in 2.3.6 because I want create android emulator 2.3.6 for installing development.apk on my nexus devices for debugging.</p>
android
[4]
2,693,952
2,693,953
I was able to open a command prompt from my Java program, How to run some exe in this command prompt using java code?
<p>I tried open a command prompt using java program, how to execute the some exe file in this command prompt using java code.</p>
java
[1]
3,970,645
3,970,646
Problem with accessing class members as an array in PHP class
<p>I'm trying to integrate the FedEx tracking class into my application. The class takes a SOAP response and puts it into a hierarchical class structure. I access the values like this: </p> <pre><code>$city = $response-&gt;TrackDetails-&gt;Events[$i]-&gt;Address-&gt;City; </code></pre> <p>This works fine for most cases. The problem I am having is when there is just one event for a given shipment, I get an error saying that I cannot treat the class as an array. Since there is just one event, I need to access it without the array index using: </p> <pre><code>$city = $response-&gt;TrackDetails-&gt;Events-&gt;Address-&gt;City; </code></pre> <p>Is there a way to deal with this without doing something like this: </p> <pre><code>if($num_events==1){ $city = $response-&gt;TrackDetails-&gt;Events-&gt;Address-&gt;City; }else{ $city = $response-&gt;TrackDetails-&gt;Events[$i]-&gt;Address-&gt;City; } </code></pre> <p>There are a ton of data fields that fall into this issue, so I don't want to use something so cumbersome if I can avoid it. Any ideas? </p>
php
[2]
1,789,119
1,789,120
PHP upload - Why isset($_POST['submit']) is always FALSE
<p>I have the following code sample upload3.php:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;PHP Form Upload&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form method='post' action='upload3.php' enctype='multipart/form-data'&gt; Select a File: &lt;input type='file' name='filename' size='10' /&gt; &lt;input type='submit' value='Upload' /&gt; &lt;/form&gt; &lt;?php if (isset($_POST['submit'])) { echo "isset submit"; } else { echo "NOT isset submit"; } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The code always returns "NOT isset submit". Why does this happen? Because the same script upload3.php calls itself?</p> <p>Thank you</p>
php
[2]
2,099,872
2,099,873
How to simulate java socket connection break?
<p>I have written java application that makes socket connections with a legacy system. </p> <p>How can I simulate the connection failure <em>(Eg Socket connection timeout, read timeout, network failure)</em>, so that i can add necessary code based on the exception trace ? </p>
java
[1]
317,112
317,113
How to find out call and sms details for last 10 days from my app
<p>I'm working on an app in that I have to fetch all call and sms records for last 10 days. Now I'm only able to find out all contacts for those who has sent me sms and all the phone contacts. So guys please help me show how I can find out or fetch last 10 days call and sms details from my applications?</p> <p>My code is like this:</p> <pre><code>final Uri SMS_INBOX = Uri.parse("content://sms/inbox"); Cursor c = getContentResolver().query(SMS_INBOX, null, "read", null, null); int readMessagesCount = c.getCount(); Toast.makeText(getApplicationContext(), "Read massage info"+readMessagesCount, 2000).show(); c.deactivate(); while (c.moveToNext()) { String asd = new String(c.getBlob(c.getColumnIndex("address"))); Toast.makeText(getApplicationContext(), asd, Toast.LENGTH_SHORT).show(); </code></pre>
android
[4]
1,974,446
1,974,447
How to delete sql entries on click
<p>Lets say i had a a button that cycles through numbers how can i store the number but if the next array is displayed then delete the previous entry so on so on and so on. When i keep on pressing the button it diplays 1, 2 , 3 but i want it to show a single value.</p> <p>Code example:</p> <pre><code> final CharSequence[] items = {"1", "2", "3"}; if (value &lt; items.length) { String s = (String)items[value]; sqlName.setText(s); String sRow1 = sqlName.getText().toString(); long lRow1 = Long.parseLong(sRow1); HotOrNot ex1 = new HotOrNot(this); ex1.open(); ex1.deleteEntry(lRow1); ex1.close(); } String name = sqlName.getText().toString(); HotOrNot entry = new HotOrNot(SQLiteExample.this); entry.open(); entry.createEntry(name); entry.close(); } </code></pre>
android
[4]
3,800,043
3,800,044
Are there any good hands-on Javascript project tutorials?
<p>I have been studying javascript for a couple of months, and I have the basics down but I feel that I cannot really improve to a professional level on my own. I mean I can write simple code that accomplishes what I want, but it is no good code and I lack in understanding when talking to "professional javascripters". It is very hard to improve if you don't know what you don't know if you know what I mean. What I think is the best and fastest way to learn a programming language is to follow professionals when they work on real projects and have them explain along the way what they are doing and why. Two of the best examples here are "Agile web-development with rails" for learning rails and "the iOS apprentice series" for learning ios programming. Here you learn the programming language from following professionals as they are developing a real project and have them explain along the way. But now when it comes to javascript books and videos the majority that I have come across follow the school approach of first describing the whole language in theory and then giving you small exercises, which in my opinion is a very bad approach to teaching a craft. I don't really feel that comfortable with reading source code at my stage either, I would rather have explanations along with the code like you get in a good tutorial.</p> <p>I have also read a lot of posts here on stack when it comes to book recommendations for learning javascript, but I think my specific question has not been asked yet. So please if you know any good resources that are hand-on like I described above, let me know. Also it doesn't matter if it is client side javascript or node.js projects.</p>
javascript
[3]
2,316,410
2,316,411
jquery count items in json
<p>I have a JSON that looks like this:</p> <pre><code>({ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "wkb_geometry": null, "code": "type 1", "code2": "type 3", "code3": "type 5", "updated_at": "2012-10-29T12:38:00.037Z" }, }, { "type": "Feature", "properties": { "wkb_geometry": null, "code": "type 1", "code2": "type 5", "code3": "type 7", "updated_at": "2012-10-29T12:38:00.037Z" }, }, { "type": "Feature", "properties": { "wkb_geometry": null, "code": "type 2", "code2": "type 3", "code3": "type 5", "activity_type": "children's play area", "updated_at": "2012-10-29T12:38:00.037Z" }, }... </code></pre> <p>Basically I want to count all the codes in this Json i.e. there are 3 occurrences of type 5.</p> <p>So far I have a loop that picks out all the type 1 codes, but I am not sure how to get the loop to count the items:</p> <pre><code>$.each(geojson.features, function(i, v) { if (v.properties.code.search(new RegExp(/type 1/i)) != -1) { console.log(v.properties.activity_type_code); } }); </code></pre>
jquery
[5]
4,777,681
4,777,682
bookmark/favorites
<p>I am trying to make an app which consists of only text. Every page(xml) is different. Now I want to make a bookmark page for the user to bookmark his/her favorites. I succeeded making a bookmark page which is activated with a button on the home-screen, I also have a bookmark button on every text page, but I can't figure out how I can send or reveal my bookmarked page/text on the bookmark page. this is what i got, which does not work:</p> <pre><code>package life.quotes; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.page1); cb = (CheckBox)findViewById(R.id.favorites); b = (Button)findViewById(R.id.button_right); Button Page2 = (Button) findViewById(R.id.button_right); Page2.setOnClickListener(new View.OnClickListener() { public void onClick (View view) { Intent myIntent = new Intent(view.getContext(), Page2.class); startActivityForResult(myIntent, 0); } }); cb.setOnClickListener(this); } private void savePrefs(String key, boolean value){ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); Editor edit= sp.edit(); edit.putBoolean(key, value); edit.commit(); } private void savePrefs(String key, String value){ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); Editor edit= sp.edit(); edit.putString(key, value); edit.commit(); } @Override public void onClick(View v) { // TODO Auto-generated method stub savePrefs("FAVORITES", cb.isChecked()); savePrefs("QUOTE1", getString(R.string.quote1)); } ` </code></pre> <p>Can anyone please help me?</p>
android
[4]
4,322,623
4,322,624
I have a Broadcast system for in site talking to users,Keeps right time up till 24 hours. After the 24 hour max the time speeds up
<pre><code>$time_ago_op = time() - $comments[$c]['bcttime']; if ($time_ago_op &lt;= 60) { $comments[$c]['time_ago'] = $time_ago_op . " secs ago."; } if ($time_ago_op &gt;= 61 &amp;&amp; $time_ago_op &lt;= (60 * 60)) { $comments[$c]['time_ago'] = CleanNumber($time_ago_op / 60) . " mins ago."; } if ($time_ago_op &gt;= (1+(60 * 60)) &amp;&amp; $time_ago_op &lt;= (60 * 60 * 24)) { $comments[$c]['time_ago'] = CleanNumber($time_ago_op / (60 * 60)) . " hours ago."; } if ($time_ago_op &gt;= (1+(60 * 60 * 24)) &amp;&amp; $time_ago_op &lt;= (60 * 60 * 24 * 7)) { $comments[$c]['time_ago'] = CleanNumber($time_ago_op / (60 * 60 * 7)) . " days ago."; } unset($time_ago_op); </code></pre> <p>After it a user posts it keeps the right time in seconds to minutes and hours, Once it hits 24 hours the time speeds up. For example a post that is 28 hours old says 3 days old and such... I am trying to figure out how to get it to keep the correct time and I am not having any luck.. If anyone can help and point out what I have set wrong it would help out a lot. Thanks</p>
php
[2]
5,462,908
5,462,909
PreferenceScreen android:summary update !
<p>In my android application I have a <code>PreferenceScreen</code> parent that has 3 <code>CheckBoxPreferences</code> as children.</p> <p>When I click the parent preferenceScreen, and the 3 checkboxes are displayed, I select one of them, and in the Preference.OnPreferenceChangeListener asociated with the checkboxes I set the parent's preferenceScreen summary with:</p> <pre><code>Parent.setSummary("string depending on the selection") </code></pre> <p>The thing is that when I return to the parent, it's summary is not updated, even if internally the value has correspondingly changed to the value setted.</p> <p>Has anyone any idea regarding this behavior? </p>
android
[4]
1,107,809
1,107,810
How to parse this string as a DateTime
<p>How can I parse the following string to <code>DateTime</code> with timezone? Should I use <code>CultureInfo</code>? <code>TimeZoneInfo</code>? Or some other kind?</p> <pre>15.08.11 17:15:18.084867000 +02:00</pre> <p>I have try to use the following format:</p> <pre><code>var z = DateTime.Now.ToString("dd.MM.yy H:mm:ss.fffffff", CultureInfo.InvariantCulture); </code></pre> <p>But it threw an exception.</p>
c#
[0]
565,647
565,648
Browser auto-complete problem
<p>I have a problem.</p> <p>I have TextBox1 where I enter information:</p> <pre><code>1 2 3 4 5 6 as sd asdasd asdas d </code></pre> <p>These data are stored in the browser. I do not want successors to the data re-appear in the browser. How can it be reached?</p>
c#
[0]
4,728,628
4,728,629
Preventing IP spoofing
<p>If I throw both of these two into a database, is that enough to prevent a site visitor from spoofing that they are coming from a different IP address?</p> <pre><code>$ip1 = $_SERVER['HTTP_X_FORWARDED_FOR']; $ip2 = $_SERVER['REMOTE_ADDR']; </code></pre>
php
[2]
4,619,854
4,619,855
How to structure so that Ember uses fewer/no metamorph tags?
<p>I'm using Ember.js/Handlebars to loop through a collection. Have an issue with ember, wrapping it with script metamorphs and ember Div's in the produced output.</p> <pre><code> &lt;script type="text/x-handlebars"&gt; {{#each App.PersonController}} {{#view App.view contentBinding="this"}} {{#with content}} {{title}} {{/with}} {{/view}} {{/each}} &lt;/script&gt; </code></pre> <p><strong>Here is what it looks like:</strong></p> <pre><code> &lt;div id="ember304" class="ember-view"&gt; &lt;script id="metamorph-0-start" type="text/x-placeholder"&gt;&lt;/script&gt; &lt;script id="metamorph-2-start" type="text/x-placeholder"&gt;&lt;/script&gt; &lt;div id="ember511" class="ember-view" aria-hidden="false"&gt; &lt;script id="metamorph-23-start" type="text/x-placeholder"&gt;&lt;/script&gt; &lt;script id="metamorph-24-start" type="text/x-placeholder"&gt;&lt;/script&gt; Mr &lt;script id="metamorph-24-end" type="text/x-placeholder"&gt;&lt;/script&gt; &lt;script id="metamorph-23-end" type="text/x-placeholder"&gt;&lt;/script&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>How can I structure this, so that ember uses fewer no metamorph tags? so that my css doesn't break?</p>
javascript
[3]
1,806,008
1,806,009
jquery trigger ctrl + click
<p>Just wondering if there is any way to trigger a CTRL + CLICK (or just any key + CLICK) in jQuery. I am thinking of something like the following:</p> <pre><code>var e = jQuery.Event("keydown"); e.which = 17; $('a.'+id, this._parent).trigger(e).trigger('click'); </code></pre> <p>or </p> <pre><code>var e = jQuery.Event("click"); e.ctrlKey = true; $('a.'+id, this._parent).trigger(e); </code></pre> <p>Thank you!</p>
jquery
[5]
1,350,682
1,350,683
Library or code to XML to JSON
<p>Does anyone know of a library that will convert XML to JSON in objective C (on the iPhone)?</p> <p>Thanks in advance,</p> <p>Rob</p>
iphone
[8]
4,899,824
4,899,825
How to read in a txt file
<p>I'm trying to read in from whats on the first two lines of a txt file, put it on a string and pass that string onto my methods. I'm confused on what I need to do in the main method. </p> <p>Heres what I have:</p> <pre><code> public class TestingClass { Stacked s;// = new Stacked(100); String Finame; public TestingClass(Stacked stack) { //Stacked s = new Stacked(100); s = stack; getFileName(); readFileContents(); } public void readFileContents() { boolean looping; DataInputStream in; String line = "" ; int j, len; char ch; try { in = new DataInputStream(new FileInputStream(Finame)); len = line.length(); for(j = 0; j&lt;len; j++) { System.out.println("line["+j+"] = "+line.charAt(j)); } } catch(IOException e) { System.out.println("error " + e); } } public void getFileName() { Scanner in = new Scanner(System.in); System.out.println("Enter File Name"); Finame = in.nextLine(); System.out.println("You Entered " + Finame); } public static void main(String[] args) { Stacked st = new Stacked(100); TestingClass clas = new TestingClass(st); //String y = new String("(z * j)/(b * 8) ^2"); // clas.test(y); } </code></pre> <p>I tried String x = new String(x.getNewFile()) I'm not sure if thats the right way to go with that or not. </p>
java
[1]
2,048,924
2,048,925
nested functions in php throws an exception when the outer is called more than once
<p>lest assume that i have the following </p> <pre><code>function a(){ function b(){} } a(); //pass a(); //error </code></pre> <p>why in the second call an exception is thrown and it says </p> <pre><code>cannot re-declare function b() </code></pre> <p>i thought that each function call makes a new active record that it contains its own scope ; like in other languages other that PHP when we declare a variable in a function and called that function all the variables are alive for their scope, why the inner function is not the same ?</p>
php
[2]
2,106,366
2,106,367
Download images from web and use downloaded images when presen
<p>My C# program needs to display, of many possible images, one at a time. The images are on the web and I have a precise URL for each one. The program needs to either load the image from the web or, if it has been loaded previously, load it from memory/file (as the previous loading from the web should have saved it to memory/file). How do I implement this? I can get the loading from the web with a WebRequest object, but that's not enough to save it for later, faster, use.</p> <pre><code>WebRequest request = WebRequest.Create(imageURL); Stream stream = request.GetResponse().GetResponseStream(); pictureBoxFirstPack.Image = Image.FromStream(stream); </code></pre>
c#
[0]
1,140,096
1,140,097
long double vs long int
<p>I'm doing a program that calculates the probability of lotteries. Specification is choose 5 numbers out of 47 and 1 out of 27</p> <p>So I did the following:</p> <pre><code>#include &lt;iostream&gt; long int choose(unsigned n, unsigned k); long int factorial(unsigned n); int main(){ using namespace std; long int regularProb, megaProb; regularProb = choose(47, 5); megaProb = choose(27, 1); cout &lt;&lt; "The probability of the correct number is 1 out of " &lt;&lt; (regularProb * megaProb) &lt;&lt; endl; return 0; } long int choose(unsigned n, unsigned k){ return factorial(n) / (factorial(k) * factorial(n-k)); } long int factorial(unsigned n){ long int result = 1; for (int i=2;i&lt;=n;i++) result *= i; return result; } </code></pre> <p>However the program doesn't work. The program calculates for 30 seconds, then gives me <code>Process 4 exited with code -1,073,741,676</code> I have to change all the long int to long double, but that loses precision. Is it because long int is too short for the big values? Though I thought long int nowadays are 64bit? My compiler is g++ win32 (64bit host).</p>
c++
[6]
4,589,938
4,589,939
How to get value of PATH environment variable programatically in Android?
<p>I wanted to implement a file search function in my Android application and I am wondering how can i get value of "PATH" environment variable from within my program?</p>
android
[4]
1,827,269
1,827,270
How can I find out the most used 2 words combo in a block of text?
<p>How can I find out what the most common two words that I used right after each other are from a block of text? In other words is there a tool online or offline (or code) where I can copy and paste text and it outputs my most used two word frequency like:</p> <p>From most used to least:</p> <p>"the cat" 2.9% "she said" 1.8% "went to" 1.2%</p> <p>Thanks</p>
php
[2]
80,748
80,749
Are we actually instantiating an Abstract class here?
<pre><code>// Concrete implementation built atop skeletal implementation static List&lt;Integer&gt; intArrayAsList(final int[] a) { if (a == null) throw new NullPointerException(); return new AbstractList&lt;Integer&gt;() { public Integer get(int i) { return a[i]; // Autoboxing } @Override public Integer set(int i, Integer val) { int oldVal = a[i]; a[i] = val; // Auto-unboxing return oldVal; // Autoboxing } public int size() { return a.length; } }; } </code></pre> <p>So far I knew we can not instantiate an abstract class at all . But what aren't we doing the same thing here with <code>return new AbstractList&lt;Integer&gt;()</code> ? I am confused .</p>
java
[1]
4,822,773
4,822,774
how to pass arralylist in basic namevalue pairs in android
<p>Hello Sir i want send list of data to php server i use following code is it correct or not please tell me</p> <pre><code> i try this code ArrayList&lt;String&gt;list1=new ArrayList&lt;String&gt;(); for(int i=0;i&lt;json.length();i++) { JSONObject e = json.getJSONObject(i); list1.add(e.getString("menuname")); } ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); nameValuePairs.add(new BasicNameValuePair("menuname",list1.toString())); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://192.168.0.103/update.php"); // "http://192.168.1.12/addnotes.php"); //url+"Notes/addnotes.php"); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); Toast.makeText(getApplicationContext(), "Saved Sucessfully", Toast.LENGTH_SHORT).show() </code></pre> <p>please see the above code is correct or not .. please tell me</p>
android
[4]
5,234,485
5,234,486
How to draw/highlight pixels by touching the screen across a Path in Android
<p>I've been trying to search what are the basic classes and methods, i should call for the task described in the title! i have been through many codes but they are not making me understand what is the basic procedure for that...</p>
android
[4]
502,091
502,092
help me to write php code for this MySQL sql
<pre><code>CREATE TABLE articles ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT , title VARCHAR(99) NOT NULL , dateposted DATE NOT NULL , author VARCHAR(99) NOT NULL ); CREATE TABLE article_rel ( this_article INTEGER NOT NULL REFERENCES articles (id) , related_article INTEGER NOT NULL REFERENCES articles (id) , PRIMARY KEY (this_article,related_article) ); </code></pre> <p>I am building article site, where i want to show related article. I can write code for articles table , just scratching heads how to do with article_rel table.</p>
php
[2]
229,091
229,092
launch command line from java without knowing OS
<p>Is there a way to launch the command line from java without knowing OS? For example, the method would open up the terminal shell for a Linux OS and open the command line for Windows. </p> <p>I do know (from looking at previous questions) that i can just check the OS and then open the proper command line, but is there a way to open the command line from a java method that is OS agnostic?</p>
java
[1]
5,177,825
5,177,826
What modern C++ libraries should be in my toolbox?
<p>I've been out of the C++ game for about 10 years and I want to get back in and start on a commercial app. What libraries are in use these days?</p> <ul> <li>User interface (e.g, <a href="http://www.wxwidgets.org/" rel="nofollow">wxWidgets</a>, <a href="http://qt.nokia.com/" rel="nofollow">Qt</a>)</li> <li>Database</li> <li>General purpose (e.g. <a href="http://www.boost.org/" rel="nofollow">Boost</a>, <a href="http://loki-lib.sourceforge.net/" rel="nofollow">Loki</a>, STL)</li> <li>Threading</li> <li>Testing</li> <li>Network/sockets</li> </ul> <p>I looking to be cross-platform compatible (as much as possible out-of-the-box).</p> <p>What libraries to do you rely on? What features do they provide that make them <em>"indispensable"</em>?</p> <p>See <a href="http://stackoverflow.com/questions/777764/what-modern-c-libraries-should-be-in-my-toolbox/782146#782146">my answer</a> below for a summary.</p>
c++
[6]
3,706,412
3,706,413
Sort list on base of multiple criteria
<p>I would like to sort a list on base of multiple criteria. </p> <pre><code>public class CustomerComparator implements Comparator&lt;Customer&gt; { public int compare(Customer customer1, Customer customer2) { int comparison = -1; comparison = customer2.getCustomerPriority().compareTo(customer1.getCustomerPriority()); if( comparison == 0 ) { comparison = customer1.getCustomerNumber().compareTo(customer2.getCustomerNumber()); } return comparison; } } </code></pre> <p>Basically, I want to sort in following order. Customer with higher priority should be on top of the list, and if two customers have same priority than one with lower customer number should go first. </p> <p>Original:</p> <pre><code>Customer Priority 1 0 2 0 3 1 4 0 5 0 </code></pre> <p>it should be sorted as below:</p> <pre><code>Customer Priority 3 1 1 0 2 0 4 0 5 0 </code></pre> <p>Thanks for help. DD</p>
java
[1]
964,770
964,771
what are atoms variable and what are usage of it?
<pre><code>public List&lt;Minterm&gt; completeMinterm(Minterm minterm, String variables){ List&lt;Minterm&gt; minterms=new ArrayList&lt;Minterm&gt;(); Minterm m1=new Minterm(); Minterm m2=new Minterm(); for (int k = 0; k &lt; minterms.size(); k++) { for (int i = 0; i &lt; variables.length(); i++) { .. } m1= minterms.get(k); m1.addAtom(new Atom(variables.charAt(i),false)); m2 = minterms.get(k); m2.addAtom(new Atom(variables.charAt(i),true)); .. } } </code></pre> <p>I used eclipse debugger to find errors, I don't understand, why the atom added to <code>m2</code> is added to <code>m1</code> too in the same time, when this line is run:</p> <blockquote> <p>m2.addAtom(new Atom(variables.charAt(i),true));</p> </blockquote> <p>any Idea why?</p>
java
[1]
4,086,770
4,086,771
javascript - image not switching in browser after i change source
<pre><code>function swapImg(imgId) { var image = document.getElementById(imgId); if (image.getAttribute("class") == "unselected") { image.setAttribute("src", "img/frownie.gif"); console.log(image); } } </code></pre> <p>if i look at what's outputted to console, the src of the image is correct. but it's not changing in my browser. what's up? (ie, the image stays the same even though the source url is changing...)</p>
javascript
[3]
5,331,147
5,331,148
The orientation of this specific activity is set to be landscape but not the other
<p>I use in the AndroidManifest:</p> <pre><code>&lt;activity android:name="Zoom" android:text="@string/Name" android:screenOrientation="landscape"&gt;&lt;/activity&gt; </code></pre> <p>to force this specific Activity(B) to be been see as landscape, my problem is when i am moving to the next Activity(c) or back to the Activity(A) its still show as landscape what i should do different??</p> <p>thanks for helping!!</p>
android
[4]
3,383,621
3,383,622
Using wheelwidget for android
<p>Iam using <code>kankans</code> wheel widget for android, and passing the minutes as below</p> <pre><code>final WheelView mins = (WheelView) view.findViewById(R.id.minutes); mins.setViewAdapter(new mywheel(activity, 0, 59,"%02d")); </code></pre> <p>now i want to display my minute values strting with 00 the 05 and continue 06 07.. i want to skip 02,03,04.</p> <pre><code>public class mywheel extends AdapterWheel { private int minValue; private int maxValue; private String format; public mywheel(Context context, int minValue, int maxValue, String format) { super(context, null); this.maxValue = maxValue; this.format = format; } @Override public CharSequence getItemText(int index) { if (index &gt;= 0 &amp;&amp; index &lt; getItemsCount()) { int value = 5 * index; return format != null ? String.format(format,value) : Integer.toString(value); } return null; } @Override public int getItemsCount() { return 59 / 5; } } </code></pre> <p>the above code gives me the minute values in multiples of 5, but i just want to skip 2,3,4 .How can i achieve this.</p>
android
[4]
2,191,584
2,191,585
How to check the status each 10 seconds with JavaScript?
<p>I have a server (<em>mysite.com/status</em>), which returns number of active tasks (just a single integer). How can I check number of active tasks each 10 seconds with JavaScript and show user something like:</p> <blockquote> <p>Number of remaining tasks: XXX</p> </blockquote> <p>And, if number of tasks is 0, then I should load another page.</p>
javascript
[3]
505,286
505,287
How do I parse a website in python once I know its url?
<p>If I know the url of a wiki site , How do I use python to parse the contents of it ?</p>
python
[7]
3,068,677
3,068,678
Should a trait be in a separate file?
<p>Assume this situation:</p> <pre><code>interface IFoo { public function Bar(); } trait Foo { public function Bar() { echo 'Bar'; } } class FooBar implements IFoo { use Foo; } $foobar = new FooBar(); $foobar-&gt;Bar(); //echos 'Bar'; </code></pre> <p>I put class FooBar in its own file, and interface IFoo also in it own file.</p> <p>But what should I do with trait Foo:</p> <ul> <li>In its own file? (my preference)</li> <li>Together with the inferface IFoo?</li> <li>When the trait is given its own file, how will autoloading deal with that?</li> </ul> <p>note: netbeans marks the code of class FooBar as invalid. Netbeans does not detect that trait Foo is used to implement IFoo. Bug?</p>
php
[2]
3,306,798
3,306,799
Problem with setInterval
<p>I have a problem with setInterval on a 'click' event. Im already spawning a hidden div. But I want spawn and fade in synced and only run the fade in ones.</p> <pre><code> var anchor = document.getElementById('anchor'); var hiddenElement = document.getElementById('hiddenElement'); var bkgFade = document.getElementById('bkgFade'); anchor.addEventListener('click', spawnImage, false); hiddenElement.addEventListener('click', despawnImage, false); function spawnImage() { setInterval(function() { document.getElementById('hiddenElement').style.display = 'block'; document.getElementById('bkgFade').style.visibility = 'visible'; hiddenElement.style.opacity += 1.0; } 1000); } function despawnImage() { document.getElementById('hiddenElement').style.display = 'none'; document.getElementById('bkgFade').style.visibility = 'hidden'; } </code></pre>
javascript
[3]
1,541,437
1,541,438
How do I learn quality java programming?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/78293/good-book-to-learn-to-program-well-in-java-engineering-or-architecture-wise-not">Good book to learn to program well in Java (engineering or architecture-wise, not syntax)</a> </p> </blockquote> <p>I am undertaking a java project and the purpose behind it is to learn and practice java programming as I am new to it. I understand that albeit there is no set way of writing programs and every programmer has there own style. But you can get into bad programming habits such as bad styling, using inappropriate syntax for e.g not turning enough design problems into classes or maybe creating too many classes ,reinventing the wheel, Not using the right design patterns or maybe even the correct algorithms. So my question is how do I become a good java programmer rather then just someone who can write code?</p>
java
[1]
3,062,435
3,062,436
what is meant by that in a servlet (private static final long serialVersionUID = 1L)?
<p>Can any one tell me that what is the meaning of</p> <pre><code>private static final long serialVersionUID = 1L </code></pre>
java
[1]
4,431,065
4,431,066
javascript class props
<p>I have a class defined like this (scheme) :</p> <pre><code>myClass = BaseClass.extend({ method1 : function(){ ...}, method2 : function(){ ...} }); </code></pre> <p>How can I call method2 from method1? something like:</p> <pre><code>myClass = BaseClass.extend({ method1 : function(){ method2(); }, method2 : function(){ ...} }); </code></pre>
javascript
[3]
387,110
387,111
com.android.ddmlib.SyncException: No space left on device (physical phone not emulator)
<p>I'm making an app that shows tutorial videos (mp4). I had it working with a couple of videos the other day but when I added all of them (25 in total) in to the app and ran it on my device I got the error:</p> <blockquote> <p>[2012-07-23 11:34:19 - Pocket Instructor] Failed to install Pocket Instructor.apk on device 'S55708b4353d8': No space left on device [2012-07-23 11:34:19 - Pocket Instructor] com.android.ddmlib.SyncException: No space left on device [2012-07-23 11:34:19 - Pocket Instructor] Launch canceled!</p> </blockquote> <p>The thing is I have enough memory on my device so this shouldnt be a problem, should it?</p> <ul> <li>I have the install location set as prefer external. </li> <li>My .apk file is 102225 kb in size. </li> <li>My project folder is 300MB. </li> <li>My phone has 75.75MB internal storage space my sd card has 1.75gb storage space</li> </ul> <p>Does anyone have any possible solution or knows what I did wrong? what I have to do?</p>
android
[4]
3,069,595
3,069,596
Can an activity change its look
<p>I have an activity and a layout having nine ImageButtons and activities(think all of these as sub apps) attached to it, I have some more additional ImageButtons and activities attached to those buttons(more sub apps), the user should be able to choose only nine activities(sub apps) for the main layout, is this possible.</p> <p>If we want that activity choose the sub app else delete any of the activity(sub app) from the main screen.</p> <p>For example </p> <p>Like what we do on our windows desktop, whatever we want we keep as shortcut we keep it as icon and if we dont need we replace it or delete the icon, can same be reproduced in android.</p> <p>Any help or pointers would be helpful.</p> <p>thanks.</p>
android
[4]
3,518,869
3,518,870
Storing settings of custom types
<p>I've used the settings system in .NET before for a winforms app. However, what I wonder is what if I need to store settings of a custom type? Could I edit the settings designer-generated class file?</p> <p>I read a thread on here about doing this and it wasn't recommended (someone mentioned pressing F11 to open the file, or a similar key).</p> <p>What can I do in this scenario?</p> <p>Thanks</p>
c#
[0]
3,067,851
3,067,852
input String was not in correct format when converting text box value into integer using C#
<pre><code> SetValueForText = Convert.ToInt32(txtpatientid.Text); </code></pre> <p>Input string was not in a correct format. Please help me. thanks in advance.</p>
c#
[0]
3,990,525
3,990,526
Javascript nested class
<p>How do I define nested class in Java Script. </p> <p>Here is the code snippet I have:</p> <pre><code>objA = new TestA(); function TestB () { this.testPrint = function () { print ( " Inside testPrint " ); } } function TestA () { var myObjB = new TestB(); } </code></pre> <p>Now I am trying to access testPrint using objA</p> <pre><code>objA.myObjB.testPrint(); </code></pre> <p>But its giving error "objA has no properties"</p> <p>How can I access testB method using objA handler?</p>
javascript
[3]
4,212,878
4,212,879
C# Look up dictionary
<p>I'm currently trying to create a program that estimates location based on signal strength. The signal strength value is an int and then i need a lookup dictionary with ranges.</p> <p>So I would have something like:</p> <pre><code>Signal Strenth Position 0-9 1 10-19 2 20-29 3 </code></pre> <p>and then I would want to look up what position a signal strength relates to, for example 15 would relate to position 2.</p> <p>I know I can just have a load of if statements but is there a good way to do this using some sort of lookup dictionary?</p>
c#
[0]
1,260,213
1,260,214
PHP execute code on page close
<p>I am trying to find a method to execute some PHP code once a user closes the page. In my application, once the user closes or navigates away from the page the server will state the user as 'Offline' in the database. This requires the code to know when the user has navigated away from the page. My application also has an endless load (i.e. it will sleep until the user closes the page).</p> <p><strong>Edit:</strong></p> <p>Thanks for the answers. I decided to go with Pekka's session method, as this seemed the most logical for my application.</p> <p>Cheers</p>
php
[2]
4,487,810
4,487,811
Iphone-SDK "unable to read symbols error" when linking to IBOutlet in tab based app
<p>I built a very simple tab based app with 2 tabs, each tab tied to its own view controller. </p> <p>Straightforward so far. I then create a simple IBOutlet on my 2nd view controller like so</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface bViewController : UIViewController { IBOutlet UITextField *aField; } @property (nonatomic, retain) UITextField *aField; @end </code></pre> <p>then i synthesize it in my .m file, then i go into my xib, drag a text field onto the view and then set the files owner to 'aField'. </p> <p>Very textbook so far. </p> <p>It builds, but when i run it and select the 2nd tab (which shows the view where i've linked the UITextfield IBOutlet), it throws this error. </p> <pre><code>warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found). warning: Unable to read symbols from "UIKit" (not yet mapped into memory). warning: Unable to read symbols for "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" (file not found). warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory). </code></pre> <p>which is VERY ODD because this only started happening recently. Any clues?</p> <p><strong>UPDATE:</strong></p> <p>I'm beginning to suspect a config error rather than a syntax error because these are stripped down samples i created just to demonstrate the problem. This fails only when i create a tab-based application. </p> <p>if i do the EXACT same thing in a view-based application, it works fine. </p>
iphone
[8]
1,182,244
1,182,245
printer and print dialog
<p>I would like to print a file but I don't want to see the print Dialog appear each time I press Ctrl+P, I would like it to print the file I specify once I choose the Print button on my form. Is there any possible way to achieve this ? [I will set up all things: page size, color, printer print my document etc those of whose properties I get to display on my form.]</p>
c#
[0]
1,890,667
1,890,668
Tip rather than question: Pseudo-Push functionality through pushed email
<p>I was just wondering if anybody was using this technique:</p> <p>Since Push Notifications will only be coming with OS 3.0, I've been thinking of using Email Pushs (Exchange, mobile.me) as a workaround:</p> <p>You can register a URL, eg. myxyappname:// for your own app in iPhone. (See examples @ developer.apple.com/iphone)</p> <p>If you have a server and want to push something app-specific to your subscribers, you can just send them an email containing a specific link, eg. myxyappname://myxyappname?requesttype=X&amp;id=Y</p> <p>When the user receives the email (pushed, so should be fast...) and clicks on the mentioned link, your app will start on the iPhone automatically (if your app registered the url correctly), and within your app you can parse the url and display the corresponding info, based on the query string.</p> <p>old fart?</p>
iphone
[8]
2,580,901
2,580,902
Javascript web server?
<p>Is it possible to build a micro (proof of concept) web server in Javascript?</p> <p>Has anyone done this before?. </p> <hr> <p><strong>EDIT:</strong> <em>Apparently explicit clarification is needed here. The question is ultimately about how to push data from the server to the browser after the initial request made by the browser has been closed. In other words, how to make the browser accept subsequent requests initiated by a server.</em></p> <p><em>Does a javascript based web server need to be installed into the browser, or is there some other method?</em></p>
javascript
[3]
5,934,640
5,934,641
Should I use std::size_t to count instance of my class?
<p>I have a class:</p> <pre><code>class Nothing { /// Constructor, Destructor, Copy and Assignment public: Nothing(); ~Nothing(); Nothing(const Nothing&amp; clone); /// Operators const Nothing&amp; operator=(const Nothing&amp; other); /// Static Members private: static unsigned long long id_counter; static unsigned long long instance_counter; }; Nothing::Nothing() { m_name.clear(); id_counter ++; m_id = id_counter; instance_counter ++; } Nothing::~Nothing() { m_name.clear(); instance_counter --; } Nothing::Nothing(const Nothing&amp; other) { } unsigned long long Nothing::id_counter = 0; unsigned long long Nothing::instance_counter = 0; </code></pre> <p>Notice I am using unsigned long long to count instances of the class. Should I use std::size_t instead?</p> <p>As an aside: If I have an instance of a class, and I do something like this:</p> <pre><code>Nothing instance; instance(Nothing()); // Calling copy constructor </code></pre> <p>Will the destructor be called before the copy constructor is called? Reason for asking is do I need <code>id_counter ++;</code> and <code>instance_counter ++;</code> inside of my copy constructor?</p>
c++
[6]
4,885,937
4,885,938
Why is my setImage line not working?
<p>I have written 1 code for</p> <pre><code>-(IBAction)action:(UIEvent *)id { [act setImage:[UIImage imageNamed:@"down.png"] forState:UIControlStateHighlighted]; } </code></pre> <p>It's working, but I have written 1 code for</p> <pre><code>-(IBAction)action:(UIEvent *)id { [act setImage:[UIImage imageNamed:@"down.png"] forState:UIControlStateHighlighted]; } </code></pre> <p>And after that I had written code for communication with server.</p> <p>Now the <code>setImage:</code> line is not working.</p> <p>What should I do?</p>
iphone
[8]
291,695
291,696
How to remake this cycle
<p>here is my code which needs to make a check about a student by his faculty number, and if there is no information to say that ...</p> <pre><code>cout&lt;&lt;"Enter faculty number of the student(8 digits): "&lt;&lt;endl; cin&gt;&gt;ch; cout&lt;&lt;"Information about student with number:"&lt;&lt;ch&lt;&lt;endl; for(i=0;i&lt;n;i++) { if(m[i][0]==ch) { for(j=0;j&lt;4;j++) cout&lt;&lt;setprecision(8)&lt;&lt;m[i][j]&lt;&lt;"\t"; } else if(m[i][0]!=ch) { cout&lt;&lt;"No information about this student"&lt;&lt;endl; } } </code></pre> <p>it works mostly fine, the problem is that if my "n"(number of student typed out of this code) is 3 ... we will have 3 student and the cycle "for" will be made 3 times .. and we type 1 student (actually we are typing 1 faculty number) when i start the program it says whole information about that student and on two new lines it says "No information about this student". I cant put the IF check out of that FOR with N because i need to roll the m[i]... thanks</p>
c++
[6]
2,259,370
2,259,371
Access the Name of all files in folder using JavaScript
<p>Can you tell me if there is a way to get the list of files in current folder. The current folder is the folder from where my .html file is executing. This will be running at server side probably if necessary.</p> <p>I have googled everything and got to know there are some ways to do it with FileSystemObject but I am not a big fan of it. I have no problem is giving credentials if required.</p>
javascript
[3]
876,354
876,355
populating two different tableviews of two different viewcontroller classes with two different sqlite files data?
<p>I am working on an app having tabbarcontroller plus navigation controller.Tabbar controller has two tabbar items.Each tab bar item has a tableview associated with it.i want to populate the two different tableviews with two different sqlite files data.how can i do so?.is there any example related to it..</p> <p>Thanks!</p>
iphone
[8]
3,525,814
3,525,815
Page doesn't postback if it has validation control after deployment
<p>I have a page with a RadioButtonList which should post back when the selection is changed. But because of RequiredFieldValidator on the page, the postback is not happening. It is working fine on //localhost/ but not after deployment to production server.</p> <p>The error on the page is: 'event' is null or not an object <br>Line: 126 Char: 5 Code: 0</p> <p>URI: <a href="http://web-dev:90/aspnet_client/system_web/2_0_50727/WebUIValidation.js" rel="nofollow">http://web-dev:90/aspnet_client/system_web/2_0_50727/WebUIValidation.js</a></p> <p>A few things which I have already tried:</p> <p>1) aspnet_client folder is in its proper place.</p> <p>2) I have added <code>Page.Validate() and if(Page.IsValid){}</code> statements with the button on whose click the validation should happen.</p> <p>3) The ValidatorCommonOnSubmit function in <code>WebUIValidation.js</code> file looks like this: <pre><code> function ValidatorCommonOnSubmit() { event.returnValue = !Page_BlockSubmit; Page_BlockSubmit = false; return event.returnValue;} </pre></code> Can somebody help me with this? Any help would be appreciated. Thanks!!</p>
asp.net
[9]
5,021,474
5,021,475
visibility of buttons and layout
<p>I have 10*3 buttons on my screen. When I click a button, I want it to be unvisible, so I do : <code>arg0.setVisibility(View.GONE);</code></p> <p>But whenever the button is gone, the buttons change their size. For example, if at the begining every button took 1/3 of a row, now when a button is gone the other buttons in the row get wider..</p> <p>Is there a way to make them not change their size when a button is removed?</p>
android
[4]
5,156,028
5,156,029
i am having issue with the $id_get['id '] funtion
<p>first off i am new to php, i want to be able to call the comment that users make on a picture on the same page as the pic. and when a different page comes up that comment for that pic is displayed also. i am able to that, but i cant seem to call the url for that pic without changing the actual code.</p> <pre><code>&lt;? include..... $picid = $_GET['picid']; $query = mysql_query("SELECT * FROM pic_info WHERE picid = 'picid1' ");// problem while($rows = mysql_fetch_assoc($query)): $picid = $rows['picid']; $title = $rows['title']; $link = $rows['link']; $description = $rows['description']; $movie_pic = $rows['movie_pic']; $source = $rows['source']; endwhile; $get_comment = mysql_query("SELECT * FROM comment WHERE picid ='$picid'");// work partially $comment_count = mysql_num_rows($get_comment); if ($comment_count&gt;0) { while ($com = mysql_fetch_array($get_comment)){ $comment_id = $com['comment_id']; $name = $com['name']; $message = $com['message']; $time_post= $com['time_post']; $messages .= '&lt;em&gt; on ' .$time_post.'&lt;/em&gt;&lt;b&gt; '.$name.' said.....&lt;/b&gt;&lt;br/&gt; '.$message.'&lt;hr/&gt;'; } ?&gt; </code></pre> <p>problem:: only work if i change picid1 to some thing else like picid2 or 3 or 4... work partially :: works when i change picid1 to some thing else like picid2 or 3 or 4... other than that it comes up saying no comment.</p> <p>i not sure if the problem is at top, cant figure it out.</p>
php
[2]
4,934,906
4,934,907
Rapidly accessing collection through singleton vs direct reference
<p>I have a collection that is defined in instance of singleton, the collection is accesed constantly (million of times).</p> <p>Right now I am adding values to collection through the singleton:</p> <pre><code>DataRepository.getInstance().addToCollection(collectionId, value); </code></pre> <p>(In add collection method I first load the collection from hashmap by collectionId, and then add value to it)</p> <p>Will I get any performance improvement if I load the instance of the collection and use the reference directly?</p> <p>like:</p> <pre><code>CustomCollection collection = DataRepository.getInstance().getCollection(collectionId); </code></pre>
java
[1]
3,095,557
3,095,558
Need the count of the particular <li> tag clicked
<pre><code>&lt;ul&gt; &lt;li&gt;&lt;div&gt;&lt;a href="#"&gt;line a&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div&gt;&lt;a href="#"&gt;line b&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div&gt;&lt;a href="#"&gt;line c&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div&gt;&lt;a href="#"&gt;line d&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div&gt;&lt;a href="#"&gt;line e&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>The output that I need is to get the position(count) of the <code>&lt;li&gt;</code> tag. I cant use the <code>index()</code> for this. For eg., if I click on "Line a", the output I need to get is "1", for "Line b" I need "2"; and so on.</p> <p>I cant use the index().</p>
jquery
[5]
337,186
337,187
Java shuffle program
<p>I have to write this program in java.</p> <p>Write a program name sorting.java that will use an array to store 10,000 randomly generated numbers (ranging from 1 to 10,000 no repeat number).</p> <p>I realize this is similar to a question I asked recently but I am wondering if anyone can check my program and see if I made any mistakes.</p> <pre><code>public class Sort { public static void main(String[] args) { Random rgen = new Random(); // Random number generator int[] nums = new int[10,000]; //array to store 10000 random integers (1-10,000) //--- Initialize the array to the ints 1-10,000 for (int i=0; i&lt;nums.length; i++) { nums[i] = i; } //--- Shuffle by exchanging each element randomly for (int i=0; i&lt;nums.length; i++) { int randomPosition = rgen.nextInt(nums.length); int temp = nums[i]; nums[i] = nums[randomPosition]; nums[randomPosition] = temp; } //Print results for (int i = 0; i &lt; nums.length; i++){ System.out.println(nums[i]); System.out.println("\n"); } } </code></pre>
java
[1]
4,171,274
4,171,275
Cannot deploy asp.net openid library on shared hosting service
<p>I have deployed successfully the dotnetopenid dll under IIS7 but on my shared hosting service it says:</p> <blockquote> <p>Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.</p> <p>Compiler Error Message: CS0246: The type or namespace name 'DotNetOpenId' could not be found (are you missing a using directive or an assembly reference?)</p> </blockquote> <p>Why ?</p>
asp.net
[9]
4,567,869
4,567,870
how to display the indexPath value
<p>my question is how can i display the value of the selected item in a UITableView (index or the text value) in NSLog i want to test on this value to select the right view thanks for your help </p>
iphone
[8]
10,466
10,467
Copying to binary file row of a matrix
<p>I want to write each row of a matrix to a binary file. I try writing it like this: </p> <pre><code>vector&lt; vector&lt;uint32_t&gt; &gt; matrix; </code></pre> <p>...</p> <pre><code>for(size_t i = 0; i &lt; matrix.size(); ++i) ofile-&gt;write( reinterpret_cast&lt;char*&gt;(&amp;matrix[i]), sizeof(uint32_t*sizeof(matrix[i])) ); { for(size_t j = 0; j &lt; numcols; ++j) { std::cout &lt;&lt; left &lt;&lt; setw(10) &lt;&lt; matrix[i][j]; } cout &lt;&lt; endl; } </code></pre> <p>but it doesn't work, I get garbage numbers. </p> <p>Any help appreciated,</p> <p>Ted.</p>
c++
[6]
4,849,781
4,849,782
jquery-ui: creating a customized collapsablility function
<p>I am trying to create <code>&lt;caption&gt;</code> tags that are, by default, uncollapsed but which, as an "onclick" property, can be collapsed. I'd also like for the expansion/collapsing to animate very slightly—I'd like for them to "unfold" or transition vertically downward when expanding and to transition vertically upward when collapsing. </p> <p>Currently I am using:</p> <pre><code>jQuery(document).ready(function(){ $('.cv .collapsable').click(function() { $(this).next().toggle('slow'); return false; }).next().hide(); }); </code></pre> <p>However, this animates the <em>presentation of the content</em> within the collapsed <code>&lt;caption&gt;</code> rather than the unfolding of the parent element. I would really like to see the parent element expanding downward before the content of the element is displayed (or would be equally satisfied with the content of the element becoming visible as the element expands). Either way the issue is that the expansion is instantaneous and a bit jarring, whereas, once expanded, the content fades in gently.</p> <p>Additionally, this function defaults to a collapsed state rather than an expanded one, and I need it to do the inverse. Basically, I want people to be able to collapse this to conserve screen real-estate if need be, but to otherwise have a normal and complete display of all the content between each <code>caption</code> tag. I'm sure this is very simple, I am complete <em>jquery</em> nub.</p>
jquery
[5]
2,946,456
2,946,457
Adding and removing elements efficiently from Collection object
<p>Below coding is the working sample,but still i am not happy with this code with related to performancewise.Please have a look and let me know if any better approach is there.Thanks in advance.</p> <p><strong>Adding items to the arraylist object</strong></p> <pre><code>String resultItems[] = paging.getMoveLeftArray().split(","); String fields[]={"id","name","name1"}; leftObj=new ArrayList(); for(int i=0;i&lt;resultItems.length;i++){ //below line mea TestVO bean=new TestVO(); String resultItem = resultItems[i]; String idANDname[] = resultItem.split("@"); String id = idANDname[0]; // name or id should not contain "-" String name[] = idANDname[1].split("-"); //values and fileds are always having same length for(int j=0;j&lt;name.length;j++) { PropertyUtils.setProperty(bean, fields[j], name[j]); } leftObj.add(bean); } </code></pre> <p><strong>Removing items from the arraylist object:availableList contains all the TestVO objects:</strong></p> <pre><code>String []removeArray=paging.getMoveRightArray().split(","); tempList=new CopyOnWriteArrayList(); newTempList=new CopyOnWriteArrayList(); for(int i=0;i&lt;availableList.size();i++){ boolean flag = false; TestVO tempObj = (TestVO )availableList.get(i); int id =(Integer)tempObj.getId(); // System.out.println("id value"+id); // availableList.get(i).getClass().getField(name); for(int j=0;j&lt;removeArray.length;j++){ String resultItem = removeArray[j]; String idandname[] = resultItem.split("@"); for(int k=0;k&lt;idandname.length;k++){ String ids[]=idandname[0].split("-"); if(id==Integer.parseInt(ids[0])){ flag = true; break; } } } if(flag){ tempList.add(tempObj); } else{ newTempList.add(tempObj); } </code></pre>
java
[1]
2,938,828
2,938,829
I can not figure out how to pass a vector back to main after it has been through the loop
<pre><code>#include &lt;vector&gt; #include &lt;iostream&gt; using namespace std; vector&lt;int&gt; fibonacci(int x, int y,vector&lt;int&gt; vi,int n){ vi[0]=x; vi[1]=y; for(int i=2;i&lt;n;i++){ x=vi[i-2]; y=vi[i-1]; vi[i]=x+y; cout&lt;&lt;vi[i]&lt;&lt;" "&lt;&lt;endl; } return vi; } void printv(string label, vector&lt;int&gt; vi, int n){ cout&lt;&lt;label&lt;&lt;" "&lt;&lt;endl; for (int j=0; j&lt;n; j++) cout&lt;&lt;vi[j]&lt;&lt;" "&lt;&lt;endl; } /*void reverseV(vector&lt;int&gt; vi,int n) { vector&lt;int&gt; rv= vi; for (int i=rv.size()-1; i&gt;=0; i--) { cout &lt;&lt; rv[i] &lt;&lt; endl; }*/ //} int main() { int x; int y; vector&lt;int&gt; vi; vector&lt;int&gt; rv; int n=100; string label; cout&lt;&lt;"enter the max number of times you want it to add"&lt;&lt;endl; cin&gt;&gt;n; cout&lt;&lt;"enter the first two fibonacci numbers"&lt;&lt;endl; cin&gt;&gt;x&gt;&gt;y; fibonacci(x,y,vi,n); printv("vector: ",vi,n); printv("vector: ",rv,n); //vi.swap(rv); } </code></pre>
c++
[6]
3,831,021
3,831,022
How to call a php static function and pass values to it
<p>I know this might be a basic question but when I google it ,found different solutions for different php versions..in brief without wasting your time I have a. class `</p> <pre><code>class UploadHandler { protected $options; public static $path; public $prop1=''; function __construct($options=null,$x){ $this-&gt;prop1 = $x; $this-&gt;options = array( 'script_url' =&gt; $this-&gt;getFullUrl().'/', 'upload_dir' =&gt; dirname($_SERVER['SCRIPT_FILENAME']).$this-&gt;getPath(), 'upload_url' =&gt; $this-&gt;getFullUrl().$this-&gt;getPath(),` ....and so on </code></pre> <p>AND methods inside it:</p> <pre><code>public function getPath() { return self::$path; } static public function setPath($autoSave) </code></pre> <p>{</p> <pre><code>self::$path = $autoSave; </code></pre> <p>}</p> <p>and in another place I do this: <code>require('upload.class.php');</code>.......//the above class consists inside this</p> <pre><code>UploadHandler::setPath('/files/'); </code></pre> <p>why doesn't it work...??..please help me or guide me to a better tutorial</p>
php
[2]
656,834
656,835
Dynamic instantiation in JavaScript
<p>Apart from eval, is there any other way to instantiate an object using variable argument list?</p> <p>E.g.: <code>var foo = instantiate(className, [arg1, arg2, ...])</code></p>
javascript
[3]
4,009,014
4,009,015
Using Response.Redirect() to a relative path
<p>I'm working with ASP.net. My website is hosted within a subfolder <code>test</code> under the IIS root directory. So the url of default.aspx is <code>http://localhost/test/Default.aspx</code>. From default.aspx, I want to use <code>Reponse.Redirect()</code> with a relative path to redirect to another url within the same web site, <code>http://localhost/test/whatever</code>.</p> <p>I tried </p> <pre><code>Response.Redirect("/whatever"); </code></pre> <p>and </p> <pre><code>Response.Redirect("~/whatever"); </code></pre> <p>Both of them redirect to <code>http://localhost/whatever</code>. Note that the <code>Redirect</code> method use <code>http://localhost</code> instead of <code>http://localhost/test/</code> as the base url. </p> <p>Any ideas?</p> <p>Thanks.</p>
asp.net
[9]
4,137,739
4,137,740
How to disable back button In camera in Android
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/13191946/disable-back-button-in-androidnot-working">Disable back button in Android(Not working)</a> </p> </blockquote> <p>I am using the default camera in my app(The inbuilt-camera feature of Android). I have tried using</p> <pre><code> public void onBackPressed() { } </code></pre> <p>but instead of blocking the back button, the app hangs forcing the user to terminate the app/restart it.</p>
android
[4]
5,835,416
5,835,417
C# numericupdown control - focus
<p>I am using numericupdown controls, one for setting the minimum range and other for the maximum range. User removes the entire value present in the minimum range numeric updown by pressing delete key or backspace key and moves to the maximumrange, now in the minimum range numericupdown a default value to be displayed. For this I am listening to the LostFocus events and assigning the values , but the values are not displayed. How to display the values in this case.</p>
c#
[0]