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,583,131
5,583,132
iPhone how to create scrollable filter like Mashable App?
<p>I'd like to create a scrollable filter just below the navigation bar like in the Mashable iPhone app.</p> <p>Here's what it looks like:</p> <p><a href="http://itunes.apple.com/us/app/mashable/id356202138?mt=8" rel="nofollow">http://itunes.apple.com/us/app/mashable/id356202138?mt=8</a></p> <p><a href="http://img20.imageshack.us/i/mashable.png/" rel="nofollow">http://img20.imageshack.us/i/mashable.png/</a></p> <p>Does anyone know how to do this ?</p>
iphone
[8]
2,549,191
2,549,192
How can i replace Space with %20 in javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/853804/jquery-javascript-replace-space-in-anchor-link-with-20">jQuery / Javascript replace &lt;space&gt; in anchor link with %20</a> </p> </blockquote> <p>I am getting sParameter like this :</p> <p><code>sParameter = document.getElementById('ddParameterType').value;</code></p> <p>If i am getting word like <code>"Test - Text"</code> as the ddParameterType item <br/>then i am replacing the space in word like below:</p> <p><code>sParameter = document.getElementById('ddParameterType').value.replace("","%20");</code></p> <p>but its returning a valur like <code>%20Test - Text</code>.<br/> I need like <code>Test%20-%20Text</code>.</p> <p>can anyone help.</p>
javascript
[3]
5,106,268
5,106,269
Android: Reading from file (Openfileinput)
<p>I am writing a basic notepad app for a unit at uni. I have created the main class with an editText which I save as string textOutput. </p> <p>I have used the following code from the android developers website to save the string to a file:</p> <pre><code> FileOutputStream fos = openFileOutput(textOutput, Context.MODE_PRIVATE); fos.write(textOutput.getBytes()); fos.close(); </code></pre> <p>However, they say to read you use the following stages:</p> <blockquote> <p>To read a file from internal storage:</p> <p>Call openFileInput() and pass it the name of the file to read. This returns a FileInputStream. Read bytes from the file with read(). Then close the stream with close().</p> </blockquote> <p>What the hell does this mean, and who to I implement it into my app?</p> <p>Please help.</p>
android
[4]
3,901,749
3,901,750
Iterate two Lists or Arrays with one ForEach statment in C#
<p>This just for general knowledge:</p> <p>If I have two, let's say, <strong>List</strong>, and I want to iterate both with the same foreach loop, can we do that?</p> <p><strong>Edit</strong></p> <p>Just to clarify, I wanted to do this:</p> <pre><code>List&lt;String&gt; listA = new List&lt;string&gt; { "string", "string" }; List&lt;String&gt; listB = new List&lt;string&gt; { "string", "string" }; for(int i = 0; i &lt; listA.Count; i++) listB[i] = listA[i]; </code></pre> <p>But with a foreach =)</p>
c#
[0]
2,783,942
2,783,943
Array iteration issue
<p>I have this array which I echo and get this result:</p> <pre><code>$hostess_ids=array(); while($row=mysql_fetch_array($resulthst,MYSQL_ASSOC)){ $hostess_ids[]=$row['hostess_id']; } $j=0; foreach($hostess_ids as $hostess_selected){ $hostess_array= explode("-",$hostess_selected); for ($j=0; $j&lt;count($hostess_array);$j++) { $hst1=$hostess_array[$j]; $sql2=""; } } </code></pre> <p>This is the output</p> <pre><code>array(1) { [0]=&gt; string(2) "16" } array(1) { [0]=&gt; string(2) "16" } array(1) { [0]=&gt; string(0) "" } array(1) { [0]=&gt; string(0) "" } array(2) { [0]=&gt; string(2) "17" [1]=&gt; string(1) "1" } array(1) { [0]=&gt; string(0) "" } array(2) { [0]=&gt; string(2) "17" [1]=&gt; string(1) "1" } array(2) { [0]=&gt; string(2) "17" [1]=&gt; string(2) "16" } </code></pre> <p>The output of hostess_ids[]</p> <pre><code> array(8) { [0]=&gt; string(2) "16" [1]=&gt; string(2) "16" [2]=&gt; string(0) "" [3]=&gt; string(0) "" [4]=&gt; string(4) "17-1" [5]=&gt; string(0) "" [6]=&gt; string(4) "17-1" [7]=&gt; string(5) "17-16" } </code></pre> <p>How can I iterate in this array to get the first ceel values, then the second one, etc.</p>
php
[2]
5,015,546
5,015,547
BalloonTip can I set diffrent colors to the title?
<p><br> <code>notifyIcon1.ShowBalloonTip</code><br> 1. Can I set the title to a diffrent color?<br> 2. Can I prevent one ballon tip to override the previous one? that means to wait until the previous dissapear and only then show?</p> <pre><code>notifyIcon.ShowBalloon(20000, "My Title", "My Text", ToolTipIcon.Info); </code></pre> <p>Thanks.</p>
c#
[0]
5,514,969
5,514,970
What type of View I can use for text+images report?
<p>I want to make some sort of <strong>non-editable</strong> "report" view with images, titles and text in it. Images generates in code, not from bandle, so I can't use UIWebView.</p> <p>User puts some data into previous view and press "done" - Next view opens with </p> <pre><code>"generated image some text title mini title image text ... " etc </code></pre> <p>I think its similar to custom UITableView + UITextView. Has anyone other suggestions?</p> <p>UPD View is dynamic (not fixed) - text and images generates from code. "report" can be different length from time to time. User can scroll this "report". It's like Help screen in some applications - rich-format text with images.</p>
iphone
[8]
4,108,339
4,108,340
How can i put navigationbar after a splash screen?
<p>I an new in iphone application i want to put Nevigation controller after a splash screen so how can i put?Is there any way to put nevigationbar in my application without Splash Screen. </p>
iphone
[8]
4,482,753
4,482,754
How can I draw a text in my view?
<p>How can I draw a text in drawRect?</p>
iphone
[8]
2,530,506
2,530,507
Adding multiple rows to the table at once based on textbox value?
<p>This is a table I created using html code, and there is a textbox field for user to insert the value. </p> <p>If the user insert two of them and click go, the 2 rows will be automatically added at once to the table below but I there is only available to add one row when clicked. </p> <p>Is that possible to add more than one at once in javascript or php?</p>
javascript
[3]
2,411,674
2,411,675
Expanding List? (android)
<p>So i want to make a list that has a number of items on the list but when a item is clicked i would like it to expand in the list to revile more information</p> <p>i have done something similar with java script before but searching google isnt helping me :(</p> <p>Does any one know a way i can achieve this or will i be stuck using multiple pages.</p>
android
[4]
2,074,090
2,074,091
Help with windows path - PHP
<p>I have this path and it is correct however, the browser will not include the source file unless I put "file:///" in front of it. I'm still developing and this will ultimately be on a Linux machine but in the mean time, I'd like to see my work as well as be able to troubleshoot it. Is there a solution for this?</p> <p>This fails:</p> <pre><code>C:\Program Files (x86)\work\site\js\rowlock.js </code></pre> <p>This does not fail:</p> <pre><code>file:///C:\Program Files (x86)\work\site\js\rowlock.js </code></pre>
php
[2]
3,430,557
3,430,558
Is it possible to wake up iPhone?
<p>I would like to know if it's possible to programatically wake up the iPhone from sleep? I have an NSTimer set to play a sound after a certain amount of time, but I also want it to wake up the iPhone when the timer rings. Is this at all possible? Thanks!</p>
iphone
[8]
872,214
872,215
JQuery .hover() functions external
<p>I run into a little problem today. I've a divbox. This divbox should expand if I hover it and should collapse if I leave it. </p> <p>so I write two functions:</p> <ol> <li>function expand(){....};</li> <li>function collapse(){....};</li> </ol> <p>and then i tried to do the hover effect as following:</p> <pre><code>$('.divboxes').hover(expand(), collapse()); </code></pre> <p>I thought this will work...but...not.</p> <p>serveral times I used it like:</p> <pre><code>$('.divboxes').hover(function(){...},function(){...}); </code></pre> <p>and it worked...so can someone explain me what I am doing wrong? I want the functions external!</p> <p>Kind Regards</p>
jquery
[5]
3,652,788
3,652,789
how to trim the Unicode \u0085 character in a String in Java
<p>I'm not able to trim the unicode control character <code>\u0085</code> in Java. How can you do this?</p> <pre><code>String str = "\u0000\u001f\u0085 hi \n" PrintStream out = new PrintStream(System.out, true, "UTF-8"); out.println(teststr); String st = teststr.replaceAll("\\p{Cntrl}", ""); out.println(st); </code></pre> <p>The character <code>\u0085</code> gets printed as ? and doesn't seem to get replaced.</p>
java
[1]
5,190,424
5,190,425
How to strip everything from a variable apart from text and numbers
<p>I'm new to PHP and i'm wondering how i would write a function like this, is there a existing function for this? </p>
php
[2]
5,758,926
5,758,927
Android - methods to alert a user?
<p>I have an android application that gets data from the web such as an event title, location, date and time. I'd like to alert the user when it is time for the event. I've tried using the calendar API but that seems to be quite vague and unsupported by android. Are there any other ways to alert a user when there is an upcoming event based on the date and time I supply? Being able to set an alarm or something would do as well.</p>
android
[4]
4,081,533
4,081,534
How to compile and host asp.net websites?
<p>I'm trying to understand the basics of deploying a c#.net website on a Godaddy server. As of now, project runs properly when I press F5 in Visual Web Developper 2010. However, when I upload it I get the error: constants does not exist in the current context. constants is defined in the file constants.cs which is located in the same directory.</p> <p>I'm not familiar with c#.net, so here are my questionments</p> <ul> <li>Do I need some kind of includes to reference constants.cs?</li> <li>Do I need to build the website a special way?</li> <li>Is there a folder structure that I need to follow?</li> </ul>
asp.net
[9]
5,504,842
5,504,843
How to place the selected Li in h4 using jquery
<p><a href="http://jsfiddle.net/soul/EamPb/" rel="nofollow">complete code JSFIDDLE</a></p> <p>as shown in the code the selected state comes below the h4 , how to display the selected state in h4 and after selecting a state it just shows that particular state and not able to select other states</p>
jquery
[5]
5,801,219
5,801,220
need to convert UTC (aws ec2) to PST in python
<p>I need to convert UTC time, (on ec2 instance) to PST. I am trying to do this. </p> <pre><code>from datetime import datetime from pytz import timezone import pytz date_format='%m/%d/%Y %H:%M:%S %Z' date = datetime.now() print 'Current date &amp; time is:', date.strftime(date_format) my_timezone=timezone('US/Pacific') date = my_timezone.localize(date) date = date.astimezone(my_timezone) print 'Local date &amp; time is :', date.strftime(date_format) </code></pre> <p>But the output is:</p> <pre><code>Current date &amp; time is: 01/10/2012 20:01:14 Local date &amp; time is : 01/10/2012 20:01:14 PST </code></pre> <p>Any reason why I am not getting the right PST time?</p>
python
[7]
3,546,150
3,546,151
inaccurate values in listitem
<p>I have the following code that should generate listitems from a string that came from server. The code is as follows: </p> <pre><code>foreach (String str in years) { if (string.IsNullOrEmpty(str) || str.Equals(" ")) { System.Diagnostics.Debug.WriteLine("empty"); } else { System.Diagnostics.Debug.WriteLine(str); yearLi.Value = str; yearList.Add(yearLi); count = yearList.Count; } System.Diagnostics.Debug.WriteLine("count--&gt;" + count); } </code></pre> <p>Now my problem is,if the string array "years" has {2011,2012} the list should be 2011 and 2012. But it has 2012,2012. I am not able to find the fault in this code. Please advice.</p>
c#
[0]
30,609
30,610
Why we cant create protected methods in JAVA intefaces?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/423032/interfaces-in-java-cannot-make-implemented-methods-protected-or-private">Interfaces in Java: cannot make implemented methods protected or private</a> </p> </blockquote> <p>By default all the methods in inteface are public and abstract. We can't define private method in inteface because its scope will be inside the interface itself. So private is meaningless resulting Compile time error.</p> <p>Now the questions comes why cant we have protected?</p>
java
[1]
5,669,118
5,669,119
In Python how can I copy a list of dictionaries, and filter specific keys, including nested ones?
<p>If I have a dictionary, which contains lists, dictionaries, strings, and integers, how can I copy that dictionary, but only specific white listed keys?</p> <p>Filtering <code>old_dict</code> through this function would give me <code>new_dict</code>. The white listed keys can be in whatever format, but the solution should be able to take an object of arbitrary white listed keys to produce the output.</p> <pre><code>old_dict = [ { 'name': {'first': "John", 'last': "Doe"}, 'groups': ["foo", "bar"], 'widgets': [ {'id': 0, 'name': "Acme"}, {'id': 1, 'name': "Anvil"}, ], }, { 'name': {'first': "David"}, 'groups': ["bar", "bash", "ding"], 'widgets': [ {'id': 1, 'name': "Anvil"}, {'id': 8, 'name': "Bingo"}, ], }, ] new_dict = [ { 'name': {'last': "Doe"}, 'widgets': [ {'name': "Acme"}, {'name': "Anvil"}, ], }, { 'name': { }, 'widgets': [ {'name': "Anvil"}, {'name': "Bingo"}, ], }, ] </code></pre>
python
[7]
5,276,897
5,276,898
How to edit file on console from Java?
<p>I'm trying to edit a file from CLI. I'm executing the <code>nano</code> command (I know that command will always be available); when I execute it, I can see nano's output but I cannot interact with it. How can I pass user input to the command? Do you have a better idea to easily edit a file from within my Java app?</p> <p>This is my code:</p> <pre><code>String command = "nano /tmp/163377867.txt "; try { Process process = Runtime.getRuntime().exec(command); InputStream inputStream = process.getInputStream(); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String line; while ((line = bufferedReader.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } </code></pre>
java
[1]
4,729,258
4,729,259
Functions with dependencies passed as parameters
<p>I'm working on a project where I'm batch generating XML files which can import to the IDE of an industrial touchscreen.</p> <p>Each XML file represents a screen, and most screens require the same functions and the process for dealing with them is the same, with the exception of the fact that each screen type has a unique configuration function.</p> <p>I'm using a <code>ScreenType</code> class to hold attributes specific to a screen type, so I decided to write a unique configuration for each type, and pass it as a parameter to the <code>__init__()</code> of this class. This way, when I pass around my <code>ScreenType</code> as it is needed, it's configuration function will stay bundled and can be used whenever needed. </p> <p>But I'm not sure what will happen if my configuration function itself has a dependency. For example:</p> <pre><code>def configure_inputdiag(a, b, c): numerical_formatting = get_numerics(a) # ... return configured_object </code></pre> <p>Then, when it comes time to create an instance of a <code>ScreenType</code></p> <pre><code>myscreentype = ScreenType(foo, man, shoe, configure_inputdiag) </code></pre> <p><code>get_numerics</code> is a module scoped function, but <code>myscreentype</code> could (and does) get passed within other modules. </p> <p>Does this create a problem with dependencies? I'd try to test it myself, but it seems like I don't have a fundamental understanding behind what's going on when I pass a function as a parameter. I don't want to draw incorrect conclusions about what's happening.</p> <p>What I've tried: Googling, Search SO, and I didn't find anything specifically for Python.</p> <p>Thanks in advance.</p>
python
[7]
754,460
754,461
Javascript Notification Pop-up?
<p>Looking for the best approach to perform a javascript notification pop-up if amount in field A is edited to a smaller amount that what is found in field B?</p> <p>We aren't using any js frameworks but that option isn't ruled out.</p> <p>Thanks.</p>
javascript
[3]
5,065,419
5,065,420
Crawling Twitter with Java twitter4j and building graph of relationships
<p>I am new to crawling social networks. Nevertheless, I need to write <strong>Twitter</strong> crawler that basically goes through <strong>Twitter</strong> and builds <strong>dependency</strong> *<em>graph</em>* between <em>Users</em> (with respect to relations like for example <strong>follows</strong>, <strong>mentions</strong>) and <em>Tweets</em>. I need to do it in <strong>Java</strong>. I know that there is <strong>twitter4j</strong> which basically can do much stuff with <strong>Twitter</strong>. The problem is that <strong>twitter4j</strong> is huge and I am somehow lost in getting what I need in my task from it. I know also that there is somehow limited <strong>search</strong> API and <strong>streaming</strong> API. Which one should I use when I want to get as much data from <strong>Twitter</strong> as possible ? So I would be greatful if anybody give me some directions how to get this data from <strong>Twitter</strong> (apart from parsing tons of <strong>JSON</strong> files if possible...). Any newbie guides much appreciated (what subset of <strong>twitter4j</strong> classes should I use, some tutorials if available, maybe some example code to get some data etc).</p> <p>PS: Is it necessary to use <strong>OAuth</strong> to have full capabilities in obtaining data from <strong>Twitter</strong> ?</p>
java
[1]
2,629,299
2,629,300
Piecewise equation program
<p>I did this program which is a piecewise equation program and I just want to know if i did anything wrong or if i missed anything. The answers are coming out to be right but just wanted to make sure i didn't miss any coding.</p> <pre><code>class RecursiveMethods { RecursiveMethods() //default constructor { } public int fOf(int x) { if (x &lt;= 10) //the base case { System.out.println(x + " &lt;= 10, therefore ... f(" + x + ") = -5"); return -5; } else { System.out.println(x + " &gt; 10, therefore ... f(" + x + ") = f(" + x + " - 3) + 2 = f(" + (x -3) + ") + 2"); return fOf(x-3) + 2; } } } public class RecursionMethodTester { public static void main(String[] args) { int x; RecursiveMethods rMethods = new RecursiveMethods(); System.out.println("---------------------------------"); System.out.println(" f(x - 3) + 2 if x &gt; 10"); System.out.println("f(x) = "); System.out.println(" -5 if x &lt;= 10"); System.out.println("---------------------------------"); System.out.println(); x = 20; System.out.println("Example 1: x = " + x); System.out.println("f(" + x + ") = " + rMethods.fOf(x)); System.out.println(); x = 19; System.out.println("Example 2: x = " + x); System.out.println("f(" + x + ") = " + rMethods.fOf(x)); System.out.println(); x = 18; System.out.println("Example 3: x = " + x); System.out.println("f(" + x + ") = " + rMethods.fOf(x)); System.out.println(); } } </code></pre> <p>Thank you for your support.</p>
java
[1]
3,808,821
3,808,822
I want that when the mouse is over one option in my dropdownlist, the background color of the option value on my second mask must be changed
<p>I have 2 dialog mask on my window. </p> <p>On the fist one I have a drop-down list with different option values.</p> <p>On the second I have a div table.</p> <p>I want that when the mouse is over one option in my drop-down list, the background color of the option value on my second mask must be changed and when I leave the background color be restored to white, so that I can know the corresponded feet and meter's value before i selected.</p> <p>Please look at the screenshot</p>
jquery
[5]
2,126,240
2,126,241
How to check if sendBroadcast has finished his job
<p>I got little problem. I'm refreshing my sdcard using:</p> <pre><code>sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); </code></pre> <p>and I have created <code>ProgressDialog</code> with a spinner which pops out at the start ("at the start" - I mean after sendBroadcast method), and after successful refresh I would like to dismiss it, but I got no idea how to check that <code>MediaScanner</code> finished his job. I tried using <code>BroadcastReciver</code> and <code>sendStickyOrderedBroadcast(...)</code>, but its seems it was wrong idea...</p> <p>I can't use <code>MediaScannerConnection</code> and <code>OnScanCompletedListener()</code> because I don't have direct paths to the files (in some situations, it doesn't exist). Does anyone have any idea how to solve my problem? I have run out of ideas</p>
android
[4]
124,005
124,006
Issue with member of custom object
<p>I have a custom class</p> <pre><code>@interface XYZ : NSObject </code></pre> <p>{ int sum; .... }</p> <p>@property (nonatomic, assign) int sum; .....</p> <p>In my method, I initialize a new class as:</p> <pre><code>XYZ *myClass = [[XYZ alloc] init]; </code></pre> <p>Then in a for loop in that method, I assign the value of sum based on a condition:</p> <pre><code>if( ) </code></pre> <p>{ myClass.sum = val;</p> <p>NSLog(@"%d", myClass.sum); }</p> <p>The NSLog prints the correct value. (The value here is = 6)</p> <p>Now, once I am out of the for loop, I again print the value of sum using the same NSLog statement:</p> <pre><code>NSLog(@"%d", myClass.sum); </code></pre> <p>This time the value is 0. I never understood why. Thinking that the value was not retained, I even used the NSString and NSNumber data types but I have not had any success.</p> <p>Is it something very basic I am missing? Please advice.</p> <p>Thanks for any help in advance</p>
iphone
[8]
4,599,728
4,599,729
skip an element in zip
<p>I have two files that are <code>zipped</code> with something like the following:</p> <pre><code>for line in zip(open(file1), open(file2)): # do-something </code></pre> <p>Unfortunately, now file2 has changed, and there is an additional line at the beginning. Yes, I could get rid of that manually (or with an additional script/program), but since the actual number of involved files is huge, I'd prefer to solve the problem at this level.</p> <p>So, what I want is something like the following (which would be valid, if open(file) were subscriptable):</p> <pre><code>for line in zip(open(file1), open(file2)[1:]): # do-something </code></pre>
python
[7]
1,734,200
1,734,201
get id's of immediate child divs of a div in jquery?
<p>how do i get the child divs and put it in a array?</p> <pre><code>&lt;div id="parent"&gt; &lt;div id="child1"&gt;&lt;/div&gt; &lt;div id="child2"&gt;&lt;/div&gt; &lt;/div&gt; var array = $('#parent &gt; div').... (im stuck). </code></pre> <p>thanks!</p>
jquery
[5]
2,012,820
2,012,821
Warning: Cannot modify header information (PHP)
<p>I have the following error:</p> <p>Warning: Cannot modify header information - headers already sent by (output started at /home/sn2010/public_html/pagetwo.php:10) in /home/sn2010/public_html/pagetwo.php on line 15</p> <p>It happens when I go to pagetwo.php... You can try it here: <a href="http://sn2010.x10.mx/" rel="nofollow">http://sn2010.x10.mx/</a></p> <p>I'm not sure exactly why it's giving me that problem, but here's my codes on both pages:</p> <p>index.html</p> <pre><code> &lt;form name="form1" action="pagetwo.php" method="POST"&gt; &lt;input type="submit" name="bootoon" value="index"&gt; &lt;/form&gt; &lt;form name="form2" action="pagetwo.php" method="POST"&gt; &lt;input type="submit" name="bootoon" value="http://www.facebook.com"&gt; &lt;/form&gt; &lt;form name="form3" action="pagetwo.php" method="POST"&gt; &lt;input type="submit" name="bootoon" value="http://www.yoyogames.com"&gt; &lt;form/&gt; </code></pre> <p>pagetwo.php</p> <pre><code>&lt;?php echo "&lt;h2&gt;SN2010&lt;br /&gt;&lt;/h2&gt;"; echo "&lt;hr align='left' width='680px' /&gt;&lt;br /&gt;&lt;br /&gt;"; $redirect = "Location: " . $_REQUEST["bootoon"] . ".php"; echo header($redirect); ?&gt; </code></pre> <p>Anyone know why the webpages are creating this error? I've tried using ob_start(); and ob_end_flush();. So those two codes are out of the picture...</p>
php
[2]
5,278,800
5,278,801
Support for different devices (action bar, left nav)
<p>I noticed that for older devices running the FB application it doesn't have action bar or the slide-in left nav. Is it common practice to have 2 different releases? Or is the same app built to accomodate all versions the best thing to do</p>
android
[4]
3,743,242
3,743,243
CSharpCodeGenerator error
<p>I am having this strange problem with my Visual Studio. Everytime, I open a project I get a warning in the Watch window saying "The type initializer for "Microsoft.VisualBasic.VBCodeGenerator" threw an exception. I get the same error when trying a C# project, but with the CSharpCodeGenerator error. When I attempt to open any form, I get the following error: [C:\Windows\assembly\GAC_MSIL\System\2.0.0.0___b77a5c561934e089\system.dll] No string associated with token.</p> <p>I tried uninstalling Visual Studio completely the reinstalling and but I am still having the same problem. It sounds that a Windows file got corrupted. I really want to avoid reinstalling windows.</p> <p>Any help on this is appreciated.</p> <p>Thanks, Ayman</p>
c#
[0]
2,467,141
2,467,142
PHP 5.3 and '::'
<p>I started into PHP with 5.3 and am using the '::' to access constants ex; class::const. However, when I try to use my code in an older PHP namely 5.1.6 and 5.2.12, I get an error that the '::' is unexpected.</p> <p>How do I access constants in these older versions of PHP5?</p>
php
[2]
1,039,578
1,039,579
Best way to stream audio and video from an Android phone to a RTMP server
<p>I'm looking for the best way to stream video and audio from an Android phone to a server using RTMP. I've spent some time on this problem and this far I've been able to stream video only using FFMPEG. There are many ways to build the lib for Android and I guess that with some more work I should be able to stream Audio too. </p> <p>The thing is that I need to encode the video in h264 and the audio in AAC, and it would be very easy to do it using Android's <a href="http://developer.android.com/reference/android/media/MediaRecorder.html" rel="nofollow">MediaRecorder</a>. So I started looking for a RTMP library for Android and found this <a href="http://code.google.com/p/android-rtmp-client/" rel="nofollow">Red5 port</a> that seems to be working pretty well. Using it I can stream a video file stored on the phone very easily, and the audio is working too.</p> <p>So my question is the following: Is there a way to connect Android's MediaRecorder output to the RTMP library? I guess the way would be to 'fake' a file in setOutputFile(), and then to send the data to the RTMP encoding methods, but I can't figure a way to do it. </p> <p>Any clue is welcome, really. Thanks in advance. </p>
android
[4]
2,693,302
2,693,303
filtering datagrid
<p>I m using a datagrid. When I enter a value in the textbox I want to search that value in the database and display that in the datagrid.</p> <p>How do i do that?</p>
c#
[0]
2,315,441
2,315,442
How can I join string variables when some might be a null?
<p>I have the following variables:</p> <pre><code>ac, pr, pa, co and it </code></pre> <p>All of these are string variables and some may be null. </p> <p>Is there a way I can create a new variable called pk that is a combination of the contents of all of these variables. I was thinking simply:</p> <pre><code>var pk = ac + pr + pa + co + it; </code></pre> <p>However would this be a problem if some varibably was null. I am not sure what happens when I add a null variable to a string.</p>
c#
[0]
4,922,107
4,922,108
Javascript - Error creating objects on the fly
<p>I am trying to simulate data to a function that would usually receive a JSON parsed data structure. When running this I get an error <code>TypeError: can't convert undefined to object</code> here: <code>data.targets[i] = {</code></p> <p>What am I doing wrong?</p> <pre><code>function SendFakeTargets(maxTargets, interval) { var data = {}; data.timestamp = +new Date; var time = data.timestamp * 0.0005; var x = Math.sin(time) * 192 + 256; var y = Math.cos(time * 0.9) * 192 + 256; console.log(x, y); for (var i = 0; i &lt; maxTargets; i++) { console.log(i); data.targets[i] = { //error is here id: i, x: x + (i * 10), y: y + (i * 10) }; } HandleTargetData(data); setTimeout("SendFakeTargets("+maxTargets+", "+interval+")", interval); } </code></pre>
javascript
[3]
4,059,352
4,059,353
Downloading a file cause error when it contains spaces - PHP
<p>Consider that i am uploading a file with following names:</p> <ol> <li>test.pdf</li> <li>test file.pdf</li> </ol> <p>When i download the test.pdf it's working fine.. </p> <p>But when i download test file.pdf it doesn't. <strong>The case is the space between the file name.</strong></p> <p><strong>Unfortunately i should not change the file name when i upload (If i can i will set "_" using str_replace between spaces and resolve this issue).</strong></p> <p><strong>Now how should i download the file ?</strong> </p> <p>My code is given below:</p> <pre><code>header('Content-disposition: attachment; filename=test file.pdf'); header('Content-type: application/pdf'); readfile('test file.pdf'); </code></pre> <p>Thanks in advance...</p>
php
[2]
2,929,930
2,929,931
Resizing picture C#
<p>need help. i want to resize a certain picture but when i run this code it give me the error {"A generic error occurred in GDI+."}</p> <pre><code> private void btnPic_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Images|*.bmp;*.jpg;*.gif|All files|*.*"; if (open.ShowDialog(this) == DialogResult.OK) { var image = Image.FromFile(open.FileName); var newImage = ScaleImage(image, 300, 400); newImage.Save(@open.FileName, ImageFormat.Png); } } public static Image ScaleImage(Image image, int maxWidth, int maxHeight) { var ratioX = (double)maxWidth / image.Width; var ratioY = (double)maxHeight / image.Height; var ratio = Math.Min(ratioX, ratioY); var newWidth = (int)(image.Width * ratio); var newHeight = (int)(image.Height * ratio); var newImage = new Bitmap(newWidth, newHeight); Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight); return newImage; } </code></pre>
c#
[0]
674,999
675,000
Importing PHP class from remote directory and using it
<p>so what I have is a simple script, set up on two different hosting accounts on the same server,</p> <p>So Account #1 has a file index.php</p> <pre><code>&lt;? function get() { return file_get_contents("http://cmyip.com"); } ?&gt; </code></pre> <p>Account #2 has another file</p> <pre><code>&lt;? require_once('../../seaview/public_html/index.php'); echo get(); ?&gt; </code></pre> <p>now what it would do, is execute it on account #1 and then bring back results, how do I import the function(it will be a class later on) and execute it on account #2, only reason I don't want to just copy paste the files into the second account is because there is going to be a lot of accounts, and managing them would be a pain, also note that the accounts do have different IPs, thats how I know that it's executing on account #1</p> <p>Please help!</p>
php
[2]
3,820,706
3,820,707
Differentiate between comma and comma space
<p>I have a line coming from a CSV file like this:</p> <p>"Item 1","Item 2","Item 3","Item 4","Item 5, Test 6" Repeat for thousands of lines There are no spaces between the items.</p> <p>The comma between Item 5 and Test 6 is supposed to be there. I am trying to turn this line into an array.</p> <pre><code>$i=1; $temp_array = array(); $number = COUNT($array); while($i &lt;= $number) { $temp_array[] = explode(",", $array[$i]); $i++; } </code></pre> <p>The array is currently outputting as this"</p> <pre><code>[1] =&gt; Array ( [0] =&gt; "Item 1" [1] =&gt; "Item 2" [2] =&gt; "Item 2" [3] =&gt; "Item 2" [4] =&gt; "Item 5 [5] =&gt; Test 6" ) </code></pre> <p>It should output as follows:</p> <pre><code>[1] =&gt; Array ( [0] =&gt; "Item 1" [1] =&gt; "Item 2" [2] =&gt; "Item 2" [3] =&gt; "Item 2" [4] =&gt; "Item 5, Test 6" ) </code></pre>
php
[2]
693,606
693,607
How to change screen dimming time programatically in android?
<p>I would like to change system dimming time in my custom application.</p> <p>My device is set 30s-timeout for sleep. So if I am in home screen and leave it, it goes dim in 23sec and screen is turned off in 30sec.</p> <p>Is there any idea for changing screen dimming time for my application?</p> <p>It's ok to change framework source.</p> <p>Thanks in advance.</p>
android
[4]
3,410,077
3,410,078
JQuery: How to hide/display a div depending on the initial state of a checkbox?
<p>Let's say I've this a checkbox and a div that contains elements that I want to <strong>hide/display</strong> depending on the checkbox being checked or not.</p> <pre><code>&lt;input type = "checkbox" id = "myCheckbox"/&gt; &lt;div id = "display-hide"&gt; //Contains more elements &lt;/div&gt; </code></pre> <p>Now, here is the JQuery script that does the trick. </p> <pre><code>&lt;script type = "text/javascript"&gt; $(function () { $("#myCheckbox").click(function(){ $("#display-hide").toggle(this.checked); }); $("#display-hide").hide(); }); &lt;/script&gt; </code></pre> <p>The first time I access the page, everything works fine (i.e. div is hidden - when I check the checkbox, the div is displayed).</p> <p>BUT, when I come back to the page (to edit, for instance), no-matter the value of the checkbox (checked or not), the div is hidden first. The div becomes only visible after I uncheck then check again. </p> <p>I guess that because of this statement:</p> <pre><code>$("#display-hide").hide(); </code></pre> <p>Is there anyway to verify the value of the checkbox and hide/show the div accordingly?</p> <p>Thanks for helping</p>
jquery
[5]
683,092
683,093
termination of program on main thread exit?
<p>I have two threads: the main thread and a thread generated from the main thread. </p> <p>When the main thread exits, will the whole program terminate?</p>
java
[1]
2,531,582
2,531,583
Activator.CreateInstance failing
<p>I have am creating an Instance dynamically using Activator.CreateInstance. However, it is saying object cannot be null on every attempt. Pasting the code below. Am I doing anything wrong?</p> <p>Is there any problem if </p> <blockquote> <p>Activator.CreateInstance</p> </blockquote> <p>replaces the conventional switch/case statements for determining the object type in the run-time? Thanks.</p> <pre><code>public abstract class Base { public abstract void Func(); } public class Derived:Base { public override void Func() { MessageBox.Show("Derived First"); } } public class Derived2 : Base { public override void Func() { MessageBox.Show("Derived Second"); } } private void button1_Click(object sender, EventArgs e) { // I was trying to make use of the overladed version // where it takes the Type as parameter. BaseClass report = (BaseClass) Activator.CreateInstance(Type.GetType("Derived")); report.Func(); } </code></pre>
c#
[0]
980,834
980,835
Handing around Lists
<p>I have a question about lists in C++. I am creating a game, where there are a set of insects moving around the screen, and I do this by creating a class, initializing a list, storing the 'insect' object and then creating a draw and move function. Now, I want to be able to pass this list as well as a similiar list of 'insecticide spray' from another class to the 'main' loop, where the game loop is running continuously. Is this possible? If so how? And is it a good idea to do so? Passing whole lists back and forth? </p>
c++
[6]
539,238
539,239
What is the regular expression for space and alpha-numeric
<p>I'm using ajax check function to check inserted category name which should be only alpha-numeric and also allowed space</p> <p>I've used this function <code>eregi_replace</code> with the following regular expression <code>[a-zA-Z0-9_]+</code></p> <pre><code>$check = eregi_replace('([a-zA-Z0-9_]+)', "", $catname); </code></pre> <p>But when i insert category name for example <code>hello world</code> it failed cause it does not accept space but if i write it as <code>helloworld</code> works so i understood that the error must be in the regular expression i'm using. </p> <p>so what is the correct regular expression that filter any special characters and allow only for alpha-numeric and space.</p> <p>Thanks a lot</p>
php
[2]
474,523
474,524
have ones app copy file from webpage
<p>I have made an app that have to copy a file from a webpage, the following code doesn't do the job, it can't find the file</p> <pre><code>File ekstern = new File("http://192.168.13.40/cache.manifest"); copyFile(ekstern, intern); </code></pre> <p>and the copyFile method:</p> <pre><code> public static void copyFile(File in, File out) throws IOException { FileChannel inChannel = new FileInputStream(in).getChannel(); FileChannel outChannel = new FileOutputStream(out).getChannel(); try { inChannel.transferTo(0, inChannel.size(), outChannel); } catch (IOException e) { throw e; } finally { if (inChannel != null) inChannel.close(); if (outChannel != null) outChannel.close(); } } </code></pre> <p>But the code says that the file doesn't exists</p> <p>testing with <em>ekstern.exists()</em></p>
android
[4]
4,778,465
4,778,466
Waiting for child window loading to complete
<p>Is there an easy hook for detecting that a window opened by a script has finished loading? Basically, I want the equivalent of the <code>onLoad()</code> hook, but I can't set it directly -- assume that the child document is a given and I can't actually put any code of my own in it.</p> <p>For instance, say I have the following two files:</p> <p><code>parent.html</code>:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Parent&lt;/title&gt; &lt;/head&gt; &lt;script type="text/javascript"&gt; var w; function loadChild() { w = window.open(); w.location.href="child.html"; // block until child has finished loading... how? w.doSomething(); } &lt;/script&gt; &lt;/html&gt; &lt;body&gt; I am a parent window. &lt;a href="javascript:loadChild()"&gt;Click me&lt;/a&gt;. &lt;/body&gt; </code></pre> <p><code>child.html</code>:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Child&lt;/title&gt; &lt;/head&gt; &lt;script type="text/javascript"&gt; function doSomething() { alert("Hi there"); } &lt;/script&gt; &lt;/html&gt; &lt;body&gt; I am a child window &lt;/body&gt; </code></pre> <p>Since setting location.href is non-blocking, <code>w.doSomething()</code> isn't defined yet and the <code>doSomething()</code> call blows up. How can I detect that the child has finished loading?</p>
javascript
[3]
4,313,331
4,313,332
How to specify each DataTable in each Row in Datagridview
<h2> Dt0</h2> <h2>DT1 | Dt1</h2> <pre><code>Dt2 | Dt2| Dt3| </code></pre> <p>I want them to arranged like this.All are from Different DataTable.Specifying each Row values. How can i achieve this.</p>
c#
[0]
4,971,046
4,971,047
Replacing An Amount in a Select Box Using Javascript
<p>OK, so I'm comparing 2 values on a webform, one is a text value, and one is in a select element. When the text value is less than the dropdown I need the dropdown to change to the highest value lower than the one in the text box.</p> <p>For example, if the user selects 2000 in the dropdown, and then enters 1100 in the text field, I would need the popup to return say 1000.</p> <p>I wrote the beginnings of something I thought would work, but I can't tell if I should use a return command in conjunction with the dropdown field name, or something like field name (of popup) is &lt; text amount. </p> <p>Here is what I have so far. If someone can just point me in the right direction, I would really appreciate it.</p> <pre><code>function compareAmts () { if ($("#TCA_Field1").val() &lt; ("#TCA_Field2").val ) { ($("#TCA_Field2").val() == ); } } </code></pre>
javascript
[3]
71,136
71,137
Puzzling C++ syntax using "&"
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5289572/what-is-the-meaning-of-in-c">What is the meaning of &amp; in c++?</a> </p> </blockquote> <p>Here is a C++ class declaration snippet containing an ampersand that doesn't make sense to me:</p> <pre><code>class rimage : public matrix { public: rimage( void ); rimage( int, int ); rimage( rimage &amp; ); rimage &amp; operator=( const matrix &amp; A ); rimage &amp; operator=( const rimage &amp; A ); rimage &amp; operator/=( int ); ... </code></pre> <p>What does <code>rimage( rimage &amp; );</code> mean? Why is the <code>&amp;</code> at the end? </p> <p>This snippet was from a text book on PCNNs </p> <p>This class declaration is giving me compilation problems so I need to figure this out.</p>
c++
[6]
3,559,573
3,559,574
Dealing with two DateTimePicker too error prone?
<p>So often, I want the user to select a start date and a finish date. But just selecting date is not enough, we also have to alter the data.</p> <p>By default, the <code>DateTimePicker.Value</code> are like</p> <pre><code>Value 1: 2012-01-01 10:12:09 Value 2: 2012-01-02 10:12:09 </code></pre> <p>When the user selects two dates, it should be obvious that he meant</p> <pre><code>Value 1: 2012-01-01 00:00:00 Value 2: 2012-01-02 23:59:59 </code></pre> <p>I often forget to do the non-intuitive </p> <pre><code>DateTime start = dateTimePicker1.Value.Date; DateTime finish = dateTimePicker2.Value.Date.AddDays(1).AddSeconds(-1); </code></pre> <p>What more effective way of dealing with this have you found?</p>
c#
[0]
4,253,149
4,253,150
error LNK2019: unresolved external symbol "__declspec(dllimport) private
<p>The project runs correctly under VC6.0, however, after I updated it under VS2012, the following link errors occur:</p> <pre><code>revel.lib(BaseEncoder.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) private: void __thiscall std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;::_Eos(unsigned int)" (__imp_?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z) referenced in function "protected: virtual void __thiscall Revel_BaseEncoder::Reset(void)" (?Reset@Revel_BaseEncoder@@MAEXXZ) </code></pre> <p>Can anyone help me with this problem? Thanks a lot!</p>
c++
[6]
928,529
928,530
Storing ab object in a class library
<p>I have an object (a system GUID) I need to use repeatedly in my class library. I would like to store it somewhere. Whats the best way to do that? Im thinking i could serialize and deserialize the object but it dosent seem like the simplest solution. </p>
c#
[0]
5,865,853
5,865,854
Store Coordinates to web server or Data base iphone
<p>Hi everyone I'm working on an application that shows you your current location and gives you more informations about it like the Town and Street.. </p> <p>So my problem is that i want to <strong>store</strong> those <strong>coordinates</strong> to <strong>Web Server</strong> or to a <strong>DatBase</strong>, if there is a tutorial or any code to do that please ! </p>
iphone
[8]
3,056,454
3,056,455
Mozilla display Problem with javascript
<p>I n an aspx page I am using a javascript function like</p> <p>function ReverseResult() {</p> <pre><code>document.getElementById("ctl00_ContentPlaceHolder1_txtIncrementAmount").value = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_txtNewCTC").value) - parseInt(document.getElementById('&lt;%=lblCurrentCTC.ClientID %&gt;').innerText); var result; result = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_txtIncrementAmount").value)*100 / parseInt(document.getElementById('&lt;%=lblCurrentCTC.ClientID %&gt;').innerText); if(result == "Infinity") { document.getElementById("ctl00_ContentPlaceHolder1_txtIncrementPerc").value = 100.00; } else { document.getElementById("ctl00_ContentPlaceHolder1_txtIncrementPerc").value = result.toFixed(2); } </code></pre> <p>}</p> <p>This works fine in IE. But in the mozilla the result display as Nan</p> <p>Pls help to solve this issue</p>
javascript
[3]
790,501
790,502
Android contacts import
<p>I am using an emulator API 8 and trying to import the contacts (more then 300 ones) I can't get an instant messengers information after all. The contacts vcards are similar that one:</p> <pre><code>BEGIN:VCARD VERSION:2.1 N:Lastname;Firstname FN:Firstname Lastname X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname;Nickname;2;;;;;;;;;;;;; TEL;HOME:000-000-000 TEL;WORK:000-00-00 EMAIL;HOME:test@testmailservertest.test NOTE: notes X-AIM:any messenger END:VCARD BEGIN:VCARD VERSION:2.1 </code></pre> <p>I am using a system's "Contacts" application for import. Please tell me what am I doing wrong?</p>
android
[4]
2,488,885
2,488,886
Determine calling executable in Python
<p>I am trying to find the best way of re-invoking a Python script within itself. Currently it is working like <a href="http://github.com/benoitc/gunicorn/blob/master/gunicorn/arbiter.py#L285" rel="nofollow">http://github.com/benoitc/gunicorn/blob/master/gunicorn/arbiter.py#L285</a>. The <code>START_CTX</code> is created at <a href="http://github.com/benoitc/gunicorn/blob/master/gunicorn/arbiter.py#L82-86" rel="nofollow">http://github.com/benoitc/gunicorn/blob/master/gunicorn/arbiter.py#L82-86</a>.</p> <p>The code is relying on <code>sys.argv[0]</code> as the "caller". However, this fails in cases where it is invoked with:</p> <pre><code>python script.py ... </code></pre> <p>This case does work:</p> <pre><code>python ./script.py ... </code></pre> <p>because the code uses <code>os.chdir</code> before running <code>os.execlp</code>.</p> <p>I did notice <code>os.environ["_"]</code>, but I am not sure how reliable that would be. Another possible case is to check if <code>sys.argv[0]</code> is not on <code>PATH</code> and is not executable and use <code>sys.executable</code> when calling <code>os.execlp</code>.</p> <p>Any thoughts on a better approach solving this issue?</p>
python
[7]
2,783,558
2,783,559
Attributes running together or a URL query string in an unquoted attribute value
<p>When running validator I am receiving this error. Alos, Internet Explorer 8 fails to load my sidebar in position. What I made wrong here ? TNX</p> <pre><code>global $layout; echo '&lt;div id=\"main\" role=\"main\" class=\"layout_" . $layout . "\"&gt;'; echo '&lt;section id="content" class="grid_8 background_1"&gt;'; echo '&lt;a id="main_btn" href="#"&gt;&lt;/a&gt;'; echo '&lt;div class="clearfix"&gt;'; echo '&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;'; </code></pre>
php
[2]
1,302,439
1,302,440
android code to launch my app as soon as phone bootsup
<p>Hi can anybody give me sample code for launching application as soon as phone boots up</p>
android
[4]
3,943,501
3,943,502
Set initial height of div based on how much space is left inside of parent div
<p><strong>I have 3 divs:</strong></p> <p><strong>.main_content, .content_top, .content_bottom</strong></p> <p>.main_content is set to 100% but 100% is not the size of the browser window, it's inside the middle of my page.</p> <p>.content_top is set at 60% height.</p> <p><strong>I want to set the height of .content_bottom to the rest of the space available inside .main_content via javascript.</strong></p> <p>For example, if .main_content was 800px high, and .content_top was 600px high, I want to set .content_bottom to 200px.</p> <p>This is a simplified example, my situation is not as easy as specifying 40% or leaving the browser to decide. For one, there's currently 46px of padding on .content_top. I'm doing a split screen like interface between .content_top and .content_bottom dragging a bar to resize both. This is mostly working, just having trouble with the bottom portion. Being able to set .content_bottom to a specific height(i.e. 198px) would solve all of my current problems. Happy to elaborate on this example, as well as dig into some actual code, but was hoping there was an easy method for calculating this and was having trouble finding a good example that worked cross-browser, thanks!</p>
javascript
[3]
5,221,955
5,221,956
php read file looking for string
<p>I'm trying to read a file and look for a specific element within the file. Once it finds it, I would like the script to add the element to a variable. So far I have not been able to find anything on this.</p> <p>This is kind of what I'm looking for:</p> <pre><code>$var = read(($file), "&lt;!--Everything in the comment line--&gt;") </code></pre>
php
[2]
3,820,619
3,820,620
Setting the transition animation to the default slide one
<p>I've been reading code for custom transitions, and while I know there are simple ways to write the xml for a slide transition, can it be done using the Android slide transition used on certain phones? Thanks!</p>
android
[4]
534,769
534,770
TypeError xxx is not a function
<p>All, I am struggling with an error which says <code>TypeError: curTemplete.addSection is not a function</code>, Please forgive that I am not familiar with the js OO, Please help to review my problem. thanks.</p> <p>The code looks like below.</p> <p><strong>Templete.js</strong></p> <pre><code>LayoutTemplete=function(currentTmpContainer,templeteId,data) { var curTemplete = this; curTemplete.addSection(null, null);//this line run with error above. this.addSection = function(uiItem, data) { alert('ddd'); }; }; </code></pre> <p>In the <strong>dom ready event</strong>.</p> <pre><code>function loadTempleteContent(templeteId) { var jData=[{name: 'jerry'},{name: 'mike'},{name: 'claire'}]; var tmp = new LayoutTemplete($("#currentTmpContainer"),templeteId,jData); } </code></pre>
javascript
[3]
2,257,836
2,257,837
DirectSound - how to get started
<p>I need to use the direct sound librarys for my C# application.</p> <p>Do I need to download a SDK and install?</p> <p>Are the libraries already installed as part of windows xp sp3?</p> <p>In C# under references I just include microsoft.directsound?</p> <p>Many thanks,</p>
c#
[0]
4,567,503
4,567,504
Dynamically Controls
<p>I have dynamically generated a button an its event too.Now want to access a textbox (Generated Dynamically) into the onClick event of the Button.How can i do this?</p>
asp.net
[9]
574,607
574,608
How to Use Ternary Operator in Python
<p>I have this method:</p> <pre><code>def get_compression_settings(self, media_type=None): return self.transmit('GET', 'compression?mediatypeid={0}'.format(media_type)) </code></pre> <p>Is there a way I can check if media_type == None and only append mediatypeid={0} if it is ~=None in a single line using a ternary operator?</p> <p>I know I could do the following, but it would nicer if my method could just be a single return:</p> <pre><code>def get_compression_settings(self, media_type=None): endpoint = 'compression?mediatypeid={0}'.format(media_type) if media_type is not None else 'compression' return self.transmit('GET', endpoint) </code></pre>
python
[7]
5,420,576
5,420,577
handling back button in android from jquery
<p>We have developed an application in j query integrated with android(which has only one activity) From this activity we are loading an HTML file on this file we are showing and hiding the div contents .On viewing the web pages provided here and pressing back button provided in android , the application exits.We want the application to be in the previous page on clicking the back button.</p> <p>(On clicking the android back button we need to show the hidden div contents.And on clicking the android back button from the div contents page the application should exit.)</p> <p>thanks in advance</p>
android
[4]
1,976,323
1,976,324
How to build a screenmate programatically?
<p>I would like to know how to build an screenmate.</p> <p>Something like this:</p> <p>Example # 1: <a href="http://www.youtube.com/watch?v=SHvDOPkGQqE" rel="nofollow">http://www.youtube.com/watch?v=SHvDOPkGQqE</a></p> <p>Example # 2: <a href="http://www.youtube.com/watch?v=5tHpmeZseIs" rel="nofollow">http://www.youtube.com/watch?v=5tHpmeZseIs</a></p> <p>Example # 3: <a href="http://www.viddler.com/explore/myvirtuallady/videos/5/" rel="nofollow">http://www.viddler.com/explore/myvirtuallady/videos/5/</a></p> <p>I guess that there has to be a way to do it, but I don't know how...</p> <p>Can this be done using some Microsoft frameworks?? Maybe with C#??</p> <p>Thanks!!</p>
c#
[0]
4,311,300
4,311,301
How do I get screen sizes from a service?
<p>From an activity I would do it like this</p> <pre><code>Display display = getWindowManager().getDefaultDisplay(); int x = display.getWidth(); </code></pre> <p>Yet a service ( keyboard ) doesn't seem to support it... any other ideas?</p> <p>Thanks!</p>
android
[4]
732,744
732,745
Is it safe to unplug the phone while USB Debugging is turned on?
<p>I am developin with Eclipse on an Android device. Each time I want to install the new version of the app on the device I need to connect it, enable USB Debugging, install the app, disable USB Debugging, unplug the device (optional). I was wondering if it was safe to just unplug the device without disabling USB Debugging. After all, the device is not mounted, right? But there is the adb, talking to it. It would be much more convenient to be able to do that. Does anyone know if it is safe or unsafe?</p>
android
[4]
4,937,677
4,937,678
Python scope inside a nested function inside a class?
<p>How can I set a class variable from inside a function inside another function?</p> <p>var.py</p> <pre><code>class A: def __init__(self): self.a = 1 self.b = 2 self.c = 3 def seta(self): def afunction(): self.a = 4 afunction() def geta(self): return self.a </code></pre> <p>run.py</p> <pre><code>cA = A() print cA.a cA.seta() print cA.a print cA.geta() </code></pre> <p>python run.py</p> <pre><code>1 1 1 </code></pre> <p>why does a not equal 4 and how can I make it equal 4?</p> <p>Thanks</p> <p>Sorry, my original code as afunction called - forgot.</p> <p>Edit:</p> <p>Thanks everyone - sorry, I just saw now. I accidentally was off by a _ in one of my names.... so my scope is actually all ok.</p>
python
[7]
5,597,862
5,597,863
how to change image on next button click +iphone
<p>i want to change image on next button click by using uiimage view. i am using following link to get images.</p> <p><a href="http://01s.in/webservices/ratemypic/getData.php?db_table=image" rel="nofollow">http://01s.in/webservices/ratemypic/getData.php?db_table=image</a></p> <p>thanks to all</p>
iphone
[8]
3,381,910
3,381,911
Get whats under the cursor
<p>Is there a way to hook the mouse to detect what it's hovering over? Say I put my mouse over my uTorrent icon on the desktop. Is there a way to detect that and give me information pertaining to that icon/file ? Any help on this matter would be helpful. Thanks.</p>
c#
[0]
2,687,306
2,687,307
filter and increment number inside of element using javascript
<p>I have this HTML code:</p> <pre><code>&lt;div&gt; 756 &lt;span&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>now using javascript I am trying to retriev the number from the div and increment it by 1. But I can not seem to figure out how to filter the <code>&lt;span&gt;</code> out of my variable and then increment only the number.</p> <p>Might you guys have any idea on how to achieve this?</p> <p>Thanks for your tips!</p>
javascript
[3]
5,641,687
5,641,688
what happens to finally block in the following cases?
<p>if i have a following code </p> <pre><code> try{ //some code }catch(Exception e){ //some code }finally{ } </code></pre> <p>what happens to the finally block in the following cases</p> <ol> <li><p>if any checked exceptions happen.</p></li> <li><p>if System.exit() is called.</p></li> <li><p>if any unchecked exceptions happen.</p></li> <li><p>if any errors happen.</p></li> </ol>
java
[1]
5,602,521
5,602,522
Dom parsing in android
<p>i have parsed xml using dom parser,but when the xml element contains no value it throws null pointer Exception.how to check this?... here my code</p> <pre><code>NodeList TrackName1 = fstElmnt2.getElementsByTagName("Artist_Name"); Element TrackElement1 = (Element) TrackName1.item(0); TrackName1 = TrackElement1.getChildNodes(); result=result+((Node) TrackName1.item(0)).getNodeValue() String Artistname=((Node)TrackName1.item(0)).getNodeValue(); } </code></pre>
android
[4]
374,280
374,281
c# using directive depth
<p>I'm trying to understand the c# using directive...Why does this work...</p> <pre><code>using System; using System.ComponentModel.DataAnnotations; namespace BusinessRuleDemo { class MyBusinessClass { [Required] public string SomeRequiredProperty { get; set; } } } </code></pre> <p>but this does not?</p> <pre><code>using System; using System.ComponentModel; namespace BusinessRuleDemo { class MyBusinessClass { [DataAnnotations.Required] public string SomeRequiredProperty { get; set; } } } </code></pre> <p>The second results in a compile error "The type or namespace DataAnnotations cannot be found. Are you missing are missing a using directive or an assembly reference?</p>
c#
[0]
5,417,566
5,417,567
hide all elements wit specific alt value
<p>I want to be able to hide all elements which have an ALT value of <code>3</code> using jquery.</p> <p>hide all elements with attribute <code>alt="3"</code></p> <p>Is this possible? And if so, how can it be done?</p> <p>Thanks</p>
jquery
[5]
3,659,487
3,659,488
what is the difference between static and normal variables in c++?
<p>I need to know the difference,am beginner.</p>
c++
[6]
5,485,117
5,485,118
disable img tag
<p>How to remove href attribute of an img on a page using jquery?</p> <p>this img tag does not have any class or ID for referencing</p>
jquery
[5]
4,442,272
4,442,273
Capture the previous value when onkeydown is executed
<p>Need help in event handling. In my scenario, I have a textbox with default value 35 and cursor is set to before the 3. There is a event for this text box which is onkeydown. When I press 4, IE and Safari captures the previous value of the text which is 35. But Mozilla and Chrome captures the new value which is 435.</p> <p>I need the javascript code which can capture the previous value of the textbox when onkeydown is fired. </p> <p>Need your hands :(</p>
javascript
[3]
1,910,152
1,910,153
Would I use an if statement here or a bool?
<p>I need to figure out a way to handle if <code>results</code> does find something, show "yes, something was found" else show "no users have been found at this time". I've tried to figure this out, but I'm unable to do so. Thank you for your time.</p> <p>My code is as follows: </p> <pre><code>DateTime dt = DateTime.Today; DateTime less5dt = dt.AddDays(-5); This.cmb1.Items.Clear(); PrincipalSearchResult results = UserPrincipal.FindByLockoutTime( adPrincipalContext, dt, MatchType.GreaterThanOrEquals); foreach (Principal result in results) { cmb1.Items.Add(result.name); } </code></pre>
c#
[0]
1,795,557
1,795,558
Download a whole website using URL class in Java
<p>I wrote a simple program which through the help of url class get the page content. However, it gets only the main page of the website, and inside a page there are also other urls. How can we download all the website including the page inside the specified url page.</p> <pre><code>import java.net.*; import java.io.*; public class Map { public static void main(String args[]){ System.setProperty("http.proxyHost","192.168.10.50"); System.setProperty("http.proxyPort","8080"); String nextLine; URL url = null; URLConnection urlConn = null; InputStreamReader inStream = null; BufferedReader buff = null; try{ // Create the UR0L obect that points // at the default file index.html url = new URL("http://www.iiu.edu.pk/index.php?page_id=10135" ); //URL url2=new URL(url,"index.php?page_id=10135"); urlConn = url.openConnection(); inStream = new InputStreamReader( urlConn.getInputStream()); buff= new BufferedReader(inStream); FileWriter writer=new FileWriter(" check.html"); BufferedWriter buf=new BufferedWriter(writer); // Read and print the lines from index.html while (true){ nextLine =buff.readLine(); if (nextLine !=null){ System.out.println(nextLine); buf.write(nextLine); buf.newLine(); } else{ break; } } buff.close(); inStream.close(); buf.close(); writer.close(); } catch(MalformedURLException e){ System.out.println(e); } catch(IOException e1){ System.out.println(e1); } </code></pre>
java
[1]
277,909
277,910
Javascript: Can a string containing a newline "\n" be used as a property name?
<p>It is clear why I would not want to do this. But I have little choice in the matter. </p> <p>Will browsers be able to handle this? </p> <p>Chrome seems to be okay with it: </p> <pre><code>&gt; var x = {}; &gt; x['a\nb'] = 1; 1 &gt; x Object a b: 1 __proto__: Object &gt; Object.keys(x) ["a b"] </code></pre>
javascript
[3]
5,310,888
5,310,889
CellBroadcast listener
<p>I am trying to write application which listens to Cell Broadcast message.</p> <p>The application supposed to be used to emergency notifications.</p> <p>I tried to use this post : <a href="http://stackoverflow.com/questions/7118378/how-to-get-cell-broadcast-message">How to get Cell Broadcast message?</a> but didn't succeded.</p> <p>Did someone succeded writing this kind of application(listens to CB messages)?</p> <p>Thank you very much,</p> <p>Yuval</p>
android
[4]
654,625
654,626
How to get `File` reference to external disk?
<p>I would like to get in my file browser <code>File</code> reference to external disk not SD Card. I mean I know that there is method</p> <pre><code>Environment.getExternalStorageDirectory(); </code></pre> <p>But to my knowledge this will get reference to SD Card. But how to get external disk (say kind of USB storage attached to Android device)? You know that device can have both SD card and external USB stick attached to them.</p>
android
[4]
3,765,178
3,765,179
c++ object sizes
<p>Suppose I have:</p> <pre><code>struct Foo: public Bar { .... } </code></pre> <p>Foo introduces no new member varaibles. Foo only introduces a bunch of member functions &amp; static functions. Does any part of the C++ standard now guarantee me that:</p> <pre><code>sizeof(Foo) == sizeof(Bar) </code></pre> <p>?</p> <p>Thanks!</p>
c++
[6]
4,163,278
4,163,279
Returning a 2-dimensional array of doubles from function
<p>I have this class in which at some point I am computing a array of two doubles:</p> <pre><code>double* QSweep::computeIntersection(double m1, double b1, double m2, double b2){ double* v=new double[2]; v[0]= (b2-b1)/(m1-m2); v[1]= (m1*b2-m2*b1)/(m1-m2); return v; } </code></pre> <p>In another function of the class I am using this array to work with its values. Depending on the values transmitted as parameters I obtained several values for this array of two daoubles. And I want to retain all this values in a array of array of two doubles. I have tried some ways but I have bur error, segementation fault or all problems as this. Any idea is welcomed.</p> <p>thank you in advance, madalina</p>
c++
[6]
4,964,611
4,964,612
How to resolve java.lang.nullpointer exception in android test project?
<p>In Eclipse i am doing to create a Android Test Project in the below way. But I am getting always java.lang.NullpointerException.</p> <p>Procedure. No Previous project is there on the eclipse.</p> <p>Select New --> Project --> Android -->Android Test Project.</p> <p>It is asking project name. I am giving test. Then it is asking android version. I am selecting android 2.2 now i am selecting ok. i am getting "java.lang.NullpointerException"</p> <p>How to resolve this?</p>
android
[4]
527,496
527,497
definition of Acme Developers for iPhone
<p>I have heard the term acme developer of iPhone. I was just wondering, what it stands for?</p> <p>I think I know the meaning, it is when a developer goes to a client and present's his/her ideas for the app.</p> <p>Thanks for your help.</p>
iphone
[8]
4,162,234
4,162,235
Add related articles - PHP custom solution
<p>I have one custom website with code created 100% by me. I need to show at the end of the article 3 related articles. How can I do it? Is there any way to pickup the most 3 used words in the article and search based on that?</p>
php
[2]
4,097,348
4,097,349
file size check at the time of upload
<p>I wan to check the size of file at the time of upload in javascript (its an image file so if possible want to check in kb or bytes or in px)</p> <p>Is there any way i can do it.</p> <p>Thanks in advance!</p> <pre><code>&lt;input type="file" name="ssimgfile2" id="ssimgfile2" /&gt; </code></pre>
javascript
[3]
3,414,912
3,414,913
int transforms into int&?
<p>code snippet:</p> <pre><code>// some code SDL_Surface* t = Display-&gt;render_text(text); int z=100; Display-&gt;blit_image(t,z,100); // some more code </code></pre> <p>does not compile because z magically changes to an int&amp;, file.cpp:48: error: no matching function for call to ‘display::blit_image(SDL_Surface*&amp;, int&amp;, int)</p> <p>how can this happen?</p> <p>post scriptum: the following works if i put them in place of Display->blit_image(t,z,100)</p> <p>Display->blit_image(t,z,100,0);</p> <p>but i am sure that th 4th param is optional because the exact same function works elsewhere without it</p> <p>pps: i created a minimal-case of my code that behaves as describd above it's 3 files:</p> <p>monkeycard.cpp: <a href="http://pastebin.com/pqVg2yDi" rel="nofollow">http://pastebin.com/pqVg2yDi</a></p> <p>display.hpp: <a href="http://pastebin.com/xPKgWWbW" rel="nofollow">http://pastebin.com/xPKgWWbW</a></p> <p>display.cpp: <a href="http://pastebin.com/nEfFX1wj" rel="nofollow">http://pastebin.com/nEfFX1wj</a></p> <p>g++ -c display.cpp monkeycard.cpp fails with: monkeycard.cpp: In member function ‘void monkeycard::messagebox(std::string)’: monkeycard.cpp:28: error: no matching function for call to ‘display::blit_image(SDL_Surface*&amp;, int&amp;, int)’ display.hpp:26: note: candidates are: void display::blit_image(SDL_Surface*, int, int, SDL_Rect*)</p>
c++
[6]
1,882,368
1,882,369
How to get a list of my app's tasks and the stack of their Activities?
<p>In order to better understand the relationship between Activities, tasks, the back-stack for each task, and different launchModes I want to write an app with about 7 Activities, running in 3 tasks, where the Activities are launched in different launchModes, and as I'm running I want to display the stacks for each activity and watch them change as I navigate through my app and launch or close different Activities.</p> <p>How can I get a list of all the Tasks for my current application and then get the Activities on those tasks' stacks? The <a href="http://developer.android.com/reference/android/app/ActivityManager.html" rel="nofollow">ActivityManager class</a> lets me query task info based on what's recent or what's running but how do I query task info just for my current app?</p> <p>Thanks in advance.</p>
android
[4]