Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
5,398,475
5,398,476
how to write a C# function to add arg of this class?
<p>very basic question I think.</p> <pre><code> public class person { public string name; public int status; public int ability; public person() { } public person(string name, int status, int ability) { this.name = name; this.status = status; this.ability = ability; } public static int praise() { return ++status; } } </code></pre> <p>I want write a class with C#, it has a function to add every new class their 'status'. but there is a error because 'status' is not static . how can i solve this problem? thank you very much.</p>
c#
[0]
4,915,013
4,915,014
Log cat doesn't appear to be working for me
<p>I have imported the library already. I'm not seeing any messages though in my screen.</p> <pre><code>final String temp = "temp"; int counter =0; Log.v(temp, "counter is " +counter); counter =20; Log.v(temp," counter is " +counter); </code></pre>
android
[4]
1,164,133
1,164,134
How to open a webpage with the built-in (stock) android browser?
<p>There are multiple browsers installed. How can I open <a href="http://www.google.com" rel="nofollow">http://www.google.com</a> programatically with the built-in (stock) browser?</p>
android
[4]
2,088,341
2,088,342
"Python" not recognised as a command
<p>I just downloaded and installed Python 2.7.2 to my laptop and I am trying to run some sample programs. My laptop is running Windows XP.</p> <p>When I open a <code>cmd</code> window and type <code>python</code> I get:</p> <blockquote> <p>'python' is not recognized as an internal or external command, operable program or batch file.</p> </blockquote> <p>I am not a Windows person (mostly mainframes). However I am guessing that there is some command that I need to execute to define python as a command. Can anyone tell me what that command is?</p> <p>The installer placed Python at <code>C:\Python27\</code>.</p>
python
[7]
2,878,076
2,878,077
How is it legal to use a function name as the argument to another function in JavaScript?
<p>I was gearing up for Javascript, reading the tutorials at <a href="http://w3schools.com" rel="nofollow">W3Schools</a> and came across this code:</p> <pre><code>function sortNumber(a, b) { return a - b; } var n = ["10", "5", "40", "25", "100", "1"]; document.write(n.sort(sortNumber)); </code></pre> <p>It sorts the elements in the Array, pretty simple. But how can we pass <code>sortNumber</code> ( a function name) as a parameter to the sort function?<br /><br /> <a href="http://w3schools.com/jsref/tryit.asp?filename=tryjsref_sort2" rel="nofollow">The original example</a></p>
javascript
[3]
3,344,612
3,344,613
Comparision of android.provider.CallLog.Date fails
<p>I am new to android . And when I do below code without that comparison it works , but with that comparison it fails . </p> <p><em><strong>Thanks to Oleg Vaskevich , Updated code with his points . And date range is 1-31 unlike month 0-11 And Date(int,int,int) replaced with Date(long)</em></strong></p> <p>edited code</p> <pre><code>Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, -1); int month = cal.get(Calendar.MONTH); int year = cal.get(Calendar.YEAR); int day=cal.get(Calendar.DATE); // for dynamic reset rates callSince.setText("since(dd/mm/yyyy) :" + day + "/" + (month+1) + "/" + year ); // month+1 because month {0-11} Date resetDateDate = new Date(cal.getTimeInMillis()); Calendar resetDateCal = Calendar.getInstance(); resetDateCal.setTime(resetDateDate); String resetDate = String.valueOf(resetDateCal.getTimeInMillis()); /* * CALL INCOMING */ projection = new String[] {CallLog.Calls.DURATION }; selection = CallLog.Calls.TYPE + "=? AND " + CallLog.Calls.DATE + " &gt;=?" ; selectionArgs = new String[] { (String.valueOf(CallLog.Calls.INCOMING_TYPE)) , (resetDate) }; try { Cursor cIn = getContentResolver().query(CallLog.Calls.CONTENT_URI, projection, selection, selectionArgs, sortOrder); startManagingCursor(cIn); </code></pre> <p>Help would be very useful to me . thanks </p>
android
[4]
2,191,407
2,191,408
Auto refresh the activity
<p>In my application I have a activity that displays contents from internet..... I just want to know how can I auto refresh the activity.....</p> <p>Please suggest and provide some code block if possible.</p>
android
[4]
1,947,738
1,947,739
change android notification message without stop and start service again
<p>This is my method for <code>Notification</code> when I start <code>Service</code> on android:</p> <pre><code>private void showNotification() { Notification notification = new Notification(R.drawable.call, "Some text", System.currentTimeMillis()); Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0); notification.setLatestEventInfo(this, getString(R.string.notification_label), getString(R.string.notification_text_short), pi); notification.flags |= Notification.FLAG_NO_CLEAR; startForeground(7331, notification); } </code></pre> <p>is it possible to change text later. Now is for example <code>"Some text"</code> and later I would like to change it without stop and start service again.</p> <p>Is that possible?</p>
android
[4]
2,027,474
2,027,475
C# Datagridview resize programmatically
<p>I have a datagridview that is populated and added to the winform programmatically.</p> <p>The number of columns within the gridview can vary greatly, so I want to change the size of the actual Gridview width to fit the number of columns.</p> <p>Could anybody suggest how to do this?</p> <p>Thanks.</p>
c#
[0]
945,248
945,249
getting code in new line
<p>I have several divs one of which is as below</p> <pre><code>&lt;div id="drawarea"&gt; &lt;img class="draggable ui-droppable ui-draggable ui-draggable-dragging" id="image1" src="user_2/1323384165.jpg" style="height: 40%; width: 50%; position: absolute; left: 0%; top: 0%;"&gt; &lt;label id="first"&gt;This is content of the div&lt;/label&gt; &lt;input type="button" value="GO"/&gt; &lt;/div&gt; </code></pre> <p>I am using jquerys below function to get the html inside the div and put in a text area</p> <pre><code> html = $('#drawarea').html(); $('#codearea').text(html); </code></pre> <p>the problem is that i am getting all the tags in same line i want to get one element code in one then others on other line so thats its easy to read.</p>
jquery
[5]
5,963,152
5,963,153
append Selectbox value to textbox on body load
<p>I am working on dynamic page.</p> <p>Using {$pagetitle} smarty tag I get selectbox something like this.</p> <pre><code>&lt;select name="page"&gt; &lt;option value="page1" title="Page1"&gt;Page1&lt;/option&gt; &lt;option value="page2" title="Page2" selected&gt;Page2&lt;/option&gt; &lt;option value="page3" title="page3"&gt;Page3&lt;/option&gt; &lt;option value="page4" title="Page4"&gt;Page4&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I can not have selectbox id as this is automatically generated through {smarty} tag</p> <p>I want to append value of previously selected option to the textbox below on body load.</p> <pre><code>&lt;input type="text" value"" id="pageno" /&gt; </code></pre> <p>How can I achieve this using JQuery?</p> <p>Thanks</p>
jquery
[5]
715,193
715,194
How many variables can a javascript array hold?
<p>I have a javascript array that is dynamically populated. Example: Array name $testarr[] And I have a database that fills it with numbers like this $testarr[id]=number. As my database is constantly growing I need to know when the array will hit the roof and refuse to take any more variables</p>
javascript
[3]
365,823
365,824
Pointer into vector, but not into a valarray?
<p>I'm trying to extract a const pointer to part way through an array. I found it works fine when using a vector, but won't compile (VS 2008) when using a valarray. Can somebody explain what the problem is?</p> <pre><code>struct vector_test { std::vector&lt;int&gt; v; const int *pointy(const int i) const { return &amp;(v[i]); // Ok } }; struct valarray_test { std::valarray&lt;int&gt; v; const int *pointy(const int i) const { return &amp;(v[i]); // error C2102: '&amp;' requires l-value } }; </code></pre>
c++
[6]
3,358,881
3,358,882
Drag an animated object with jquery?
<p>I have a fiddle here where a black box moves slowly across the screen. I also want to be able to drag the black box and move it into the pink box, but I can't figure it out. I was trying to use the code below but it kept breaking everything. I'm a newbie, so if you can help, please give as much explanation as you can. Thanks a lot!</p> <p><strong>Update: Sorry, I initially had the wrong fiddle posted. This is correct now</strong></p> <p><a href="http://jsfiddle.net/mjmitche/LeztD/1/" rel="nofollow">http://jsfiddle.net/mjmitche/LeztD/1/</a></p> <pre><code>$(function() { $( "#draggable, #draggable-nonvalid" ).draggable(); $( "#droppable" ).droppable({ accept: "#draggable", activeClass: "ui-state-hover", hoverClass: "ui-state-active", drop: function( event, ui ) { $( this ) .addClass( "ui-state-highlight" ) .find( "p" ) .html( "Dropped!" ); } }); }); </code></pre>
jquery
[5]
572,056
572,057
Android: Parse simple mathematical formula string
<p>I have users entering numbers into EditText fields, but would like them to be able to write things like 100+32+10 into the fields as well. I expect simple expressions only, common four functions. In fact, just addition would cut it too.</p> <p>For just addition, I guess it wouldn't be that hard to split up the string and do it myself I suppose, but I'm curious to know if there is a library which can do what I want much more cleanly.</p> <p>Any suggestions?</p>
android
[4]
590,389
590,390
FindFieldTemplate() return always null
<p>I have a problem with Asp.net 4.0 Dynamic Data. I've created a CustomField Template that contains FileUpload control and I need to access to it in the Insert.aspx page of Dynamic Data.</p> <pre><code> protected void Custom_ItemInserting(object sender, EntityDataSourceChangingEventArgs e) { News news = (News)e.Entity; var fldTmpUsrCtl = FormView1.FindFieldTemplate("Image"); } </code></pre> <p>fldTmpUsrCtl var is always null!! Why??? Help!!!! </p>
asp.net
[9]
4,710,589
4,710,590
Grenular permissions on Android. why not?
<p>From what I uderstand, there is no way to do something like</p> <pre><code>if(have certain permission){ //do something that requires the permission } </code></pre> <p>where the application can request optional permissions. For example I want to track usage of my app only if the user accepts to being tracked. But still allow the user to download and use the app with tracking disabled if he dosen't agree. Is this at all possible ? If not, what is the reasoning behind not supporting this feature ?</p> <p>EDIT: to clarify, Im referring to Android permissions, like using the camera or looking at the contact list.</p>
android
[4]
5,154,442
5,154,443
How do I get around uninitialized global variables in another module in Python?
<p>I have a problem where I'm trying to use a function from another module but that function calls a debug function which checks if a global variable has a certain attribute. This global variable is not set (otherwise set using <code>parser.parse_args</code>) when I import the function so the function complains that the attribute doesn't exist. For clarification: </p> <p>File <code>findfile.py</code>:</p> <pre><code>_args = {} def _debug(msg): if _TEST and _args.debug: print msg def findfile(filename): ... _debug("found file") ... if __name__ == "__main__": ... _args = parser.parse_args() ... </code></pre> <p>File <code>copyafile.py</code></p> <pre><code>import findfile findfile.findfile("file1") </code></pre> <p>This gives me</p> <pre><code>AttributeError: 'dict' object has no attribute 'debug' </code></pre> <p>Now I understand that <code>parser.parse_args()</code> returns a namespace (??) and that <code>_args.debug</code> isn't really looking in the <code>dict</code>. But my question is: How can I in this situation properly assign something to <code>_args</code> to set the <code>_args.debug</code> to <code>False</code>?</p> <p><strong>I can not change <code>findfile.py</code> but I can change <code>copyafile.py</code>.</strong></p> <p>How are these things usually handled otherwise? What is the pythonic way of enabling debug flags in a script?</p>
python
[7]
3,465,949
3,465,950
Issues with JavaScript settimeout function
<p>I am very new to JavaScript and cannot seem to get the setTimeout command to do anything. I know this has been asked many times before, but I have spent the last two hours looking at all previous cases of it and it still isn't working for me. Here is what I have got at the moment:</p> <pre><code>&lt;html&gt; &lt;script type="text/javascript"&gt; var i = 0; function aloop() { document.write(i); i++; } function afunction() { if (i &lt;= 12) { setTimeout(aloop(), 1000); afunction(); } } &lt;/script&gt; &lt;form&gt; &lt;input type=submit value="Click me!" onClick="afunction()"&gt; &lt;/html&gt; </code></pre> <p>Can anyone tell me what I should do to make this work?</p>
javascript
[3]
5,897,465
5,897,466
Generate password using a for loop
<p>I am making a password generator that generates a random number, then I have it converted to a letter using ascii. Inside the for loop, I need the letters to convert a string instead of a list. It works, but it just displays random letters as a list. </p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; class MainClass { static void Main() { int x = 1; int length; string a = "Press any key to continue"; object num; while (x == 1) { Console.WriteLine("How many Characters would you like the Password to be? (Press -1 to Stop)"); length = Convert.ToInt32(Console.ReadLine()); try { for (int i = 0; i &lt; length; i++) { int num1 = Number(); Int32 ASCII = num1; num = (char)num1; if (length &gt; 0) { Console.WriteLine(num); } } } catch { Console.WriteLine(a); } if (length == -1) break; } } static Random _r = new Random(); static int Number() { return _r.Next(65, 90); // decimal } } </code></pre>
c#
[0]
4,260,014
4,260,015
Run python function multiple times with different arguments
<p>Hi I need to have a function that would take a function and return a function that will run that argument function eg. 1000 times and each time evaluate it's argument. I have something like this:</p> <pre><code>def runner(f): def inner(*args): for i in xrange(1000): f(*args) return inner </code></pre> <p>But it seems that invocation like this:<code>runner(f)(random.randint(1,UPPER_BOUND))</code> runs f 1000 times with the same argument. How to do it correctly?</p>
python
[7]
2,404,162
2,404,163
sound notification
<p>I am using the raw folder contain notification.wav file. When the notification comes in the phone it will be alert of sound notification.wav file.</p> <p>I am using this code:</p> <pre><code>Uri path = Uri.parse("android.resource://" + getPackageName() + "/notification.wav"); notification.sound = path; </code></pre> <p>Please help.</p>
android
[4]
1,983,527
1,983,528
why Array constants can only be used in initializer?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6348479/arrays-constants-can-only-be-used-in-initializers-error">Arrays constants can only be used in initializers error</a> </p> </blockquote> <p>i was studying array and i came through this short-cut method of declaring and initializing an array in 1 line.e.g- </p> <pre><code>int[] a = {1,2,3,4,5}; </code></pre> <p>but when i tried to do following code i got this compiler error saying "Array constants can only be used in initializer".</p> <pre><code>int[] a; a={1,2,3,4}; </code></pre> <p>please help</p> <p>thanks</p>
java
[1]
2,360,024
2,360,025
TV out an iphone application
<p>Using the UIScreen API is it possible to display the same app screen on both ipod screen and external display. I have tried using UIScreen but application is displaying only on external display, not on ipod screen. Please guide me on right way</p>
iphone
[8]
3,135,373
3,135,374
Data structure using c++
<p>if we are having are having an array of pointer i.e. </p> <pre><code>struct node*ptr[]; </code></pre> <p>and if we want to initialize its value of first index (<code>ptr[0]</code>) by null then how can we do that?</p>
c++
[6]
2,471,006
2,471,007
php - problem with displaying text around a search term
<p>I found this bit of code on stackoverflow at <a href="http://stackoverflow.com/questions/1195947/best-practices-on-displaying-search-results-with-associated-text-snippets-from-ac">http://stackoverflow.com/questions/1195947/best-practices-on-displaying-search-results-with-associated-text-snippets-from-ac</a></p> <p>However it doesn't quite do what i want. It displays the text around a given search term, but there are two problems</p> <p>1) I want <strong>whole words only</strong>; 2) It doesn't limit the characters <strong>after</strong> the search term, only the ones before</p> <p>Here's the code below. How can I edit it to solve the two problems? Thanks in advance:</p> <pre><code>$text = 'This is an example text page with content. It could be red, green or blue or some other random color. It dont really matter.'; $keyword = 'red'; $size = 15; // size of snippet either side of keyword $snippet = '...'.substr($text, strpos($text, $keyword) - $size, strpos($text, $keyword) + sizeof($keyword) + $size).'...'; $snippet = str_replace($keyword, '&lt;strong&gt;'.$keyword.'&lt;/strong&gt;', $snippet); echo $snippet; </code></pre>
php
[2]
147,180
147,181
Variable not the same type in two different functions
<p>I have two functions which print into an excel file. THe only input is the file name. Here is the code:</p> <pre><code>#excelpy import excelpy #Tinker from Tkinter import * from tkSimpleDialog import * from tkFileDialog import * </code></pre> <p>Function Mode1</p> <pre><code>def Mode1(full_name): print full_name print type(full_name) testwbook = excelpy.workbook(full_name) testwbook.show() testwbook.set_cell((1,1),'TEST1', fontColor='red') testwbook.set_range(2,1,['Number','Name']) m1 = testwbook.save(full_name) testwbook.close() return m1 </code></pre> <p>Function Mode2</p> <pre><code>def Mode2(full_name): print full_name print type(full_name) testwbook = excelpy.workbook(full_name) testwbook.show() testwbook.set_cell((1,1),'TEST2', fontColor='red') testwbook.set_range(2,1,['Number','Name']) m2 = testwbook.save(full_name) testwbook.close() return m2 </code></pre> <p>Main</p> <pre><code>root = Tk() d = str(asksaveasfilename(parent=root,filetypes=[('Excel','*.xls')],title="Save report as...")) d = d + '.xls' d = d.replace('/','\\') root.destroy() Mode1(d) Mode2(d) </code></pre> <p>And once in a while I get the following error:</p> <pre><code>Traceback (most recent call last): File "T:\TEST\testpy.py", line 2035, in &lt;module&gt; Mode2(d) File ""T:\TEST\testpy.py"", line 1381, in Mode2 print type(full_name) TypeError: 'str' object is not callable </code></pre> <p>Any idea why is this happening? How can I prevent it?</p>
python
[7]
1,561,861
1,561,862
How to do jquery code AFTER page loading?
<blockquote> <p>If you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and <strong>before</strong> the page contents are loaded.</p> </blockquote> <p>I want to do javascript code only <strong>after</strong> the page contents are loaded how can I do that?</p>
jquery
[5]
1,646,931
1,646,932
How can I make my image rotate about a fixed point when using bitmap?
<p>I'm trying to rotate an image at a fixed point, but the image is rotating at its top left position. I've tried rotateAnimation and it works fine, but the problem is when I rotate my image again it starts rotating from the original position.</p> <pre><code> Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.arw2); int w = bmp.getWidth(); int h = bmp.getHeight(); float px = 160,py = 215; Matrix mtx = new Matrix(); mtx.setRotate(rAngle, px, py); Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true); BitmapDrawable bmd = new BitmapDrawable(rotatedBMP); myImageView.setImageDrawable(bmd); </code></pre> <p>What am I doing wrong?</p>
android
[4]
2,501,567
2,501,568
How to test if a directory is a python module path?
<p>In order to test if a directory <code>path</code> if a python module path (i.e. contains a file named <code>__init__.py</code>) one can do something like</p> <pre><code>os.path.isfile(os.path.join(path, '__init__.py')) </code></pre> <p>I wonder if there is a special function call to do that?</p>
python
[7]
3,709,134
3,709,135
Parse http request header
<p>I am getting a request header with value containing multiple double quotes, How do i parse it in my java code ?</p> <p>here is how header looks like</p> <p>pp-groups: "Administrator","SuperUser","view","Edit"</p>
java
[1]
3,889,807
3,889,808
getJSON return variable.. solution?
<p>My function fetches if the user is banned and i want to return a variable that determines if a popup displays; but as I've found out you can't return a variable from a <code>getJSON</code> function.</p> <pre><code> function fetchban() { $.getJSON('/fetchban.php',function(data) { if(data==0) { var banned = data; } else { $.each(data,function(index,result) { $('#ban-prompt').html(result); $('.popup-background').show(); $('#ban-container-2').show(); }); } }); return banned; } $('.button').click(function() { var banned = fetchban(); if(banned==0) { //display-popup } }); </code></pre> <p>There are alot of lines i call the <code>fetchban</code> function, so i would prefer the <code>getJSON</code> in a function. What is the solution?</p>
jquery
[5]
3,703,204
3,703,205
arraylist size exception
<pre><code>for(int i=0;i&lt;charset.size();i++) { for(int j=0;i&lt;charset.size();j++) { for(int k=0;k&lt;charset.size();k++) { String plaintext= charset.get(i)+charset.get(j)+charset.get(k); String hashtext=CreateHash.returnString(plaintext); BufferedWriter bw = new BufferedWriter(new FileWriter("/root/MD5List.txt", true)); //opens file bw.write(plaintext+" = "+hashtext); bw.newLine(); bw.close(); } } } </code></pre> <p>When I run this program, I get a stacktrace of: (the arraylist size is 10 by the way) the variable k is clearly less than the size of the arraylist. Any help would be appreciated.</p> <pre><code>Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 10, Size: 10 at java.util.ArrayList.rangeCheck(ArrayList.java:571) at java.util.ArrayList.get(ArrayList.java:349) at MD5HashTable.Hash.main(Hash.java:57) Java Result: 1 </code></pre>
java
[1]
4,303,459
4,303,460
Pull live prices from web page
<p>I need to pull prices from a web page in order to use them inside a Java app. Any hint about how to do this would be welcome. An example of page: <a href="http://www.eurexchange.com/market/quotes/orderbook_en.html?symbol=FGBL&amp;name=Euro-Bund" rel="nofollow">http://www.eurexchange.com/market/quotes/orderbook_en.html?symbol=FGBL&amp;name=Euro-Bund</a> Futures</p>
java
[1]
211,171
211,172
Variable arguments weirdness
<p>Ok, so this piece of code works fine in the Debug but not in Release build.</p> <pre><code>int AddString(LPCTSTR lpszString, ...) { RArray&lt;LPCTSTR&gt; strings; va_list args; va_start(args, lpszString); do { strings.Add(lpszString); } while (lpszString = va_arg(args, LPCTSTR)); va_end(args); // ... rest of code ... } </code></pre> <p>It seems in Release, va_arg just returns an extra value containing rubbish. So if I pass on 3 parameters: I fetch 3 in Debug and miraculously 4 in Release... How is this possible? Using VS2010 btw.</p> <p>(RArray is just a simple template class comparable to MFC's CArray, does not influence results)</p> <p>Thanks!</p> <p>Edit: I call it like this</p> <pre><code>AddString(_T("Hello, world!"), _T("Hallo, wereld!"), _T("Hallo, Welt!")); </code></pre>
c++
[6]
4,185,632
4,185,633
NS_ERROR_XPC_BAD_CONVERT_JS , when creating a new form and input fields
<p>i am new to javascript and i have been trying things out lately . but i am stuck here in one function which return the error :</p> <pre><code>[10:55:47.027] NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMHTMLFormElement.appendChild] @ http://localhost/myproj/test5.html:15 </code></pre> <p>Now let me explain what the code does : 1) i have defined a function called "add" it takes one argument which is a arary of strings. when it is called , the function creates a new form and new input's with type "text" and value the same as each string in the argument array.</p> <p>here is the code : </p> <pre><code>function add(index_array) { //create the form var myform = document.createElement("form"); myform.id="k_form" for ( i =0 ; i &lt;index_array.length ; i ++) { var mytext = document.createElement("input"); mytext.tpye="text"; mytext.value="index_array[i]"; mytext.id="index_array[i]"; myform.appendChild("mytext"); console.log("error"); } mydiv=document.getElementById("d_div"); mydiv.appendChild("myform"); } </code></pre> <p>now when i execute it , i get the error displayed above , i cant figure out my mistake can anyone please help with that. thanks a ton!</p>
javascript
[3]
1,871,624
1,871,625
Get Changed Environment Variable in Python
<p>I have a requirement where 1 process sets a value as environment variable and I read that value in python using </p> <blockquote> <p>os.environ</p> </blockquote> <p>As per python doc:</p> <blockquote> <p>This mapping is captured the first time the os module is imported, typically during Python startup as part of processing site.py. Changes to the environment made after this time are not reflected in os.environ, except for changes made by modifying os.environ directly.</p> </blockquote> <p>My problem is the process set/change the variable every time it calls the python script.<br> Please tell me a way to read the changed value. </p> <p>Thanks,</p>
python
[7]
5,975,407
5,975,408
Opening an image on a click of image present in the same layout
<p>I want to have a home screen which has a small circle in the middle and when I click it it should expand as in the image uploaded.</p> <p><img src="http://i.stack.imgur.com/fbJAY.jpg" alt="Image"></p> <p>When I click on the black circle , red box should appear and when I click again on the circle it should disappear.</p> <p>I know how to have a click event on a image but not able to do it in the same layout.</p> <p>Please help approaching this.Do I need to have animation for this? or can be done by normal xml.</p>
android
[4]
3,577,737
3,577,738
Getting started designing and implementing an idea for Android App
<p>Does anyone have any good references for designing and implementing an idea I have for an android application. </p> <p>My idea is for an application that stores information and reviews about a specific location and presents this information to user.</p> <p>I have gone through all the tutorials and have been reading up on anything and everything about android. Now I am ready to challenge myself with my first app.</p> <p>Any suggestions on getting started would be greatly appreciated.</p>
android
[4]
4,543,937
4,543,938
EXC_BAD_ACCESS on NSString,when application is brought to foreground from background [ on 4.0 OS ]
<p>Currently My application is getting crashed on accessing NSString after bringing application to foreground from background [on 4.0 OS].</p> <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; iDatabasePath = [documentsDirectory stringByAppendingPathComponent:KApp_DB_Name]; </code></pre> <p>iDatabasePath is declared as NSString* and it is globally declared. </p> <p>When Application is moved to background and brought to foreground when I make a call to</p> <pre><code> iDatabasePath = [documentsDirectory stringByAppendingPathComponent:KApp_DB_Name]; </code></pre> <p>Application crashes due to EXC_BAD_ACCESS to iDatabasePath and this is happening on 4.0 OS</p> <p>Please help me on this.</p> <p>Thanks,</p> <p>Sagar</p>
iphone
[8]
2,868,215
2,868,216
C++ fast division/mod by 10^x
<p>In my program I am using a lot of integer division by 10^x and integer mod function of power 10.</p> <p>ex:</p> <pre><code>unsigned __int64 a = 12345; a = a / 100; .... </code></pre> <p>or</p> <pre><code>unsigned __int64 a = 12345; a = a % 1000; .... </code></pre> <p>If i am going to use bite shift >> , then i will get mode of 2^x, which is not what i want.</p> <p>Is there any way, I can speed up my program in integer division and mod functions ?? Thank you</p>
c++
[6]
1,725,231
1,725,232
\tssr>"&\8=f23' as String C#
<p>I have a short question. I want do put this \tssr>"&amp;\8=f23' into a String (Language C#).</p> <p>But the compiler always shows an error because for example "\8" is a command.</p> <p>can someone help me?</p> <p>Thank you very mutch.</p>
c#
[0]
4,202,930
4,202,931
Should I use accessor methods or object variables to access a value?
<p>I am making an API wrapper for twitch.tv in python and I was wondering whether I should use accessor methods (ex.)</p> <pre><code>import twichtvwrapper apiobject = twichtvwrapper(useragent, username, password) channel = twich.channel(channelname) channel.getcurrentgame() #this will return the current game </code></pre> <p>or should I just use object variables? (ex.)</p> <pre><code>import twichtvwrapper apiobject = twichtvwrapper(useragent, username, password) channel = twich.channel(channelname) print(channel.currentgame) #this will print the current game </code></pre> <p>Which one should I use?</p>
python
[7]
5,115,125
5,115,126
Is there a way to animate on a Home Widget?
<p>I want to use an animation on a Home page Widget, i.e. an AppWidgetProvider. I was hoping to use the "Frame Animation" technique:</p> <p><a href="http://developer.android.com/guide/topics/graphics/2d-graphics.html#frame-animation" rel="nofollow">http://developer.android.com/guide/topics/graphics/2d-graphics.html#frame-animation</a></p> <p>which I've used successfully in an activity. But I can't translate that code to an AppWidgetProvider.</p> <p>Basically, in an AppWidgetProvider, I create and work with a RemoteViews object, which AFAIK doesn't provide me with a method to get a reference to an ImageView in the layout for me to call start() on the animation. There is also not a handler or a callback for when the widget displays so I can make the start() call.</p> <p>Is there another way this can be done? I suppose that I can probably do the animation on my own with very fast onUpdate() calls on the widget, but that seems awfully expensive.</p>
android
[4]
282,072
282,073
Make map() return a dictionary
<p>I have the following function:</p> <pre><code>def heading_positions(self): return map( lambda h: {'{t}.{c}'.format(t=h.table_name,c=h.column_name) : h.position }, self.heading_set.all() ) </code></pre> <p>It gives me output like this:</p> <pre><code>[{'customer.customer_number': 0L}, {'customer.name': 2L}, ... ] </code></pre> <p>I would prefer just a single dictionary like this:</p> <pre><code>{'customer.customer_number': 0L, 'customer.name': 2L, ... </code></pre> <p>Is there a way to make <code>map</code> (or something similar) return just a single dictionary instead of an array of dictionaries?</p>
python
[7]
5,712,704
5,712,705
getRight, getLeft, getTop returning zero
<p>I am using following code. But all methods are returning zero value. I know that to get the coordinates of the view our view should be drawn. That why i am using the code in onResume method but still not working. Any Idea?</p> <pre><code> @Override public void onResume(){ super.onResume(); System.out.println("Onresume"); System.out.println("tab1 - left" + btn_Tab7 .getLeft()); System.out.println("tab1 - Top" + btn_Tab7.getTop()); System.out.println("tab1 - right" + btn_Tab7.getRight()); System.out.println("tab1 - bottom" + btn_Tab7.getBottom()); } </code></pre>
android
[4]
1,501,209
1,501,210
Checking for rights
<p>I am building an application in asp.net using C# where people have their own profiles, and if they want to see others profile they can, but they only have read permission; how to set all these read write permissions in Ms Sql? </p>
asp.net
[9]
1,910,894
1,910,895
Should log() be used in place of try/throw/catch when 'bubbling up' is not needed?
<p>I have a function that wraps console.log like this.</p> <pre><code>NS.log("error"); </code></pre> <p>which I use for error logging. It is a simple one liner to let the app developer know that something went wrong. It does not stop program flow and shows up unobtrusively in the console.</p> <p>However, I've heard in university courses, etc., that using a try/throw/catch is best practice as it uses an error control system already in place.</p> <p>However, I don't need the error to "bubble" up after a throw statement. I would catch it immediately like this:</p> <pre><code>try { throw "error" } catch (e) { } </code></pre> <p>Are there any cons to simply logging the error as opposed to using a more formal structure.</p> <p>My assumption is that try/throw/catch is for more complex structures.</p> <p>But I wanted to make sure.</p> <p><strong>Notes:</strong></p> <ul> <li>requirejs uses throw a total of 4 times | no use of console or log</li> </ul>
javascript
[3]
5,698,196
5,698,197
How to set browser specific css in JavaScript?
<p>How to set style <code>-webkit-box-shadow: 0px 0px 11px #000</code> to an element via JavaScript?</p>
javascript
[3]
3,645,727
3,645,728
How to make this large if-statement more readable in JavaScript
<p>I need to make the following large if-statement more readable in JavaScript.</p> <p>Any ideas?</p> <pre><code>if ( Tools.Array.contains( that.pAutocompleteAliasUsed[i], this.currentString) !== false &amp;&amp; ( this.autocomplete.list.length === 0 ) || ( this.currentString.toLowerCase() !== this.autocomplete.list[0].target.alias.toLowerCase() ) ) { make something } </code></pre>
javascript
[3]
964,566
964,567
jquery accessing label of input
<p>I have some HTML like this:</p> <pre><code>&lt;input type="radio" class="MyRadio" name="TheName"&gt; &lt;label for="TheLabel"&gt;the text&lt;/label&gt; </code></pre> <p>How do I change the label's text?</p> <p>Tried </p> <pre><code>$('#TheLabel').text('My New Text'); </code></pre> <p>It doesn't work. What's the way to do it?</p> <p>Thanks.</p>
jquery
[5]
5,324,246
5,324,247
Assigning table column width w/jQuery
<p>I have a table. The first column contains labels. The rest of the columns contain values. I do not know how many columns can there be but I would like to make all but the first column the same width.</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;label&lt;/td&gt; &lt;td&gt;data&lt;/td&gt; &lt;td&gt;data&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>So, I know the table width </p> <pre><code>var tW = $("#myTbl").width(); </code></pre> <p>I can get the width of the first column:</p> <pre><code>var fcW = $("#myTbl th:first").width(); </code></pre> <p>Now i need to find how many columns are there in the table, subtract the width of the first column from the table width and divide the rest by the (number of cols - 1).</p> <p>How do I find the number of columns?</p> <p>Tried but failed</p> <pre><code>var nimCol = $("#myTbl th:first").parent().find("th").length - 1; </code></pre>
jquery
[5]
114,173
114,174
Singleton Factory method
<p>Is it possible to have a singleton in a factory method? I have many domains using the factory method. How do I work around with this. Please help me with an example.</p>
java
[1]
3,480,473
3,480,474
Redefine an reference in Java (Extend usage)
<p>I have a question about the usage of extend that I dont reach to understand. For that example I'll use two classes:</p> <pre><code>public class Father { protected String message="Father"; public void printme(){ System.out.println(this.message); } } </code></pre> <p>And</p> <pre><code>public final class Son extends Father { protected String message="Son"; } </code></pre> <p>My question is, why if I call:</p> <pre><code>new Son().printme(); </code></pre> <p>It prints "Father"? How can I solve that changing only the "Son" class?</p> <p>Thanks in advance</p>
java
[1]
3,417,538
3,417,539
How to check my internet access on Android?
<p>What I really want is, when the user has no connection, I want to show some dialog that he or she has no connection. </p> <p>I tried to put this on my MainActivity but still didn't work.</p> <pre><code>public boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo().isConnectedOrConnecting(); } </code></pre> <p>I also used this one but it didn't also work:</p> <pre><code>public class ConnectionChangeReceiver extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService( Context.CONNECTIVITY_SERVICE ); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); NetworkInfo mobNetInfo = connectivityManager.getNetworkInfo( ConnectivityManager.TYPE_MOBILE ); if ( activeNetInfo != null ) { Toast.makeText( context, "Active Network Type : " + activeNetInfo.getTypeName(), Toast.LENGTH_SHORT ).show(); } if( mobNetInfo != null ) { Toast.makeText( context, "Mobile Network Type : " + mobNetInfo.getTypeName(), Toast.LENGTH_SHORT ).show(); } } } </code></pre> <p>I added this on my manifest:</p> <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; </code></pre> <p>Can someone tell me what I'm doing wrong, I would really appreciate it a lot. Thanks in advance!</p>
android
[4]
3,187,912
3,187,913
Calling a joomla module from JQuery
<p>I'm quite new to Joomla and using Joomla 1.5 as a beginner. I wonder how to call a Joomla module for mouse hover event on a menu item. Simply how can we make a function call for a joomla module from a jquery? Any help is much appreciated.</p> <p>Thanks in advance.</p>
jquery
[5]
3,728,496
3,728,497
Javascript for mobile HTML form
<p>I am having some problems with Javascript :( This is an HTML form for a mobile webpage. To save space I put the names of the text fields inside the boxes. The name disappears when you focus on the box, but I am not able to make it reappear if the user didn't write anything. </p> <p>Here is the Script (in head tag):</p> <pre><code>&lt;script type="text/javascript"&gt; resetDefault();{if (this.value.length==0); this.value="default";} &lt;/script&gt; </code></pre> <p>Here is the HTML code:</p> <pre><code>&lt;input onfocus="this.value=''" onblur="resetDefault()" name="nom" type="text" value="Nom complet" default="Nom complet"/&gt;&lt;br&gt;&lt;input onfocus="this.value=''" onblur="resetDefault()"name="courriel" type="text" value="Courriel" default="Courriel"/&gt;&lt;br&gt; </code></pre> <p>I keep getting a "resetDefault is not defined" error. I don't know if default is an accepted attribute for input, but I can't set it to "value" because value becomes 0 once someone has focused on the text field, right?</p>
javascript
[3]
5,242,405
5,242,406
C++ Static Initializer - Is it thread safe
<p>Usually, when I try to initialize a static variable</p> <pre><code>class Test2 { public: static vector&lt;string&gt; stringList; private: static bool __init; static bool init() { stringList.push_back("string1"); stringList.push_back("string2"); stringList.push_back("string3"); return true; } }; // Implement vector&lt;string&gt; Test2::stringList; bool Test2::__init = Test2::init(); </code></pre> <ol> <li>Is the following code thread safe, during static variable initialization?</li> <li>Is there any better way to static initialize stringlist, instead of using a seperate static function (init)?</li> </ol> <p>Although the initialization shall happen before main function (Hence, there can be no threads to simultaneous access the init), my concern is that :</p> <ol> <li>I have an exe application.</li> <li>My exe application will load a.dll, b.dll and c.dll</li> <li>a/b/c.dll, in turn will load common.dll. The above code are inside common.dll</li> <li>I had already verify. Since 3 dll are within single process, they will be referring to the same static variable (vector).</li> <li>In this case, to prevent 3 dlls from simultaneous access init (Can I view them as 3 threads? Although doesn't make sense at first thought), for the init function, shall I use a critical section to protect it?</li> </ol> <p>I am using Windows XP, VC6 and VC2008 compiler.</p>
c++
[6]
1,760,255
1,760,256
in javascript, how do you sort a subset of an array?
<p>I have an array and would like to sort all but the last n elements.</p> <p>For example, if the array is 10 elements long, would like elements 0 through 7 to be sorted while elements 8-9 are left in place.</p>
javascript
[3]
4,036,910
4,036,911
iPhone - animating a tableView section Header
<p>I have created this tableView section header. It is basically a UIView container where I wrapped all elements that will go on that section header.</p> <p>This container view is returned by </p> <pre><code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section </code></pre> <p>and everything is working fine.</p> <p>Now I want the header to appear in fade in, as the table appears. So, I initially declare alpha = 0 for the container and then do this on viewDidAppear (ah, this table is inside a view controller that is appearing).</p> <pre><code>- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [UIView animateWithDuration:1.0 animations:^{ [self.tableHeader setAlpha:1.0f]; }]; } </code></pre> <p>nothing happens and the header continues invisible.</p> <p>I have tried to add</p> <pre><code>[self.tableView beginUpdates]; //and [self.tableView beginUpdates]; </code></pre> <p>before and after the mentioned animation, without success.</p> <p>It appears to me that the table header is not updating and continues invisible.</p> <p>How can I do that?</p> <p>thanks.</p>
iphone
[8]
3,238,175
3,238,176
What is the best way to show a message to user and redirect to home page when a session times out
<p>I am currently working on a asp.net 3.5 web application which is being used by 500 + concurrent users and the session time-out is set to 24 hours but a recycling of ASPNet process on the server is scheduled to trigger everyday at 3:00 A.M. is causing the session gets timed out. </p> <p>What is the best way to show a message to user and redirected to home page after session is expired? There are lot of pages in the project, so adding code to every page of the site is not really a good solution. </p> <p>Thanks in advance BB</p>
asp.net
[9]
1,877,990
1,877,991
Problem accessing global variable in javascript
<p>I am working on google maps and I need to create an array of items. Here is my pseudo code:</p> <pre><code>&lt;script&gt; var myvar=new array(); function initialize(){ for i=1 to 10 { callAnotherFunct(i); } access myvar() here; } function callAnotherFunct(i){ myvar=array_element_i; } &lt;/script&gt; </code></pre> <p>I am expecting myvar to behave as a global variable but it is not. I cannot get any values for myvar in the initialize().</p> <p>What am I doing wrong here?</p>
javascript
[3]
242,499
242,500
What are some convenience / debugging features for programmers in the Java SDK?
<p>I am interested in learning about some convenience features in the Java SDK intended to make life easier for programmers.</p> <p>These are my list:</p> <ol> <li>print(abc...) variable args - very handy when working with variable arguments.</li> <li>Arrays.toString,toDeepString..etc which makes debugging easy by printing values easily.</li> <li>ListIterator very good in bidirectional iteration.</li> <li>Date.after,before..etc</li> </ol>
java
[1]
1,373,848
1,373,849
Timeout in Dropdown selectindex changed event
<p>I have built one web application and in that i had bound drop down with 10K records and when i will change index then i will get page timeout error!!</p> <p>can anyone suggest me the cause of this problem?</p>
asp.net
[9]
970,437
970,438
Predefined variable $s in PHP?
<p>This is a very weird error. I am dealing with a script that uses variable <code>$s</code> as on object. This script has been running for a long time.</p> <p>Randomly, on the page it suddenly said:</p> <p><code>Trying to get property of non-object...</code></p> <p>Confused, I put <code>var_dump($s)</code> on several places throughout the script, including the VERY TOP (before any includes or anything). </p> <p>The output: <code>string(32) "8251ca989c1e9aec382f07f6e047e5f3"</code></p> <p>Even <em>more</em> confused, I put the <code>var_dump($s)</code> in another script to test it. Once again, it showed the same 32 character string.</p> <p>What is happening here? Is this a hack of some kind?</p> <p>EDIT:</p> <p>I made a new script and this is LITERALLY the <strong>entire</strong> code:</p> <pre><code>&lt;?php var_dump($s); ?&gt; </code></pre> <p>When I visit in a browser it says: <code>string(32) "8251ca989c1e9aec382f07f6e047e5f3"</code></p>
php
[2]
3,890,519
3,890,520
Best method for getting an accurate timestamp?
<p>I am working on an app where there is a need for a reliable, accurate timestamp in JavaScript. As such, I would prefer not to rely on the client system time. Although it is likely to be correct, I need something more certain.</p> <p>I was hoping there was an API available from a well endowed provider such as Google that would allow me to access an accurate timestamp from some server somewhere. I haven't been able to find that, so I came up with another idea: create a tiny dummy file on our server, retrieve it via AJAX and extract our own server's timestamp from response headers: </p> <pre><code>$.ajax({ type: 'POST', url: 'dummy.json', complete: function (response) { // header is available as a string: response.getAllResponseHeaders(); } } </code></pre> <p>Headers:</p> <pre><code>Date: Fri, 14 Oct 2011 14:07:41 GMT Content-length: 18 Last-modified: Thu, 13 Oct 2011 20:35:28 GMT Server: Netscape-Enterprise/6.1 AOL Etag: "0-0-12-0" Content-type: text/plain Accept-ranges: bytes </code></pre> <p>Is this not the most ridiculous work-around ever? Am I going crazy? Is there a better solution?</p> <p>If not could somebody help me write a regex to extract just the date from the above response header string?</p> <p>edit: forgot to mention the reason why this is a problem is I don't have access to the backend to create some simple service for polling a timestamp from the server or anything like that. I have to do it in JavaScript for this particular application.</p>
javascript
[3]
4,063,857
4,063,858
Is memory allocated for an object automatically deleted if an exception is thrown in a constructor?
<p>Suppose there is this code:</p> <pre><code>class CFoo { public: CFoo() { iBar = new CBar(); } private: CBar* iBar; }; .... CFoo* foo = new CFoo(); </code></pre> <p>When the above line is executed, first memory will be allocated to hold the CFoo object. But then if the line new CBar() throws an exception (due to lack of memory) does the system automatically deallocate the memory that was previously allocated to the CFoo object? I presume it must, but cannot find any explicit reference saying so. If it doesn't how can the memory be deallocated by the coder as it will not have been assigned to foo?</p>
c++
[6]
1,720,288
1,720,289
read child class variables in parent class
<p>I am trying to access child class variables in parent class..can u suggest me how to proceed based on below code snippet?</p> <pre><code>public abstract class Base{ //some abstract methods //one more method to parse the xml public final void parseXml(){ String clName = Thread.currentThread().getStackTrace()[1].getClassName(); //child class name if(xmlFile_+clName){ //i am trying to access "Test.xmlFile_Test", //execute the if string is available } } } public class Test extends Base{ public static final String xmlFile_Test = "&lt;Hello&gt;sample&lt;/Hello&gt;"; public int execute(){ parseXml(); //This should call base class method } } </code></pre> <p>Where is my wrong step.. this is psuedo code, which might help you to answer</p>
java
[1]
79,896
79,897
Does anyone know a "working" Python library that can read .ARC files?
<p>An ARC file is a lossless data-compression format. <a href="http://en.wikipedia.org/wiki/ARC%5F%28file%5Fformat%29" rel="nofollow">http://en.wikipedia.org/wiki/ARC%5F%28file%5Fformat%29</a></p> <p>I've tried googling some, but the Python ARC readers are 404 errors, or cannot be found.</p> <p>Anyone know of any library I can use?</p>
python
[7]
1,343,908
1,343,909
Display a div below an input field of the exact width using jQuery
<p>I currently use the following code to position a div directly below an input text field on focus. The problem is the width of the div varies between browsers. Is there a way to ensure the div that appears is the exact width as my input field?</p> <pre><code> // get the field position var inputField = $('#inputfield'); var fieldDiv = $('div.divname'); var sf_pos = field.offset(); var sf_top = sf_pos.top; var sf_left = sf_pos.left; // get the input field size var sf_height = inputField.height(); var sf_width = inputField.width(); fieldDiv.css("position","absolute"); fieldDiv.css("left", sf_left); fieldDiv.css("top", sf_top + sf_height + 6); fieldDiv.css("width", sf_width); $('#inputfield').focus(function() { fieldDiv.fadeIn('medium'); }).blur(function() { fieldDiv.fadeOut('medium'); }); </code></pre>
jquery
[5]
4,337,034
4,337,035
How to display Annotation view without clicking on pin in mapview?
<p>I have implemented one map application in which i have display pin animation for current location.When i click on the pin at that time annotation view will open. But i want to display annotation view without clicking on pin.Is it possible if possible then please give me idea about that.</p> <p>Thanks in advance.</p>
iphone
[8]
5,171,444
5,171,445
How do you search through a map?
<p>I have a map:</p> <pre><code>Map&lt;String, String&gt; ht = new HashMap(); </code></pre> <p>and I would like to know how to search through it and find anything matching a particular string. And if it is a match store it into an arraylist. The map contains strings like this:</p> <p>1,2,3,4,5,5,5</p> <p>and the matching string would be 5.</p> <p>So for I have this:</p> <pre><code> String match = "5"; ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;(); Enumeration num= ht.keys(); while (num.hasMoreElements()) { String number = (String) num.nextElement(); if(number.equals(match)) { result.add(number); } } </code></pre>
java
[1]
2,215,683
2,215,684
php length or count string
<p>I am working on sorting some text, I want to count how many times a certain word occurs.</p> <p>the text part like</p> <blockquote> <p>I have no <strong>idea</strong>, you got some <strong>idea</strong>, we will work out some <strong>idea</strong>, I have no <strong>idea</strong>, you got some <strong>idea</strong>, we will work out some <strong>idea</strong>, I have no <strong>idea</strong>,you got some <strong>idea</strong>, we will work out some <strong>idea</strong></p> </blockquote> <p>how can I use php to count how many times "idea" occurred, like word "idea" occurred <strong>9</strong> I am confused on count and length.</p> <p>Could someone give an example please? many thanks</p>
php
[2]
2,406,099
2,406,100
typeerror python
<p>I looked into the example here <a href="http://stackoverflow.com/questions/35988/c-like-structures-in-python">C-like structures in Python</a></p> <p>But The example is of "bunch" but anyways the code is here</p> <pre><code>class Bunch: def __init__(self, **kwds): self.__dict__.update(kwds) </code></pre> <p>BUt I am using it like this</p> <pre><code>p = Bunch(x,y) </code></pre> <p>BUt I am getting a type error</p> <pre><code>TypeError: __init__() takes exactly 1 argument (3 given) </code></pre> <p>What am I doing wrong??</p>
python
[7]
2,959,485
2,959,486
How to add EditText in ListView multiple choice type
<p>I have inside LinearLayout ListView with multiple select choice(all strings). How to add on last position in ListView EditText. I have used ArrayAdapter to fill list with strings. How to add that field ?</p>
android
[4]
4,833,213
4,833,214
Why can't I display a new image using javascript?
<p>I am trying to create a page that allows viewers to view a new image every time the user clicks on it. The images are named 0.jpg, 1.jpg, 2.jpg, 3.jpg, and 4.jpg.</p> <p>However, the image URL never changes upon clicking. I also tried analyzing the image in Chrome Developer tools, and the console issues no errors. Why is that?</p> <p>Here is my javascript.</p> <pre><code>var imageCount = 5; var currentIndex = Math.floor(Math.random() * imageCount); function loadNewPhoto() { currentIndex = (currentIndex + (Math.random() * 3) + 1) % imageCount; alert(currentIndex); document.getElementById('generatedImage').src = 'images/' + currentIndex + '.jpg'; } // Shuffle order of photos. document.onready = function() { loadNewPhoto(); document.getElementById('getMeNewPhotoLink').onclick(function(e) { e.preventDefault(); loadNewPhoto(); }); } </code></pre> <p>and HTML</p> <pre><code>&lt;a href="#" id="getMeNewPhotoLink"&gt; &lt;img id="generatedImage" src="images/0.jpg" alt="" /&gt; &lt;/a&gt;​ </code></pre> <p><a href="http://jsfiddle.net/qLQZf/" rel="nofollow">http://jsfiddle.net/qLQZf/</a></p>
javascript
[3]
28,663
28,664
reading value from registry and storing it in a bin file in a folder
<p>I am writing a C# code. As shown in the image, I need to retrieve the value of a key called <code>LicenseKey</code> (right side of the image) from the registry path <code>HKEY_LOCAL_MACHINE/Software/Avtec, Inc/LicenseKey</code> and store the value in a bin file called <code>pml.bin</code></p> <p>Can anyone help me with the code? Thanks in advance.</p> <p><img src="http://i.stack.imgur.com/9yiU8.png" alt="enter image description here"></p>
c#
[0]
2,761,873
2,761,874
Testing an equation in JavaScript
<p>How can I test if a mathematical expression is true?</p> <pre><code>var equation = "1 + 1 = 2"; if (equation === true){ document.write("1 + 1 = 2"); }else{ document.write("1 + 1 =/= 2"); } </code></pre> <p>For obvious reasons, this code ^^^ doesn't work, but I just wanted to know if there was a function that would do this; evaluate a mathematical expression then return its verity as a boolean (true/false).</p>
javascript
[3]
367,151
367,152
get value of checked[ALL] or unchecked box jquery
<p>I have read this.</p> <p><a href="http://stackoverflow.com/questions/2048485/jquery-checkbox">http://stackoverflow.com/questions/2048485/jquery-checkbox</a></p> <pre><code>&lt;input type="checkbox" name="checkGroup" id="all"&gt; &lt;input type="checkbox" name="checkGroup" id="one" value="1"&gt; &lt;input type="checkbox" name="checkGroup" id="two" value="2"&gt; &lt;input type="checkbox" name="checkGroup" id="three" value="3"&gt; &lt;input type="hidden" name="storeCheck" value=""&gt; $(function(){ $("#all").click(function(){ $("input:checkbox[name='checkGroup']").attr("checked",$(this).attr("checked")); //array[1,2,3] will be pass to value of storeCheck }); $("input:checkbox[name='checkGroup']:not('#all')").click ( function(){ var totalCheckboxes = $("input:checkbox[name='checkGroup']:not('#all')").length; var checkedCheckboxes = $("input:checkbox[name='checkGroup']:not('#all'):checked").length; if ( totalCheckboxes === checkedCheckboxes ) { $("#all").attr("checked" , true ); } else { $("#all").attr("checked" , false ); } }); }); </code></pre> <p><a href="http://jsbin.com/uwoze" rel="nofollow">Demo</a></p> <p>I am trying to get the value of the checkboxs are checked as an array.</p> <p>for example </p> <pre><code>if I checked All Get value array_check = 1,2,3 and passed this array to hidden name="storeCheck" otherwise: Get value of array_check( checkboxs checked ).and passed this array to hidden name="storeCheck" </code></pre>
jquery
[5]
451,040
451,041
How come this is true?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4089284/why-does-0-5-3-return-true">Why does (0 &lt; 5 &lt;3) return true?</a> </p> </blockquote> <p>How come this is true?: </p> <p><code>console.log(100 &lt; 210 &lt; 200); // outputs true</code></p> <p>Oops! Your question couldn't be submitted because: It does not meet our quality standards.</p>
javascript
[3]
1,473,103
1,473,104
how can i rotate my screen shot image in IPhone?
<p>I am a newbie in IPhone programming.I was sending one of my views screen shot as email.How can i rotate my screen shot image to 270 degree to make it suitable for me ? Any help will be greatly appreciated..</p>
iphone
[8]
3,311,516
3,311,517
jQuery hover and active state
<p>I'm having some problems trying to make the hover and active state work on my website. I'm new to jQuery and I'm finding it difficult. This is the code that I currently have:</p> <pre><code>$(document).ready(function(){ $('.st_tab').hover(function(){ $(this).stop().animate({opacity : '0', left: '+=50',}, 100); }, function(){$(this).stop().animate({'opacity' : '1'}, 500);}) }); </code></pre> <p>I want it to work like this example : <a href="http://www.queness.com/resources/html/fadein/index.html" rel="nofollow">http://www.queness.com/resources/html/fadein/index.html</a></p> <p>I created a test page of site and you can see it here: <a href="http://jm-ai.com/test/index.html" rel="nofollow">http://jm-ai.com/test/index.html</a></p> <p>I'm using a sprite image for the normal, hover, and active state.</p> <p>The problem is that whenever I hover the animation disappears too quickly and when I click there is no animation.</p>
jquery
[5]
4,986,784
4,986,785
C# - How to find the custom tag's Name and Text from Html
<p>I have requirement where I have input Html like this - </p> <pre><code> &lt;col name="col1"&gt;Text1&lt;/col&gt; &lt;col name="col2"&gt;Text2&lt;/col&gt; &lt;col name="col3"&gt;text3&lt;/col&gt; </code></pre> <p>Now I have to parse this Html and create a csv file with below output - </p> <pre><code>col1,col2,col3 Text1,Text2,text3 </code></pre> <p>Please let me know how can this be achieved in C#.</p>
c#
[0]
141,467
141,468
Doing a foreach and ordering using $i++; for example but depending on a parent id in PHP
<p><strong>question updated:</strong></p> <p>I've the next array, obtained from a nested sortable tree. The <code>$key</code> means the id of a PAGE and the <code>$value</code> it's the parent id. In my MySQL table I've to modify the <code>parent_id</code> of every page (when updating) and store the ORDER of a PAGE depending of the parent ID.</p> <p>In the next example I've 3 ids with <code>parent_id</code> = 1: 5, 2 and 3. I've to update on MySQL 5,2 and 3 saving like:</p> <pre><code>UPDATE pages SET parent_id=1,order=0 WHERE id=5 UPDATE pages SET parent_id=1,order=1 WHERE id=2 UPDATE pages SET parent_id=1,order=2 WHERE id=3 Array ( [1] =&gt; 0 [5] =&gt; 1 [2] =&gt; 1 [3] =&gt; 1 [4] =&gt; 3 [6] =&gt; 3 ) </code></pre> <p>How I can handle this with PHP? I'll do a <code>foreach</code> for every page id and send a MySQL update on each of loop for the <code>foreach</code>?</p> <p>Thank you in advance!</p>
php
[2]
1,174,372
1,174,373
Parse “math340-05 =?UTF-8?B?4oCTIEF1ZmdhYmUgNS4x?=”
<p>I want to extract the subject from an email which is stored in an <code>.eml</code> file using Python 3:</p> <p>The subject line from the file is the following:</p> <pre><code>Subject: math340-05 =?UTF-8?B?4oCTIEF1ZmdhYmUgNS4x?= </code></pre> <p>I try to parse the name using the <code>email</code> module, but it returns the string as is:</p> <pre><code>with open(filename, "r") as f: m = email.message_from_file(f) print(m["Subject"]) </code></pre> <p>How can I decode that?</p>
python
[7]
4,906,572
4,906,573
ASIHTTP: addOperation when other threads are running
<p>I have a project using ASIHTTP to multi download files from a site</p> <p>when I add a new request:</p> <pre><code>[networkQueue cancelAllOperations]; [networkQueue setDownloadProgressDelegate:a]; [networkQueue setDelegate:self]; [networkQueue setRequestDidFinishSelector:@selector(requestDone:)]; NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request startAsynchronous]; [networkQueue addOperation:request]; [networkQueue go]; </code></pre> <p>it reported:</p> <p><strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> -[ASINetworkQueue addOperation:]: operation is executing and cannot be enqueued'</p> <p>It looks like I can not add a new request when others are running.</p> <p>Welcome any comment</p> <p>Thanks</p> <p>interdev</p>
iphone
[8]
4,865,182
4,865,183
JQuery hover function not working properly
<p>I have three images (ex. tab1.jpg) along with mouseover images (ex. tab1m.jpg) that I'm trying to reduce into a single JQuery hover function. Before I was using: </p> <pre><code>$('#tab1').hover(function(){ $(this).attr("src", 'images/tab1m.jpg'); }, function(){ $(this).attr("src", 'images/tab1.jpg'); }); $('#tab2').hover(function(){ $(this).attr("src", 'images/tab2m.jpg'); }, function(){ $(this).attr("src", 'images/tab2.jpg'); }); $('#tab3').hover(function(){ $(this).attr("src", 'images/tab3m.jpg'); }, function(){ $(this).attr("src", 'images/tab3.jpg'); }); </code></pre> <p>which worked, but was unnecessarily long and verbose. So I tried changing it to: </p> <pre><code>$('.navimg').hover(function(){ var tab = ($(this).attr('id')).substring(3,4); $(this).attr('src','images/tab'+tab+'m.jpg'); }, function(){ $(this).attr('src','images/tab'+tab+'.jpg'); }); </code></pre> <p>which hasn't been working--when I mouse over the image it changes successfully but does not revert back to the original (tab1.jpg/tab2/tab3) image. Can anyone tell me why this is happening? Thanks!</p>
jquery
[5]
912,779
912,780
C#: TextChanged event of a Control not firing on "assign"
<p>Ok, here's the deal.</p> <p>I have a graph, that "listens" to some labels' textfields, and graphs their values. It does this by adding the values on the TextChanged event.</p> <p>The problem: TextChanged only fires when the text has actually changed (obviously), and not when it has been assigned a new value.</p> <p>What I need: A way to detect if the Text field of label has been updated (assigned to), and all I have to work with is a reference to the Control (ie the Label).</p> <p>I realize TextChanged wasn't designed for this, which is why I'm wondering if any of you guys have encountered a similar problem, and found a solution to it.</p>
c#
[0]
2,754,424
2,754,425
Live feedback on how many chars there are left in textbox
<p>I have a textarea element what i want to limit to, lets say, 100 chars. my current task is to give a visual feedback to the user. Starting with empty box it should be "100 chars left".</p> <p>Now, i added a javascript function charsLeft() to the textarea's onChange but it works only 50% as intended. It only updates the div containing the number when i leave (focus) the textarea and not as i type. how do i go about to do that? So that my user can see, as they type, how many chars they have left in my textarea?</p>
javascript
[3]
4,519,631
4,519,632
how to test android.intent.action.SYNC
<p>Does anybody know the working of <code>android.intent.action.SYNC</code>? How would one go about testing a <code>android.content.BroadcastReceiver</code> which waits for this event.</p> <p>Wait unti it happes. If so, how often does it happen?</p> <p>Send yourself a message with adb? If so, what do you send to make it realistic?</p>
android
[4]
5,817,530
5,817,531
Python counting file extensions
<p>I am trying to print the file extension in a certain directory and the count of each extension.</p> <p>This is what I have so far...</p> <pre><code>import os import glob os.chdir(r"C:\Python32\test") x = glob.glob("*.*") for i x: print(i) &gt;&gt;&gt; file1.py file2.py file3.py file4.docx file5.csv </code></pre> <p>So I am stuck, I need my overall output to be...</p> <pre><code>py 3 docx 1 csv 1 </code></pre> <p>I have tried to use something like i.split("."), but I get stuck. I think I need to put the extension in a list and then count the list, but that is where I am running into problems.</p> <p>Thanks for the help.</p>
python
[7]
132,404
132,405
virtual path change
<p>I want to change Virtual Path(The path is out of project means local system or Server.) of the file Which is save on the folder in asp.net.</p> <p>Code is</p> <pre class="lang-default prettyprint-override"><code>DataTable dtFiles = GetFilesInDirectory(HttpContext.Current.Server.MapPath(UPLOADFOLDER)); gv.DataSource = dtFiles; gv.DataBind(); if (dtFiles != null &amp;&amp; dtFiles.Rows.Count &gt; 0) { double totalSize = Convert.ToDouble(dtFiles.Compute("SUM(Size)", "")); if (totalSize &gt; 0) lblTotalSize.Text = CalculateFileSize(totalSize); } private static string UPLOADFOLDER = "D:/Uploads"; </code></pre> <p>And the error show "D:/Uploads is not a valid virtual path.".</p>
asp.net
[9]
3,906,291
3,906,292
Android Seekbar Thumb position
<p>i want to place the thumb of the seek bar in android at extreme right corner which is by default at extreme left corner.Is it possible ?</p>
android
[4]
1,344,480
1,344,481
Custom UITableViewCell with round rect
<p>I have created custom tableViewCell.My table is of grouped style.My custom tableViewCell is having background color.Problem is cells will come round rect but there is still some white color view backside of my cell.So how to create custom cell with round rect so that ican set background color and add multiline text. I tried creating background view of round rect.It worked.But i have to create one more view to add multiline text.Is there way to create cell with background color,multiline text and round rect's.</p>
iphone
[8]
797,074
797,075
conditional python with
<p>I have a five or six resources that have nice 'with' handlers, and normally I'd do this:</p> <pre><code>with res1, res2, res3, res4, res5, res6: do1 do2 </code></pre> <p>However, sometimes one or more of these resources should not be activated. Which leads to very ugly repetitive code:</p> <pre><code> with res1, res3, res4, res6: # these always acquired if res2_enabled: with res2: if res5_enabled: with res5: do1 do2 else: do1 do2 else if res5_enabled: with res5: ... </code></pre> <p>There must be clean easy ways to do this surely?</p>
python
[7]
3,388,328
3,388,329
tokenizer and "Exception in thread "main" java.lang.NullPointerException" runtime error
<p>I'm trying to tokenize a string and assign each token to a cell of array in java. this is my code to tokenize but I got following run-time error:</p> <pre><code>Exception in thread "main" java.lang.NullPointerException </code></pre> <p>this error is appeared at line 10.</p> <p>can anybody help me to solve this error bye an example????? </p> <pre><code>#1 Scanner in = new Scanner(System.in); #2 System.out.print("Enter your name: "); #3 String name = in.nextLine(); #4 String a[]=null; #5 int i=0; #6 StringTokenizer tokenizer=new StringTokenizer(name," "); #7 while (tokenizer.hasMoreTokens()) #8 { #9 String token = tokenizer.nextToken(); #10 a[i]= token; #11 i++; #12 } </code></pre>
java
[1]
382,182
382,183
Read a file without storing on the server?
<p>I have created a program that decrypts whats stored in a export file from a certain program,</p> <p>at the moment people need to open the file and copy and paste into a text feild, i know that i can use the form type "file" but to read the contents of what has been POSTED it needs to be saved to the server if i am correct?</p> <p>Is there no way of just reading the file contents without saving it to the server?</p> <p>Thanks!</p>
php
[2]
2,373,958
2,373,959
How to set Input Box max length propert
<p>I want to add an input box with <code>max-length</code> property, But when I set its max length property to 500 and enter maximum text in input box, it's not taking maximum text. Its only working when I enter a limit text in Input Box.</p>
asp.net
[9]
5,493,707
5,493,708
importing files residing in an unrelated path
<p>Consider I have a directory called <code>root</code> that has two directories: <code>x</code> and <code>y</code>. I have a module file that resides in <code>x</code>, let us call that <code>test.py</code>. Now in <code>y</code>, I have a module that needs to call <code>test.py</code></p> <p>I am doing a simple:</p> <p><code>from x import test</code></p> <p>And it works. I was wondering, how this works? </p> <p>EDIT: How it works, as in there was no <code>__init__.py</code> file in <code>x</code>, but yet from <code>y</code> I was able to call a module from there.</p>
python
[7]
2,024,792
2,024,793
receiving unexpected T_CONSTANT_ENCAPSED_STRING, Create Directory
<p>I tried to create folder directory name "code", and I want to save it to "status.txt".</p> <p>This is my code problem with received the unexpected T_CONSTANT_ENCAPSED_STRING.</p> <pre><code>if(is_writeable($newdir . "/status.txt")) { if (fwrite($statusTxt, $statusCode . "," . $status . "," . $share . "," . $date . "," . $permission "\n")){ } </code></pre> <p>Is this way is correct to create a directory and save it to status.txt? Below is the rest of the code.</p> <p>Thank you so much, and appreciate for the help.</p> <pre><code>$newdir = "../../data/code"; umask(0007); if(!file_exists($newdir)) { mkdir($newdir, 02770); $statusTxt = fopen($newdir. "/status.txt", "a"); } if(is_writeable($newdir . "/status.txt")) { if (fwrite($statusTxt, $statusCode . "," . $status . "," . $share . "," . $date . "," . $permission "\n")){ } echo "&lt;p&gt;Your form has succesfully been submit!&lt;/p&gt;"; } fclose($statusTxt); } </code></pre>
php
[2]