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
4,908,965
4,908,966
Efficient way to convert a list to dictionary
<p>I need help in the most efficient way to convert the following list into a dictionary: </p> <pre><code>l = ['A:1','B:2','C:3','D:4'] </code></pre> <p>At present, I do the following:</p> <pre><code>mydict = {} for e in l: k,v = e.split(':') mydict[k] = v </code></pre> <p>However, I believe there should be a more efficient way to achieve the same. Any idea ?</p>
python
[7]
3,103,448
3,103,449
Get height of image inside a hidden div
<p>i want to to get the height/width of an image inside a hidden div-containter, but <code>.height()</code> and <code>.width()</code> both returns 0 (like expected).</p> <pre><code> $('body').append('&lt;div id="init"&gt;&lt;img id="myimg" src="someimage.png" /&gt;&lt;/div&gt;'); $('#init').hide(); $('#myimg').height(); // == 0 $('#myimg').width(); // == 0 </code></pre> <p>How can i get the correct height/width of the image? I need it to make some decisions :-)</p> <p>Best regards, Biggie</p>
jquery
[5]
4,240,224
4,240,225
how to get the registration id for C2DM server of google for push notification?
<p>For push notification i'm planning to use C2DM google server but to use it registraion ID is need.I tried alot to get the registration id but unable to get registration id if anyone have succeded to get it then please assist me to get it </p> <p>thank you in advance.</p>
android
[4]
2,318,170
2,318,171
COM library Initilization failed with code 0x80010106 in c#
<p>i was trying to push data manually to NT using c# but i was getting an error as: "Failed to initialize COM library(0x80010106)." I have already added the reference 'Ninjatrader.Client.dll' i am posting my code as below:</p> <pre><code>using System; using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; namespace read_file { public static class Program { [DllImport("NtDirect.dll", EntryPoint = "Connected", SetLastError = true)] public extern static int Connected(int showMessage); [DllImport("NtDirect.dll", SetLastError = true)] public static extern int Last(string instrument, double price, int size); public static void Main(string[] args) { NinjaTrader.Client.Client NTClient = new NinjaTrader.Client.Client(); int ConnectStatus = Connected(1); NTClient.Command("PLACE", "Sim101", "ES 03-08", "BUY", 1, "LIMIT", 1245.00, 0, "GTC", "ax1234", "", "", ""); int k; for (int i = 0; i &lt; 100; i++) { k = 10 * (i + 1); Last("AUDUSD", k, 4); for (int j = 0; j &lt; 999999999; j++) { } Console.WriteLine(k); } } } } </code></pre> <p>please tell me the correct suggestion. thank you</p>
c#
[0]
4,156,502
4,156,503
Find next lower item in a sorted list
<p>let's say I have a sorted list of Floats. Now I'd like to get the index of the next lower item of a given value. The usual for-loop aprroach has a complexity of O(n). Since the list is sorted there must be a way to get the index with O(log n).</p> <p>My O(n) approach:</p> <pre><code>index=0 for i,value in enumerate(mylist): if value&gt;compareValue: index=i-1 </code></pre> <p>Is there a datatype for solving that problem in O(log n)?</p> <p>best regards Sebastian</p>
python
[7]
2,829,038
2,829,039
Asp.net UrlWriting
<p>can any one tell me why url rewriting not working in iis6?</p>
asp.net
[9]
664,142
664,143
How do I get the module instance for a class in Python?
<p>I am learning Python, and as always, I'm being ambitious with my starter projects. I am working on a plugin system for a community site toolkit for App Engine. My plugin superclass has a method called <code>install_path</code>. I would like to obtain the <code>__path__</code> for the <code>__module__</code> for <code>self</code> (which in this case will be the subclass). Problem is, <code>__module__</code> returns a <code>str</code> rather than the module instance itself. <code>eval()</code> is unreliable and undesirable, so I need a good way of getting my hands on the actual module instance that doesn't involve <code>eval</code>ling the <code>str</code> I get back from <code>__module__</code>.</p>
python
[7]
592,966
592,967
Identifying index position of duplicates in a list and fetching the elements at the identified index of another list in Java
<p>I have two list say 'src' and 'dest'. src contain some duplicates. I need to identify the index of the duplicate elements. After identifying the index, I want to fetch elements from the same index position of the 'dest' list </p>
java
[1]
1,063,174
1,063,175
Jquery conflicts between jquery.js and jquery-1.9.0.js
<p>I have two jquery one for responsive navigation and other for banner. But both are not working same time. I think there is jquery conflicts. when i comment <strong>jquery.js</strong> for banner then banner with <strong>jquery-1.9.0.js</strong> is working well. Will any one please help me to fix this. I am going to give you the link of my page.<a href="http://dipannita.me/demo/" rel="nofollow">here is the link </a>. Its just a trial i am working. Thanks for advance. </p>
jquery
[5]
4,503,260
4,503,261
Learning classes but having an odd issue that I am sure is simple
<p>So I am learning how to use classes and python and I am creating a simple program to perform arithmetic operations with rational numbers. I am creating a class called ArithmeticOperations. In this class I have a main function definition which prompts the user for the numerator and denominator of 2 rational numbers, then performs either the sum, difference, product, or quotient based on the choice of the user. The operations are performed in a separate function. Right now I have created the main function and the product function, but when I run it I get an error that says </p> <blockquote> <p>TypeError: product() takes exactly 5 arguments (6 given)</p> </blockquote> <p>I am sure this is something simple but I am new to classes so i am having a bit of trouble debugging. Here is my current program:</p> <pre><code>class ArithmeticOperations: # Given numbers u0, v0, and side, design a pattern: def product(self,n1, d1, n2,d2): self.numerator = n1*n2; self.denominator = d1*d2; print n1,'/',d1,'*',n2,'/',d2,'=',self.numerator,'/',self.denominator; def main(self): n1 = input('Enter the numerator of Fraction 1: '); d1 = input('Enter the denominator of Fraction 1: '); n2 = input('Enter the numerator of Fraction 2: '); d2 = input('Enter the denominator of Fraction 2: '); print '1: Add \n 2: Subtract\n 3: Multiply\n 4: Divide' ; question = input('Choose an operation: '); if question == 1: operation = self.sum(self,n1,d1,n2,d2); elif question == 2: operation = self.difference(self,n1,d1,n2,d2); elif question == 3: operation = self.product(self,n1,d1,n2,d2); elif question == 4: operation = self.quotient(self,n1,d1,n2,d2); else: print 'Invalid choice' ao = ArithmeticOperations(); ao.main(); </code></pre>
python
[7]
846,429
846,430
Installing a large size apk application on Android phone
<p>I have an application which is of size 130MB. when i try to install its displaying insufficient memory error. but i have around 170MB left in available space in internal memory. How can i Install this app? The size of the app is large because it contains many media files. In Motorolla droid its getting installed. but on Nexus One its giving this error.</p>
android
[4]
5,569,527
5,569,528
How to minimize compilation time in C++
<p>I've coded an script that generates a header file with constants like version, svn tag, build number. Then, I have a class that creates a string with this information.</p> <p>My problem is the following: As the file is created in every compilation, the compiler detects that the header has changed, and forces the recompilation of a large number of files. I guess that the problem is in the situation of the header file. My project is a library and header has to be in the "interface to the world" header file (it must to be public).</p> <p>I need some advice to minimize this compilation time or to reduce the files forced to recompile.</p>
c++
[6]
5,377,469
5,377,470
How to change the value of a textView within a widget, from the value of a textEdit in another activity
<p>If I have a widget that has a textView within it, and then a different class with an activity with a editText, is there a way to change the widget textView value, to the same value of the editText?</p>
android
[4]
4,822,401
4,822,402
android how to build a repeat AlarmManager for the day that user select every week?
<p>I want to build an Activity that user could select the days they want</p> <p>such as Sun, Mon, Tue, wed,...,Sat</p> <p>and a method in the Activity is use to set the time user choose </p> <p>'</p> <pre><code> if(action) { //10分鐘該一次 PendingIntent sender = PendingIntent.getBroadcast(MedicationAddRemineActivity.this , 0 , intent, 0 ); alarm.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP , fireTime, 10*60*1000, sender); } else { //關閉鬧鐘 PendingIntent cancelSecder = PendingIntent.getBroadcast(MedicationAddRemineActivity.this , 0 , intent, 0); alarm.cancel(cancelSecder); } }` </code></pre> <p>but I want to build a function to handle user selected days every week by the radioButton</p> <p>if the user selected monday and friday, device should show a dialog to user</p> <p>every monday and friday, until it be canceled.</p> <p>how do i build the function?</p> <p>count the AlarmManager start time:</p> <p>`</p> <pre><code>long totalTime = 0; if(moon.equals("下午")) { totalTime = total + 12*3600; } else {totalTime = total + 0;} //取得系統當時時間 Time t = new Time(); int sysHour = t.hour; int sysMin = t.minute; int sysSecond = t.second; long sysTotal = sysHour*3600 + sysMin*60 +sysSecond; //處理用藥提醒時間 SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); long transfer = Long.parseLong(format.format(totalTime)); String transferdTime = String.valueOf(sysTotal - transfer); return transferdTime; </code></pre> <p>}`</p>
android
[4]
4,973,540
4,973,541
Should you make private properties?
<pre><code>private string mWhatever; private string Whatever { get { return this.mWhatever; } set { this.mWhatever = value; } } </code></pre> <p>I've seen some people who make properties for every single member, private or not... does this make any sense? I could see it making sense in 1% of the cases at times when you want to control access to the member inside the class containing it because if you didn't use properties for every member it would lead to inconsistencies and checking to see if the member has an access or not (since you have access to both in the scope of the class).</p>
c#
[0]
4,596,224
4,596,225
Is it possible for a user app to capture a screenshot(anytime) in android?
<p>Is it possible to capture a screenshot of whatever view the user has, in android using a user app - without rooting/adb. So basically i want to create a screenshot app. Hopefully my doubt is clear enough. Not enough info is there whether android allows the user app to do this or not.</p>
android
[4]
2,094,943
2,094,944
how to get the DIV ID from given HTML in JQuery
<p>I have below HTML format:</p> <pre><code>&lt;ul class="whatlike-list"&gt; &lt;li class="first"&gt; &lt;a href="/SessionHandler.aspx" class="button-flight-search"&gt;Search for Flights&lt;/a&gt; &lt;div class="open-block-holder"&gt; &lt;div id="slideFlightSearch" class="open-block" style="display: block; left: 650px;"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Now I am looking to get DIV ID="<strong>slideFlightSearch</strong>" on the click of link <strong>"Search for Flights"</strong>, I have got the class "button-flight-search" in my $this object. Something like below in my JQuery.</p> <pre><code>$(link).click(function() { alert($(this).attr("class")); }) </code></pre> <p>In the above alert I am getting the class "button-flight-search", however I need the inner DIV ID slideFlightSearch</p> <p>Please suggest using JQuery.</p>
jquery
[5]
4,436,047
4,436,048
Firefox/chrome is not displying uploaded image but IE6 is displaying in php why so
<p>HI Everybody</p> <p>I am uploading an user image while he/she sign up and then in his/her home page i have given a link if he/she want to show his/her uploaded image.There is no problem ..</p> <p>But when i try to see this image through firefox/chrome my image is not displaying only a tiny icon is displaying there.Image is jpeg type</p> <p>But when i am trying to display this image through IE6 it is displyed no problem there..</p> <p>May i know why this..</p> <pre><code>&lt;?php session_start(); $con=mysql_connect("localhost","root",""); if(!$con) { die('Could Not Connect:'.mysql_error()); } mysql_select_db("tcs",$con); $usr=$_SESSION['employee']['username']; $query="select * from employee where Username='$usr'"; $result=mysql_query($query,$con); if ($result) { $row=mysql_fetch_array($result); $addr=$row['File Name']; } ?&gt; &lt;html&gt; &lt;body&gt; &lt;img src="&lt;?php echo $addr ; ?&gt;" width="200" height="150" alt="Deepak Narwal"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is how i am displaying the uplaoded image which one use upload at the time of sign-up i am storing it into hard disk in one folder under htdocs and full address of this i am storing into database under File Name</p>
php
[2]
3,450,046
3,450,047
Function for bigrams matching
<p>I have got a following function:</p> <pre><code>public static ArrayList&lt;String&gt; matchLists(ArrayList&lt;String&gt; ar1, ArrayList&lt;String&gt; ar2, ArrayList&lt;String&gt; ar3) { ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;(); for (int i = 0; i &lt; ar1.size(); i++) { for (int j = 0; j &lt; ar2.size(); j++) { for (int k = 0; k &lt; ar3.size(); k++) { String[] s1 = ar1.get(i).split("\\s"); String[] s2 = ar2.get(j).split("\\s"); String[] s3 = ar3.get(k).split("\\s"); if (s1[1].equals(s2[0]) &amp;&amp; s2[1].equals(s3[0])) { result.add(s1[0] + " " + s2[0] + " " + s3[0] + " " + s3[1]); } } } } return result; } </code></pre> <p>It takes as input 3 ArrayLists of bigrams and compares them. If the second word from the first array list matches the word from the second array list then they create a sentence.</p> <p>Example:</p> <pre><code>1st Array List: he ate 2nd Array List: ate two 3rd Array List: two apples </code></pre> <p>creates a sentence he ate two apples. But this function is only limited to 3 ArrayLists. I would like to make it more robust so It would accept a 2d ArrayList of strings where each single ArrayList would be a collection of bigrams and would be checking all the possible matchings from the available bigrams. Can somebody help me with that?</p>
java
[1]
977,926
977,927
Rounding up with pennies in Python?
<p>I am making a change program in python. The user must input a dollar amount and then the program will calculate the change in twenties, tens, fives, ones, quarters, dimes, nickels, and pennies. I was instructed to use the round function for the pennies because If I input an amount of $58.79, the program tells me to give 3 pennies back when it should be 4. Is there a way to round up these pennies?</p> <p>I know the value of a penny is .01, but python reads this as .100000000001 which I believe is the problem. </p> <p>Any help is appreciated, here is the section I need rounded:</p> <pre><code># get the amount to change from the user change = input("Please enter the amount to change: $") print "To make change for $",change,"give the customer back:" # calculate number of twenties twenties = int(change/ 20) print twenties, "twenties" change = change - twenties *20 # calculate tens tens = int(change / 10) print tens, "tens" change = change - tens *10 #calculate fives fives = int(change / 5) print fives, "fives" change = change - fives *5 #calculate ones ones = int(change / 1) print ones, "ones" change = change - ones * 1 #calculate quarters quarters = int(change / .25) print quarters, "quarters" change = change - quarters * .25 #calculate dimes dimes = int(change / .10) print dimes, "dimes" change = change - dimes * .10 #calculate nickels nickels = int(change / .05) print nickels, "nickels" change = change - nickels * .05 #calculate pennies pennies = int(change / .01) print pennies, "pennies" </code></pre>
python
[7]
2,593,295
2,593,296
How to sort array key based on two key values?
<p>Let's say I need to run a for loop through an array where I need to check against to key value. I would like to print the array element that doesn't match BEFORE the element that doesn't match.</p> <p>So using the array from below (extra values added for clarity), I would like it to print as follows. It needs to match the <code>current_tag</code> and <code>last_tag</code> values. If they don't match, that key needs to be printed prior to the others.</p> <p><strong>Desired results</strong></p> <pre><code>TEST2 TEST1 TEST3 TEST4 </code></pre> <p><strong>Array</strong></p> <pre><code>array(2) { [0]=&gt; array(3) { ["name"]=&gt; string(3) "TEST1" ["current_tag"]=&gt; string(13) "20121129_TEST1" ["last_tag"]=&gt; string(13) "20121129_TEST1" } [1]=&gt; array(3) { ["name"]=&gt; string(3) "TEST2" ["current_tag"]=&gt; string(13) "20121205_TEST2" ["last_tag"]=&gt; string(13) "20121129_TEST2" } ... ... ... ... } </code></pre>
php
[2]
3,387,481
3,387,482
How create enum in javascript
<p>I need create named constant.</p> <p>for example:</p> <pre><code>NAME_FIELD: { CAR : "car", COLOR: "color"} </code></pre> <p>using:</p> <pre><code>var temp = NAME_FIELD.CAR // valid var temp2 = NAME_FIELD.CAR2 // throw exception </code></pre> <p>most of all I need to make this enum caused error if the key is not valid</p>
javascript
[3]
1,353,077
1,353,078
Storing and retrieving a long array from NSUserDefaults
<p>How can I store a long array into NSUserDefaults and retrieve it?</p> <p>Here is how my long array looks:</p> <p>long *arr;</p> <p>arr = new long [10];</p> <p>for(int i = 0 ; i&lt;10 ; i++) {</p> <p>arr[i] = i;</p> <p>}</p> <p>Now I want to store this arr into UserDefaults and then retrieve it later</p>
iphone
[8]
3,275,204
3,275,205
In C++, how can I create two interfaces for a class?
<p>For example, when creating a class library, I would like to specify an internal API and a public API for each classes, so I can hide some details from the user. The internal API would be used by other classes in the library, and the public API would be used by the library user.</p> <p>Is it possible?</p>
c++
[6]
3,183,141
3,183,142
Android device specific camera path in android
<p>I created a sample app, in my app i capture a photo and save it in a specific folder. The app runs successfully on the emulator with target 2.3.3, but when installing it on a mobile the image gets stored in the default folder in <code>/mnt/sdcard.DCIN/100ANDRO/sample.jpg</code>. Please tell me how can I overcome this issue.</p>
android
[4]
57,206
57,207
only sound is being generated not video Why?
<pre><code>public void surfaceCreated(SurfaceHolder holder) { try { mp.setDisplay(holder); mp.setDataSource("/sdcard/family.3gp"); Toast.makeText(this, "Surface created", Toast.LENGTH_LONG).show(); mp.prepare(); mp.setLooping(true); mp.start(); } catch (IllegalArgumentException e1) { Toast.makeText(this, "Surface created 1", Toast.LENGTH_LONG).show(); e1.printStackTrace(); </code></pre> <p>Her i'm only getting the sound and i'm unable to get the video .... Please help me out...</p>
android
[4]
5,006,709
5,006,710
Difference between int and numbers.Integral in Python
<p>I'm trying to get a deeper understanding in Python's data model and I don't fully understand the following code:</p> <pre><code>&gt;&gt;&gt; x = 1 &gt;&gt;&gt; isinstance(x,int) True &gt;&gt;&gt; isinstance(x,numbers.Integral) True &gt;&gt;&gt; inspect.getmro(int) (&lt;type 'int'&gt;, &lt;type 'object'&gt;) &gt;&gt;&gt; inspect.getmro(numbers.Integral) (&lt;class 'numbers.Integral'&gt;, &lt;class 'numbers.Rational'&gt;, &lt;class 'numbers.Real'&gt;, &lt;class 'numbers.Complex'&gt;, &lt;class 'numbers.Number'&gt;, &lt;type 'object'&gt;) </code></pre> <p>Based on the above, it seems that <code>int</code> and <code>number.Integral</code> are not in the same hierarchy.</p> <p>From the Python reference (2.6.6) I see</p> <blockquote> <p>numbers.Integral - These represent elements from the mathematical set of integers (positive and negative).</p> </blockquote> <p>What's the difference between <code>int</code> and <code>numbers.Integral</code>? Does it have something to do with the <code>type int</code> vs <code>class numbers.Integral</code> I see in the above output?</p>
python
[7]
5,825,774
5,825,775
Adding a space between two linked labels
<p>This might be the silliest question ever. But how do I get to put a space between the Edit and the Delete labels? </p> <pre><code>echo " &lt;a href=\"update.php?id=" . $id . "\"&gt; Edit &lt;/a&gt;"; echo " &lt;a href=\"confirm.php?id=" . $id . "\"&gt; Delete &lt;/a&gt;"; </code></pre> <p>I tried putting <code>echo " ";</code> in between but doesn't work. The underline is straight from Edit to Delete as if they are the same label!</p>
php
[2]
5,874,083
5,874,084
jQuery : reserve key this, and ambiguous cases
<p>I´m littel confused with <code>this</code> reserve key and cases caused errors. Here a sample code where this causes errors.</p> <pre><code>var sample = { init: function() { this.sampleFunction0(); this.sampleFunction1(); }, sampleFunction0 : function(){ var something0, something1, something2; something0 = this.sampleFunction2(); // works, there is no ambiguity whit 'this' jQuery('#list li').click(function(){ something1 = this.sampleFunction2(); // ambiguity: not works, but sample.sampleFunction2(); works something1 = sample.sampleFunction2(); // it´s works something2 = $(this).text(); // list item val console.log(something0) // something console.log(something1); // something : using sample.sampleFunction2(); console.log(something2); // item val }); }, sampleFunction1 : function(){ return 'someting'; }, sampleFunction2 : function(){ return 'something'; } } jQuery(document).ready(function(){ sample.init(); }); </code></pre> <p>I don´t know if is correct to use <code>sample.sampleFunction2();</code> instead <code>this.sampleFunction2();</code></p>
jquery
[5]
1,643,666
1,643,667
gallery item selector in android
<p>I am suffering from a problem regarding gallery item selector. I don't see any selector property of Gallery widget like GridView and ListView. There should be a property like android:listSelector for Gallery also. Though i have forcefully tried the android:listSelector property in Gallery, but it is not working at all. Can some body help me regarding this... I am attaching an image how i want the item selector should like..<img src="http://i.stack.imgur.com/0TPdD.jpg" alt="enter image description here"></p> <p>Thanks &amp; Regards</p>
android
[4]
1,718,152
1,718,153
Storing GUI text as a ResourceBundle (no localization)?
<p>I would like to extract out the labels, error messages, button text etc from out the java code. There is too much discrepancy right now and changing things is a pain.</p> <p>There are too many of these Strings to be implemented as constants in a java file. Ideally I would like it be something like a properties file.</p> <p>Should I be using the ResourceBundle? This application is strictly English and will be in English for its life.</p>
java
[1]
1,313,317
1,313,318
AttributeError: 'datetime.date' object has no attribute 'date'
<p>I have a script like this:</p> <pre><code>import datetime # variable cal_start_of_week_date has type &lt;type 'datetime.date'&gt; # variable period has type &lt;type 'datetime.timedelta'&gt; cal_prev_monday = (cal_start_of_week_date - period).date() </code></pre> <p>When the above statement is executed, I get the error:</p> <p>AttributeError: 'datetime.date' object has no attribute 'date'</p> <p>How to fix this?</p>
python
[7]
5,228,457
5,228,458
Connection to ODBC in very restricted environment (sort of challenge)
<p>I usually type too much, so <strong>read bold copy if in a hurry</strong>.</p> <p>I'm trying to develop a little app in a very restrictive environment (at work)... I want to read data from a database, but I cant install stuff on my machine (so my usual choice of using python or visual studio is a no-no). Basically I will have to do with whatever I've got at hand...</p> <p><strong>What solution can you come up with to access an odbc connection and read the records of a table in an environment where you can't install any software?</strong> feel free to suggest any language, as long as you don't need to install anything.</p> <p>My best idea so far is trying to use the web-browser (since i only need notepad to code), so... basically using only HTML and javascript to try to access it (although I have no clue how to acomplish that task, as I've never done it before)...</p> <p>I know it is not a good idea, but since I won't post this on internet (I only I would have access to this from my desk, and the DB is on my local network), I don't think security is an issue.</p> <p>Even if I don't get a solution, I would like to hear what would you guys try if the need arose. But any ideas or links pointing me in the right direction would be appreciated.</p> <p>Edit: For clarity's sake, it is a Windows environment.</p>
javascript
[3]
3,021,100
3,021,101
limit Google autocomplete list to "belgium, france, germany, thaliand and south africa
<p>limit Google maps of countries in the autocomplete list to "belgium, france, germany, thaliand and south africa</p>
jquery
[5]
2,693,563
2,693,564
Read from internal storage file (Android)
<p>How to read the particular data from the internal storage file. For eg., I have stored 1. Device 2. Time(epoch format) 3. button text</p> <pre><code> CharSequence cs =((Button) v).getText(); t = System.currentTimeMillis()/1000; s = cs.toString(); buf = (t+"\n").getBytes(); buf1 = (s+"\n").getBytes(); try { FileOutputStream fos = openFileOutput(Filename, Context.MODE_APPEND); fos.write("DVD".getBytes()); fos.write(tab.getBytes()); fos.write(buf); fos.write(tab.getBytes()); fos.write(buf1); //fos.write(tab.getBytes()); //fos.write((R.id.bSix+"\n").getBytes()); fos.write(newline.getBytes()); //fos.flush(); fos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>then while reading, how can we read only price from the file? (using fos.read()) </p> <p>Thanks</p>
android
[4]
1,454,619
1,454,620
select 1 random keyword per line in txt
<pre><code>$kw=explode("\n",file_get_contents("keyword.txt")); shuffle($kw); </code></pre> <p>keyword.txt is just keyword in line, example :</p> <pre><code>keyword1 keyword2 keyword3 keyword4 keyword5 keyword6 keyword7 keyword8 keyword9 </code></pre>
php
[2]
379,293
379,294
How to remember to use return value?
<p>Sometimes I forget to use the return value when I <strong>have</strong> to. For example</p> <pre><code>var s = "foobar"; s.Replace("foo", "notfoo"); // correct: s = s.Replace("foo", "notfoo"); </code></pre> <p>This also applies to my custom value-like classes, for example, where I use fluent x.WithSomething() methods that return new value object instead of modifying x.</p> <p>One solution would be to use unit tests. However, this is not always applicable. So, how do I force a compiler - or, at least, runtime - error when returned value is not used?</p> <p>Maybe, there's a ReSharper or VS solution?</p> <p>UPDATE: OK it is not enforced by language. So null arguments are, but still I can throw exception if argument is null. And ReSharper can warn me about many things that are not enforced by C#. But I see no way to do the same for not-used return value - for those return values that I want to be used.</p> <p>If not for system functions (like string.Replace), but at least for my own classes - is there any way? Like, returning RequiredReturn&lt;T&gt; or something like this.</p> <p>UPDATE: what about AOP / PostSharp? If I mark return value or method with [UsageRequired], can I detect somehow using PostSharp that return value was used?</p> <p>(note the C# tag)</p>
c#
[0]
4,609,109
4,609,110
Invoke a non static method from a static method
<p>Can anyone please explain me why it is illegal for static method to invoke a non static method?</p>
java
[1]
348,398
348,399
It is an error to use a se`enter code here`ction registered as allowDefinition='MachineToApplication' beyond application level.
<p>When i m trying to run my asp site it comes this error:</p> <p>Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.</p> <p>Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.</p> <p>How can i fix this error?</p>
asp.net
[9]
5,888,715
5,888,716
Shuffle Class Instances
<p>My program is a quiz which asks questions for US States I create three instances of a class say State</p> <pre><code>State st1 = new State(); State st2 = new State(); State st3 = new State(); </code></pre> <p>like it asks a question about a state what is capital of st1.name and line below that it gives 3 option </p> <pre><code>String Builder sb; sb.append("What is Capital of "+st1.name+"\n"); sb.append("\n"+st1.capital); sb.append("\n"+st2.capital); sb.append("\n"+st3.capital); mainText.setText(sb.toString); </code></pre> <p>now the problem is every time it comes up with correct answer in first line... how do i avoid that ?</p>
android
[4]
3,736,721
3,736,722
jquery inserts in div
<p>i am having problem with jquery inserts i am using bbedit to inserts images links bold italic etc in my message box and jquery inserts the required html in the corresponding form but its not doing correctly. in below code </p> <p>in the below code .bbedit-toolbar and .bbedit-smileybar is getting inserted by jquery automatically but in my code its not getting inserted .here is the link for the complete bbcode example <a href="http://www.w3theme.com/jquery-bbedit/" rel="nofollow">http://www.w3theme.com/jquery-bbedit/</a></p> <p>any help will be highly appreciated.</p> <pre><code>$("#form_message").bind("change keyup", function() { $("#form_submit").removeAttr("disabled"); $("#form_submit").addClass("att_submit_active"); }); $("#form_message").keyup(function() { if ($("#attachment").val() == "status") { var max = parseInt($("#form_message").attr("maxlength")); if ($(this).val().length &gt; max) { $(this).val($(this).val().substr(0, $(this).attr("maxlength"))); } $("#charsRemaining").html("You have &lt;strong&gt;" + (max - $(this).val().length) + "&lt;/strong&gt; characters remaining"); } }) </code></pre>
jquery
[5]
1,022,431
1,022,432
how to get ontouch event in bitmap inside canvas?
<p>i have a bitmap inside a canvas.the class implements ontouchlistener.i need to hide the image while touch on the image.</p> <pre><code>class Panel extends View implements View.OnTouchListener { Paint linepaint=new Paint(); public Panel(Context context) { super(context); } @Override public void onDraw(Canvas canvas) { Bitmap imgtable = BitmapFactory.decodeResource(getResources(), R.drawable.table_01); canvas.drawBitmap(imgtable, centrex, centrey, null); public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub return false; } } </code></pre>
android
[4]
2,148,842
2,148,843
Javascript Weird construction in simple object?
<p><a href="http://jsbin.com/ufihev/3/edit" rel="nofollow">http://jsbin.com/ufihev/3/edit</a></p> <p>Pretty simple code : </p> <pre><code>var t = new function () //line 1 { this.a1 = function () { return function () { alert("1"); }; }(); this.a2 = function () { alert("a2"); }; }; //line 16 t.a1(); </code></pre> <p>But <strong>jsBin red line bellow</strong> tells me : </p> <blockquote> <p>Line 1: var t = new function () --- Weird construction. Delete 'new'.</p> <p>Line 16: }; --- Missing '()' invoking a constructor.</p> </blockquote> <p>the code is working fine.</p> <p>What am I doing wrong ?</p>
javascript
[3]
2,795,401
2,795,402
Dynamically Selecting by ID
<p>I have the ID of a selected textarea stored in a variable. Is it possible to use that variable to select the element by ID later on in the code? For example:</p> <pre><code>var currentTextarea = null; function foo() { currentTextarea = 'pageid'; // This will be set dynamically via an event. Example only. } function bar() { $('#' + currentTextarea).val(); // Although this don't seem to work } </code></pre>
jquery
[5]
5,882,615
5,882,616
Upload of MediaFiles is always returning NullPointException
<p>I am encountering this weird error when uploading voice recordings from the Android device to an backend.</p> <p>I am getting the following error and nothing is uploaded:</p> <p>java.lang.NullPointerException at java.io.File.fixSlashes (File.java.=:205)</p> <p>The file name consists of the data timestamp, I have tried without data timestamp and still have the same error.</p> <p>The weird part is that, I have tested with textfiles and it gets uploaded without any issue nor exception.</p> <p>Anyone knows what's the issue?</p> <p>Thanks In Advance</p>
android
[4]
3,282,016
3,282,017
Some trouble with jQuery
<p>Is this html </p> <pre><code> &lt;div class='title centered'&gt;SCE&lt;/div&gt; &lt;div class='description'&gt; Magna tristique pulvinar porta montes, scelerisque odio montes porta habitasse, ut, arcu scelerisque vel, pellentesque &lt;/div&gt; </code></pre> <p>I need to fade childer div (description) after clicking on parent (title).</p> <pre><code> $('.title').click(function() { $(this).find('.description').fadeOut(fadeTime); }) </code></pre> <p>What is wrong?</p>
jquery
[5]
2,846,294
2,846,295
Why does double dispatch not work in C++?
<pre><code>#include&lt;iostream.h&gt; #include&lt;conio.h&gt; using namespace std; class SpaceShip {}; class GiantSpaceShip : public SpaceShip {}; class Asteroid { public: virtual void CollideWith(SpaceShip *) { cout &lt;&lt; "Asteroid hit a SpaceShip" &lt;&lt; endl; } virtual void CollideWith(GiantSpaceShip *) { cout &lt;&lt; "Asteroid hit a GiantSpaceShip" &lt;&lt; endl; } }; class ExplodingAsteroid : public Asteroid { public: virtual void CollideWith(SpaceShip *) { cout &lt;&lt; "ExplodingAsteroid hit a SpaceShip" &lt;&lt; endl; } virtual void CollideWith(GiantSpaceShip *) { cout &lt;&lt; "ExplodingAsteroid hit a GiantSpaceShip" &lt;&lt; endl; } }; int main() { SpaceShip * s = new GiantSpaceShip(); Asteroid * a = new ExplodingAsteroid(); a-&gt;CollideWith(s); getch(); return 0; } </code></pre> <p>How can I enable double dispatch in C++?</p>
c++
[6]
388,846
388,847
adding all person in form of array in ABRecordRef
<p>how can i add the people from the contacts to 'people'- array then to abrecordref.??? Actually i want all the contacts in tableview and can able to edit individual record. here is my code:</p> <pre><code>-(void)showPersonViewController { // Fetch the address book ABAddressBookRef addressBook = ABAddressBookCreate(); // Search for the person named "rubal" in the address book NSArray *people = (NSArray *)ABAddressBookCopyPeopleWithName(addressBook, CFSTR("naina")); // Display "KETAN" information if found in the address book if ((people != nil) &amp;&amp; [people count]) { ABRecordRef person = (ABRecordRef)[people objectAtIndex:0]; ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease]; picker.personViewDelegate = self; picker.displayedPerson = person; // Allow users to edit the person’s information picker.allowsEditing = YES; [self.navigationController pushViewController:picker animated:YES]; } else { // Show an alert if "KETAN" is not in Contacts UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Could not find naina in the Contacts application" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; [alert show]; [alert release]; } [people release]; CFRelease(addressBook); } </code></pre> <p>instead of only 'naina' i want all record in table view and edit individually</p>
iphone
[8]
3,580,507
3,580,508
Spin image onclick Javascript
<p>Like the title says, I am trying to rotate an image once a user clicks a button. I am new to javasript so I am still trying to figure out how things work. I have found a good example but the two images they have are always spinning. I want my image to just spin once for 45 degrees.</p> <p>I want the image to spin like the ones here: <a href="http://jsfiddle.net/Pvtzv/276/" rel="nofollow">http://jsfiddle.net/Pvtzv/276/</a> but not everytime just once</p> <p>Here is what I have so far:</p> <pre><code> function doSpin() { wheel = new Image(); //wheel.onload = initialDraw; // Once the image is loaded from file this function is called to draw the image in its starting position. wheel.src = "./female_avatar.gif"; var surfaceContext = surface.getContext('2d'); surfaceContext.drawImage(wheel, 0, 0); p += .02; var r = 100; var xcenter = 150; var ycenter = 150; var newLeft = Math.floor(xcenter + (r* Math.cos(p))); var newTop = Math.floor(ycenter + (r * Math.sin(p))); var newLeft1 = Math.floor(xcenter + -(r* Math.cos(p))); var newTop1 = Math.floor(ycenter + -(r * Math.sin(p))); wheel.animate({ top: newTop, left: newLeft, }, 2, function() { doSpin() }); } </code></pre> <p>In my html</p> <pre><code> &lt;button onclick="doSpin()"&gt;spin image&lt;/button&gt; </code></pre>
javascript
[3]
5,249,013
5,249,014
Getting selected value from second dropdownlist depending on first dropdown in grid view
<p>what i m trying is i have two dropdownlists inside the gridview... namely say '<strong>Client</strong>' and '<strong>User</strong>' i have 10 values in drop down list '<strong>Client</strong>' ... now what i want is if the selected value of '<strong>Client</strong>' is "onsite" the value in drop down list '<strong>User</strong>' should get pre-populated.This should be done in post back event when page is loading .i have tables for both dropdown lists in sql server and depending on dropdown value '<strong>Client</strong>' the value of dropdown list '<strong>User</strong>' comes in dropdown. please help me out with some code Thanks a lot in advance.</p>
asp.net
[9]
3,344,361
3,344,362
How can I split text on commas not within double quotes, while keeping the quotes?
<p>So I'm trying to split a string in javacript, something that looks like this:</p> <pre><code>"foo","super,foo" </code></pre> <p>Now, if I use <code>.split(",")</code> it will turn the string into an array containing <code>[0]"foo" [1]"super [2]foo"</code> however, I only want to split a comma that is between quotes, and if I use <code>.split('","')</code>, it will turn into <code>[0]"foo [1]super,foo"</code></p> <p>Is there a way I can split an element expressing delimiters, but have it keep certain delimiters WITHOUT having to write code to concatenate a value back onto the string? </p> <p>EDIT:</p> <p>I'm looking to get <code>[0]"foo",[1]"super,foo"</code> as my result. Essentially, the way I need to edit certain data, I need what is in [0] to never get changed, but the contents of [1] will get changed depending on what it contains. It will get concatenated back to look like <code>"foo", "I WAS CHANGED"</code> or it will indeed stay the same if the contents of [1] where not something that required a change</p>
javascript
[3]
5,842,944
5,842,945
Need help deciphering PHP error message
<p>How to overcome from below error:</p> <pre><code>Notice: Use of undefined constant temp_members_db - assumed 'temp_members_db' in /var/www/signup_ac.php on line 10 Cannot send Confirmation link to your e-mail address </code></pre> <p>Below is the Code:</p> <pre><code>&lt;?php ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); include('config.php'); // table name $tbl_name=temp_members_db; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $email=$_POST['email']; $country=$_POST['country']; // Insert data into database $sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')"; $result=mysql_query($sql); // if suceesfully inserted data into database, send confirmation link to email if($result){ // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email; // Your subject $subject="Your confirmation link here"; // From $header="from: your name &lt;your email&gt;"; // Your message $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; //$message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code"; $message.="http://localhost/confirmation.php?passkey=$confirm_code"; // send email $sentmail = mail($to,$subject,$message,$header); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } ?&gt; </code></pre>
php
[2]
5,426,399
5,426,400
How to format numbers using javascript?
<p>I want to format numbers using javascript.</p> <p>For example:</p> <pre><code>10 =&gt; 10.00 100 =&gt; 100.00 1000 =&gt; 1,000.00 10000 =&gt; 10,000.00 100000 =&gt; 1,00,000.00 </code></pre>
javascript
[3]
1,954,901
1,954,902
Execute script only for newly added HTML
<p>i am creating this mini-module framework and what i'm trying to do is to reuse a module definition on a dynamically loaded HTML. it's like using the same weather widget script to power two or more weather widgets on screen, one loaded on page load, and the others loaded later. defining the module uses this format.</p> <pre><code>framework.module.create('module_name',function(){ //execute when starting the module this.init = function(){ //for example, bind a click handler $('button').on('click',function(){ alert('foo'); }); } }); </code></pre> <p>the module name and constructor is stored in an array and during page load, executed like</p> <pre><code>//store function create(name,fn){ modules[name] = fn; } //execute function start(){ //for each module definition stored var module = new modules[name](); module.init(); } </code></pre> <p>now event handlers are bound to the elements. this works when the module html is already on the page. however, if i try loading another copy of that module's HTML which doesn't have handlers yet, calling <code>start()</code> binds it the handlers, but now doubles the handler for the existing/already initialized HTML. clicking the button on the preloaded HTML now fires click events twice.</p> <p>i can't do this magic on the module definition. i need to preserve the "constructor/callback function" format. also, i don't want users to do workarounds for this. this has to be done under the framework code.</p> <p>how do i execute the module script only for the newly added, exactly identical HTML?</p> <p>or</p> <p>how do i prevent the script from affecting the already initialized HTML?</p>
javascript
[3]
4,075,157
4,075,158
References to incomplete types
<p>According to the C++03 standard, is it valid to have references to incomplete types? I'm not aware of any implementation that implements references as any other than non-null pointers, so such code ought to work. However, I wonder whether it's standard conforming.</p> <p>I would appreciate answers with quotes and references to the C++ standard.</p>
c++
[6]
3,446,196
3,446,197
cin.get() not working?
<p>I'm using C++ for the first time from php. I was playing around with some code. To my understanding cin.get() was suppose to stop the page from closing until I press a key, however it doesn't seem to be working because of the code before it, I don't know what the problem is. Here is my code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;cstdlib&gt; using namespace std; int multiply (int x, int y); int main () { int x; int y; cout &lt;&lt; "Please enter two integers: "; cin &gt;&gt; x &gt;&gt; y; int total = multiply(x, y); cout &lt;&lt; total; cin.get(); } int multiply (int x, int y) { return x*y; } </code></pre>
c++
[6]
5,364,864
5,364,865
How To Code a Basic Questionnaire
<p>I am new to Android and have the SDK up and running fine. I am looking for some model code to make an app with a 15-item questionnaire (yes/no) and score it. </p> <p>Suggestions?</p> <p>Thanks</p>
android
[4]
3,077,951
3,077,952
multiple file upload using jquery uploadify
<p>I have a form which used file upload. once I Pressed the uploadify button it goes to database and displayed the name it in the form. My question is that dont store it into the database until submit the form..can anyone help me to upload the file by onclick using jquey uploadify settings.</p>
php
[2]
1,109,604
1,109,605
Except statement
<p>In a function <code>check_price()</code> I try to open a .txt file, that does not exist, to read and I wanted to use except statement to catch the IOerror.</p> <p>But after, I created a .txt file and I want to use the same function to read it. However my function doesn't read the file. Can anyone help me?</p> <p>I'm suppose to make a price checker program.</p> <p>The sample looks like this.</p> <pre><code>Menu: (I)nstructions (L)oad Products (S)ave Products (A)dd Product (C)heck Prices (Q)uit &gt;&gt;&gt; C No products. Menu: (I)nstructions (L)oad Products (S)ave Products (A)dd Product (C)heck Prices (Q)uit &gt;&gt;&gt; L Enter file name: products.txt Menu: (I)nstructions (L)oad Products (S)ave Products (A)dd Product (C)heck Prices (Q)uit &gt;&gt;&gt; c Huggies is $0.39 per unit. Snugglers is $0.26 per unit. Baby Love is $0.23 per unit. </code></pre> <p>My function:</p> <pre><code>def check_price(): while True: try: text_file = open("product.txt",'r') break except IOError: print"no product" text_file = open("product.txt",'r') line = text_file.readline() if line == "": break print "" </code></pre>
python
[7]
49,707
49,708
user input determines count of displays
<p>I have been trying for days to get this to work. I have the basic code but every time I try to get the last requirement added, I break the code. I'm sure I am missing a lot and that's why I can't add the alert box with the count of displays. So it asks the users name, the number of times they want to see and alert box and if they enter invalid answers they see alert boxes telling them to enter a correct value. The last part that I am stuck on is the value the user enters determines how many alert boxes show their name and the box needs to say which box it is. So, <code>&lt;Name&gt;</code> this is time number <code>&lt;count of displays&gt;</code> of <code>&lt;total time to display&gt;</code>. I was trying different things with limiting and FOR , with the user Y variable being the limiter. Any clues or help would be greatly appreciated.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;p&gt;Please enter your name followed by how many times you would like to be alerted.&lt;/p&gt; &lt;button onclick="myFunction()"&gt;Start&lt;/button&gt; &lt;script&gt; function myFunction() { var x; var name = prompt("Please enter your name", ""); if (name == null || name == "") { alert("Please input a name."); return false; } else { var y; var y = prompt("Please enter a number between 1-10"); if (y == null || y == "") { alert("Please input a number for the times to alert the name."); return false; } if (y &gt; 10) { alert("Please input a number between 1 and 10.") var y = prompt("Please enter a number between 1-10"); } if (y &lt;= 0) { alert("Please input a number great than zero.") var y = prompt("Please enter a number between 1-10"); } } } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
1,307,946
1,307,947
check for online update when open program in C#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/555118/suggest-a-method-for-auto-updating-my-c-sharp-program">Suggest a method for auto-updating my C# program</a> </p> </blockquote> <p>I'm sorry if this question has been asked already. i have a problem whit online update because i don't know how can add code for check for update program and after check if find newer version upgrade itself.</p> <p>However, every time I make changes to the program people will have to download the new version.</p> <p>i have a host and no any problem whit host. well only i need add code for check for online update</p> <p>how can add code for check for update when open program ? what can i do ? what do i do ? can u please help me ?</p> <p>please <strong>give me sample code or sample project</strong> for understand. thanks.</p>
c#
[0]
5,212,680
5,212,681
jQuery Show One Div and Hide the Others
<p><a href="http://jsfiddle.net/yrM3H/2/" rel="nofollow">http://jsfiddle.net/yrM3H/2/</a></p> <p>I have the following code:</p> <pre><code>jQuery(document).ready(function() { jQuery(".toggle").next(".hidden").hide(); jQuery(".toggle").click(function() { $('.active').toggleClass('active').next('.hidden').slideToggle(300); $(this).toggleClass('active').next().slideToggle("fast"); }); }); </code></pre> <p>I have multiple <code>&lt;div&gt;</code>'s, and my idea is that when I open a <code>&lt;div&gt;</code> it toggles another <code>&lt;div&gt;</code>. And then, when I click another <code>&lt;div&gt;</code>, it hides the open <code>&lt;div&gt;</code>. Therefore only one <code>&lt;div&gt;</code> is open at a time.</p> <p>My only issue is that with this code, when I try to close a <code>&lt;div&gt;</code> that is already open, it will close and then open again. Thus one <code>&lt;div&gt;</code> will always be open.</p> <p>Any help will be appreciated, thank you.</p> <p>I added the HTML and CSS below. Everything works fine, except that I cannot get it so that all of them are closed.</p> <p>I have 5 of these stacked on each other in a wrapper.</p> <p>*edited for clarity *</p> <pre><code>// HTML &lt;div class="toggle"&gt;&lt;/div&gt; &lt;div class="hidden"&gt;&lt;/div&gt; // CSS .toggle {width:398px; height:48px; cursor: pointer;} .hidden {width:300px; height:75px; background-color:#333333; margin-left:50px; text-indent:25px;} </code></pre>
jquery
[5]
603,484
603,485
Difference Between Cast, Convert and AS operator?
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/3168704/when-to-use-a-cast-or-convert">When to use a Cast or Convert</a><br> <a href="http://stackoverflow.com/questions/702234/what-is-the-difference-between-the-following-casts-in-c">What is the difference between the following casts in c#?</a> </p> </blockquote> <p>How do they differ in different synarios and which one to use for Value types and reference types?</p>
c#
[0]
133,591
133,592
Can I create a server php variable?
<p>I want to have my own variable that would be (most likely an array) storing what my php application is up to right now.</p> <p>The application can trigger few processes that are in background (like downloading files) and I want to have a list what is being currently processed. </p> <p>For example </p> <ul> <li>if php calls exec() that will be downloading for 15mins </li> <li>and then another download starts</li> <li>and another download starts </li> </ul> <p>then if I access my application I want to be able to see that <code>3 downloads</code> are in process. If none of them finished yet.</p> <p>Can do that? Only in memory, not storing anything on the disk?</p> <p>I thought that the solution would be a some kind of server variable.</p>
php
[2]
2,794,133
2,794,134
Writing a latlng to a file on the computer
<p>I made a function that can take a an address from url and return its latlng and show a marker on the address. Is there a javascript function that can write the latlng to clipboard. Thanks.</p>
javascript
[3]
1,891,358
1,891,359
Animated background using jQuery
<p>Is it possible to have a set of small images of various sizes falling continuously (like gentle snowfall) in the body or a background wrapper element using jQuery. I've looked online and found the falling leaves jQuery but it didn't look that smooth. </p>
jquery
[5]
4,536,932
4,536,933
Java voice processing
<p>I now have a demand that is, for a given speech file, like TOEFL listening or celebrities speech English, is it possible to realize the automatic conversion, text, and automatic segmentation, intercept point in time? Is there any readily available API calls?</p>
java
[1]
4,734,799
4,734,800
MVC Framework that is similar to ASP.NET MVC but for Winform
<p>I know there are MVC for Winform (MVC# etc.) but if have to develop on ASP.NET MVC and then on Desktop I don't want to have 2 different frameworks so is there anything close to ASP.NET MVC but for Winform ?</p> <p>What I mean is that the specific part of ASP.NET which is url routing for example should be replaced by something on winform so that one can readily switch from one platform to the other.</p> <p>This seems rather common sense needs to me so why doesn't this seem to exist or taken into account at Microsoft ? </p> <p>All focus seems to be on web development nowadays which I regret because there are many desktop apps in enterprise that have the same level of complexity as web app and would benefit from not reinventing the wheel and use a widely spread MVC framework.</p>
c#
[0]
2,093,022
2,093,023
Limiting a web page to a single mac address
<p>Does any body know php code to limit the webpage you design to open on a particular pc or mac address?</p>
php
[2]
1,195,973
1,195,974
Help me out with my sloppy HTML/PHP
<p>This might sound like a silly question but how would I make this code seem...neater?</p> <pre><code> echo "&lt;h3&gt;&lt;font face='helvetica'&gt;&lt;font size='4'&gt;&lt;b&gt;&lt;font color='B80000'&gt;$title&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/b&gt; &lt;font color='A0A0A0'&gt;$category &amp;nbsp;&lt;/font&gt;&lt;font color='A0A0A0'&gt;&lt;a href='profile.php?id=$userid'&gt;$user&lt;/a&gt;&lt;/font&gt; &lt;font face='helvetica'&gt;&lt;font size='3'&gt;&lt;br&gt;&amp;nbsp;$desc&lt;/font&gt;&lt;/font&gt;&lt;br&gt; &lt;h3&gt;&lt;font color='101010'&gt; &amp;nbsp;$city,$state&amp;nbsp;$zip&amp;nbsp;&lt;font color='A0A0A0'&gt;$date&lt;/font&gt; &lt;/font&gt;&lt;/h3&gt;"; ?&gt; </code></pre> <p>There's nothing wrong with the code but it looks so sloppy - I was wondering if someone could help me out with making it look neat and tidy</p>
php
[2]
3,767,160
3,767,161
Simple MultiThread Safe Log Class
<p>What is the best approach to creating a simple multithread safe logging class? Is something like this sufficient? How would I purge the log when it's initially created?</p> <pre><code>public class Logging { public Logging() { } public void WriteToLog(string message) { object locker = new object(); lock(locker) { StreamWriter SW; SW=File.AppendText("Data\\Log.txt"); SW.WriteLine(message); SW.Close(); } } } public partial class MainWindow : Window { public static MainWindow Instance { get; private set; } public Logging Log { get; set; } public MainWindow() { Instance = this; Log = new Logging(); } } </code></pre>
c#
[0]
3,032,023
3,032,024
"this" inside of a nested prototype not pointing to instance
<p>Given:</p> <pre><code>var x = function () { }; x.prototype = { y: { z: function () { console.log(this); } } }; var foo = new x(); foo.y.z(); </code></pre> <p>Why is <code>this</code> logged in the <code>console</code> as <code>y</code> instead of <code>x</code> and how is that possible given <code>y</code> is a literal object without a constructor?</p>
javascript
[3]
3,908,239
3,908,240
Memory free up string builder an d byte[] in c#: Out of memory exception
<p>I am working on c#. I want know how i can free the stringbuilder n byte[]....Because I am getting an out of memory exception while using string builder.... Another thing is String.Replace() is also giving an out of memory exception or else is there any other way to do the same....please tell me how I can overcome these problems... thanks in advance</p>
c#
[0]
436,707
436,708
Using && for conditionals in Javascript
<p>I have this:</p> <pre><code>var field = query("form#"+form.id+" input[name='" + error.field + "']"); if(field.length){ if( field[0].id ) { widget = registry.byId( field[0].id ); if(widget){ ... } } </code></pre> <p>I would have thought I could write:</p> <pre><code>var field = query("form#"+form.id+" input[name='" + error.field + "']"); if(field.length &amp;&amp; field[0].id &amp;&amp; widget = registry.byId( field[0].id) ){ ... } </code></pre> <p>But if I use the second, "shortened" form, I get a Javascript error. </p> <p>Sorry, it would be messy to give a JSFiddle. The problem happens when query() returns 0 values -- <code>field[0].id</code> &amp;&amp; <code>widget = registry.byId( field[0].id)</code> were still interpreted.</p> <p>I thought that I was playing it safe as the second <code>field[0].id</code> would only happen if <code>field.length</code> was <code>&gt; 0</code> and then <code>widget = registry.byId( field[0].id)</code> would only happen if <code>field[0].id</code> is true...</p> <p>What am I missing?</p> <p>Merc.</p>
javascript
[3]
59,713
59,714
PHP : Can I compile/build my site like .NET?
<p>I am new to PHP, and working on a class based web site. So my question is simple. Can I compile the site like I can in .NET?</p> <p>This would be helpful to me because I changed my IsAAction interface to accept an error callback function as a parameter of the Execute function, and I would like all of my implementations to break so I can easily see where to change them.</p> <p>Thanks in advance.</p>
php
[2]
4,182,881
4,182,882
How does PHP work - literature
<p>I'm interested in literature (articles on internet, in magazines, books, podcasts - I don't really mind anything) that describes how PHP works internally, about its gotchas and perhaps some advanced functions. Is there anything like this out there? I tried to search on Google, but majority of articles were about starting with PHP and its basic functions.</p> <p>Any input is really welcome as I'm trying to understand the language internally - I'm tired of my mindless typing of code without understanding its essence.</p>
php
[2]
3,515,254
3,515,255
How to change progress bar fore color?
<p>I want to change progress bar default(yellow) color to green color.Please help me</p> <p>Regards Mona</p>
android
[4]
2,029,122
2,029,123
How to get contacts from only Phone device?
<p>This code get contacts both Phone device and Sim Card. Now, How to get contacts only from phone <strong>without Sim card</strong>?</p> <pre><code>String selector = Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"; mCursor = managedQuery(ContactsContract.Data.CONTENT_URI, null, selector, null, ContactsContract.Data.DISPLAY_NAME + " ASC"); </code></pre>
android
[4]
4,981,845
4,981,846
What does `array(&$this)` mean?
<p>Please, I would like to know what <code>array(&amp;$this)</code> means.</p>
php
[2]
3,888,237
3,888,238
Create Android App That Acts As A Shortcut To Our Mobile Site
<p>We have a special mobile version of our site that we would like to promote in the android marketplace. The "app" would effectively be a shortcut to the website, but you would be able to download it and have an icon for it, just like any other app.</p> <p>Is this possible? If so, can you link me to instructions? I was not able to find any info searching google.</p> <p>Thanks, Jonah</p>
android
[4]
5,724,360
5,724,361
PHP arrays & keys - fetching particular ones
<p>Lets say I have an array with a structure like this:</p> <pre><code>$arr= Array( array( "id"=&gt;"a" "type"&gt;"apple"), array( "id"=&gt;"b"), array( "id"=&gt;"c"), array( "id"=&gt;"c" "type"=&gt;"banana") ); </code></pre> <p>now I want to have a foreach loop which fetches all the array elements which have a key in them named "type".</p> <p>Something like</p> <pre><code>foreach(all arrays which have type in them as $item) </code></pre> <p>How would I do that?</p> <p>many thanks.</p>
php
[2]
964,427
964,428
javascript function not working correctly
<p>I have the following simple javascript function to slide an object up and down.</p> <p>When I first click it should slide down which it should do and alerts with true which it should do. However on the second click I want it to slideup however it detects firstclick to be true again. Any ideas</p> <pre><code>&lt;script type="text/javascript"&gt; var firstclick = true; function slidedown(){ if (firstclick = true){ $( '#rerooftext' ).slideDown(500); alert(firstclick); firstclick = false; } else { $('#rerooftext').slideUp(500); $firstclick = true; } } &lt;/script&gt; </code></pre>
javascript
[3]
4,495,589
4,495,590
A class design of animal food choice question
<pre><code>class Animal { }; class Herbivore:Animal { void eat(); }; class Carnivore:Animal { void eat(); }; class Food { bool bMeat; bool bVegeable; }; </code></pre> <p>I start out this class and all of a sudden I don't know what to do to with the class Food, as I would like to print out the correct food type each "kind" of animal favors most.</p> <p>Sorry my food class size is small but I can't delete it as my whole program requires it to distinguish the food type. I will not mind if you suggest a different solution.</p>
c++
[6]
5,961,045
5,961,046
jQuery Mobile Page Load Issue
<p>I'm building a mobile web app using jQuery Mobile. I'm facing some very strange issues.</p> <p>Pages are connected with the standard tag. Whenever I click on a link, the location in address bar changes and I do get redirected to the new page but in order for the page to render something I need to explicitly refresh it using Cntrl+F5 or click on the refresh browser button. I have tried with FF11 and Chrome. Is this a known issue?</p> <p>Thanks</p>
jquery
[5]
3,065,766
3,065,767
history.go(-1) going back doesnt work in Chrome
<p><code>href="#" onclick="closeOrCancel()</code> and <code>history.go(-1)</code> in that js method doesnt work in Chrome (neither <code>history.back()</code>)</p> <p>It works with <code>href="javascript:closeOrCancel()"</code> , but Opera doesn't allow <code>href="javascript:...</code></p> <p>How to make history go back using onclick= "myFunction()" ?</p> <p>Edit: <code>closeOrCancel()</code> returns false</p>
javascript
[3]
3,468,391
3,468,392
Click on Text and Checkbox separately in CheckBoxPreference
<p>I am creating a PreferenceActivity by using the PreferenceScreen xml. I wants to open a new preference screen when click on the label(title) of a CheckBoxPreference and when the user click on check box of this CheckBoxPreference then normal preference functionality will work. So how can I do it?</p> <p><strong>For Example:</strong> Change a user profile(by click on radio buttons) and changing its properties(by clicking on label of this radio button) in android</p>
android
[4]
4,802,448
4,802,449
Animation with pure javascript, no jquery
<p>I was using jquery/jquery-ui's <code>slideDown()</code> animation function for a particular task. It now transpires that I will not be able to use jQuery in this project. I also cant use YUI or any other libraries. So I wondering is there a way to perform a slideDown style animation using pure javascript?</p> <p><strong>Edit:</strong> I have to do it without jQuery because I am using selenium to control a webpage and on this particular site adding jQuery to the page breaks event handlers for some reason.</p>
javascript
[3]
5,733,635
5,733,636
Java String.indexOf API
<p>I have following situation,</p> <pre><code>String a="&lt;em&gt;crawler&lt;/em&gt; &lt;em&gt; Yeahhhhh &lt;/em&gt;&lt;/a&gt;&lt;/h3&gt;&lt;table"; System.out.println(a.indexOf("&lt;/em&gt;")); </code></pre> <p>It returns the 11 as the result which was the first that it founds.</p> <p>Is there any way to detect the last instead of the first one for the code written above?</p>
java
[1]
4,660,309
4,660,310
Running 2 instances of the Camera at the same time
<p>was wondering if it is possible to have 2 instances of the camera preview in android. what i mean is running 2 instances of the camera at the same time. if it is, How would one go about this, will there be need to implement an instance on a different thread? I have not used the camera api before, so i would appreciate it if i can have a heads up on the issue, so i don't waste time on it. Thank you.</p> <p>by the way, Happy New Year everyone!</p>
android
[4]
4,550,974
4,550,975
Change color in part of my message
<p>I need to change my text color for specific word in my text. I have used to generate my text as below.</p> <pre><code>String message=string.empty; String message1=”something”; String message2=”something”; message += “My Message is”+ message1+ “and” + message2; </code></pre> <p>and I send this message as a email body. So I need to change text color only part of this message. Lets say I want to message2 as red color. How can I do this? Thanx.</p>
c#
[0]
2,040,585
2,040,586
<identifier> expected. java
<p>I have this snippet of java code. I am a noob in java.. </p> <p>Error :</p> <pre><code>&lt;identifier&gt; expected cfg = new Config; </code></pre> <p>Code:</p> <pre><code>import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import java.io.*; import java.util.*; import java.util.Properties; public class Config { Properties configFile; public Config() { configFile = new java.util.Properties(); try { configFile.load(this.getClass().getClassLoader().getResourceAsStream("config")); }catch(Exception eta){ eta.printStackTrace(); } } public String getProperty(String key) { String value = this.configFile.getProperty(key); return value; } } public class ClosureBuilder { </code></pre> <p><code>cfg = new Config();</code></p> <pre><code>private static String JDBC = cfg.getProperty("JDBC"); private static String URL = cfg.getProperty("URL"); private static String DIMENSION_TABLE = cfg.getProperty("DIMENSION_TABLE"); private static String CLOSURE_TABLE = cfg.getProperty("CLOSURE_TABLE"); private static String KEY = cfg.getProperty("KEY"); private static String PARENT_KEY = cfg.getProperty("PARENT_KEY"); private static Object TOP_LEVEL_PARENT_KEY = '0'; private Object topLevel = null; private Set&lt;Object&gt; processedNodes; private PreparedStatement aPst; public static void main(String[] args) throws Exception { ----------- More code -------- </code></pre>
java
[1]
5,322,352
5,322,353
How to find out if a letter's unicode number is odd or even without checking for said unicode number in java?
<p>For example the unicode number for 'A' is 65, and the one for 'B' is 98. </p> <p>Thus a, c, e, g, etc have odd unicode numbers and b, d, f, h, etc have even unicode numbers. </p> <p>How would I go about checking whether a char is odd or even?</p> <p>Keep in mind I'm not an advanced programmer. </p>
java
[1]
95,624
95,625
How to get a reference of the content window of the parent window from an iframe, when the parent is cross domain
<p>I need to so that the iframe can send a postMessage to it.</p>
javascript
[3]
4,517,442
4,517,443
php script that populates photos to a html div
<p>I currently have a picture page with about 250 jpeg. Images and I currently have a web page where I manually assigned a picture to a section on the page, however this is very time consuming and would like to create a script that will run through and assign the images to a div. While this normally would be easy my problem is the way they filed the images. On the web page I have a quad drawling, and each portion of the quad needs a image assigned to it. the image file names vary and is causing my headache:</p> <p>The file format Ex is below. so each quad would have 4 images, the first set of numbers before the underscore is the pict id and the number in between the underscores is which section of the quad the pict goes to. But the pict id vary in length and I’m not sure how to go about this. Any thoughts or recommendations are appreciated.</p> <ul> <li>1234_1_01.jpeg</li> <li>1234_2_03.jpeg</li> <li>1234_3_02.jpeg</li> <li>1234_4_01.jpeg</li> <li>345422_1_01.jpeg</li> <li>345422_2_02.jpeg and so on</li> </ul>
php
[2]
1,790,681
1,790,682
How to check string vector for a certain letter or phrase?
<p>I have a string vector in C++ with this [Apples,Orangesandgrapes], Now i would like too search the vector not for the whole string but the part of the string that says "andgrapes" and would like to change it too, "nograpes". All just an example.</p> <p>Answer on <a href="http://stackoverflow.com/questions/3497310/substring-search-interview-question">Substring search interview question</a> Sorry I couldn't make it clearer.</p>
c++
[6]
3,041,284
3,041,285
unresolved externals of creating a static instance in C++
<p>I have produced this C++ code:</p> <pre><code>class TestInstance { public: TestInstance(); ~TestInstance(); static TestInstance&amp; GetInstance(); private: static TestInstance* testInstance; }; </code></pre> <p>But I got this error when compiling:</p> <blockquote> <p>error LNK2001: unresolved external symbol "private: static class TestInstance* TestInstance::testInstance" (?testInstance@TestInstance@@0PAV1@A)</p> <p>fatal error LNK1120: 1 unresolved externals</p> </blockquote> <p>Any idea?</p> <p>Thanks in advance. </p>
c++
[6]
476,506
476,507
Combining PHP Variables
<p>I've the following code:</p> <pre><code>if ($type == 'unit'){ $item_title = $result["title"]; } elseif ($type == 'message'){ $item_title = $result["description"]; } // all should combine unit and message elseif ($type == 'all'){ $item_title = $result["description"] $item_title .= $result["title"]; } if (stripos( $item_title, $filter ) !== false || stripos( $item_title, $filter ) !== false) </code></pre> <p>How can I combine the unit and message results in the <code>elseif ($type == all)</code> statement?</p>
php
[2]
2,686,586
2,686,587
jquery checkboxes, how to get all selected checkboxes and add them to array?
<p>Hi I have the following page:</p> <pre><code>&lt;input type="checkbox" name="fruit1" id="1" class="box"&gt;Banana&lt;br /&gt;&lt;br /&gt; &lt;input type="checkbox" name="fruit2" id="2" class="box"&gt;Cherry&lt;br /&gt;&lt;br /&gt; &lt;input type="checkbox" name="fruit3" id="3" class="box"&gt;Strawberry&lt;br /&gt;&lt;br /&gt; &lt;input type="checkbox" name="fruit4" id="4" class="box"&gt;Orange&lt;br /&gt;&lt;br /&gt; &lt;input type="checkbox" name="fruit5" id="5" class="box"&gt;Peach&lt;br /&gt;&lt;br /&gt; &lt;input type="button" id="groupdelete" value="clickme"&gt;&lt;br /&gt; </code></pre> <p> </p> <pre><code> $(document).ready(function(){ $('#groupdelete').on('click', function(){ var names = []; $('input:checked').each(function() { names.push($('input:checked').attr("name") + $('input:checked').attr('id')); }); console.log(names); }) }) </code></pre> <p></p> <p>What I am trying to do is the following:</p> <p>To add the checked checkboxes in the array. And after that, I would like to be able to pass the value in php variable.</p> <p>When I excecute the code now, I am getting result like this:</p> <p>["fruit22", "fruit22", "fruit22"]</p> <p>Any help will be deeply appreciated.</p> <p>Regards, Zoreli</p>
jquery
[5]
4,608,069
4,608,070
Insert text to editor, when focus is not in the div editor
<p>I want to insert some text into the editor. But the focus is not inside the editor(div contenteditable="true"). How can i insert text before cursor is shown.</p>
javascript
[3]
2,579,461
2,579,462
asp.net dataset xsd error : variable is used before it has been assigned a value
<p>I am using visual studio vb asp.net, i am trying to use dataset.xsd. but i am getting error. It is showing error , that ABC variable is used before it has been assigned a value a null reference exception could result at the runtime</p> <p>in my program i have loginDataSet.xsd > uloginDS</p> <p>this is the coding</p> <pre><code>Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim uloginAdapter1 As New loginDataSetTableAdapters.uLoginDSTableAdapter Dim ds1 As loginDataSet.uLoginDSDataTable Dim abc As loginDataSet.uLoginDSRow ds1 = uloginAdapter1.GetData() Dim k As String = abc.uName txtUserPassword.Text = k End Sub </code></pre> <p>This video shows how to work with dataset design and it has more parts. it is a youtube video link.</p> <p><a href="http://www.youtube.com/watch?v=sIgKuATsb-E" rel="nofollow">http://www.youtube.com/watch?v=sIgKuATsb-E</a></p> <p>But this video not shows how to read 1 row or 1 data entry. i try some coding but getting a error</p>
asp.net
[9]