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,859,022
4,859,023
PHP script to find domain name age
<p>I am trying to write a script (in PHP) that find a domain age (creation date and maybe if possible, last update and expiration date as well). I want the script to return something like: 2009,2009,2010 if creation date is 2009, update date is 2009, and expiration is 2010 (an array)</p> <p>help?</p> <p>(This is NOT a homework question so please provide as much help as possible)</p> <p>If you need more information to explain the problem please write a comment and I will be glad to provide more information</p>
php
[2]
3,962,460
3,962,461
Replacing function contents dynamically in JavaScript
<p>How do you completely replace a function in JavaScript? </p> <p>I got this code, but it doesn't work. The DOM gets updated, though. What's up with that?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script id="myScript" type="text/javascript"&gt; function someFunction() { alert("Same old."); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="button" onclick="someFunction();" value="A button." /&gt; &lt;script&gt; function replace() { var oldFunctionString = someFunction.toString(); var oldContents = oldFunctionString.substring(oldFunctionString.indexOf("{") + 1, oldFunctionString.lastIndexOf("}") ); var newCode = "alert(New code!);"; var newFunctionString = "function someFunction(){"+newCode+"}"; var scriptTag = document.getElementById('myScript'); scriptTag.innerHTML = scriptTag.innerHTML.replace(oldFunctionString,newFunctionString); } replace(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>JSfiddle <a href="http://jsfiddle.net/6yAaw/" rel="nofollow">here</a></p>
javascript
[3]
245,716
245,717
PHP Include operator can't seem to find php script
<p>I am having an odd problem that continues to baffle me. I appreciate your advice....</p> <p>In a PHP 5.3 script I am including another PHP script using the following code; </p> <pre><code>include 'moninit.php?id=1234'; // initialize array variables </code></pre> <p>moninit.php is stored as C:\xampp\htdocs\CarmelServices\moninit.php</p> <p>In php.ini the include path is: </p> <pre><code>include_path = "C:\xampp\htdocs\CarmelServices" </code></pre> <p>So, the <code>include</code> should execute moninit.php but I get the following error returns; </p> <blockquote> <p>Warning: include(moninit.php?id=1234) [function.include]: failed to open stream: No error in C:\xampp\htdocs\CarmelServices\SensorW.php on line 48</p> <p>Warning: include() [function.include]: Failed opening 'moninit.php?id=1234' for inclusion (include_path='C:\xampp\htdocs\CarmelServices') in C:\xampp\htdocs\CarmelServices\SensorW.php on line 48</p> </blockquote> <p>If I execute moninit.php directly using a browser, it works fine. So, somehow the include cant seem to find moninit. SensorW is also in the same folder as moninit. </p> <p>Very odd, at least to me. Thanks!</p>
php
[2]
2,478,761
2,478,762
How to reset a PHP environment?
<p>At some point in my code, I want to undo everything that has been made and simulate a fresh start in some file.php.</p> <p>Example: Unsetting all variables, all functions, all classes, etc.</p> <p>Is there a way to do this?</p> <hr> <h2>DETAILS</h2> <p>I have a framework that redirects all the requests to <code>index.php</code> but i want to roll some tests on it (testing the framework itself!). So i need to write a controller to access <code>/test/index.php</code> and it will start including the files and testing the functions and stuff. The thing is, I will get errors if the files are already included, the classes already exists, etc.</p>
php
[2]
1,364,330
1,364,331
implementing a file deletetion function
<p>I have a system, where users (even public) can upload *.pdf files,now I want to implement a feature which provides the ability to delete the uploaded files. </p> <p>This is what I have in mind :</p> <ul> <li>create an unique delete hash for each file and store it in database ( associate it with unique id of each file )</li> <li>Generate and display the delete url to the user who has uploaded the file</li> <li>When the delete url (Along with id and hash ) is called, check if the delete hash matches with the id</li> <li>unlink the file </li> </ul> <p>is this system ok ? I just want to make sure the user can delete only the file which he has uploaded , but not other files.</p> <p>Thanks</p> <p>Edit : Please suggest me a method to create a hash , which cannot be guessed .</p>
php
[2]
45,903
45,904
How can I play a movie and add a text overlay with DirectX in C#
<p>How can I play a movie and add a text overlay with DirectX in C#, please specify some references, because I am new in this area.</p>
c#
[0]
837,242
837,243
JavaScript constants | Style and keyword
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/130396/are-there-constants-in-javascript">Are there constants in Javascript?</a> </p> </blockquote> <p>For example here i set the close time on this menu to 1 second or 1000 miliseconds.</p> <p>Does javascritp have a const like C or a Define like PHP? </p> <pre><code>menu.menu_timer=window.setTimeout(menu.hide_menu, 1000); </code></pre>
javascript
[3]
3,055,845
3,055,846
Can someone explain Python hasattr/delattr on a method attribute?
<p>I've got a bug caused by some weird behavior. I might be fundamentally missing something about the semantics of function attributes. Or it may be a bug. I'm on </p> <pre><code>$ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 </code></pre> <p>First I define a class, and add an attribute to one of its methods.</p> <pre><code>&gt;&gt;&gt; class Foo(object): ... def bar(self): ... pass ... bar.xyzzy = 'magic' ... </code></pre> <p>Now I can see that exists on <code>Foo.bar</code></p> <pre><code>&gt;&gt;&gt; hasattr(Foo.bar, 'xyzzy') True </code></pre> <p>And I can retrieve it.</p> <pre><code>&gt;&gt;&gt; Foo.bar.xyzzy 'magic' &gt;&gt;&gt; getattr(Foo.bar, 'xyzzy') 'magic' </code></pre> <p>But I can't delete it.</p> <pre><code>&gt;&gt;&gt; del Foo.bar.xyzzy Traceback (most recent call last): ... AttributeError: 'instancemethod' object has no attribute 'xyzzy' &gt;&gt;&gt; delattr(Foo.bar, 'xyzzy') Traceback (most recent call last): ... AttributeError: 'instancemethod' object has no attribute 'xyzzy' </code></pre> <p>Any ideas why? I assume it is something to do with the fact that <code>Foo.bar</code> is being reported as an 'instancemethod' here, rather than an unbound method if you just ask what <code>Foo.bar</code> is. But I'm not sure if it is an expected side-effect, if I'm misunderstanding something, or if there's a bug.</p>
python
[7]
5,549,749
5,549,750
Android: R cannot be resolved after adding a new class
<p>I get the following error in eclipse: <code>r cannot be resolved</code>. However that appeared just after I added my own library as a resource to my project. It seems that eclipse cannot resolve which R to use, the library one or the project one. Note also that the library is marked with the <em>is library</em> check box in the project set-up. Also whenever I remove my library from the reference list eclipse does not show any errors, but upon compiling logCat shows a <code>Class Not Found</code> exception. How do I fix this issue? Thanks</p>
android
[4]
4,891,270
4,891,271
Passing/Using non primitive objects between Activities
<p>I need to pass a List of my objects between activities. I do not want to use parcelable or serialize the data each time. I also do not want to save it in a local file or database. That probably leaves me with using static objects.</p> <p>Lets say I to use ListA between activities Activity1 to Activity2. I ca</p> <p>Approach1: Create a static ListA in one of those activities and do all my stuff of that static ListA.</p> <p>Approach2: Create a static list in another class which I use just for storing this List and doing all my stuff on this list. But this means that this stays as long as my process is running and I have to manually set it to null when I do not need it.</p> <p>Approach3. I am extending the above class to implement it using a static HashMap. I have two methods one to store the list in a static HashMap using a unique key and another method to retrieve the list and remove it each time data is retrieved so that the List is no longer present in the static HashMap. So we essentially have to pass only the random key generated to store data between activities which I can pass as an extra using Intents.</p> <p>Will there be any issues when I use any of the above approaches and which will be the best approach.</p>
android
[4]
4,776,925
4,776,926
C# how to Register exe?
<p>How Would I find another exe's path by knowing its name in .net?</p> <p>Would I add name to the OS environment variable? Would the other application have to 'register' itself somewhere else?</p> <p>I need App A to start-up App B and call some WCF services on it.</p> <p>Thanks!</p>
c#
[0]
489,754
489,755
Using a PHP Counter and want to use mutiples of 3
<p>So I've got this code here</p> <pre><code>&lt;?php $COUNT = 0; if ($handle = opendir('.')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." &amp;&amp; $entry != ".." &amp; $count % 3 == 0) { echo "&lt;td&gt;&lt;a href='$entry'&gt;$entry&lt;/a&gt;&lt;/td&gt;"; echo $Count; $Count++; } else {echo "&lt;tr&gt;&lt;td&gt;&lt;a href='$entry'&gt;$entry&lt;/a&gt;&lt;/td&gt;&lt;tr&gt;"; echo $Count; $Count++; } } closedir($handle); } ?&gt; </code></pre> <p>and I just can't seem to get it to work. I want a new table row every time the counter is a mutiple of 3</p>
php
[2]
215,000
215,001
Android Light Sensor stops Reporting when display turned off in Jelly Bean with Nexus 7
<p>I have an app that needs to read the light sensor values when the display is off. This works fine a Galaxy Nexus running ICS, however with the new Nexus 7 the light sensor is disabled as soon as the display is turned off. Accelerometer still works when the display is off but light sensor does not work until display is turned back on. This is running in a foreground service with a partial wakelock. </p> <p>Is there a way to overcome this in software or is this a hardware difference that cannot be overcome?</p>
android
[4]
614,703
614,704
How to read a file with variable multi-row data in Python
<p>I have a file that is about 100Mb that looks like this:</p> <pre><code>#meta data 1 skadjflaskdjfasljdfalskdjfl sdkfjhasdlkgjhsdlkjghlaskdj asdhfk #meta data 2 jflaksdjflaksjdflkjasdlfjas ldaksjflkdsajlkdfj #meta data 3 alsdkjflasdjkfglalaskdjf </code></pre> <p>This file contains one row of meta data that corresponds to several, variable length data containing only alpha-numeric characters. What is the best way to read this data into a simple list like this:</p> <pre><code>data = [[#meta data 1, skadjflaskdjfasljdfalskdjflsdkfjhasdlkgjhsdlkjghlaskdjasdhfk], [#meta data 2, jflaksdjflaksjdflkjasdlfjasldaksjflkdsajlkdfj], [#meta data 3, alsdkjflasdjkfglalaskdjf]] </code></pre> <p>My initial idea was to use the <code>read()</code> method to read the whole file into memory and then use regular expressions to parse the data into the desired format. Is there a better more pythonic way? All metadata lines start with an octothorpe and all data lines are all alpha-numeric. Thanks!</p>
python
[7]
4,837,313
4,837,314
Open links in a new window
<p>I have a div called 'divLinks'</p> <p>I want all links inside the divLinks to open in a new window.</p> <p>How can I write a cross-browser effective script to achieve this?</p>
javascript
[3]
3,387,458
3,387,459
some code's meaning of javascript?
<pre><code> &lt;script language="JavaScript" type="text/javascript"&gt; var city=[ ["city1","city2","city3","city4"], ["city5","city6","city7"], ["city8","city9","city10"], ]; function getCity(){ var sltProvince=document.form1.province; var sltCity=document.form1.city; var provinceCity=city[sltProvince.selectedIndex - 1]; sltCity.length=1; for(var i=0;i&lt;provinceCity.length;i++){ sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]); } } &lt;/script&gt; &lt;FORM METHOD=POST ACTION="" name="form1"&gt; &lt;SELECT NAME="province" onChange="getCity()"&gt; &lt;OPTION VALUE="0"&gt;select province &lt;/OPTION&gt; &lt;OPTION VALUE="province1"&gt;province 1 &lt;/OPTION&gt; &lt;OPTION VALUE="province2"&gt;province2&lt;/OPTION&gt; &lt;OPTION VALUE="province3"&gt;province3 &lt;/OPTION&gt; &lt;/SELECT&gt; &lt;SELECT NAME="city"&gt; &lt;OPTION VALUE="0"&gt;select the city&lt;/OPTION&gt; &lt;/SELECT&gt; &lt;/FORM&gt; </code></pre> <p>the above code is according to the province select its city. there are some lines i don't understand well. expect some one can explain it. thank you.</p> <p>1, what's these lines do and meaning? </p> <pre><code>var provinceCity=city[sltProvince.selectedIndex - 1]; </code></pre> <p>and</p> <pre><code> sltCity.length=1; sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]); </code></pre>
javascript
[3]
1,358,044
1,358,045
Conversion of .wav to .mp3 file
<p>Hi I am new to android platform. I am struck at one place i want to convert .wav file to .mp3 <strong>is this possible in android</strong>? if possible can you recommend any of them. Thank you.</p>
android
[4]
4,214,273
4,214,274
.keyup or .change events to trigger for readonly fields in jquery?
<p>I have list of input fields. In which some are readonly fields. I am using .keyup() event to trigger when something changes in input field. But it won't effect for readonly field. Somehow i want to change those fields also . Any help?</p>
jquery
[5]
3,664,484
3,664,485
Passing reference types into variable argument list
<pre><code>int g_myInt = 0; int&amp; getIntReference() { return g_myInt; } void myVarArgFunction( int a, ... ) { // ......... } int main() { myVarArgFunction( 0, getIntReference() ); return 0; } </code></pre> <p>In the (uncompiled and untested) C++ code above, is it valid to pass in an <code>int&amp;</code> into a variable argument list? Or is it only safe to pass-by-value?</p>
c++
[6]
1,983,575
1,983,576
Android draw marker in runtime or at on LocationChange?
<p>It is possible to draw markers in runtime or at onLocationChange event, not on Create event?</p>
android
[4]
4,808,663
4,808,664
How to set RadioButton properties in code?
<p>I'm using this code to dynamically create new RadioButton in Android:</p> <pre><code>RadioButton radioButton = new RadioButton(getBaseContext()); radioButton.setText("test text"); radioGroup.addView(radioButton); </code></pre> <p>I need to set RadioButton properties "android:button", "android:minWidth" and "android:textAppearance" in code (not in xml), before adding radioButton to radio group.</p>
android
[4]
87,911
87,912
Get absolute path of current script
<p>I have searched high and low and get a lot of different solutions and varialbles containing info to get the absolute path. But they seem to work under some conditions and not under others. Is there one silver bullet way to get the absolute path to the current executing script in php? For me the script will be running from the command line but it should just as well function if run within apache etc.</p> <p>Clarification: The initial executed script (I only had one here so therefore I missed stating that)</p>
php
[2]
801,309
801,310
Change photo background and css with jquery
<p>My client want the background of his website change in a kind of slideshow(like supersized script does) but the tough thing is that he wants to change css bg color of the menu container also to match the photo (like on <a href="http://www.blitzagency.com" rel="nofollow">http://www.blitzagency.com</a>).</p> <p>How would you do that?</p> <p>Any clue is welcome.</p> <p>Thks Sam</p>
jquery
[5]
4,481,844
4,481,845
Distance Matrix Api returned wrong results randomly
<p>I'm trying to figure out a bug in a web form that I've create that uses the Distance Matrix API.</p> <p>I basically have a simple web form requires the user to enter his or her postal code which then I use the distance Matrix API to return the closest location that I have within a list presented in an XML format which I then set with in a hidden field that I submit and capture the data for later use.</p> <p>What I've created works fine. The problem that I'm having is that out of 100 hundred users submissions 2 out of the 100 submissions return the wrong results. The closest location didn’t correspond to what was returned.</p> <p>My form is pretty bullet proof it’s using all the right types of validations in order to prevent the user from giving wrong values to the API to return wrong results.</p> <p>I’ve even looked up the postal code that the users entered on Google maps and the location was good, as well as my XML list of locations which the API will return the closest driving distance to that location with a comparison made from my XML.</p> <p>I was wondering if anyone has ever had similar issue with wrong a result randomly returned by the API?</p>
javascript
[3]
207,296
207,297
How to make drop down content with javascript?
<p>I want to add a similar function on my blog like on <a href="http://techcrunch.com/2011/08/04/groupon-acquires-software-devlopment-startup-obtiva/" rel="nofollow">http://techcrunch.com/2011/08/04/groupon-acquires-software-devlopment-startup-obtiva/</a> when you press on author. It is a drop down made with javascript. Anybody can help with a similar javascript as I was trying different implementations for the whole night with no luck.</p> <p>Thanks in advance!</p>
javascript
[3]
5,544,847
5,544,848
Do I need to dynamically allocate double arrays to pass them?
<p>Here's a simple compile error, I'm allocating double arrays like so:</p> <pre><code>double mixmu[][1] = {{1},{-1}}; double mixvar[][1] = {{1},{1}}; double coef[] = {1,1}; </code></pre> <p>can I not pass these as double** objects?</p> <pre><code>error: no matching function for call to ‘MixtureModel::MixtureModel(int, int, double [2], double [2][1], double [2][1], Distribution*)’ ./problems/MixtureModel.h:25: note: candidates are: MixtureModel::MixtureModel(int, int, double*, double**, double**, Distribution*) </code></pre>
c++
[6]
2,568,664
2,568,665
How do I change a display using TreeView?
<p>I'm trying to change a panel to a specific form (as this is the only way I can fathom it) based on the selected TreeView node. For example, in Visual Studio, if you right-click on "Solution 'solutionname' (1 Project)", click 'Properties', it comes up with a tree list on the left side. When you click on a selection, the right pane changes.</p> <p>I've searched continuously for hours the previous few days and only found a tutorial showing how it can affect a webBrowser control.</p> <p>This is a farfetched example that I can understand:</p> <p><code>private void tree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)<br> {<br> treeNode nName = e.Node;<br> //For testing:<br> string pg = "";<br> pg = nName.Tag;<br> if (pg == "Form2") display = Form2;<br> } </code></p> <p>Display is a panel. I know this is absolutely wrong, but I couldn't find any proper method using my search terms.</p>
c#
[0]
5,997,264
5,997,265
How to use JQuery to load images with callback facility
<p>i use this code to preload images.</p> <pre><code>var ImagePath='../images/pop.gif'; var _images = [ImagePath]; $.each(_images, function (e) { $(new Image()).load(function () { }).attr('src', this); }); </code></pre> <p>i want to attach a callback which will notify when image load completed in client machine. please guide me. thanks</p> <h2>UPDATE</h2> <p>just see my below code. i just need to know can i write in this way to notify when each image loading will be completed.</p> <pre><code>$.each(_images, function (e) { $(new Image()).load(function () { // image load completed }).attr('src', this); }); </code></pre> <p>please guide. thanks</p>
jquery
[5]
919,073
919,074
Javascript variable scope inside for loop
<p>How do I maintain access to the <code>i</code> variable inside my for loop below? I'm trying to learn, not just get the answer, so a bit of explanation would be very helpful. Thank you!</p> <pre><code>var el, len = statesPolyStrings.length; for (var i = 0; i &lt; len; i++) { el = document.getElementById(statesPolyStrings[i]); google.maps.event.addDomListener(el, 'mouseover', function() { $("#"+statesPolyStrings[i]).addClass("highlight"); statesPolyObjects[i].setOptions({ strokeWeight: '2' }); }); } </code></pre>
javascript
[3]
1,260,670
1,260,671
Server's MySQL DB is updated only in Debug mode
<p>I have the following server-client relationship:</p> <p>This is the relevant part of the Server's code:</p> <pre><code>public class Server { public static void main(String[] args) throws IOException{ ServerSocket server=new ServerSocket(7000); final ControllerInterface iController=new ControllerInterface(); iController.initializeDatabase(); while(true){ final Socket socket=server.accept(); new Thread(new Runnable() { public void run(){ try{ PrintStream outputStream=new PrintStream(socket.getOutputStream()); ObjectInput objectInputStream=new ObjectInputStream(socket.getInputStream()); int choose=inputStream.readInt(); while(choose!=0){ switch(choose){ case 1: Document doc=(Document)objectInputStream.readObject(); iController.readFromFile(doc); break; </code></pre> <p>And this is the relevant part from the Client's code:</p> <pre><code>private void scanBuilding(){ String xmlFilePath=Console.readString("Please enter xml file path:"); try{ //get the xml file SAXBuilder builder = new SAXBuilder(); File xmlFile = new File(xmlFilePath); Document document = (Document) builder.build(xmlFile); //pass xml file to controller objectOutputStream.writeObject(document); Console.printPrompt("The buildings was inserted successfully."); } </code></pre> <p>Problem is, that when I run the program normally, the Server does not recieve the object the Client is sending to it.</p> <p>But, in debug mode, if I put breakpoint INSIDE iController's readFromFile method, it does.</p> <p>Any ideas?</p>
java
[1]
3,119,558
3,119,559
What is the rationale behind the decision to have "null as string" return null?
<p>Is there any compelling reason, beyond backwards compatibility, for:</p> <pre><code>(null as string) == null; //true </code></pre>
c#
[0]
1,829,195
1,829,196
Data Sharing Strategy Among Activities and Remote Service
<p>I was wondering, is there any good data sharing strategy, among Activities, and a spawned remote service running in separate process. So far, I had tried 3 methods, none of them work.</p> <h2>Use <code>Application</code></h2> <p>I first thought, there will be only an <code>Application</code>, shared among 2 different processes, as their are origin from a single application. </p> <p>But that is not the case. I realize, before a main <code>Activity</code> is created, an <code>Application</code> will be created. When I spawn a remote service, another new <code>Application</code> instance will be created too.</p> <h2>Use <code>Preferences</code></h2> <p>My first thought is that, this is a file based. So, whenever I write a value to <code>Preferences</code> through <code>sharedPreferences.edit().putString(key, value).commit()</code>, the change will be committed to file. Another process should be able to read the latest changes. </p> <p>But this is not the case. My guess is that, this is because in my service, I acquire the <code>Preferences</code> instance only once during service start up through <code>PreferenceManager.getDefaultSharedPreferences(application)</code>. It only read value from file during 1st time. Subsequent call <code>getString</code> will be read from memory.</p> <h2>Use Global Static Variables</h2> <p>Not workable as <code>Activity</code> and remote <code>Service</code> are in 2 different processes. They are having 2 different memory spaces.</p> <p>Any better strategy I can try out?</p>
android
[4]
1,454,150
1,454,151
How to make Transparent GLsurfcaeview and adding some android widgets(textview etc) above it
<p>I want to make transparent glSurfaceView with some 3d bars on it and want to place it in another view with some background image. I am doing it by setting the ZorderOnTop to TRUE, and it is coming fine. But at same time i want to place some textview, labels or another view with some text over the GLSurfaceView. My problem is by setting the ZOrderOnTop to true the background is transparent but other widgets cannot be added above the 3d bars of glsurfaceview.</p> <p>How can i resolve this problem. Thanks in advance.</p>
android
[4]
3,849,056
3,849,057
Different NSTimeZone names being returned
<p>I've noticed that on some devices the <code>NSTimeZone</code>'s <code>name</code> method for a particular timezone can return different values. When testing the Brisbane time zone, my device returns <code>@"Australia/Brisbane"</code> whereas another user's device returns <code>"Etc/GMT-10"</code>. Both iPhone's are running 3.1.2.</p> <p>The <a href="http://developer.apple.com/IPhone/library/documentation/Cocoa/Conceptual/DatesAndTimes/Articles/dtTimeZones.html#//apple_ref/doc/uid/20000185" rel="nofollow">Date and Time Programming Guide for Cocoa</a> states that:</p> <blockquote> <p><strong>timeZoneWithName</strong>: The name passed to this method may be in any of the formats understood by the system, for example EST, Etc/GMT-2, America/Argentina/Buenos_Aires, Europe/Monaco, or US/Pacific, as shown in the following code fragment.</p> </blockquote> <p>I'd just like to know what could determine which value is used? The device? The language?</p>
iphone
[8]
1,714,830
1,714,831
List assignment to other list
<p>Is there a reason that assigning a list to another list and changing an item in one reflects the change in both, but changing the entire list of one does not reflect the change in both?</p> <pre><code>a=5 b=a a=3 print b #this prints 5 spy = [0,0,7] agent = spy spy[2]=8 print agent #this prints [0,0,8] spy = [0,0,7] agent = spy spy = "hello" print agent #this prints [0,0,7] </code></pre>
python
[7]
3,519,005
3,519,006
How to pass current id in fancybox jquery as a parameter
<pre><code>$("#image_data a").fancybox( { 'titlePosition' : 'inside', 'docid': $('#company_name').val(), 'productId' : '1234' }); </code></pre> <p>How i can pass productId as a current id of a tag.</p> <pre><code>$("#image_data a").fancybox( { 'titlePosition' : 'inside', 'docid': $('#company_name').val(), 'productId' : $(this).attr('id') }); </code></pre> <p>Given code is not working, So any other ideas.</p>
jquery
[5]
2,684,006
2,684,007
Need help on a php school problem
<p>I am currently in a class for the first time for php. I have run into a problem that I am racking my brain over. It consist of having to show function for OTpay. It has a pay rate, total weekly hours, regular pay, overtime pay, and also weekly pay. And it has to have an echo to the page to fill in a submit box when finished. Would appreicate any help.</p>
php
[2]
4,152,130
4,152,131
printing out lists and dictionaries with indents in python
<p>Is there any way to print lists or dictionaries (or a list with a dictionary in it) in a human readable format (multi-line,indented) instead of just on one long line?</p>
python
[7]
1,525,429
1,525,430
How to get user's google market account?
<p>How can I get the user's market account, the account with which they install applications in google market, from code?</p>
android
[4]
2,570,855
2,570,856
how do i pass a variable to a function in this context?(for an onclickevent)
<pre><code>function check(child) { var y = "&lt;span onclick=remove(" + child + ") onmouseover='hove(this)'&gt;x&lt;/span&gt;"; child = child + " " + y; send = '&lt;span class="elements" &gt;' + child + '&lt;/span&gt;' ; } function remove(child) { // some of mycode; } </code></pre> <p>These are the 2 functions I have. OK let me tell you this, child is a variable passed from one function to the check() function and again im trying to pass this child value to remove function, adding to the onclick event of span tag but it does not seem to work. I am unable to get out of this.</p> <p>I want to add onclick event to the span tag and it should pass the child value to remove function. Please help me with this. Any help is greatly appreciated. Thanks</p>
javascript
[3]
5,423,053
5,423,054
how to set color for the textView in android?
<p>In the string.xml file i use the following tag </p> <pre><code>&lt;color name="mycolor1"&gt;#F5DC49&lt;/color&gt; </code></pre> <p>if i use </p> <pre><code> textview1.setTextColor(Color.CYAN); </code></pre> <p>it works, But</p> <pre><code> textview1.setTextColor(R.color.mycolor1); </code></pre> <p>This is not working</p> <p>how to use the color tag in android.</p>
android
[4]
1,699,835
1,699,836
Dynamic Data Connection
<p>I am Building Dynamic Data ASp.net web site. In the application user is provided with login box where user will enter his user id and password. But we need pass the entity connection string in Glabal.ASAX file. At this point I do not have user id and passowrd. How Should handle this DynamicData</p>
asp.net
[9]
4,235,515
4,235,516
Android password lock
<p>i want a code to lock my phone and open with only with a specific password.and also if possible tell me how can i change the fuctionality red button of an android phone The phone lock will ask the password for the first time and will save that permanently and till the time the user don't enter that password it wont let user do anything else.</p>
android
[4]
2,738,056
2,738,057
PHP: Finding the text between <p>'s
<p>Quick and probably incredibly easy question;<br/></p> <pre><code>$str="&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque turpis risus, rutrum pretium scelerisque nec, sollicitudin ac quam. Nulla eu dolor sapien, id bibendum augue. Aliquam eu nunc mi. Nam consectetur vestibulum leo elementum condimentum. Etiam varius malesuada sapien eget fermentum. Aenean ut massa lacus. Duis non enim enim. &lt;/p&gt; &lt;p&gt;Nam egestas laoreet eros, a mattis dui fringilla ac. Aliquam erat volutpat. Mauris mattis vulputate condimentum. Vivamus libero quam, tincidunt at viverra id, iaculis a tellus. Cras venenatis ante non enim interdum ac adipiscing neque euismod. Pellentesque nec elementum metus. &lt;/p&gt;" </code></pre> <p>I would like to obtain each text between '&lt; p >' tags. Since I'm a beginner php programmer I wanted to ask if there is any easy way before constructing a straight-forward <b>for</b> loop.</p>
php
[2]
3,543,243
3,543,244
Python not defined error when using with block
<pre><code>class fcount(object): def __init__(self, func): self.func = func self.count = 0 self.context_count = 0 def __enter__(self): self.context_count = 0 def __call__(self, *args): self.count += 1 self.context_count += 1 return self.func(*args) def __exit__(self, exctype, value, tb): return False </code></pre> <p>This is a decorator. The idea is to keep a separate count when using a 'with' block.</p> <p>If I do this:</p> <pre><code>@fcount def f(n): return n+2 with fcount(foo) as g: print g(1) </code></pre> <p>I get this error: TypeError: 'NoneType' object is not callable</p> <p>I tried printing out the type of g inside that with block, and of course the type is None.</p> <p>Any idea why g isn't being assigned to fcount(foo)?</p> <p>This does work:</p> <pre><code>g = fcount(foo) with g: g(1) </code></pre>
python
[7]
1,021,270
1,021,271
Is there anyway to know if user stopped loading a page?
<p>I want to know if it's possible to know if a user has let a page to load or he has clicked de X from chrome or firefox to stop it perfoce.</p> <p>I have this code:</p> <pre><code>jQuery(window).load(function () { if (condition == 1){ ... else ... </code></pre> <p>If user let to load the website until the end, first condition will comply.</p> <p>If user forces to stop the loading, second condition will comply.</p>
jquery
[5]
2,231,765
2,231,766
How can I add all of my array values together in PHP?
<p>How can I add all of my array values together in PHP? Is there a function for this?</p>
php
[2]
4,157,109
4,157,110
MediaPlayer Android Increment on button click
<p>I have created a button and need to increment mp3 tunes on click. </p> <p>So far I have the mp3 playing like: </p> <pre><code> final MediaPlayer sentence = MediaPlayer.create(Options.this, R.raw.indra); </code></pre> <p>and then calling sentence.start(); in onclick. </p> <p>Is it possible to increment more tunes in onclick?</p> <p>Thanks. </p>
android
[4]
4,465,853
4,465,854
jQuery: if class=active?
<pre><code>$(document).ready(function() { $('a#fav').bind('click', function() { addFav(&lt;?php echo $showUP["uID"]; ?&gt;); }); }); </code></pre> <p>I need to modify this so if the a#fav has class="active" then it should do</p> <pre><code> removeFav(&lt;?php echo $showUP["uID"]; ?&gt;); </code></pre> <p>instead How can i do this?</p>
jquery
[5]
59,320
59,321
If a function is not called in PHP does the code still run within the function?
<p>I was wondering, I have a few functions in PHP that're not called every time but still are included in my files on each load. Does it still run the code even if your not calling the function at that time? The reason I'm asking, the codes in my function are expensive to run CPU wise and I don't call them every time and want to make sure if there not called they do not run the code within the function.</p> <p>Thank you</p>
php
[2]
1,505,636
1,505,637
How to move gun projectile in state line
<p>I have spawn point of projectile and I have to move it in state line direction but I don't know the destination point. So what formula or concept I will have to write to go in state line of projectile.</p> <p>Suppose spawn point is (4,5) so it should go towards the direction (-4,-5), for any coordinate value. Thanks in advance</p>
c++
[6]
1,070,719
1,070,720
How to declare any ArrayList object of type File?
<p>I am trying to get the file names from a particular drive for eg: C:\ or D:\ etc. The File object is of type array and hence its not able to store lot of data in it. Need your advice on how i can store lots of file names in a File object. Below is my Code:</p> <pre><code>public static void getContentsInDirectory(File directory) throws IOException{ File[] listOfFiles = directory.listFiles(); try{ for(File file : listOfFiles){ if(file.isDirectory()){ System.out.println("It is a Directory:"+file); getContentsInDirectory(file); } else if(file.isFile()){ System.out.println("File: "+ file); } } } catch(Exception e){ e.printStackTrace(); } } </code></pre> <p>When i tried it with small size directories it worked well but when i give the whole drive like D: it throws Null Pointer Exception or sometimes Array IndexoutofBounds exception.</p> <p>List listOfFiles = new ArrayList(); this </p>
java
[1]
4,038,115
4,038,116
manipulate python lists into string type i want
<p>I have a nested list that is for example: <code>A_board=[['0', '0'],['1', '1']]</code>. And I want to take this nested list apart and get a result, which if I call print result, it would display: <code>&lt; 0 0 &gt; &lt; 1 1 &gt;</code></p> <p>I am not sure how to approach this with loops, I made the matrix into a list first, by doing:</p> <pre><code>boardWidth_a=len(A_board) listLength=len(board[0]) for q in range(0,boardWidth_a): for x in range(0, listLength): board1D.append(int(board[q][x])); </code></pre> <p>with <code>board1D</code> being <code>[0, 0, 1, 1]</code> now, what can i do to <code>board1D</code> to make it into <code>&lt; 0 0 &gt; &lt; 1 1 &gt;?</code></p>
python
[7]
2,955,820
2,955,821
How to use base64 to encrypt and decrypt?
<p>I am trying to convert byte array to base64 format in java.<br> my problem is sun.misc.BASE64Decoder cannot be used? Is there any alternative?</p> <pre><code>byte[] buf = new byte[] { 0x12, 0x23 }; String s = new sun.misc.BASE64Encoder().encode(buf); </code></pre>
java
[1]
3,461,889
3,461,890
how can i get rupee symbol in app through keyboard
<p>can anybody help me in getting the Rupee currency symbol font in textview through keyboard.</p>
android
[4]
2,739,657
2,739,658
Checking if two strings contain the same characters, not considering their frequencies
<p>I have two dictionary corresponding to character counts of two different strings. I want to check if they are made up of same characters or not, <strong>regardless of the frequencies of the characters.</strong> </p> <hr> <p>Say, I have two strings <code>caars</code> and <code>racs</code> They are made up of same characters <code>a,c,r,s</code></p> <hr> <p>I know of <code>cmp</code> method to compare two dictionaries, which also compares both the key-value pairs. But I don't want to compare their values or counts. </p> <hr> <p>Just in case, you may ask, why do I have dict then for both the strings. Well, I do need them in some other part of the problem. So, why not use them.</p> <hr> <p>How can I do this in python quickly?</p>
python
[7]
2,155,707
2,155,708
How does this memoize function work?
<p>I am feeling very stupid today. I keep looking at this code, trying to trace it, but I just cannot figure out:</p> <ol> <li>What it's actually meant to do</li> <li>How it works</li> </ol> <p>As far as I can see, the very first time it's called it's the only time <code>action</code> is the same as <code>callFn</code>. So, the very first time it's run, it creates the stack array. Then I lose it. Action is assigned a function that just adds the passed callback to the stack. Then fn is <em>actually</em> called and based on its result, "action" is set to either callFn (?!?) or to a function that calls the callback... And then, all the calls in the stack are called.</p> <p>I hate getting lost in code, but this is a little beyond me. Anybody smarter than me able to "get it"?</p> <pre><code>var memoize = function(fn) { var callFn = function(callback) { var stack = [callback]; action = function(callback) { stack.push(callback); }; fn(function(err, val) { action = err ? callFn : function(callback) { callback(null, val); }; while (stack.length) stack.shift()(err, val); }); }; var action = callFn; return function(callback) { action(callback); }; }; </code></pre>
javascript
[3]
142,703
142,704
How to save output of a generated text
<p>I am using the following code to generate a text:</p> <pre><code>for i in xrange(300): sys.stdout.write(alphabet[bisect.bisect(f_list, random.random()) </code></pre> <p>and I would like to know how to store the same text (in the variable <code>text1</code>) so that I can use it later in this code:</p> <pre><code>for i in xrange(300): text1=sys.stdout.write(alphabet[bisect.bisect(f_list, random.random()) for word in text1: fd.inc(word) </code></pre>
python
[7]
443,226
443,227
Conditional compilation for working at home
<p>I code C++ using MS Dev Studio and I work from home two days per week. I use CVS to keep my sources synchronized between the two computers but there are difference between the environments the machines are in.</p> <p>Can anyone suggest a way I can conditionally modify constants in my code depending on whether I am compiling on my home box or not ?</p> <p>What I am after is a way of defining a symbol, let's call it _ATHOME, automatically so I can do this:</p> <pre><code>#ifdef _ATHOME # define TEST_FILES "E:\\Test" # define TEST_SERVER "192.168.0.1" #else # define TEST_FILE "Z:\\Project\\Blah\\Test" # define TEST_SERVER "212.45.68.43" #endif </code></pre> <p><em>NB: This is for development and debugging purposes of course, I would never release software with hard coded constants like this.</em></p>
c++
[6]
3,189,563
3,189,564
Android: EditText.setInputType() how to setup for email but not auto-suggest
<p>I am using an <code>EditText</code> box for user to enter their email address.</p> <p>I set it up using:</p> <pre><code>box.setInputType( InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS ); </code></pre> <p>This results in the soft keyboard popping up with the '@' and '.' (and some keyboards '.com') keys on the initial keyboard layout. Great just what I want.</p> <p>However, I notice the text is all black (when I specified white). I found this is due to auto-suggest. If I go into <code>Settings-&gt;Languages/Keyboards-&gt;Touch Input-&gt;TextInput</code> and disable Prediction and Word Completion, then the text shows up white.</p> <p>Now the question: How do I get auto-complete programmatically disabled for this?</p> <p>I have tried setting up the box by doing:</p> <pre><code>box.setInputType( InputType.TYPE_CLASS_TEXT | TYPE_TEXT_FLAG_NO_SUGGESTIONS ); </code></pre> <p>This results in all white text (i.e. no auto-suggest). But then I longer have email '@' and '.com' buttons! Bah-humbug.</p> <p>Anyway to get both? Thanks.</p>
android
[4]
1,181,031
1,181,032
Is it possible to use CursorLoader in an Activity not Fragment with android compatibility
<p>Can I use a CursorLoader in a subclass of an Activity (not a subclass of FragmentActivity) with the android-compatibility library? If I can, how do I get the Cursorloader since getLoaderManager().init(...) is not available in an activity subclass with the compatibility layer. </p>
android
[4]
458,698
458,699
Change the title of window.open
<p>I have a window.open function call on click, which opens an .swf albumplayer.</p> <pre><code>var win = null; function NewWindow(wizpage, wizname, w, h, scroll){ LeftPosition = (screen.width) ? (screen.width-w)-8 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height=' + h + ',width=' + w + ',top= 100,' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable'; win = window.open(wizpage, wizname, settings); } </code></pre> <p>I would want to change the title of the opened window, that it has some meaningful title (a constant 'Album Player' or something would be fine), so that doesn't use the default filename/application-shockwave... text.</p> <p>Thanks for the help.</p>
javascript
[3]
3,294,063
3,294,064
what are the best practices to separate resource file from the ASP.NET web project?
<p>I have a web application project which contains few resource file. i am planning to create another one project for Mobile where i should be able to use the same resource files.</p> <p>so can you suggest me some best practices to separate the resource files.</p> <p>Let me know if you need any clarifications for the same.</p>
asp.net
[9]
2,043,556
2,043,557
lift list of values to a list of lists of values
<p>Here's a tricky one. I want to take a list of integers, and turn it into a list of lists containing that integer. This is so that I can later append to that list. Unfortunately <code>list()</code> does not take a single integer, so I can't <code>map</code> it to the list.</p> <p>Here's a more concrete explanation:</p> <p>Given,</p> <pre><code>&gt;&gt;&gt; a = range(5) &gt;&gt;&gt; a [0, 1, 2, 3, 4] </code></pre> <p>How can I elegantly turn it into,</p> <pre><code>[[0], [1], [2], [3], [4]] </code></pre> <p>I tried <code>map</code>'ing <code>list</code>:</p> <pre><code>&gt;&gt;&gt; map(list,a) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; TypeError: 'int' object is not iterable </code></pre> <p>Same thing with <code>tuple</code>. In fact ideally I'd be able to map the tuple or list operators, but of course that doesn't work with Python's syntax:</p> <pre><code>&gt;&gt;&gt; map((,),a) File "&lt;stdin&gt;", line 1 map((,),a) ^ SyntaxError: invalid syntax </code></pre> <p>So the only way I can come up with a solution is to define my own list constructor:</p> <pre><code>&gt;&gt;&gt; L = lambda x: [x] &gt;&gt;&gt; map(L,a) [[0], [1], [2], [3], [4]] </code></pre> <p>That works fine, but I'm wondering if there is a more Pythonic solution. Mostly I was just surprised to discover that <code>list(3)</code> does not give <code>[3]</code>.</p>
python
[7]
3,602,768
3,602,769
Need to redirect to success page after jTweetsAnywhere post
<p>I have a page that makes use of the jTweetsAnywhere code (from <a href="http://thomasbillenstein.com/jTweetsAnywhere/" rel="nofollow">here</a>)</p> <p>I want to be able to make use of a redirect once the page comes back after successfully posting the Tweet. Has anyone done anything like that and care to share the code?</p> <p>Here is my current code. Would I just add a function within here?</p> <pre><code>&lt;div id="tweetbox"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; $('#tweetbox').jTweetsAnywhere({ showTweetBox: { counter: false, width: 500, height: 60, label: '', defaultContent: '#MyTest http://stackoverflow.com' } }); &lt;/script&gt; </code></pre>
jquery
[5]
5,203,737
5,203,738
Jquery - targetting with a combination of variable and classname
<p>I'm sure this is an easy one but I've not had to write this syntax before and i cant find an answer online!</p> <p>I have a various graph sliders within a html page - each have the below code - </p> <pre><code> &lt;div class="sliderDbWk"&gt; &lt;div class="spanner"&gt; &lt;div class="number"&gt; &lt;span class="timer"&gt; &lt;/span&gt; &lt;Span class="timerPc"&gt;%&lt;/Span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Each parent class is different (ie sliderDbMnth, sliderDbCal), i pass in to a function the sliders parent class and want to target the child .number div within this - so the parent class is stored as a variable - I'm not sure how to combine a variable and a class name in a function - i've tried below - but it doesn't work!</p> <p>Any ideas?</p> <pre><code> $(sliderSelect).children(' .number').css('margin-left',0); </code></pre>
jquery
[5]
1,217,419
1,217,420
How to debug C# process
<p>I want to debug two process,(ProcessA.exe and ProcessB.exe)</p> <p>In the usual scenario, while starting the ProcessA will start ProcessB. ProcessA is a cross platform exe. ProcessB is C# application.(Visual Studio 2010 Professional).</p> <p>I did the following for debugging ProcessB (C#)</p> <ol> <li>Started ProcessA from C:\Program Files\Test by clicking the exe.</li> <li>ProcessB through Visual Studio 2010 from C:\MyProjects. Attached ProcessA. </li> </ol> <p>In Visual Studio 2010 Attach to Process window:, </p> <p>Attach to: as "Managed(v4.) code).</p> <p>I put the break point in C# code. But the break point is never getting executed also ProcessB call is not getting executed without debug also( ie, started all processes from different locations)</p>
c#
[0]
4,819,087
4,819,088
How do I force a UIWebView to update when it's offscreen?
<p>I have a UIWebView that I'm setting to some text and displaying and then hiding, changing the text, and displaying again. The issue I'm running in to is that when I make the view visible again I see the old text for an instant. Is there a way to force the UIWebView to show the new text when it displays?</p> <p>The code is ordered correctly and looks like this:</p> <pre><code>[back assignLabelText:[facts getCurrentFact].answer]; [self doAnimation:back.view andViewToHide:front.view flipRight:YES]; </code></pre>
iphone
[8]
1,462,452
1,462,453
jConfirm access value from injected HTML element
<p>I have this code which makes a fancy jQuery alert box with several inputs:</p> <pre><code>//jConfirm( message, [title, callback] ) $('#buttonNew').click(function(){ jConfirm('&lt;form&gt;&lt;input id="postTitle" type="text"/&gt;&lt;br/&gt;&lt;textarea id="postBody"&gt;&lt;/textarea&gt;&lt;/form&gt;', 'New Post', function(r){if(r==true){ alert($('#postTitle').val()); //Expecting the input value but getting "undefined" } }); }) </code></pre> <p>When I try to use the value entered into the inputs (such as with an alert() for testing as shown above) I'm getting "undefined". How do I access those values of the injected HTML inputs from within the callback function?</p>
jquery
[5]
5,699,429
5,699,430
Comparison between POST and GET (httpwebrequest in C#) - in terms of "visibility"
<p>I would like to implement an online activation feature (something like activating using a cd key), and I would like to do so via http.</p> <p>I would like to send the key together with an internal password to the server each time an activation request is sent.</p> <p>The password's use is that, since the http service is exposed publicly, I would like it to be used only by my application, not any unknown third party (like brute-force trying different keys).</p> <p>As I know that in a web browser, end users can see the GET form values in the address bar, but for POST method it won't have this issue.</p> <p>What I want to ask is:</p> <blockquote> <p>Since, obviously, I don't want this internal password to be known to others, when submitting the cd key and the password via the C# class httpwebrequest, is there any difference between using the GET and POST method, in terms of "visibility"?</p> </blockquote> <p>It makes sense that I should use POST in the rationale that the form values are visible in the web browser address when using GET, but since now I'm using httpwebrequest, there is no web browser "address bar" to be seen, so is it actually no difference at all? </p> <p>Or, is it that there is when there is like a hacker that intercepts the web request of my application?</p> <p>Thanks a lot for your help!</p>
c#
[0]
6,009,625
6,009,626
Application is Crashed & gives this reason
<ul> <li>Reason:</li> </ul> <p>I am having selected value in the table accordingly the displayed value in the previous view's Label (in the label first time country will be according to the current location),</p> <p>Table is filled up using database, on the press of the Done button application is getting crashed without selecting any value from the table.</p> <p>I am getting this message in the debugger,</p> <p><em>*</em> Terminating app due to uncaught exception 'NSRangeException', reason: '</p> <p><em>*</em> -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds [0 .. 64]'</p> <p><em>*</em> First throw call stack:</p> <p>(0x328b18bf 0x3671b1e5 0x327fab6b 0x13b77 0x3280b435 0x3113f9eb 0x312053cf 0x3280b435 0x3113f9eb 0x3113f9a7 0x3113f985 0x3113f6f5 0x3114002d 0x3113e50f 0x3113df01 0x311244ed 0x31123d2d 0x37f49e13 0x32885553 0x328854f5 0x32884343 0x328074dd 0x328073a5 0x37f48fed 0x31152743 0x2e13 0x2dc8)</p> <p>terminate called throwing an exceptionProgram received signal: “SIGABRT”.</p> <p>Data Formatters temporarily unavailable, will re-try after a 'continue'. (Can't find dlopen function, so it is not possible to load shared libraries.)</p> <p>Please suggest me how can i solve the above mentioned problem.</p>
iphone
[8]
4,574,894
4,574,895
pg:224 Stroustrup - C++ Programming Language, 3E
<pre><code>struct Date { int d, m , y; void init_date(Date&amp; d, int, int, int); void add_year(int n); void add_month(Date&amp; d, int n); void add_day(Date&amp; d, int n); } Date my_birthday; void f() { Date today; today.init(16, 10, 1996); my_birtday.init(30, 12, 1950); Date tomorrow = today; tomorrow.add_day(1); // ... } </code></pre> <p><strong>Question A:</strong> In the above snippet, isn't: Date tomorrow = today; wrong in the sense that there is no "copy constructor" provided within <em>struct Date</em>. I know there is a "default constructor" auto generated by the compiler - but I'm not sure what exactly it does or how exactly it works (it can call the default constructor of a member-class, but it doesn't initialize: int i; and stuff like that). Could someone clarify how the compiler's default constructor works?</p> <p><strong>Question B:</strong> We would have to insert something like this: const Date&amp; Date(const Date&amp; r); correct? But, the above constructor implies we pass it one argument (a reference to "today"). So, how does an "initialization": <em>"Date tomorrow = today"</em> translate to a function call: <em>Date tomorrow(today);</em> Is there any "magic" happening here??</p> <p><strong>Question C:</strong> What is the format of the operator, new? Stroustrup uses it in different ways but there's no clear listing of all its uses. So far I could find: new ; new Type[size]; new Type(size); new Type; Is this listed/given anywhere? Have I missed out any?</p>
c++
[6]
5,419,130
5,419,131
php nearest ten-th value
<p>I am getting a max value through value. It can be any digit (whole number). I want it to take to next tenth-value, using PHP</p> <p>Example:</p> <p>If value is 66, then I need value 70<br> If value is 6, then I need value 10<br> If value is 98, then I need value 100<br></p>
php
[2]
4,878,288
4,878,289
Using SimplePie on sample php page
<p>I am trying to use simplepie on a basic page. so I download simplepie from the simplepie site and set it up just like it says in documentation. I am using xampp on windows vista business sp2. I create 2 folders php and cache in my root directory and put the simplepie.inc file in php. when I run my code I get these errors:</p> <pre><code>Deprecated: Assigning the return value of new by reference is deprecated in C:\Users\PDG-PC\xampp\htdocs\rssproject\php\simplepie.inc on line 738 </code></pre> <p>Deprecated: Assigning the return value of new by reference is deprecated in C:\Users\PDG-PC\xampp\htdocs\rssproject\php\simplepie.inc on line 1108 Strict Standards: Non-static method SimplePie_Misc::fix_protocol() should not be called statically, assuming $this from incompatible context in C:\Users\PDG-PC\xampp\htdocs\rssproject\php\simplepie.inc on line 834</p> <p>Strict Standards: Non-static method SimplePie_Misc::normalize_url() should not be called statically, assuming $this from incompatible context in C:\Users\PDG-PC\xampp\htdocs\rssproject\php\simplepie.inc on line 9317</p> <p>the first errors run about 20 lines and the later errors another 10 lines. I am using simplepie 1.2.1 and xampp 1.7.7. is there anything that I am missing or should know about?</p>
php
[2]
4,518,521
4,518,522
Why iphone app start slowly?
<p>i'm newbie in iphone dev, i got an issue with running an app in my iphone device. I added my provisioning profile to xcode and build successfully in my iphone (iphone 3G). But, i don't know why when the app start, <strong>it takes 2 seconds to run the app</strong>.my app is a sample project create by xcode (file - new project - view based application), i don't add any more code to it. i wonder that: does my provisioning profile make it slowly? Please help me ...</p>
iphone
[8]
5,106,813
5,106,814
Reception of broadcast in service
<p>Is there a way to get broadcast reception in a Service context? I have tried adding the <code>receiver</code> intent-filter in the manifest file but of course Android tries to instantiate the service every time and an exception is throwed.</p> <p>How can I do this?</p> <p>( did I mention I am a complete noob on Android ? )</p>
android
[4]
2,133,708
2,133,709
Merge images with PHP
<p>I have written a code for merge two images.</p> <p>My code is:</p> <pre><code>$rnd = rand("99000", "99999"); $dst_path = "/home/maxioutl/public_html/images/urunler/"; $dst_file_name = "tresim-{$rnd}.jpg"; $dst_file = $dst_path.$dst_file_name; $dst = imagecreatetruecolor(250, 375); imagefill($dst, 0, 0, imagecolorallocate($dst, 255, 255, 255)); $src = imagecreatefromjpeg("http://www.goldstore.com.tr/upload/product/raw/3.72925.0332.JPG"); imagecopymerge($dst, $src, 40, 60, 0, 0, 250, 375, 100); imagejpeg($dst, $dst_file, 90); </code></pre> <p>Result:</p> <p><img src="http://i.stack.imgur.com/R94Du.jpg" alt="black bg"> Black background. Where is it?</p>
php
[2]
3,078,058
3,078,059
Jquery UI sortable, store location and size?
<p>I am new to Jquery and am trying to store the location and size of the elements on a page which are being sorted using the Jquery UI plugin. I want the user to "save" the current layout, and the data to be stored in a database using php/mysql so when they re-visit the elements will be the same size and location?</p> <pre><code> &lt;script type="text/javascript"&gt; $(function() { $("#sortable").sortable({ revert: true, axis: 'y', opacity: 0.9, tolerance: 'pointer', }); $("#draggable").draggable({ connectToSortable: '#sortable', helper: 'clone', revert: 'invalid' }) $("#sortable").resizable({}) }); &lt;/script&gt; </code></pre> <p>Above is part of my script which basically allows boxes to be sorted and dragged using a list.</p> <p>Many Thanks.</p> <p>EDIT:</p> <pre><code>&lt;body&gt; &lt;div class="demo"&gt; &lt;ul id="sortable"&gt; &lt;li class="ui-state-default"&gt;Item 1&lt;/li&gt; &lt;li class="ui-state-default"&gt;Item 2&lt;/li&gt; &lt;li class="ui-state-default"&gt;Item 3&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I am trying to use div tags alone without having to get them in a list also? Without having to include the divs inside a list.</p> <p>Thanks again.</p>
jquery
[5]
2,282,198
2,282,199
Which one would be best in use for to show read only data in asp.net ? repeater or html created at runtime?
<p>I have a scenario where we need to show data in tabular form. there will be 10 different data tables in form so which approach will be good to use: 1. Create html table at runtime based on data. 2. Use asp.net's repeater control.</p> <p>Main criteria is performance, page should not take more time to load. </p>
asp.net
[9]
849,271
849,272
absolute and relative paths
<p>Ok I have a question. What is the difference with a absolute and relative path? I am asking cause I am working on a project for school. Yes this is homework. I am trying to understand alittle bit more. This is one example of what is being asked.</p> <blockquote> <p>• When the user clicks the “Save” button, write the selected record to the file specified in txtFilePath (absolute path not relative) without truncating the values currently inside</p> </blockquote> <p>this is what I have</p> <pre><code> private void button2_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { StreamWriter myWriter = new StreamWriter(saveFileDialog1.FileName); myWriter.Write(txtFilePath.Text); myWriter.Close(); } } </code></pre> <p>Now I am not understanding if I am doing this right. I know when I save it to my desktop and I delete it from my listbox and when I try to reload it again nothing shows up. This is what I have on my form</p> <pre><code>private void Form1_Load(object sender, EventArgs e) { string[] myFiles = Directory.GetFiles("C:\\"); foreach (string filename in myFiles) { FileInfo file = new FileInfo(filename); employeeList.Items.Add(file.Name); } </code></pre> <p>and this is the load</p> <pre><code>private void button1_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { StreamReader myReader = new StreamReader(openFileDialog1.FileName); txtFilePath.Text = openFileDialog1.FileName; txtFilePath.Text = myReader.ReadToEnd(); myReader.Close(); } } </code></pre> <p>Can someone please help me make sense of this. Thanks.</p>
c#
[0]
4,283,346
4,283,347
explorer right click context menu with python?
<p>I'm wondering how to go about adding a menu item to explorers right click context menu. For instance, when I right click on a file I get things like winrars "Add to archive" I want something like that and I'm wondering how to do it with python.</p>
python
[7]
3,053,848
3,053,849
What is wrong with this one line of code? (php inside php)
<p>I'm new to php. I have the following line in a functions.php file of my WordPress site. I think there is something wrong with the way I formatted <code>get_the_bag</code>. Can someone let me know what is wrong?</p> <p><code>$output .= "&lt;span class='bag-item'&gt;. get_the_bag(); .&lt;/span&gt;";</code></p>
php
[2]
4,003,531
4,003,532
using $.each to addClass to elements
<p>I'm trying to style a sub-set of anchors using an array</p> <p>HTML &amp; CSS:</p> <pre><code>&lt;div&gt; &lt;a href="#1"&gt;one&lt;/a&gt; &lt;a href="#2"&gt;two&lt;/a&gt; &lt;a href="#3"&gt;three&lt;/a&gt; &lt;a href="#4"&gt;four&lt;/a&gt; &lt;a href="#5"&gt;five&lt;/a&gt; &lt;a href="#6"&gt;six&lt;/a&gt; &lt;a href="#7"&gt;seven&lt;/a&gt; &lt;/div&gt; .hilight { background: #f00; } </code></pre> <p>e.g. how would I add the class 'hilight' to anchors 2, 5, &amp; 6...</p> <p>Having tested this:</p> <pre><code>$("a[href='#5']").addClass('hilite'); </code></pre> <p>I tried the the following with $.each(), which doesn't work. I guess I'm iterating over each anchor 3 times, but I didn't expect NO output! </p> <pre><code>var arr = ["#2", "#5", "#6"]; $.each(arr, function(index, value) { $("a[href=value]").addClass('hilite');' }); </code></pre> <p>Can someone point me in the right direction please :)</p>
jquery
[5]
2,467,432
2,467,433
need help using quotes in href with javascript
<p>I need help writing a link using js.</p> <p>This is what I have but I can't get it to jive. Can you help?</p> <pre><code>document.write('&lt;a href=\"\http://www.domain.com/drowning-accidents/\"\ target=\"\_blank\"\ onClick=\"\trackOutboundLinktarget=(this, 'Outbound Links', 'domain.com'); return false;\"\&gt;&lt;img src=\"images/infographic.png\" border=\"0\" class=\"borders\" alt=\"Check out the Infographic\" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/center&gt;'); </code></pre> <p>I think it has to do with the single quotes around Outbound... but not sure.</p> <p>Thanks!</p>
javascript
[3]
3,370,800
3,370,801
Want to delete array
<p>Can anyone help me to improve this code? I want to delete array if it already exists. Thanks</p> <pre><code>if(count($cart['Item']) &gt; 0) { unset($cart['Item']); $items['Item'] = array(); $cart = array_merge($cart, $items); } </code></pre>
php
[2]
4,038,856
4,038,857
how to only select links that have text and no picture links
<p>I'm new to jQuery. This would be no problem for me using xpath expressions, but how can i do this the 'jQuery' way?</p> <p>Given following example:</p> <pre><code>&lt;stuff&gt; &lt;a href="target.html"&gt;ASDF&lt;/a&gt; &lt;a href="target.html"&gt;&lt;img src="asdf.png"/&gt;&lt;/a&gt; &lt;/stuff&gt; </code></pre> <p>How can i select with jQuery only the text links and leave the links with the img tags untouched?</p> <p>Help me j Query kenobi, you are my only hope ;)</p> <p>Princess Lia</p>
jquery
[5]
2,850,284
2,850,285
Achieving multithreading in PHP
<p>I am writing a kind of test system in php that would test my database records. I have separated php files for every test case. One (master) file is given the test number and the input parameters for that test in the form of URL string. That file determines the test number and calls the appropriate test case based on test number. Now I have a bunch of URL strings to be passed, I want those to be passsed to that (master) file and every test case starts working independently after receiving its parameters.</p>
php
[2]
3,366,009
3,366,010
Undefined variable in PHP, what am I doing wrong?
<p>I've been trying to get this PHP script to work, but I can't seem to have it work. :\</p> <pre><code>&lt;?php function getBrowser() { $u_agent = $_SERVER['HTTP_USER_AGENT']; $ub = ''; if(preg_match('/MSIE/i',$u_agent)) { $ub = "Internet Explorer"; } elseif(preg_match('/Firefox/i',$u_agent)) { $ub = "Mozilla Firefox"; } elseif(preg_match('/Safari/i',$u_agent)) { $ub = "Apple Safari"; } elseif(preg_match('/Chrome/i',$u_agent)) { $ub = "Google Chrome"; } elseif(preg_match('/Opera/i',$u_agent)) { $ub = "Opera"; } elseif(preg_match('/Netscape/i',$u_agent)) { $ub = "Netscape"; } return $ub; } echo $ub; ?&gt; </code></pre> <p>I am just trying to make PHP detect browsers correctly, but I always get, "Undefined Variable: ub" at "echo $ub;"</p> <p>What am I doing wrong this time?</p>
php
[2]
347,259
347,260
Passing as const and by reference - Worth it?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2139224/how-to-pass-objects-to-functions-in-c">How to pass objects to functions in C++?</a> </p> </blockquote> <p>In my game I make excessive use of mathematical vectors and operator overloading of them.</p> <pre><code>class Vector { float x, y; }; </code></pre> <p>That's basically all about my Vector class (methods excluded).</p> <p>Now I am not an expert in C++ and I've seen and read about passing as const and passing by reference.</p> <p>So, where are the performance differences in the below code example?</p> <pre><code>Float RandomCalcuation( Vector a, Vector b ) { return a.x * b.x / b.x - a.x * RANDOM_CONSTANT; } // versus.. Float RandomCalcuation( Vector&amp; a, Vector&amp; b ) { return a.x * b.x / b.x - a.x * RANDOM_CONSTANT; } // versus.. Float RandomCalcuation( const Vector&amp; a, const Vector&amp; b ) { return a.x * b.x / b.x - a.x * RANDOM_CONSTANT; } </code></pre> <ul> <li>Which of the three should I use, and why?</li> <li><p>What advantages for the optimization process of the compiler does each of the options have?</p></li> <li><p>When and where do I have to be especially careful?</p></li> </ul>
c++
[6]
343,583
343,584
z-index problem with helper clone
<p>This is my code (please see <a href="http://jsfiddle.net/VCfSc/1/" rel="nofollow">http://jsfiddle.net/VCfSc/1/</a>):</p> <pre><code>$('.first').draggable({ cancel: null, helper: 'clone' }); $('.second').droppable({ over: function(event, ui) { $(this).css('z-index', 1); ui.helper.css('z-index', 0); } }); </code></pre> <p>I am trying to have the helper clone go <em>under</em> the droppable element when it is dragged over it. What am I doing wrong?</p>
jquery
[5]
1,421,854
1,421,855
Replace words in TextView with a smooth scale transition
<p>Visit this website.</p> <p><a href="https://zapier.com/" rel="nofollow">https://zapier.com/</a></p> <p>See this portion of the website.</p> <p>I wan that same in my android application that text changes after some time</p> <p><img src="http://i.stack.imgur.com/MYKPV.png" alt="enter image description here"></p> <p>For this i use count down timer to introduce delay between the text view changes. but it doesnt work.</p>
android
[4]
4,926,508
4,926,509
What should I focus on as I port a PHP 4 application to the current version of PHP?
<p>I have a couple of old applications which were written in around 2003 in PHP4 which I would like to port to a modern, current version of PHP. I want to first get the old functionality working on a modern server before I start rewriting the code to add feature, modernize the UI and update the code for the current state of the web. </p> <p>But before I start porting I'd like some guidance about what I should be watching for which has changed - what parts of the code will likely require the most care to rewrite?</p>
php
[2]
1,748,683
1,748,684
How to identify checked and unchecked exceptions in java?
<p>While reading about exception, I will always come across checked exceptions and unchecked exceptions, So wanted to know how to distinguish that which is what?</p> <p>Edit: I want to know if i create any exception class then how can i create as a checked or as an unchecked?</p> <p>and what is the significance of each?</p>
java
[1]
4,814,366
4,814,367
Check jdk availability
<p>How can I manually check if jdk is installed on my machine, and if yes, what version?</p> <p>If I had jdk in Windows 7, and now I installed Windows 8 separately on the same machine, do I need to reinstall the jdk? Or can I reuse it?</p>
java
[1]
2,907,090
2,907,091
Invoking a method on a static object in Java evaluates some incorrect value
<p>The following simple program retrieves the current year <strong>(2011)</strong> from the system and then simply subtracts <strong>1950</strong> from the current year.</p> <pre><code>package calculation; import java.util.Calendar; final public class Main { private static final Main INSTANCE = new Main(); private static final int CURRENT_YEAR = Calendar.getInstance().get(Calendar.YEAR); private final int beltSize=CURRENT_YEAR - 1950; private int beltSize() { return beltSize; } public static void main(String[] args) { Main main=new Main(); System.out.println("Wears a size " + main.beltSize() + " belt."); System.out.println("Wears a size " + INSTANCE.beltSize() + " belt."); } } </code></pre> <hr> <p>The following statement from the code above returns a correct value.</p> <pre><code>Main main=new Main(); System.out.println("Wears a size " + main.beltSize() + " belt."); </code></pre> <p>It invokes the <strong>beltSize()</strong> method which returns correctly the evaluation of CURRENT_YEAR - 1950 which is <strong>61</strong>.</p> <hr> <pre><code>private static final Main INSTANCE = new Main(); System.out.println("Wears a size " + INSTANCE.beltSize() + " belt."); </code></pre> <p>The above statement invokes the same method <strong>beltSize()</strong> using the <strong>static final</strong> object INSTANCE which is a class member and it returns incorrectly <strong>-1950 (negative)</strong> rather than the correct value of 61. Why?</p>
java
[1]
1,617,899
1,617,900
Javascript prototype and closures
<p>Given this code:</p> <pre><code>function Test(){ var $D = Date.prototype; $D.addDays=function(value){this.setDate(this.getDate()+value);return this;}; $D.clone = function() { return new Date(this.getTime()); }; alert(new Date().addDays(5)); var x = 5; } Test(); alert(new Date().addDays(1)); ​alert(x);​ </code></pre> <p>The only error is thrown by <code>alert(x)</code> which throws the "x is undefined" error, because x is limited to function <code>Test()</code></p> <p>The call to <code>addDays()</code> works both within the function and outside it.</p> <p>I'm assuming this is because the scope of the Date prototype is global, so it's irrelevant that I extend it within a closure.</p> <p>So if I wanted to extend Date within a closure, BUT NOT allow any other javascript to get the extension, how would I do it?</p> <p>The reason I'm asking is because when I'm extending core javascript objects, I don't want to conflict with other libraries which may make the same modifications.</p>
javascript
[3]
2,490,690
2,490,691
extract number from string in reverse without dots
<p>I have a string <strong>6.7.0.0.1.3.6.6.1.6.1.e164.arpa</strong></p> <p>how can I get only the number in reverse</p> <p>like <strong>16166310076</strong>.</p> <p>Any help is appreciated.</p>
php
[2]
5,950,027
5,950,028
Jquery .change function not triggering
<p>I was just wondering why doesn't this script works? I'm trying to get the value of the selected (one or many items) options in a SELECT MULTIPLE. What is missing?</p> <p>Thanks</p> <pre><code>&lt;script type="text/javascript" src="js/jquery-1.7.1.min.js"&gt;&lt;/script&gt; &lt;script&gt; $('#ooo').change(function() { var foo = []; $('#ooo :selected').each(function(i, selected){ foo += $(selected).valueOf(); }); alert(foo); //$("#test").text(str); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;select name="test" id="ooo" multiple="multiple"&gt; &lt;option value="1"&gt;test&lt;/option&gt; &lt;option value="2"&gt;bbbb&lt;/option&gt; &lt;option value="3"&gt;aaaa&lt;/option&gt; &lt;option value="4"&gt;xxx&lt;/option&gt; &lt;option value="5"&gt;zzz&lt;/option&gt; &lt;/select&gt; </code></pre>
jquery
[5]
2,509,963
2,509,964
why instance has no __name__ attribution in python?
<pre><code>&gt;&gt;&gt; class Foo: ... 'it is a example' ... print 'i am here' ... i am here &gt;&gt;&gt; Foo.__name__ 'Foo' &gt;&gt;&gt; Foo().__name__ Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; AttributeError: Foo instance has no attribute '__name__' &gt;&gt;&gt; Foo.__doc__ 'it is a example' &gt;&gt;&gt; Foo().__doc__ 'it is a example' &gt;&gt;&gt; Foo.__dict__ {'__module__': '__main__', '__doc__': 'it is a example'} &gt;&gt;&gt; Foo().__dict__ {} &gt;&gt;&gt; Foo.__module__ '__main__' &gt;&gt;&gt; Foo().__module__ '__main__' &gt;&gt;&gt; myname=Foo() &gt;&gt;&gt; myname.__name__ Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; AttributeError: Foo instance has no attribute `__name__` </code></pre> <p>what is the reason instance has no attribute <code>__name__</code>?<br> maybe it is ok that the <code>__name__</code> of instance-myname is <code>myname</code>.<br> would you mind tell me more logical ,not the unreasonable grammar rules?</p>
python
[7]
4,354,500
4,354,501
How to convert a C++ string to a char*?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/347949/convert-stdstring-to-const-char-or-char">Convert std::string to const char* or char*</a> </p> </blockquote> <p>Simple question but I'm new to C++. How do I convert a string to a <code>char *</code> (I read a string from <code>cin</code> then I have a function that operates on <code>char[]</code> so need to get a <code>char *</code>)? Thanks.</p>
c++
[6]