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
1,666,511
1,666,512
Saving a file to the external temp dir from R.raw.some_file.m4a
<p>I need to be able to save a file to the external storgage temp dir. The file I am saving though is the R.raw directory of my app. </p> <p>I have used this example here. <a href="http://stackoverflow.com/questions/6979521/move-raw-file-to-sd-card-in-android">Move Raw file to SD card in Android</a></p> <p>The issue is 1. The app seems to read the .m4a file I want (possible reads the bytes wrong here). 2. When the file is saved to the /tmp dir the file size is totally wrong. eg one file goes from 30kb to 300kb, another goes from 25kb, to .25kb. </p> <p>Any suggestions</p> <pre><code>public String saveAs(int ressound, String whipName){ byte[] buffer=null; InputStream fIn = getBaseContext().getResources().openRawResource(ressound); int size=0; try { size = fIn.available(); buffer = new byte[size]; fIn.read(buffer); fIn.close(); } catch (IOException e) { // TODO Auto-generated catch block Log.i("saveas", "did not save1"); //return false; } String path= Environment.getExternalStorageDirectory().getAbsolutePath()+"/tmp/.pw2"; String filename="/"+whipName+".m4a"; Log.i("path", "file path is " + path); boolean exists = (new File(path)).exists(); if (!exists){new File(path).mkdirs();} FileOutputStream save; try { save = new FileOutputStream(path+filename); save.write(buffer); save.flush(); save.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block Log.i("saveas", "did not save2"); //return false; } catch (IOException e) { // TODO Auto-generated catch block Log.i("saveas", "did not save3"); //return false; } File k = new File(path, filename); return k.getAbsolutePath(); } </code></pre>
android
[4]
5,518,848
5,518,849
Increasing the scope of object from local scope
<p>I want to create an object using a method but I want it (object+reference) to live even after the method ends. Example of code:</p> <pre><code>public class start{ public static void main (String [] Args){ public void createObject(){ object1 createdObject = new object1(); } createObject(); createdObject.doSomething(); } } public class object1{ //code for object 1 } </code></pre> <p>So my main question is: how to create object using method and let it live even after method ends. The problem is that reference <code>createdObject</code> is popped of <code>stack</code> after method ends and therefore I can't use it anymore. Is it even possible to create object for further use this way?</p>
java
[1]
5,769,207
5,769,208
Get html file Java
<h3>Duplicate:</h3> <blockquote> <p><a href="http://stackoverflow.com/questions/238547/how-do-you-programmatically-download-a-webpage-in-java">How do you Programmatically Download a Webpage in Java?</a></p> <p><a href="http://stackoverflow.com/questions/31462/how-to-fetch-html-in-java">How to fetch html in Java</a></p> </blockquote> <p>I'm developping an application that consists on: the user inputs an URL of some website, and then the application have to analyze that URL.</p> <p>How can I have access to the HTML file, using Java? Does I need to use HttpRequest? How does that works?</p> <p>Thks.</p>
java
[1]
2,161,609
2,161,610
C# - threadPool.SetMaxThreads returning false
<p>Wondering if you can help!</p> <p>My understanding of SetMaxThreads() in C# was that it can not be set to less than the number of processors.</p> <p>But in my code I am unable to set the number to less than 8, I have no idea why this is.</p> <p>If I set it to lower it returns false!</p> <p>(Running an Intel Core 2)</p> <p>Thanks for the help!</p> <p>MeeMMeeM</p>
c#
[0]
8,867
8,868
Php shopping cart
<p>When we write a shopping cart, should we save cart info in the database with session id or should we save only session variables? Why?</p>
php
[2]
3,225,906
3,225,907
displaying photo?
<p>I was trying to do this in an alert box only to find out that I can't now. I cannot manage to get this to display at all. Instead of the variable I get <code>[object HTMLImageElement]</code>. I am missing something but what is it? </p> <pre><code>function joePic(){ var joe_fat = new Image; joe_fat.src = "pic1.jpg"; document.getElementById('photo').innerHTML = joe_fat; } </code></pre> <pre><code>&lt;input type="button" value="Click here it find out" name="joePhoto" onclick="joePic()" height="150" width="150" /&gt; </code></pre>
javascript
[3]
5,101,074
5,101,075
What happens if sdk's are missing - (advert aggregation)
<p>There are some mobile advertising aggregators (mopub for example) that insist on apps including the sdk's (which, correct me if I'm wrong, means jar files) of each separate ad network that they are aggregating.</p> <p>One thing that has always bothered me is what would happen if I forgot to include one of the jar's? Would the program crash as soon as the aggregator attempted to serve an ad from that particular network? And if not, how is the crash avoided?</p> <p><strong>EDIT:</strong> What I really want to do is test that my app is fully capable of displaying all the ads that the aggregator may serve.</p>
android
[4]
1,991,602
1,991,603
Is it possible to take a table layout with images for a photo gallery and re-code to be a ul?
<p>I have a table layout with the following code</p> <pre><code>&lt;table cellspacing="0" class="photogalleryTable"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/alexdefending.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=100&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c72488%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5cnyrkqrsraqvat.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/cheerweb.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=100&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c72488%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5cpurrejro.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Is it possible to use jQuery to re-format to a unordered list? Somehow convert the td tag to a li tag and remove the rest?</p> <p>Thanks in advance for any help.</p>
jquery
[5]
327,429
327,430
i don't know the error in my program>>>>> java
<pre><code> public class Assign2Shape { private String nameOfShape; public void setNameOfShape(String theNameOfShape) { nameOfShape = theNameOfShape; } public String getNameOfShape() { return nameOfShape; } public Assign2Shape() { nameOfShape = "no name yet"; } public Assign2Shape(String theNameOfShape) { nameOfShape = theNameOfShape; } public void writeOutput(String theNameOfShape) { System.out.println(getNameOfShape()); } }; public class Assign2Square extends Assign2Shape { private int height, length, area; public void setHeight(int oneHgight) { height = oneHgight; } public void setLength(int oneLength) { length = oneLength; } public void setArea(int oneArea) { area = oneArea; } public int getHeight() { return height; } public int getLength() { return length; } public int getArea() { return height*length; } public Assign2Square() { super(); height =0; length =0; } public Assign2Square(String theNameOfShape,int oneHgight, int oneLength) { super(theNameOfShape); height = oneHgight; length = oneLength; } public void writeOutput(String theNameOfShape, int oneHgight, int oneLength) { super.writeOutput(theNameOfShape); System.out.println(getHeight()+ getLength()); } }; public class Assign2Driver { public void main (String [] args) { Assign2Square obj1 = new Assign2Square(); Assign2Square obj2 = new Assign2Square(); obj1.setHeight(23); obj1.setLength(10); obj1.writeOutput("Square",10 23); System.out.println("the height: " + obj1.getHeight()); System.out.println("the length: " + obj1.getLength()); System.out.println("the length: " + obj1.getArea()); } } </code></pre>
java
[1]
291,001
291,002
Android UI elements for messaging i.e like Google Talk
<p>Are there specific UI elements for messaging within android apps? For example the elements used in the Google Talk app. </p> <p>Thanks</p>
android
[4]
2,781,002
2,781,003
integer part of the root withot using functions
<p>The calculation of the integer part of the square root of a number can be done by trial and error, starting from 1, by executing the square until the result is less than or equal to the starting value of which is calculated by the root.</p> <p>The following program returns the integer part of the root</p> <pre><code>def radice(x): z = 0 t = 0 while True: t = z*z if t &gt; x: z -= 1 return z z += 1 radice(17) // 4 </code></pre> <p>Will be possible to write it without using functions and break? Here is my code witout function but I dont' know how to write the same algo with no <code>break</code></p> <pre><code>z = 0 t = 0 while True: t = z*z if t &gt; x: z -= 1 break z += 1 print 'The integer part of the root is: ', z </code></pre>
python
[7]
4,177,189
4,177,190
Java issue with var-args and boxing
<p>I have a question related to the following code snippet:</p> <pre><code> class VarArgsTricky { static void wide_vararg(long... x) { System.out.println("long..."); } static void wide_vararg(Integer... x) { System.out.println("Integer..."); } public static void main(String[] args) { int i = 5; wide_vararg(i, i, i); // needs to widen and use var-args Long l = 9000000000l; wide_vararg(l, l); // prints sucessfully "long..." } } </code></pre> <p>The first call to wide_vararg fails to compile(saying that the method is ambigous) while the second compiles just fine. </p> <p>Any explanations about this behaviour? Thanks!</p>
java
[1]
412,394
412,395
Need help with my first python script
<p>So I've read a few books on python but I'm still really in the dark about how python works over tcp/ip etc. I've been trying to randomly read different modules that supposedly have support for this kind of thing but it's all incomprehensible jargon to me.</p> <p>Here's what I'm trying to do: HOST program, when it receives a packet or some kind of activation key from the CLIENT program, executes a .bat file located on the host computer. </p> <p>The execution of the .bat file I have down. What I'm completely in the dark about is how to get the Client program, which I plan to run on my work computer, to send a packet to the host program that says "open the file." And also, how to get the host program to respond and realize it is being sent a packet.</p> <p>If anyone could point me in the right direction I would much appreciate it. :)</p>
python
[7]
1,262,200
1,262,201
Pass variable to a class which extends another one
<p>I'm using tFPDF class.</p> <p>I'm extending this class using this code to get custom Header and Footer</p> <pre><code>class PDF extends tFPDF{ function Header(){ $this-&gt;Image('../../images/logo-admin.png',10,6,30); $this-&gt;SetFont('DejaVu','',13); $this-&gt;Cell(247,10,$produto,0,0,'C',false); $this-&gt;SetDrawColor(0,153,204); $this-&gt;SetFillColor(98,197,230); $this-&gt;SetTextColor(255); $this-&gt;Cell(30,10,date('d/m/Y'),1,0,'C',true); $this-&gt;Ln(20); } function Footer(){ $this-&gt;SetY(-15); $this-&gt;SetFont('Arial','',8); $this-&gt;Cell(0,10,'P'.chr(225).'gina '.$this-&gt;PageNo().'/{nb}',0,0,'C'); } } </code></pre> <p>What I need to do, is to somehow change the <code>$produto</code> with a variable that doesn't belong to the class.</p> <p>I'm calling this class using <code>$pdf = new PDF();</code>.</p> <p>How may I pass a variable to this class so I can use a string, something like <code>$pdf = new PDF('SomeString');</code> and use it inside the class like <code>$this-&gt;somestring = $somestringfromoutside</code></p>
php
[2]
2,990,219
2,990,220
to find the angle for cosine! vector products
<p>I am looking for an answer to find an angle-alpha for cosine. </p> <pre><code>cos(alpha)=RT(vector).R(vector)/(modulus)RT(vector).(modulus)R(vector) </code></pre> <p>then I should need to find the angle alpha.</p> <pre><code>public double dot1(double[] vectorA, double[] vectorB){ double[] vecPro; vecPro = new double[2]; vecPro[0] = vectorA[0]*vectorB[0]; vecPro[1] = vectorA[1]*vectorB[1]; return 0; } </code></pre> <p>this code is just an sample I did so far! for the dot product of <code>RT(vector).R(vector)</code>. hmm is that correct that I did, because I am new to java language.</p>
java
[1]
3,078,809
3,078,810
open() function python default directory
<p>I'm new and I have no idea where the default directory for the <code>open()</code> function is.</p> <p>For example <code>open('whereisthisdirectory.txt','r')</code></p> <p>Can someone advise me? I've tried googling it (and looking on stackoverflow) and even putting a random txt file in so many folders but I still can't figure it out. Since I'm beginning, I want to learn immediately rather than type <strong>"c:/directory/whatevevr.txt"</strong> every time I want to open a file. Thanks!</p> <p>Ps my python directory has been installed to <strong>C:\Python32</strong> and I'm using 3.2</p>
python
[7]
4,904,960
4,904,961
Folder check in javascript
<p>How to check whether a folder exists or not using Javascript?</p> <p>Thanks, Karthick</p>
javascript
[3]
154,076
154,077
Is it possible to create a struct type based on file contents?
<p>Is it possible in C++ to create a struct type based on file contents?</p> <pre> STRUCT_NAME int var1; int var2; string v3; STRUCT NAME *pointer; </pre> <p>The first line would be the name of the struct, the other lines would be the variables</p>
c++
[6]
5,792,226
5,792,227
PregMach with php GET method
<p>I have a page test.php in which I have a list of names:</p> <pre><code>name1='992345' name2='332345' name3='558645' name4='434544' </code></pre> <p>In another page <code>test1.php?id=name2</code> and the result should be:</p> <blockquote> <p>332345</p> </blockquote> <p>I've tried this PHP code:</p> <pre><code>&lt;?php $Text=file_get_contents("test.php") $id = $_GET["id"]; ;preg_match_all('/$id.=\'([^\']+)\'/',$Text,$Match); $fid=$Match[1][0]; echo $fid; ?&gt; </code></pre> <p>if the code is used like this</p> <pre><code>&lt;?php $Text=file_get_contents("test.php") ;preg_match_all('/name3=\'([^\']+)\'/',$Text,$Match); $fid=$Match[1][0]; echo $fid; ?&gt; </code></pre> <p>the result is good </p> <blockquote> <p>558645</p> </blockquote> <p>But i wanto be able to change the name of <code>'/name3=\'</code> from <code>;preg_match_all('/name3=\'([^\']+)\'/',$Text,$Match)</code> with GET method like this if <code>test1.php?id=name4</code> the result wil bee <code>434544</code>.</p>
php
[2]
2,017,116
2,017,117
How to avoid call-time pass-by-reference deprecated error in PHP?
<p>I'm trying to <strong>reduce the warnings</strong> that are sent to my apache server log.</p> <p>One warning is:</p> <blockquote> <p>Call-time pass-by-reference has been deprecated.</p> </blockquote> <p>It is <strong>hard for me to imagine</strong> why this was deprecated since it is such a useful programming feature, basically I do this:</p> <pre><code>public function takeScriptsWithMarker(&amp;$lines, $marker) { ... } </code></pre> <p>and I call this function repeatedly getting results back from it and processing them but also letting the array $lines build up by being sent into this method repeatedly. </p> <ol> <li>To reprogram this would be extensive.</li> <li>I don't want to just "turn off warnings" since I want to see other warnings.</li> </ol> <p>So, as call-by-reference is deprecated, <strong>what is the "accepted way" to attain the functionality</strong> of this pattern: namely of sending an array of strings into a method, have them be changed by the method, then continuing to use that array?</p>
php
[2]
951,351
951,352
If option selected do this or this on form
<p>I have the following options:</p> <pre><code>&lt;li&gt;&lt;label for="r1"&gt;&lt;input type="radio" name="post_category" id="r1" value="12" checked="checked" /&gt; Share an Article&lt;/label&gt;&lt;/li&gt; &lt;li&gt;&lt;label for="r4"&gt;&lt;input type="radio" name="post_category" id="r4" value="14" /&gt; Share a Link&lt;/label&gt;&lt;/li&gt; &lt;li&gt;&lt;label for="r3"&gt;&lt;input type="radio" name="post_category" id="r3" value="13" /&gt; Share some Code&lt;/label&gt;&lt;/li&gt; </code></pre> <p>and I have these two lines to send data from two fields, now if the options arn't selected then I don't want the content being sent to these fields so they need some conditionals around them that check if an option is selected or not:</p> <pre><code>$post_url = $_POST['post_url']; $post_code = htmlentities($_POST['post_code'], ENT_QUOTES, 'UTF-8'); </code></pre> <p>so only post the URL field if the link option is chosen and only post the CODE field if the code option is chosen. can anyone help?</p>
php
[2]
5,481,725
5,481,726
Why include when you can require in PHP?
<p>What is the point of attempting to <code>include</code> or <code>include_once</code> a library in PHP if you often have to use <code>require</code> or <code>require_once</code> instead (as they're usually critically important)?</p>
php
[2]
993,068
993,069
Javascript: Hijack Copy?
<p>I was just reading the Times online and I wanted to copy a bit of text from the article and IM it to a friend, but I noticed when I did so, it automatically appended the link back to the article in what I had copied. </p> <p>This is not a feature of my IM client, so I assume this happened because of some javascript on Times website.</p> <p>How would I accomplish this if I wanted to implement it on my site? Basically, I would have to hijack the copy operation and append the URL of the article to the end of the copied content, right? Thoughts?</p> <p>Here's the article I was reading, for reference: <a href="http://www.time.com/time/health/article/0,8599,1914857,00.html" rel="nofollow">http://www.time.com/time/health/article/0,8599,1914857,00.html</a></p>
javascript
[3]
2,114,914
2,114,915
function template overloading
<p>Can anybody summarize the idea of function template overloading? What matters, template parameter or function parameter? What about the return value?</p> <p>For example, given a function template </p> <pre><code>template&lt;typename X, typename Y&gt; void func(X x, Y y) {}; </code></pre> <p>what's the overloaded function template?</p> <pre><code>1) template&lt;typename X&gt; void func(X x, int y) {}; 2) template&lt;typename X, typename Y&gt; X func(X x, Y y) {}; 3) template&lt;class X, class Y, class Z&gt; void func(X x, Y y, Z z) {}; </code></pre>
c++
[6]
1,356,984
1,356,985
How can I map an integer value to a string more easily in PHP?
<p>How can I re-factor the following code to make it more concise and more maintainable? </p> <pre><code>if ($row['vocation'] == 1) $vocation = "sorcerer"; if ($row['vocation'] == 2) $vocation = "druid"; if ($row['vocation'] == 3) $vocation = "paladin"; if ($row['vocation'] == 4) $vocation = "knight"; if ($row['vocation'] == 5) $vocation = "master sorcerer"; if ($row['vocation'] == 6) $vocation = "elder druid"; if ($row['vocation'] == 7) $vocation = "royal paladin"; if ($row['vocation'] == 8) $vocation = "elite knight"; else $vocation = "none"; </code></pre>
php
[2]
2,515,080
2,515,081
Display a number from array in PHP
<p>Hello I would like to have a code that displays randomly from an array a number and displays it. For example this code</p> <pre><code>&lt;?php $firstquarter = array(1 =&gt; 'January', 'February', 'March'); print_r($firstquarter); ?&gt; </code></pre> <p>will return</p> <pre><code>Array ( [1] =&gt; January [2] =&gt; February [3] =&gt; March ) </code></pre> <p>Instead of this, I would like to display on</p>
php
[2]
2,759,865
2,759,866
How to minimize application to tray by using command line argument
<p>How can i minimize application to system tray by using command line argument.</p> <p>eg:when i open my application using command line like this. c:\myfile.exe totray</p> <p>i writed some code for that but it never worked.</p> <pre><code>static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length &gt;0) { MessageBox.Show(args[0]); } Application.Run(new Form1()); } </code></pre> <p>Here the messagebox is showing with my argument "totray". so i just added code like </p> <pre><code>static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length &gt;0) { // MessageBox.Show(args[0]); if (args[0] == "totray") { Form1 frm1 = new Form1(); frm1.Hide(); } } Application.Run(new Form1()); } </code></pre> <p>But this idea is not working. is it possible to do get the argument to the form? what code i need to write here?</p>
c#
[0]
5,315,731
5,315,732
Why are parentheses used when declaring a textview
<p>I'm fairly new to android. I've got experience with c# and java but I can't figure this out.</p> <p>I know how to use it. I've written a couple apps already. It's probably really simple but I don't understand this. Why is (TextView) in parentheses.</p> <p>I've searched the sdk documentation and afaik it doesn't mention this.</p> <pre><code>TextView example = (TextView) findViewById(R.id.example); </code></pre>
android
[4]
2,578,149
2,578,150
Can i use activities for all my layouts for any application?
<p>I am beginner in android application development. If i am using n number of layouts in my project and i need to change layouts with the user interaction. Should i use different activities for different layouts or can i use setContentView to switch layouts. Which one will be effecient?</p>
android
[4]
2,842,764
2,842,765
Customising context menus in Android
<p>Is there a way to change the look and feel of a context menu?<br> I want to add my own background, list item seperator and maybe the selector as well. I want to change it in famework so that i will get the customised menu every where i will use it.</p> <p>Can someone point me in the right direction? As far as I could make out - Context menu is just an alert dialog with a list. Am I right? How can i change the look and feel and from where?</p>
android
[4]
251,522
251,523
Implement (or use) a lock screen
<p>Is there a way I can use the android default lock screen (SDK)? OR should I implement my own? If I implement my own Any pointers how to do that?</p> <p>I basically want to unlock the screen using the keypad and If I use certain pattern then I can receive calls from X only and if I use a different pattern then I can receive calls from Y only (X and Y being certian contact).</p> <p>Please help me .. I need hint and I can take it from there Thanks</p>
android
[4]
1,013,132
1,013,133
Java: having files containing only general methods?
<p>I was wondering if there was a way to have methods separated from the main and class files (like how in c you can have .c &amp; .h with just methods that you can import into projects).</p> <p>Specifically I have a 'logical exclusive or' function that I want to use across several classes and I thought it would be good practice not to have the same function repeated across several classes.</p>
java
[1]
4,732,418
4,732,419
Select table row and check checkbox using JQuery
<p>I have a table and I want to select the rows that satisfy my criteria and check their respective checkbox. Let's say I want to get the rows with date <code>2013-03-21</code>. How can I do this using JQuery?</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt; Record1 &lt;/td&gt; &lt;td&gt; 2013-03-21 &lt;/td&gt; &lt;td&gt; &lt;input type="checkbox"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Record2 &lt;/td&gt; &lt;td&gt; 2013-03-22 &lt;/td&gt; &lt;td&gt; &lt;input type="checkbox"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Record3 &lt;/td&gt; &lt;td&gt; 2013-03-21 &lt;/td&gt; &lt;td&gt; &lt;input type="checkbox"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
jquery
[5]
3,860,553
3,860,554
manual gridview paging
<p>i'm am pulling 10 out of 100 records back from the database and placing into gridview (no datasource objects here). </p> <p>how do i enable paging that comes with the gridview? I know the total records is 100 can I use that somehow to activate the paging?</p> <p>I know I can do this easily with DataSource objects but was just wondering if I could do it completely manually as far as the GridView is concerned.</p> <p><strong>Markup</strong></p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" onpageindexchanging="GridView1_PageIndexChanging" onsorting="GridView1_Sorting"&gt; &lt;/asp:GridView&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Code-behind</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { GridView1.DataSource = GetCustomers(); GridView1.DataBind(); } </code></pre> <p><strong>strong text</strong></p>
asp.net
[9]
2,202,666
2,202,667
access to google with python
<p>how i can access to google !!</p> <p>i had try that code</p> <pre><code>urllib.urlopen('http://www.google.com') </code></pre> <p>but it's show message <code>prove you are human</code> or some think like dat</p> <p>some people say try user agent !! i dunno !</p>
python
[7]
4,989,321
4,989,322
Compare dictionary values and key in python
<p>I have a dictionary <code>item</code>. It has strings as keys and the values are lists e.g.:</p> <pre><code>item['title'] = [u'python'] item['image'] = [u'/link/to/image'] item['link'] = [u'link to article'] </code></pre> <p>I want to check if any value is 0 in length, but link or image may be empty, so I did the following:</p> <pre><code> for key, value in item.iteritems(): if len(value) == 0: if key != 'image' or key != 'link': raise DropItem("Item is empty: %s" %item) return item </code></pre> <p>So an item should be dropped only if the value is 0 and it is not an image or a key. My problem is now that this condition does not work. The item is still dropped when the image or link is empty.</p> <p>Any idea whats wrong? (I am new to python^^)</p>
python
[7]
1,713,662
1,713,663
how to create a timer and background service who make call to a get location()(langitude and longitude ) after every 5 min
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7592569/how-to-fetch-the-current-location-in-every-1-min-of-interval">How to fetch the Current Location in Every 1 min of Interval?</a> </p> </blockquote> <p>iam creted on working location class and another sendsms class </p> <p>now i need to create back ground service with the help of timer to send sms current location after every 5 min</p>
android
[4]
958,631
958,632
target to a div without reloading the page in javascript
<p>i wrote a web page that included some stuff. There, i need to create a input text box after clicking on a button, but it will be at the bottom due to existing stuff and i can't see the input box as it is in the out of visible area.there i'v to scroll down to find that.I tried with focus method , it focuses to the input box, it is unable to take the input box to visible area.in the top , i'v some javascript stuff .so i need to do this without refreshing.Here is the code snippet i'v tried. </p> <pre><code>&lt;script&gt; function create(){ var inputBox=document.createElement('input'); inputBox.setAttribute('id','myInput'); var body=document.getElementsByTagName('body')[0]; body.appendChild(inputBox); document.getElementById('myInput').focus(); } &lt;/script&gt; &lt;body&gt; &lt;button onclick="create()"&gt;Click me&lt;/button&gt; &lt;/body&gt; </code></pre> <p>Can anyone help me !</p>
javascript
[3]
186,810
186,811
javascript - find number in string
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1183903/regex-using-javascript-to-return-just-numbers">Regex using javascript to return just numbers.</a> </p> </blockquote> <p>How do I get the humber from a string like this?</p> <pre><code>blabla-33434 </code></pre>
javascript
[3]
196,275
196,276
Builtin Function to Convert from Byte to Hex String
<p>This is a question similar to <a href="http://stackoverflow.com/questions/2294153/a-builtin-function-to-convert-byte-to-string">this one here</a>.</p> <p>Is there a built-in method that converts an array of byte to hex string? More specifically, I'm looking for a built in function for </p> <pre><code> /// &lt;summary&gt; /// Convert bytes in a array Bytes to string in hexadecimal format /// &lt;/summary&gt; /// &lt;param name="Bytes"&gt;Bytes array&lt;/param&gt; /// &lt;param name="Length"&gt;Total byte to convert&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public static string ByteToHexString(byte[] Bytes, int Length) { Debug.Assert(Length &lt;= Bytes.GetLength(0)); StringBuilder hexstr = new StringBuilder(); for (int i = 0; i &lt; Length; i++) { hexstr.AppendFormat("{0,02:X}", Bytes[i]); } hexstr.Replace(' ', '0'); //padd empty space to zero return hexstr.ToString(); } </code></pre>
c#
[0]
5,705,730
5,705,731
My loop for class? lost
<blockquote> <p>Simulate a cash register as it totals a user's purchases. The program should execute for an unspecified number of items for a single user. The program should prompt the user for the quantity and unit cost of each item. The user should indicate the end of purchases by entering a negative quantity. The program should output on one line the quantity, unit cost, item total (the quantity times the unit cost), and the current subtotal to the file <code>purchases.txt</code>. These values should be separated by a space. The program should output the final total to both the file and the screen.</p> </blockquote> <p>I have the file I/O down pretty well. What I'm having trouble in class with is creating my loops and making them stop when something is entered.</p> <pre><code>import os.path outFile = open("purchases","w") quantity = raw_input("What is the quantity of the item") cost = raw_input("How much is each item") outFile.write() while quantity &lt;= ???? : </code></pre> <p>I understand the math but the loop just loses me.</p>
python
[7]
1,873,291
1,873,292
Twilio : Response application link not working
<p>I am unsing Twilio Rest Api for SMS functionality. My SMS is send sucessfully problem is when user response to SMS, I have to capture that response in my application and send confirmation email to user</p> <p>I am unable to capture response from application URL.Please give me some idea.</p> <p>Thanks in advance</p>
php
[2]
5,025,234
5,025,235
Timer not stopped when i click back button in android
<p>I am using the countdown timer but when i click back button the timer continues.Can any body tell me how can i stop when i click my phone back button not my application back button.</p> <p>Sorry for my English.</p> <p>Thanks in advance. </p>
android
[4]
235,990
235,991
C# speed of File.AppendAllText
<p>I fetch data from a database and use <code>File.AppendAllText</code> to write each database row into one file totalling 8000 files. This whole process repeats in a loop(of queries) and it seems to be taking forever. Is there a better way to go about doing this? Does it make sense to store all the file handlers?</p>
c#
[0]
5,685,385
5,685,386
Using CoreData with different instances of same viewcontroller with different data
<p>I am developing an app which is based on UITabBarController, one of the tab(Follow) shows the user's(The user who is using the app currently) followings and followers details in a UITableview. The data is different for different users and is downloaded from the server based on the UserId sent from the client and stored using CoreData entities(Follower, Following). The same ViewController(Follow) is also pushed upon selection of any other user profile from another view controller. In this case i am requesting the server with the new UserId and removing the data stored in the database and restoring with the new data. Now if user selects the tab(Follow), I am requesting the server with userId(The user who is using the app currently) and removing the old data restoring the new and reloading the table. The flow continuous.</p> <p>Can we avoid making multiple requests for the user(The user who is using the app currently) data with the same CoreData and entities.</p> <p>Please let me know if the flow that I explained is not clear, requires more information.</p>
iphone
[8]
5,300,695
5,300,696
Call function dynamically, regardless of being instance method or static?
<p>I need to be able to call a method without having to know whether or not it is static.</p> <p>For example, this doesn't work and I would like it to:</p> <pre><code>class Groups { public function fetchAll($arg1, $arg2){ return $this-&gt;otherFunction(); } public static function alsoFetchAll($arg1, $arg2){} } $arguments = array('one', 'two'); $result = call_user_func_array(array('Groups', 'fetchAll'), $arguments); $result = call_user_func_array(array('Groups', 'alsoFetchAll'), $arguments); </code></pre> <p>I'm getting an error for the instance varirable:</p> <pre><code>Fatal error: Using $this when not in object context </code></pre> <p>The reason it doesn't work is because I need to instantiate the class for the instance variables to work. But my constructor doesn't take any arguments so I want a quick way to skip this step.</p> <p>How can I write this so that it doesn't matter what kind of method it is?</p>
php
[2]
2,665,637
2,665,638
Google Adsense clash with SSL certificate
<p>When I add the below AdSense script to my SSL secure page it shows crossed red mark when browsed using chrome. When I remove this adsense script my SSL works great and perfect. Confused why the SSL does not accept even if I use https secure external link</p> <pre><code>&lt;script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/show_ads.js"&gt; </code></pre>
jquery
[5]
3,142,876
3,142,877
Long click on rectangle
<p>I created a view with rectangles which are clickable using the method onTouchEvent (using ACTION_DOWN motion). I want to enable a long click on the rectangle which open a dialog, and I tried to do it using ACTION_UP, but then the dialog is presented only after I release the finger. How can I do it in the same way that OnLongClickListener of buttons do?</p>
android
[4]
1,078,678
1,078,679
jQuery("body").css("margin") does not return a value in Chrome
<pre><code>jQuery("body").css("margin") </code></pre> <p>Does not return the margin value in Chrome, I just get <code>""</code> back. The value in the user agent stylesheet is <code>8px</code>. What am I doing wrong? Is this a bug?</p>
jquery
[5]
192,255
192,256
multiple submit buttons from multiple custom controls messing up the postback in asp.net
<p>I currently have a scenario where i am including two custom controls into a page, where each custom control has a submit button. The submit button works as long as only one control is added to the page, but once the second control is loaded both of the submit buttons stop working, the control never goes to the submit_click method in the custom control.</p> <p>Thanks.</p>
asp.net
[9]
360,081
360,082
Fetching all (javascript) global variables in a page
<p>Is there a way to retriev the name/value of all global variables on a page?</p> <p>I would like to write a javascript function to do the following:</p> <ol> <li>Find all global variables prefixed with 'xxx_' and stick them in an array (for e.g.)</li> <li>build a query string using the name value pairs as follows: xxx_glob_var1=value1&amp;xxx_glob_var2=value2 etc</li> </ol> <p>Could anyone offer some snippets to show how I may do this?</p>
javascript
[3]
957,982
957,983
Return value as 'customvariablename'
<p>I am attempting to crawl through a file and insert "../../" at the beginning of every image path. Unfortunately though, the script is timing out, and since it only took a few seconds to run before this was added something tells me it is not doing what I think it should be. This is how I'm doing it:</p> <pre><code>$filedata = substr_replace(substr($filedata,$imageBeginning,1),"../../",$imageBeginning); </code></pre> <p>I am crawling entire HTML files to accomplish this, so I need an efficient solution. Any help is appreciated.</p>
php
[2]
3,921,396
3,921,397
return non duplicates numbers in array from method
<p>I am trying to remove duplicate numbers using method and return non-duplicate numbers, actually I am stuck in method right now. this is my code :</p> <pre><code>import javax.swing.JOptionPane; public class duplicateRemover{ public static void main(String[] args) { int[] array = new int[5]; for (int i=0; i&lt;array.length;i++) { String s=JOptionPane.showInputDialog(null,"PLEASE ENTER AN INTEGER:","INTEGERS",JOptionPane.QUESTION_MESSAGE); array[i] = Integer.parseInt(s); } removeDuplicates(array); for (int i=0; i&lt;array.length;i++) { JOptionPane.showMessageDialog(null,array[i],"UNIQE INTEGERS",JOptionPane.PLAIN_MESSAGE); } } public static int[] removeDuplicates(int a []) { int []removedDup=new int[a.length]; for (int i = 0; i &lt; a.length; i++) { for (int j = i-1; j &lt; a.length; j++){ if (a[i] == a[i]) { removedDup[i] = j; break; } } </code></pre>
java
[1]
4,688,268
4,688,269
Get rowid from listview for deleting the row in the database
<p>I am using Custom Adapter to populate a listview which is reading from the database.Here when i do a longpress on a listitem,i want to delete the item from the listview and the database.How to get the rowid to delete that item from the database.</p> <p>Thanks.</p>
android
[4]
4,200,025
4,200,026
Can parentheses take arbitrary identifiers as arguments? C++
<p>For example, is</p> <pre><code>(const int)* someInt; </code></pre> <p>valid code?</p> <p>If so, is that statement different than</p> <pre><code>const int* someInt; </code></pre> <p>?</p>
c++
[6]
1,057,798
1,057,799
Is there anything wrong with throwing exceptions in the try block?
<p>Is it a good design practice to code a <code>try-catch</code> block as follows? That is, use a <code>throw</code> in the try block and then catch it in the catch block.</p> <pre><code>try { if (someCondition){ throw new Exception("Go the the associated catch block!"); } } catch(Exception ex) { logError("I was thrown in the try block above"); } </code></pre>
c#
[0]
649,012
649,013
Load module with variable path in python 2.6?
<p>My dev environment is python 2.6, so the importlib.import_module() syntax is not available to me. I'm trying to load a module with a path that is set by a variable; is this even possible in 2.6?</p> <p>The background is that I'm polling a number of devices from different vendors, so in various directories I have wrapper classes, all with identical methods and return types, which handle the vendor-specific methods for grabbing the data I need. So based on the vendor, I might need to load "platform_foo.stats" or "platform_bar.stats", then call the same methods on the resulting module.</p> <p>So, something like this, except this is obviously non-working code:</p> <pre><code>vendor = get_vendor(hostname) vendor_path = 'platform_%s.stats' % vendor import vendor_path stats = vendor_path.stats(constructor_args) </code></pre> <p>Any ideas?</p>
python
[7]
2,901,059
2,901,060
Lazy Loading in UITableview Sections IPhone
<p>I have "n" Arrays with Images and I want to display images correspondingly in "n" sections of tableview using lazy loading concept.I know how to display one array images in table containing one section.Can anyone Help me??? Thanks in Advance</p>
iphone
[8]
1,213,125
1,213,126
Replace a pattern in python
<p>How to replace the pattern in the string with</p> <pre><code> decoded_str=" Name(++info++)Age(++info++)Adress of the emp(++info++)" The first pattern "(++info++)" needs to replaced with (++info a++) The second pattern "(++info++)" needs to replaced with (++info b++) The third pattern "(++info++)" needs to replaced with (++info c++) If there many more then it should be replaced accordingly </code></pre>
python
[7]
4,420,270
4,420,271
how can I give command line arguments in java and validate it
<p>I am trying to code for 2 command line arguments where the first one is 'u' or 'l', nothing else and second a dna sequence(a,c,g,t) between 10 -20 letters, using regular expression to validate both arguments and trying to print sequence in uppercase if arg. is u and in lowercase if arg is l.the problem is i am not getting desired output. Please guide me how to do this code in java.</p>
java
[1]
5,994,831
5,994,832
Disable Uninstall button in android manageapplication
<p>How to disable the Uninstall button in android management applications ?</p> <p>If i once install the app in mobile device, if any end user want to uninstall that app, then he not able to uninstall it.</p>
android
[4]
240,857
240,858
PHP, Creating a folder when I run file_put_contents()
<p>I have uploaded a lot of images from the website, and need to organize files in a better way. Therefore, I decide to create a folder by months.</p> <pre><code>$month = date('Yd') file_put_contents("upload/promotions/".$month."/".$image, $contents_data); </code></pre> <p>after I tried this one, I get error result.</p> <blockquote> <p>Message: file_put_contents(upload/promotions/201211/ang232.png): failed to open stream: No such file or directory</p> </blockquote> <p>If I tried to put only file in exist folder, it worked. However, it failed to create a new folder. </p> <p>Is there a way to solve this problem?</p>
php
[2]
1,911,687
1,911,688
Play any video file using asp.net in IE and mozila
<p>i have used "embed" tag for Flv file, Flash Player for "swf" file and "object tag for other files... everything working fine with IE but in Mozilla only swf files working properly.. can anybody suggest me right way to play video of any type in IE and Mozilla both</p>
asp.net
[9]
1,199,569
1,199,570
How to remove empty paragraph tags from string?
<p>I ran into a slight coding problem with WordPress template. This is the code I use in template:</p> <pre><code>&lt;?php echo teaser(40); ?&gt; </code></pre> <p>In my functions, I use this to strip tags and get content from allowed tags only.</p> <pre><code>&lt;?php function teaser($limit) { $content = explode(' ', get_the_content(), $limit); if (count($content)&gt;=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); } $content = preg_replace('/\[.+\]/','', $content); $content = apply_filters('the_content', $content); $content = str_replace(']]&gt;', ']]&amp;gt;', $content); $content = strip_tags($content, '&lt;p&gt;&lt;a&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;&lt;em&gt;&lt;strong&gt;'); return $content; } ?&gt; </code></pre> <p>The problem: I use the above code to strip tags from the content, but WordPress already puts image tags within paragraph. So the result is empty paragraph tags where images are stripped. </p> <p>Just for the sake of cleaning up my code and useless empty tags. My question is how to remove empty paragraph tags?</p> <pre><code>&lt;p&gt;&lt;/p&gt; </code></pre> <p>Thanks a lot in advance! :)</p>
php
[2]
5,736,283
5,736,284
C# control flow
<p>I made a number which asks for 2 numbers with C# and responds with the corresponding message for the case. how come it doesnt work for the second number ? Regardless what I enter for the second number , I am getting the message "your number is in the range 0-10".</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string myInput; // declaring the type of the variables int myInt; string number1; int number; Console.WriteLine("enter a number"); myInput = Console.ReadLine(); //muyInput is a string which is entry input myInt = Int32.Parse(myInput); // myInt converts the string into an Integer if (myInt &gt; 0) Console.WriteLine("Your number {0} is greater than zero.", myInt); else if (myInt &lt; 0) Console.WriteLine("Your number {0} is less than zero.", myInt); else Console.WriteLine("Your number {0} is equal zero.", myInt); Console.WriteLine("enter another number"); number1 = Console.ReadLine(); number = Int32.Parse(myInput); if (number &lt; 0 || number == 0) Console.WriteLine("Your number {0} is less than zero or equal zero.", number); else if (number &gt; 0 &amp;&amp; number &lt;= 10) Console.WriteLine("Your number {0} is in the range from 0 to 10.", number); else Console.WriteLine("Your number {0} is greater than 10.", number); Console.WriteLine("enter another number"); } } } </code></pre>
c#
[0]
5,106,662
5,106,663
I want to dynamic change dialog's list item's textcolor. But list.getChildAt() confused me very much! Can you help me?
<p>I got that it seems the list.getchildAt() method return not null only when the list has shown once. If the list has not shown before, I call List.getChildAt() will return null. How can I do it, I want before the dialog's list shown before to change the list item's textcolor?</p>
android
[4]
1,841,092
1,841,093
Php how to use Explode in a sentence
<p>I am thinking a way to do this. I want to get some text in a sentence.</p> <p>This is a sample of $item_title in database:</p> <p><strong>cat1 + sub1 of cat1 + test 1 of sub1 of cat1</strong></p> <p>All i want to do is get the sentence starting from first ' + '</p> <p>In this case i want to have:</p> <p><strong>sub1 of cat1 + test 1 of sub1 of cat1</strong></p> <pre><code>$pieces = explode(" + ", $item_title); $idonotneed = $pieces[0]; // cat1 </code></pre>
php
[2]
2,526,607
2,526,608
Strange Behaviour w/ JavaScript workers
<p>I created a JavaScript worker. When I visit the page in the browser it tries to print the page. Strange right? You can see the page in action here:</p> <p><a href="http://galesupport.com/fb/workers.php" rel="nofollow">http://galesupport.com/fb/workers.php</a></p> <p>Can someone please explain this to me? Thanks :)</p>
javascript
[3]
5,653,905
5,653,906
validation on weight in asp.net?
<p>can i get validation on weight which can take decimal values and also integer. suppose if i enter 60 it has to accept and if i enter 60.50 it has to accept (60.1..etc) but not characters. Thank you. </p>
asp.net
[9]
4,014,699
4,014,700
I used heredoc syntax to cover my string. But It displays error. Below is my code:
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2305869/heredoc-interfering-with-code-indentation">HEREDOC interfering with code indentation</a> </p> </blockquote> <pre><code>&lt;?php $my_string = &lt;&lt;&lt;TO Everything in this rather unnecessarily wordy ramble of prose will be incorporated into the string that we are building up inevitably, inexorably, character by character, line by line, until we reach that blessed //final line which is this one. TO; echo $my_string; ?&gt; </code></pre> <p>it's error is:</p> <pre><code>Parse error: syntax error, unexpected $end in C:\wamp\www\ITP - Teaching\PHP\Chapter VIII - String\Heredoc Syntax\index.php on line 19 </code></pre>
php
[2]
4,000,469
4,000,470
files upload using java
<p>java code which handles files upload file from location in the system and to save that file to a specific location in the same system</p>
java
[1]
4,334,652
4,334,653
Get value of final field of a static class using reflection
<p>I have following class structure:</p> <pre><code> private static class MyStaticClass { public final String name; public final String photoUri; private MyStaticClass(String pName, String pPhotoUri) { this.name = pName; this.photoUri = pPhotoUri; } public static MyStaticClass getNewMyStaticClass(String pName) { return new MyStaticClass(pName, null); } } </code></pre> <p>Now when I want to read the value of "name" and "photoUri" fields, it gives me "Object is not an instance of class". Following is the code:</p> <pre><code>void printValues() { try { Class cls = Class.forName("my.pkg.name.TestClass$MyStaticClass"); for(Field field: cls.getDeclaredFields()) { System.out.println("Field name: " + field.getName()); System.out.println("Field value: " + field.get(cls)); } } catch (Throwable e) { e.printStackTrace(); } } </code></pre> <p>I also tried to pass "null" at field.get(null) to read the value but it gives null pointer exception.</p> <p>Please help me, how can I read the value of the field "name" and "photoUri"?</p>
java
[1]
1,605,341
1,605,342
Changing formatting string from % to alternate character?
<p>In python 2.6, is there a way to specify an alternate character other than % for string formatting operations? Or is the % char hardcoded in the python interpreter?</p> <p>For example, to generate a string that looks like this:</p> <pre><code>param1%02param2%03param3... </code></pre> <p>I currently have to do this:</p> <pre><code>str = "%s%%02%s%%03%s" % (param1, param2, param3) </code></pre> <p>What I'd like to be able to do is substitute, say, ^ for % and be able to do:</p> <pre><code>str = "^s%02^s%03^s" ^ (param1, param2, param3) </code></pre> <p>which IMO is far more readable.</p>
python
[7]
4,950,520
4,950,521
Is it possible to modify the Contacts using URI and cursorLoader instead of ContentResolver() insert() , delete() modfiy() etc
<p>I am new to Android development and trying to add an activity that would let me manipulate the contacts without going to the contacts app. </p> <p>I used a cursorLoader() to access the the Contacts and displayed it in a listView. Now I want to insert, delete or edit a new contact . </p> <p>My question is do I have to use ContentResolver().insert() for this or is there a way to do it using CursorLoader() itself. Is CursorLoader() just for accessing data ? </p> <p>I do see examples to do this using ContentResolver() but wondering if that is not recommended anymore ? </p> <p>Please let me know. </p>
android
[4]
1,862,610
1,862,611
Question on updating/inserting a datatable in a dataset
<p>I need to open a connection to SQL database and read a subset of a table and either update a record if exists or insert if not found. Having truoble updating</p> <pre><code> SqlConnection conn = new SqlConnection(ConnectionStrings.PgenIntranet.SqlClientConnectionString); SqlDataAdapter indicators = new SqlDataAdapter(); string sql = "SELECT * FROM BusinessApplications.tbl_WPI_Site_Indicators where Year = '" + year + "' and Month = '" + month + "' and PlantId = " + site.ID; indicators.SelectCommand = new SqlCommand(sql, conn); SqlCommandBuilder cb = new SqlCommandBuilder(indicators); indicators.UpdateCommand = cb.GetUpdateCommand(); DataSet ds = new DataSet(); indicators.Fill(ds, "indtable"); DataTable indtable = ds.Tables["indtable"]; // this logic not working if (indtable.Rows.Count == 0) { indtable.NewRow(); } DataRow dr = indtable.NewRow(); /// not sure how to make this work indtable[1]["PlantId"] = site.ID; dr["PlantId"] = site.ID; </code></pre>
c#
[0]
3,916,528
3,916,529
Returning a Random Number Type Problem
<p>I'm trying to return a random number from a method but apparently the implicit type is not correct. It says "Cannot implicitly convert type 'Randomize.RandomNumber' to 'int'"</p> <p>RandomNumber.cs:</p> <pre><code>using System; using System.Collections.Generic; using System.Text; namespace Randomizer { class RandomNumber { public int RandomInRange(int l, int u) { Random generator = new Random(); return generator.Next(l, u); } } } </code></pre> <p>Program.cs:</p> <pre><code>using System; using System.Collections.Generic; using System.Text; namespace Randomizer { class Program { static void Main(string[] args) { Console.Out.WriteLine("Please enter the minimum range for the random number\n"); int min = int.Parse(Console.In.ReadLine()); Console.Out.WriteLine("Please enter the maximum range for the random number\n"); int max = int.Parse(Console.In.ReadLine()); int RandomInt = new RandomNumber(); Console.Out.WriteLine("Your random number is: " + RandomInt.RandomInRange(min, max)); Console.In.ReadLine(); } } } </code></pre> <p>I know it's pretty much a noob question, but I'm used to C++. Thanks for the help in advance. =]</p>
c#
[0]
741,324
741,325
How to detect orientation change in layout in Android?
<p>I just implemented the orientation change feature. </p> <p>When the layout changes from portrait to landscape (or vice versa), how can I detect when the orientation change event finished.</p> <p>I tried to use <code>OrientationEventListener</code>, but it seems not a good idea.</p> <p>I just want to be notified only when layout orientation changes. How to do that?</p>
android
[4]
4,402,903
4,402,904
accessing variable outside for loop in c#?
<p>Here i need to access the variable <code>delval</code> outside the for loop as in the code below </p> <pre><code>cmd_mail.Parameters.Add("@deleteusers", SqlDbType.NVarChar).Value = delval; </code></pre> <p>..How to do this.. </p> <p>Here is my code</p> <pre><code> for (int i = 0; i &lt;= NoOfUsers - 1; i++) { using (SqlConnection Conn = new SqlConnection(constr_str)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = Conn; Conn.Open(); cmd.CommandText = "Select top 1 Login_User_Name from Rode_Provisioning_User where RequestId=@RequestId and CustomerCode =@CustomerCode and disableflag=0 order by User_Count"; cmd.Parameters.Add("@CustomerCode", SqlDbType.VarChar).Value = CustomerCode; cmd.Parameters.Add("@RequestId", SqlDbType.VarChar).Value = RequestId; string Loginusername = cmd.ExecuteScalar(); Conn.Close(); string delval = ""; if (string.IsNullOrEmpty(delval)) { delval = Loginusername; } else { delval = delval + "," + Loginusername; } } } } if (flag == "Yes") { string constr_dep = "server=" + _strServer + ";database=" + _strDatabase + ";uid=" + _strUserid + ";pwd=" + _strPassword + ";"; SqlConnection con_dep = new SqlConnection(); con_dep.ConnectionString = constr_dep; SqlCommand cmd_mail = new SqlCommand("delete_user_mailsend_sp", con_dep); cmd_mail.CommandType = CommandType.StoredProcedure; cmd_mail.CommandTimeout = 0; cmd_mail.Parameters.Add("@companycode", SqlDbType.NVarChar).Value = CustomerCode cmd_mail.Parameters.Add("@deleteusers", SqlDbType.NVarChar).Value = delval; try { con_dep.Open(); cmd_mail.ExecuteNonQuery(); } catch (SqlException ee) { VWLogger.LogMessage("Exception in delete_user_mailsend_sp:", TraceEventType.Critical); VWLogger.LogMessage(ee, TraceEventType.Critical); return ee.Message; flag = ee.Errors(0).ToString(); } con_dep.Close(); } </code></pre> <p>Any suggestion?</p>
c#
[0]
3,780,231
3,780,232
A newbie's try for a Q on SO
<p>I have a little newbie's hitch.</p> <p>I have got something like this:</p> <pre><code>// Assign Device ID if ($line == "IMEI 358998018395510\r\n"){ $device_id = 1; }elseif($line == "IMEI 352924028650492\r\n"){ $device_id2 = 3; } ........ ........ if (fwrite($outFile,$device_id or device_id2. ",". $date.",".$line)===FALSE){ </code></pre> <p>I want to be able to determine which one of the variables of device_id or device_id 2 would finally be the result so i can append it to the fwrite statement on the last line above. Can someone please show how?</p>
php
[2]
217,129
217,130
where to look if app crashes on startup
<p>I am a beginner to android. in java and other programming languages we get error in the console. how to find the same as if there is no error in the code and app crashes on start up. </p>
android
[4]
5,126,721
5,126,722
Regarding binding array to gridview
<p>Hi I have created session array :</p> <pre><code> int[] a = (int[])Session["values"]; </code></pre> <p>Now i have to bind this value to my gridview. I have one column (boundfield in my gridview) in gridview. I used code to bind array to gridview as follows, but its giving last value only as i want all the values to bind :</p> <pre><code> for (int i = 0; i &lt; a.Length; i++) { str = "select * from Quest_Info where Quest_id='" + a[i] + "' order by Quest_id"; SqlDataAdapter da2 = new SqlDataAdapter(str, sqlconn); ds2 = new DataSet(); da2.Fill(ds2, "Result"); reviewgrid.DataSource = ds2; reviewgrid.DataBind(); } </code></pre> <p>Which code will work for this? Asp.net, c# Thank You.</p>
asp.net
[9]
589,155
589,156
can not access e-mail attachment
<p>I used the code below to get the email attachment file url.</p> <pre><code>NSURL *url=(NSURL*)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey]; </code></pre> <p>but </p> <pre><code>bool b=[[NSFileManager defaultManager] fileExists:[url absoluteString]; </code></pre> <p>always returns NO, which means the email attachment file does not exist.</p> <p>Welcome any comment</p>
iphone
[8]
36,173
36,174
modify checkbox using javascript
<p>I had declared 5 checkboxes with name and id attribute in a html:</p> <pre><code>&lt;input type="checkbox" name="category" value="One" id=11&gt;One&lt;br/&gt; &lt;input type="checkbox" name="category" value="Two" id=12&gt;Two&lt;br/&gt; &lt;input type="checkbox" name="category" value="Three" id=13&gt;Three&lt;br/&gt; &lt;input type="checkbox" name="category" value="Four" id=14&gt;Four&lt;br/&gt; </code></pre> <p>After declaration, I want to run a javascript that would enable the checkbox1 using that checkbox id.</p> <p>Let me know to clarify something.</p>
javascript
[3]
3,982,671
3,982,672
How to get word from CurrentInputConnection in android?
<p>I am working on custom InputConnection in android. Everything is working fine, but i want to get characters between cursor's current position and start position of particular word.</p> <p>Is there any suggestion? how can i do that?</p> <p>Thanks..</p>
android
[4]
2,233,004
2,233,005
Preg match problem
<p>I try to "validate" a date field. I only want to allow, numeric chars and - character.</p> <pre><code> $born_date=$_POST['date']; $goodchars = array("1","2","3","4","5","6","7","8","9","0","-"); $char_re_good = '/['.preg_quote(join('', $goodchars), '/').']/'; if (!(preg_match($char_re_good, $born_date))) { echo "not ok, contain INVALID chars" }else{ echo "ok, contain valid chars" } </code></pre> <p>If i try to search for "1960" then OK. If i try to search for " asdfg" then NOT OK. But if i search for "1960/" then the output is OK. I dont understand why. </p> <p>Could you help me modify to check if user only "0-9" and "-" chars fill out the field.</p> <p>Thank you</p>
php
[2]
3,096,191
3,096,192
howto split a int into its single numbers?
<p>how can i split a int in c++ to its single numbers, e.g.: 23 to 2 and 3 ??</p>
c++
[6]
2,133,952
2,133,953
jQuery: how to add buttons that can in turn add more buttons
<p>I am writing a script that allows users to add friends on a form. I need to be able to have them add a friend, click an add button button next to the input, add another friend, click the add button next to that input and so on. I am trying to do that with jQuery, but am stuck. I achieved this, but my script adds buttons like I want, but it adds inside the original button. I know it is because I am using "this" in my script, but I can't get it working without this. If my code is not the way to do this, I am open to other suggestions. Here is my code, which is wrapped in document.ready higher up in the script:</p> <pre><code>$("button#add-friend").click(function (e) { $(this).trigger('addFriend'); }); $('#add-friend').on('addFriend', function() { $(this).append('&lt;input type="text" value="Friend"&gt;&lt;span id="add"&gt;&lt;input type="button" id="add-friend" value="+"&gt;&lt;/span&gt;&lt;br/&gt;'); }); </code></pre> <p>The HTML is:</p> <pre><code>&lt;input type="text" value="Friend"&gt;&lt;span id="add"&gt;&lt;input type="button" id="add-friend" value="+"&gt;&lt;/span&gt; &lt;div id="add-friend"&gt;&lt;/div&gt; </code></pre> <p>By the way I am using jQuery 1.7, which has the new "on" syntax. ".on('click', ... )" is the same as ".click(...)"</p>
jquery
[5]
1,501,713
1,501,714
Why didn't my Application crash after it used more memory than VM budget?
<p>I was running my app on Nexus S, the per-app memory limit on which is 32M bytes.</p> <p>I ran the command to check the memory usage of the app:</p> <p>adb -d shell dumpsys meminfo com.mycomp.myapp</p> <pre><code>Applications Memory Usage (kB): Uptime: 1128469 Realtime: 1128466 ** MEMINFO in pid 841 [com.mycomp.myapp] ** native dalvik other total size: 29148 9415 N/A 38563 allocated: 20259 6273 N/A 26532 free: 379 3142 N/A 3521 (Pss): 9253 2049 25338 36640 (shared dirty): 1984 1520 7836 11340 (priv dirty): 9180 960 16212 26352 Objects Views: 0 ViewRoots: 0 AppContexts: 0 Activities: 0 Assets: 24 AssetManagers: 24 Local Binders: 11 Proxy Binders: 23 Death Recipients: 1 OpenSSL Sockets: 0 SQL heap: 173 MEMORY_USED: 173 PAGECACHE_OVERFLOW: 28 MALLOC_SIZE: 50 DATABASES pgsz dbsz Lookaside(b) Dbname 1 14 61 webview.db 1 8 53 webviewCache.db </code></pre> <p>From the memory report above, my app already used 38563K memory, which has already exceeded 32M VM budget. But why hasn't the app crashed yet?</p>
android
[4]
3,675,023
3,675,024
Error when I am redirecting page
<p>I am getting an error <strong>"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."</strong> When i am redirecting my page from one to another. I am using this code.</p> <pre><code>try { Session["objtwitter"] = obj_UserDetSumit; Response.Redirect("TwitterLogin.aspx"); } catch (Exception ex) { lblStatus.Text = "Account Creation Failed, Please Try Again"; } </code></pre> <p>And i got a solution and i tried also this <code>Response.Redirect("home.aspx",false);</code> It's not throwing an error but it's also not redirecting page.</p>
asp.net
[9]
5,491,326
5,491,327
problem in array $_POST
<p>i have this code it can go to <code>if(array_key_exists('p',$_POST))</code> but can't go to <code>if(isset($_POST['p'][$i]) &amp;&amp; $_POST['p'][$i]==$row[0])</code></p> <p>i tried to <code>echo $_POST['p'][0]</code> in <code>if(array_key_exists('p',$_POST))</code> but it tells me 0 is undefined</p> <p>i don't know my error.</p> <pre><code>if(array_key_exists('update',$_POST)){ //somecode echo"&lt;td&gt;&lt;input type='Checkbox' name='p[$i]' value='$row[0]' unchecked onclick='openinput()'/&gt;&lt;/td&gt;"; if(array_key_exists('p',$_POST)) { $result=mysql_query($query); if($result) { $num=mysql_num_rows($result); if($num&gt;0) { if(isset($_POST['p'][$i]) &amp;&amp; $_POST['p'][$i]==$row[0]) { foreach($_POST['p'] as $key=&gt;$value) { //some code } } } } } } </code></pre>
php
[2]
3,210,081
3,210,082
Can one have different colored text sentences in the same list view item in Android?
<p>For example, look at this sentence:</p> <blockquote> <p>"I have to get on at A4 junction, And Getoff at B2 junction".</p> </blockquote> <p>Here I want to change the color of </p> <blockquote> <p>"get on at A4 junction"</p> </blockquote> <p>to blue in and </p> <blockquote> <p>"getOff at B2 junction"</p> </blockquote> <p>and other words to white in the same listview item. Can anyone give me the solution for this problem?</p>
android
[4]
1,136,756
1,136,757
DataTable RowGrouping Not Grouping Error
<p>I am using DataTable 1.9 and the RowGrouping pluging. The IQueryable collection being binded to the datatable is not sorted or grouped before the databinding event. When I used the following code</p> <pre><code> var oResultGrid = $("[id$='gvReportData']"); if (fixEmptyDataRow(oResultGrid)) { var oTable = oResultGrid.dataTable({ "bPaginate": false, "bFilter": false, "bInfo": false }).rowGrouping({ bExpandableGrouping: true, iGroupingColumnIndex: 2 }); } else { oResultGrid.dataTable({ "sPaginationType": "full_numbers", "aaSorting": [[1, 'asc']] }).rowGrouping({ bExpandableGrouping: true, iGroupingColumnIndex: 2 }); } </code></pre> <p>I can see that the rowgrouping takes the 2nd column as the grouping field. I see the gray grouping header on top of each row/record, but the common row in term of the column are not grouped. I only see the grouping field in gray header on top of each row but they are not group under the grouping field, therefore, no + expandable or collapsible function. </p> <p>Been spinning for hours on this. Any help is greatly appreciated.</p>
asp.net
[9]
3,242,339
3,242,340
Get Value from local .resx file
<p>How can i get value from local .resx file in asp.net?</p>
asp.net
[9]
787,738
787,739
How to extend array or object prototype for a specific javascript object?
<p>Say I have the following:</p> <pre><code>function Myobj = { name: "Julia", birthdate: "xxxx", genres: [], movies: [{title: "movie1", rating: 5, genre: "Horror"}, {title: "movie2", rating 3, genre: "Comedy"},{title: "movie3", rating 3, genre: "Comedy"}, {title: "movie4", rating 3, genre: "Comedy"}, {title: "movie5", rating 3, genre: "Horror"}] } </code></pre> <p>What I want to be able to do is have some function like:</p> <pre><code>Myobj.prototype.pushMovie(somejson) { // code to add somejson to "movies", and add the "genre" to the "genres" array } </code></pre> <p>Such that I can go:</p> <pre><code>obj1 = new Myobj(); obj1.pushMovie({title: "movie1", rating: 5, genre: "Horror"}); </code></pre> <p>Or is it better practice to override the array prototype? If so, is it possible to give a prototype a specific array as opposed to all arrays like:</p> <pre><code>Myobj.Array.prototype.pushMovie() { // code to inherit from regular push, and do some operation to add to "genres" } </code></pre> <p>I do not know what the syntactically correct or best approach is.</p>
javascript
[3]
1,678,102
1,678,103
Android (min 2.1): load images from name string
<p>I want to be able to load images dynamically from res/drawable. I don't how many files there will be, but I do know they will be named by convention as "image_N", where N is sequential integer. It is possible that new images will be uploaded while the app is running.</p> <p>My code is basically</p> <pre><code>Resources rs = getResources(); String imgName = "android.resource://" + this.getPackageName() + "/drawable/image_" + i; int imgID = rs.getIdentifier(imgName , null, getPackageName()); if (imgID != 0) { Drawable d = rs.getDrawable(imgID); //etc. } </code></pre> <p>but <code>imgID</code> being returned is always <code>0</code>.</p> <p>I also tried another approach</p> <pre><code>String imgName = "android.resource://" + this.getPackageName() + "/drawable/image_" + i; b = BitmapFactory.decodeFile(imgName); if (b != null) //etc </code></pre> <p>But <code>b</code> is always <code>null</code>.</p> <p>I know there are files in the folder with the right names because I put a few there. Not sure what I'm doing wrong. Any help would be greatly appreciated!</p>
android
[4]
3,389,703
3,389,704
jQuery getting ID
<p>I'm trying to get the image SRC using this: <code>var SRCNow = $('#'+ID+'.item').attr("src");</code></p> <p>on this:</p> <pre><code>&lt;a id='17' href='#' name='item' class='tilelink'&gt;&lt;img title='17' id='17' style='background:red'; class='item' src='line_tile/t17.png' /&gt;&lt;/a&gt; </code></pre> <p>So when I click on that image by doing on click image...: <code>var ID = $(this).attr("id");</code></p> <p>and then I do <code>alert(SRCNow);</code> and I get undefined.... when it should say the SRC.</p>
jquery
[5]
1,830,403
1,830,404
Android Powerdown device after 10 minutes inactive
<p>I need for my app to shutdown the device if there is 10 minutes or more of inactivity. So what is best way to detect and shutdown after 10 minutes? Thanks</p>
android
[4]
3,044,731
3,044,732
how to immediately run a function while an element.innerHTML change?
<p>First,I planed to set an element's <strong>innerHTML</strong> a <code>getter</code> and <code>setter</code><br> But I found it wouldn't work,I know why it wouldn't,but is there a way to accomplish this task?<br> Thanks </p>
javascript
[3]
4,911,289
4,911,290
const_cast for vector with object
<p>I understand that const_cast to remove constness of objects is bad, </p> <p>I have the following use case, </p> <pre><code>//note I cannot remove constness in the foo function foo(const std::vector&lt;Object&gt; &amp; objectVec) { ... int size = (int) objectVec.size(); std::vector&lt;Object&gt; tempObjectVec; //Indexing here is to just show a part of the vector being //modified for (int i=0; i &lt; (int) size-5; ++i) { Object &amp;a = const_cast&lt;Object&amp;&gt; objectVec[i]; tempObjectVec.push_back(a); } foo1(tempObjectVec); } </code></pre> <p>If i change tempObjectVec objects in foo1, will the original objects in ObjectVec change, I say yes since I am passing references, further is this efficient. Can you suggest alternatives. </p>
c++
[6]
105,849
105,850
Java: library to calculate the mean?
<p>Is there a function in Jave to calculate the mean ?</p> <p>I've tried by myself but I'm afraid that sum has too high value: 5 642 782 840</p> <p>Can a integer be 5 642 782 840 in Java ? I don't think so...</p> <pre><code>for (int i = 0; i &lt; timeValues.length; i++) { sum = sum + Integer.parseInt(timeValues[i]); } time = Integer.toString(sum / timeValues.length); </code></pre> <p>thanks</p>
java
[1]