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
3,178,250
3,178,251
How to change the width of the row of a UITableView
<p>Can we resize the width of the row of a UITableView.</p>
iphone
[8]
2,527,903
2,527,904
How to sort list of objects by some property
<p>I have simple class </p> <pre><code>public class ActiveAlarm { public long timeStarted; public long timeEnded; private String name = ""; private String description = ""; private String event; private boolean live = false; } </code></pre> <p>and List con. How to sort in asc order by timestarted, then by time ended ? Can anybody help ? I know in C++ with generic algorithm and overload operator &lt;, but I am new to Java.</p>
java
[1]
1,913,815
1,913,816
php date string sql server 2008 insert
<p>Trying to insert date as a string from array to SQL Server 2008 and getting this error </p> <blockquote> <p>Array ( [0] => Array ( [0] => 22007 [SQLSTATE] => 22007 [1] => 241 [code] => 241 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Conversion failed when converting date and/or time from character string. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Conversion failed when converting date and/or time from character string. ) ) </p> </blockquote> <p>The insert array is like this </p> <pre><code>$data = array( 'date' =&gt; '2012-10-12', 'time' =&gt; '10:37:10' ); </code></pre> <p>date field datatype date time field datatype time(7)</p> <pre><code>$sql = "INSERT INTO test (p_date, p_time) VALUES (?, ?)"; $stmt = sqlsrv_prepare($conn, $sql, array(&amp;$data['date'], &amp;$data['time'])); if( sqlsrv_execute($stmt) === false) { die( print_r( sqlsrv_errors(), true)); } </code></pre>
php
[2]
3,247,791
3,247,792
returning a Tuple with a null item
<p>I have some code that looks like this:</p> <pre><code>public Tuple&lt;bool, SomeObjectModel&gt; CheckIfJsonIsValid(string IncomingJson) { SomeObjectModel TheObjectModel = new SomeObjectModel(); JavascriptSerializer TheSerializer = new JavascriptSerializer(); ..... try { TheObjectModel = TheSerializer.Deserialize&lt;SomeObjectModel&gt;(IncomingJson); } catch { return new Tuple&lt;bool, SomeObjectModel&gt;(false, null); //question here } ..... return new Tuple&lt;bool, SomeObjectModel&gt;(true, TheObjectModel); } </code></pre> <p>The calling method first check the returning tuple's Item1, and if it's false, ends its process.</p> <p>Is it better practice a) to return a null value in the Tuple or b) to return a new and fresh instance of SomeObjectModel? Are there any performance implications?</p> <p>Thanks for your suggestions.</p>
c#
[0]
4,018,866
4,018,867
Workaround if the Application is Down
<p>We have deployed an application on the server. Problem is, sometimes the application will be down due to some issue (Ex: While Downloading huge volume of data into Excel). The application will be up after manually restarting the IIS. We are creating a new application, so we are not working to fix this issue. As a workaround, we are trying to build an exe with the below requirement: Ping the application deployed on the server and find out whether the application is up or down, If the application is down, restart IIS.</p> <p>Is it possible to ping a local website on the IIS? Is there any other way to do a temporary fix?</p>
asp.net
[9]
993,210
993,211
How can I make driving navigation app on Android
<p>How can I draw an Arrow showing the driving direction in MapView ?.</p>
android
[4]
5,969,599
5,969,600
jQuery: Selecting an item in a drop down list using the text value
<p>Using jQuery, what is the easiest way to select an item in a drop down list using the text value.</p> <p>For example, I have drop down list that has a list of states. And I have the text value of β€œPA”. I want to make β€œPA” be the selected value. What is the best way to do this using jQuery. I have been doing Google searches for hours and I cannot find an example to this question.</p> <p>Note each item in the drop down list has a numeric key. And I know that $(#ddlStates).val(key) will select the value I want. However, I do not have the key only the test (β€œPA”)</p> <p>Thanks for your help. </p>
jquery
[5]
4,275,656
4,275,657
File is being used by another process
<p>I am developing a c# application, backend as sqlite.In my application i have an option for clean databse.It means the curren .db file will delete using File.Delete method and again it create empty databse using File.create method.Now let me explain the problem.</p> <p>To perform cleandatabse task, i have to stop all the process which is running ,after doing that if i click on clean database it is throwing an error that file cannot delete, it is being used by another process.i am able to stop all the thread which is running.</p> <p>Somehow i am able to find which process is blocikng the file ,</p> <pre><code>foreach (var process in Process.GetProcesses()) { var files = GetFilesLockedBy(process); if (files.Contains(filePath)) { procs.Add(process); Console.WriteLine(process.ProcessName); process.Kill(); File.Delete(filePath); } } </code></pre> <p>But in the above code i used process.Kill, which close the window form which i am running. without using kill, i tried close and dispose which doesn't work for me.</p> <p>Can you please help me to release the file from the process without closing the application and then yo delete the db file.</p> <p>Thank you in advance</p> <p>Best regards</p> <p>Sangita.</p>
c#
[0]
2,538,988
2,538,989
Run jQuery function immediately after an animate
<p>im using the following JSfiddle: <a href="http://jsfiddle.net/edddotcom/7NQKU/1/" rel="nofollow">http://jsfiddle.net/edddotcom/7NQKU/1/</a></p> <p>I'm using a callback function to change the background of the text immediately after the image is clicked,</p> <p>The is the sibling of the so i was hoping i could just use .sibling() but it doesnt work, what am i doing wrong?</p> <p>HTML:</p> <pre><code>&lt;div class="container"&gt; &lt;img src="http://cloudsmaker.com/hipsterwall/img/salto-al-norte.jpg" height="100%"&gt; &lt;span&gt;TEXT HERE TEXT HERE TEXT HERE &lt;/span&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.container { display: block; width: 900px; height: 116px; background-color: red; } span { float: left; margin-top: 10px; margin-left: 10px; max-height: 100%; } img { float: left; height:100%; max-width: 400px; min-width: 200px; } </code></pre> <p>JavaScript:</p> <pre><code>$(document).ready(function() { //ON CLICK $("img").toggle(function () { //fired the first time $(this).parent().animate({ //FIRSTCLICK COMMAND height: "232px" },function(){ $(this).sibling().css("background-color","yellow"); }); }, function () { // fired the second time $(this).parent().animate({ //SECONDCLICKCOMMAND height: "116px" },function(){ $(this).sibling().css("background-color","white"); }); }); }); </code></pre> <p>removing the .sibling() part makes the background change which also confused me. How can i make it so only the text background changes?</p>
jquery
[5]
5,808,964
5,808,965
How to Initialize a char array inside a class?
<p>I was about to initialize a char array inside a class as</p> <pre><code>class a{ char a[25]; }; a::a(){ a[] = {'a','b','c'}; } </code></pre> <p>but gives compile time error.</p>
c++
[6]
5,155,128
5,155,129
Hyperlink pdf on MUPDF
<p>I have build MUPDF library for android and its working fine to view a pdf but any one know how I can able to view pdf with hyper link using mupdf as mupdf said support hyperlink?????</p>
android
[4]
1,356,659
1,356,660
File encoding from English text to UTF-8
<p>How to convert a Non-ISO extended-ASCII English text, with CRLF line terminators to utf-8 in Python</p>
python
[7]
2,711,424
2,711,425
Jquery - How to check, if child in hidden DIV is visible?
<p>how can i check a div in a hidden div ... if visible or not?</p> <p><strong>HTML</strong></p> <pre><code>&lt;div style="display:none;"&gt; &lt;div id="two_child"&gt;&lt;/div&gt; &lt;div id="three_child" style="display:none"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>JS</strong></p> <pre><code>if($('#two_child').is(':visible')) { alert('true'); } </code></pre> <p>This will not work. </p> <p>Any ideas`?</p> <p>Thanks in advance! Peter</p>
jquery
[5]
5,153,743
5,153,744
Understanding the negate() function example from Eloquent Javascript (Chapter 6)
<p>As a new javascript developer, I have spent some time with this code snippit from <a href="http://eloquentjavascript.net/chapter6.html" rel="nofollow">Chapter 6 of Eloquent Javascript</a>, I am still trying to understand the following code example : </p> <pre><code>function negate(func) { return function(x) { return !func(x); }; } var isNotNaN = negate(isNaN); document.writeln(isNotNaN(NaN)); </code></pre> <p>Where it particular loses me is the following line, I just don't understand the call in general and where the variable/value for <strong>NaN</strong> comes from:</p> <pre><code>document.writeln(isNotNaN(NaN)); </code></pre>
javascript
[3]
4,918,992
4,918,993
Broadcast Receiver not responding
<p>Can any one let me know what is the best practise to do when there is a BroadcastReceiver that hasn't finished executing within 10 seconds</p>
android
[4]
2,324,355
2,324,356
Altering variable in a method
<pre><code>private int myInt; public var(int a) myInt = a; var x = new var(1) var y = new var(5) var z = y; x = increment(y) // where the increment method increments y by 1. </code></pre> <p>If the increment method alters the value of y, is the value of z also changed? In my book, when y is altered, z is also altered, but, how is that possible if z was already assigned to y before the increment method was called? Also I don't understand why x has anything assigned to it after the method. I thought that the scope of the method stays within the method; therefore after increment(y) exits, the value of x remains unchanged.</p> <p>Please correct me if I am wrong because I am fairly new to programming.</p> <p>Thank You!</p>
java
[1]
4,180,103
4,180,104
Java real time strategy game development
<p>I'm coming to the end of my first year of CS and I thought a great way to consolidate all the things I've learnt this year would be a personal game project.</p> <p>I would like to implement a 2D based rts, I'm thinking along the lines of starcraft I, warcraft II or even command and conquer. I will have about 3 months without interruptions to implement the game.</p> <p>So to anyone experienced with java game programming, I have a few questions:</p> <p>Is it realistic to design a 2D rts engine from scratch in 3 months? If so what are some good books/resources to get started?</p> <p>Would it be better to modify some existing project? I would think the experience of having to work with a lot of someone else's code would be good since our exposure to such topics in an undergrad cs degree seems very rare, if non-existent.</p> <p>Are there any decent open source 2d rts projects that anyone could recommend? I've looked through a few but most seem to be written in c/c++</p> <p>My humble thanks</p> <p>Edit: Thanks for the quick responses, I think that perhaps it was a bad idea to post this in a rush since I think I misrepresented what I want to do. </p> <p>When I say "along the lines of warcraft II etc" I mean more like that style of rts using sprites. I don't intend to implement a game nearly that complex, more like just a basic prototype. </p> <p>My goal would be some thing more like a flat textured map with some basic obstacles like trees, a single unit producing structure like a barracks. I'd like to have the units to have health bars, be able to move and attack and die (and possible morph into another unit). </p> <p>Far off goals would be to implement some basic pathing using a modified version of the dijkstra shortest path algorithm, ranged units with missle attack, etc.</p> <p>I don't plan to implement any opponents or ai or networking or anything like that.</p>
java
[1]
717,565
717,566
How to separate a Python list into two lists, according to some aspect of the elements
<p>I have a list like this:</p> <pre><code>[[8, "Plot", "Sunday"], [1, "unPlot", "Monday"], [12, "Plot", "Monday"], [10, "Plot", "Tuesday"], [4, "unPlot", "Tuesday"], [14, "Plot", "Wednesday"], [6, "unPlot", "Wednesday"], [1, "unPlot", "Thursday"], [19, "Plot", "Thursday"], [28, "Plot", "Friday"], [10, "unPlot", "Friday"], [3, "unPlot", "Saturday"]] </code></pre> <p>I want to separate it into two lists according the <code>Plot</code> and <code>unPlot</code> values, resulting:</p> <pre><code>list1=[[8, "Plot", "Sunday"], [12, "Plot", "Monday"], ...] list2=[[1, "unPlot", "Monday"], [4, "unPlot", "Tuesday"], ...] </code></pre>
python
[7]
5,622,440
5,622,441
Password protect app like Dropbox does it
<p>How do I password protect my app? I didn't think it was possible but the Dropbox app does it.</p>
android
[4]
2,728,192
2,728,193
Best Java 'framework' for LOW-END 3D Graphics?
<p>I've made my share of 2D games on various platforms but I have never developed a 3D game.</p> <p>I want to make a small "mmorpg". I already made my server in python and it works just fine with my flash 2D game but I decided I want to step it up and try out 3D. I want to make a 3D game for the web browser and I think Java might be a good choice for this. </p> <p>So basically I'm just looking for a straight forward and well documents 'framework' to make LOW-END 3D games. Keep in mind that I will be targeting peoples with very low-end PC's (plus my 3d modeling skills aren't great so I wouldn't mind hiding it somewhat, haha)</p>
java
[1]
5,752,596
5,752,597
Accessing another third party app in android
<p>How to access another third party application from my application in android?</p>
android
[4]
2,043,744
2,043,745
MapView not showing data
<p>I have created the simple <code>MapView</code> example in <code>android</code>, but it is not displaying anything in the emulator</p> <p>Logcat Datails are:</p> <pre><code>01-30 10:24:53.976: W/System.err(1033): IOException processing: 26 01-30 10:24:53.983: W/System.err(1033): java.io.IOException: Server returned: 3 01-30 10:24:54.003: W/System.err(1033): at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115) 01-30 10:24:54.020: W/System.err(1033): at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473) 01-30 10:24:54.022: W/System.err(1033): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117) 01-30 10:24:54.022: W/System.err(1033): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994) 01-30 10:24:54.022: W/System.err(1033): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702) 01-30 10:24:54.032: W/System.err(1033): at java.lang.Thread.run(Thread.java:856) 01-30 10:24:54.263: W/Trace(1033): Unexpected value from nativeGetEnabledTags: 0 01-30 10:24:54.263: W/Trace(1033): Unexpected value from nativeGetEnabledTags: 0 01-30 10:24:54.343: W/Trace(1033): Unexpected value from nativeGetEnabledTags: 0 </code></pre>
android
[4]
274,016
274,017
How can you round up a number and display it as a percentage?
<p>I'm a bit rusty on my mathematics so I hope someone can help me. Using the code below I would like to do the following: Depending on the amount of memory installed, I would like to display the percentage of available memory and not how much is left in megabytes.</p> <pre><code>private void timer1_Tick(object sender, EventArgs e) { string memory; int mem; memory = GetTotalMemoryInBytes().ToString(); mem = Convert.ToInt32(memory); mem = mem / 1048576; progressBar2.Maximum = mem; progressBar2.Value = mem - (int)(performanceCounter2.NextValue()); label2.Text = "Available Memory: " + (int)(performanceCounter2.NextValue()) + "Mb"; } //using Microsoft visual dll reference in c# static ulong GetTotalMemoryInBytes() { return new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory; } </code></pre>
c#
[0]
5,042,294
5,042,295
How to update an value in app.config file?
<p>This is my code:</p> <pre><code>Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); KeyValueConfigurationCollection settings = configuration.AppSettings.Settings; settings["IP"].Value = "10.0.0.2"; configuration.Save(ConfigurationSaveMode.Modified); </code></pre> <p>when I break on settings["IP"].Value line, i get the correct value.<br> The method completes without any errors but app.config file remains unchanged. </p>
c#
[0]
6,024,662
6,024,663
identifying objects, why does the returned value from id(...) change?
<blockquote> <h3>id(object)</h3> <p>This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. </p> </blockquote> <p>Can you explain this output? Why does <code>j</code>'s id change?</p> <pre><code>&gt;&gt;&gt; i=10 &gt;&gt;&gt; id(i) 6337824 &gt;&gt;&gt; j=10 &gt;&gt;&gt; id(j) 6337824 &gt;&gt;&gt; j=j+1 &gt;&gt;&gt; id(j) 6337800 &gt;&gt;&gt; id(i) 6337824 </code></pre>
python
[7]
4,434,997
4,434,998
What minifier was used to generate the official JQuery "minified" version?
<p>I need to edit the current JQuery library 1.4.x (and completely rename the JQuery "object/function") in a high conflicting environment. </p> <p>My question is, with what minifier has the official JQuery minified version been generated. Where can I find this minifier? (As I want to use it for minifing my version too).</p> <p>Thank you! Tim</p>
jquery
[5]
1,532,630
1,532,631
Android ListView with CheckBox and a selectable item
<p>I have seen plenty of samples which support a checkbox for each item in a list but this seems to be about as far as they go. My problem is that I have two lists of items which interact.</p> <p>The first list displays Method Statements - when the user select a method statement the second list displays a list of Risk Assesments for this method statement. I have this all working with no issues.</p> <p>I now need to extend this so that the user can select (via a checkbox) the Method Statements that they want to use. What this means is that I do not want the selection of the listitem to set or clear the check box, just populate the second listbox. I do however need the user to be able to manually check the item to include it.</p> <p>Any suggestions please would be most welcome - maybe a ListView is not the correct way to do this, perhaps a dynamically created table within a scroll view?</p>
android
[4]
5,169,212
5,169,213
Random weighted choice
<p>I have data like that:</p> <pre><code>d = ( (701, 1, 0.2), (701, 2, 0.3), (701, 3, 0.5), (702, 1, 0.2), (702, 2, 0.3), (703, 3, 0.5) ) </code></pre> <p>Where (701, 1, 0.2) = (id1, id2, priority) Is where pretty way to choice id2 if I know id1, using priority?</p> <p>func(701) should return:<br> &nbsp;&nbsp;1 - in 20% cases<br> &nbsp;&nbsp;2 - 30%<br> &nbsp;&nbsp;3 - 50%<br> Percent will be rough of course</p>
python
[7]
290,517
290,518
Limit Geocoder getFromLocationName scope to one specific City
<p>The following is my method:</p> <pre><code>List&lt;Address&gt; addresses = null; addresses = new Geocoder(passengerHomeActivity).getFromLocationName(this.addressInput.getText().toString(), 1); </code></pre> <p>is there any way to limit the <code>Geocoder</code> <code>getFromLocationName</code>'s scope to one specific city? Sometimes when I enter an Address without writing the city name, it leads me to an address which is the same but in another city.</p> <p>My idea is by getting the <code>latitude</code> and <code>longitude</code> of the user, get the value of the city, and set the limit scope to the <code>getFromLocationName</code> method, but I don't have any clue with the implementation.</p> <p>Thanks</p>
android
[4]
3,091,878
3,091,879
why can not display HTML codes?
<p>In test.txt, I have 2 lines of sentences.</p> <pre><code>The heart was made to be broken. There is no surprise more magical than the surprise of being loved. </code></pre> <p>In codes:</p> <pre><code>import urllib2 file = open('/Users/name/Desktop/textfile.txt','r') data = file.readlines() file.close() countline = 0 for line in data: countline = countline + 1 line_replace = line.replace(" ", "+") line_url = 'http://sentistrength.wlv.ac.uk/results.php?text=' + line_replace + '&amp;submit=Detect+Sentiment' requesturl = urllib2.Request(line_url) openurl = urllib2.urlopen(requesturl) readurl = openurl.read() print readurl </code></pre> <p>I am trying to print out HTML codes. If there is only 1 sentence in Textfile. Everything work fine but there is an error when there is 2 sentences in text file (I want to display html codes of both sentence.) Any possible way for solving this?</p> <p>The error: </p> <pre><code>URLError: &lt;urlopen error no host given&gt; </code></pre>
python
[7]
3,804,336
3,804,337
File not found error in Android
<p>I have two folders inside my assets folder which contains 3 html files. I am loading one of this HTML file in a webview and inside this file I am referring other two files using href. When I run this code and click on this link inside the webview I am getting an error in the webview that It cannot find the file. How should I give the path of the file. I am just giving the file name only because it is in the same path as the referring HTML file. What am I doing wrong?</p> <p>This is inside my html file.</p> <blockquote> <pre><code>Functions &lt;a href="android.resource://com.com.com/assets/begin.html"&gt;begin()&lt;/a&gt; </code></pre> </blockquote> <pre><code>&lt;a href="android.resource://com.mypack.test/assets/begin.html"&gt;begin()&lt;/a&gt; &lt;a href="file:///android_asset/begin.html"&gt;begin()&lt;/a&gt; </code></pre> <p>I tried both didn't work</p> <p>I am trying to get the begin.html file.</p> <p>This is my java code </p> <pre><code> WebView web = (WebView)findViewById(R.id.webview); String str = readFile(parent_folder +"/"+ folder_name); web.loadData(str, "text/html", null); </code></pre> <p>readFile() reads the HTML file and returns the contents.</p> <p>inside this webview I am linking to another html file inside the assets folder.</p>
android
[4]
3,103,711
3,103,712
Is there any way to do this without using '__init__'?
<pre><code>class a(object): c=b()# how to call the b method d=4 def __init__(self): print self.c def b(self): return self.d+1 a() </code></pre> <p>how to call the 'b' method not in the <code>__init__</code> </p> <p>thanks</p> <p>the error is :</p> <pre><code>Traceback (most recent call last): File "D:\zjm_code\a.py", line 12, in &lt;module&gt; class a(object): File "D:\zjm_code\a.py", line 13, in a c=b()# how to call the b method NameError: name 'b' is not defined </code></pre>
python
[7]
2,704,008
2,704,009
Looking for a simple example of informal protocols in Objective C, to understand how informal protocol works actually
<p>I am looking for a simple example, which shows how informal protocols works!</p>
iphone
[8]
4,304,956
4,304,957
Attach to Property's setter
<p>I haven't found similiar post so I'm asking this.<br> Let's say I defined somewhere an application wide available static Property (I mean it's not local) and in one class I would like to know when this property is being changed. Apart from aop (transparentproxy etc.) which I think doesn't suit me well here (and I can't add that to project anyway), what are the options here? </p> <p>One solution I can think of, which is probably a very nasty one, is to use some event that would be executed in the setter and just attach it in the class(es) which needs that. Something like: </p> <pre><code> public static event EventHandler CurrentNumberChanged= delegate {}; public static int CurrentNumber { get { return currentNumber; } set { currentNumber = value; CurrentNumberChanged(null, EventArgs.Empty); } } </code></pre> <p>I know it's really unsafe to use such events ( <a href="http://stackoverflow.com/questions/289002/how-to-raise-custom-event-from-a-static-class/289358#289358">read here</a> ). And since I would use it in asp.net makes it even more ugly. Do you have any advices ?</p>
c#
[0]
2,617,437
2,617,438
Download file created by PHP without changing windows
<p>I'm generating a file whenever a php script is run, which is downloaded in at the same time by the user (no copies are saved to the server).</p> <p>Currently I'm redirecting a user from the file creation php script back to the original page.</p> <p>I'd like to not redirect the user back to the original page but have them stay on the original page and the PHP script to still run and prompting them to save the custom created file.</p> <p>I'm not entirely sure, but would be adding/changing something from the end of my current PHP script or simply changing my HTML link to it somehow? I'm</p> <p>My HTML</p> <pre><code>&lt;a href="fileCreator.php"&gt;Download File&lt;/a&gt; </code></pre> <p>My PHP</p> <pre><code>header("Content-type: text/txt"); header("Content-Disposition: attachment; filename=file.txt"); header("Pragma: no-cache"); header("Expires: 0"); header("Location: [ORIGINAL PAGE]"); echo $txtFile; </code></pre>
php
[2]
2,325,533
2,325,534
Import javascript file in javascript function
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/3991492/include-a-javascript-file-in-a-javascript-file">Include a javascript file in a javascript file</a><br> <a href="http://stackoverflow.com/questions/950087/include-javascript-file-inside-javascript-file">Include JavaScript file inside JavaScript file?</a> </p> </blockquote> <p>What is the best way to import javascript file (file.js) in javascript function().</p> <p>For example what is the best way to replace the todo statement:</p> <pre><code>function doSomething() { if (xy.doSomething == undefined) { // todo: load 'oldVersionPatch.js' } ... } </code></pre> <p>Possibly the best solution is to create script element and add it into html page. My questions are:</p> <ul> <li>is it better to add/append it into head, or body (what will load when)?</li> <li>is it better to use javascript or jquery (what is more cross-browser compatible)?</li> </ul>
javascript
[3]
5,816,129
5,816,130
Find in a stl map doesn't work when a custom compare function is written which stops keys from sorting
<pre><code>class compare { public: bool operator()(const int x,const int y) const { if(x-y == 0) return false; else return true; } }; int main() { std::map&lt;char,int,compare&gt; mymap; //Add data into map mymap.insert ( std::pair&lt;char,int&gt;('f',100) ); mymap.insert ( std::pair&lt;char,int&gt;('a',100) ); mymap.insert ( std::pair&lt;char,int&gt;('k',100) ); mymap.insert ( std::pair&lt;char,int&gt;('z',200) ); //try to find a key in map std::map&lt;char,int,compare&gt;::iterator l_pos = mymap.begin(); l_pos = mymap.find('z'); if(l_pos != mymap.end()) { printf("\nfound = %c\n",l_pos-&gt;first); } else { printf("Not found = %c\n",l_pos-&gt;first); } } </code></pre> <p>Result:</p> <pre><code>Not found = </code></pre> <p>But if I display the map I can see the contents. mymap contains: f => 100 a => 100 k => 100 z => 20</p> <p>Find in a stl map doesn't work when a custom compare function is written which stops keys from sorting. The Find fails. Is there a way to fix this? Find doesn't return any data. I know stl maps are not for this purpose. But is there way to fix this? The Compare function stops sorting. The entries are stored in reverse order. When I use a for loop to iterate through the map I can see all the values. It is only the find command which is not working.</p>
c++
[6]
1,716,550
1,716,551
vibration and sound won't be played
<p>I have the following code:</p> <pre><code>String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); CharSequence tickerText = "HI!"; long when = System.currentTimeMillis(); Notification notification = new Notification(R.drawable.droid, tickerText, when); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.flags |= Notification.DEFAULT_SOUND; notification.flags |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.DEFAULT_VIBRATE; </code></pre> <p>for some reason - none of the flags really applied except for the auto cancel.</p> <p>No vibration, no sound, no lights.</p> <p>What can cause this? I tried in 3.1 &amp; in 2.2.1</p> <p>Thanks</p>
android
[4]
64,381
64,382
How can I get the ID of an icon of another application?
<p>I need to create home shortcuts of other applications. in order to do that I need to get the ID of the icon drawable.</p> <p>I can get the actual drawable, but i dont know how to get the ID of it without knowing the name of the drawabale.</p> <p>Is there a way to find the name of the drawable or get the ID from the drawable object?</p> <p>i think i said drawable too many times.</p> <pre><code>//get icon drwable public Drawable getIcon(String pack) { final PackageManager pm = context.getPackageManager(); try { return pm.getApplicationIcon(pack); } catch (NameNotFoundException e) { e.printStackTrace(); return null; } } public void makeShortcut(String pack){ Intent shortcutIntent; shortcutIntent = new Intent(); shortcutIntent.setComponent(new ComponentName(pack, ".classname")); int iconId =geIconId(pack); // a default icon for now TODO Log.i("icon id", ""+iconId); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); final Intent putShortCutIntent = new Intent(); putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); // Sets the custom shortcut's title putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getAppName(pack)); putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext( context,iconId)); putShortCutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); context.sendBroadcast(putShortCutIntent); } </code></pre>
android
[4]
1,781,255
1,781,256
PHP mobile emulator program
<p>I am working on project on page i have a big image of mobile. There is top input box which is looking for any site url.If somebody is any website url theta website output will be display in mobile interface. I am using <p>Thanks in Advance</p>
php
[2]
3,671,120
3,671,121
how to get select elements randomly from an array
<p>i have an array with 12 objects {0,1,2,3,4,5,6,7,8,9,10,11}</p> <p>from this array i have to pick 6 values randomly,but they are unique not repeated.</p> <p>i am using this for (int i =0; i&lt;6; i++) { NSLog(@"%d",rand()%12); } it gets as 7 1 5 2 10 8</p> <p>for second time it gets as 0 2 11 1 0 5,Here 0 is repeated.But i always need as my first output means values are not repeated.</p> <p>how can i done, </p> <p>can any one please help me.</p> <p>Thank u in advance. </p>
iphone
[8]
5,961,447
5,961,448
Doing something different with last sequence in a loop
<p>I am looking for the basic syntax of doing something different with the last itteration through a loop, using C#</p>
c#
[0]
412,326
412,327
If offset.top listen
<p>I have a long scrolling page, and want to test if an element is 100px from the top, then apply a class elsewhere (until the next element in line is 100px from the top)</p> <p>If I could just get the basic statement I would be ecstatic, anything extra would be a bonus!</p>
jquery
[5]
1,533,963
1,533,964
how to create a new php page with php- apostrophe issue
<p>To be more clear, I do understand how to create a new php file with php, I'm using <code>fwrite</code>, like so:</p> <pre><code>//actually create the file now $my_file=$post_title_edited . ".php";; $fh= fopen($my_file, 'w'); fwrite($fh, $head); fwrite($fh, $body); fwrite($fh, $php); fwrite($fh, $php2); fwrite($fh, $php3); fwrite($fh, $phpend); fwrite($fh, $end); fclose($fh); //redirect to created file header("location:". $post_title_edited .".php"); </code></pre> <p>Now it all works just fine, or rather it would, if it were not for this issue:</p> <pre><code>$php3=' session_start(); if(isset($_SESSION['login'])){ $myusername = $_SESSION['login']; echo ' &lt;div id="header-logedin"&gt; &lt;h3&gt;Hello ' . $myusername . '&lt;/h3&gt; &lt;a href="login/logout.php"&gt;Log out&lt;/a&gt; &lt;/div&gt;&lt;!--header-logedin--&gt; '; } else { echo $log; } </code></pre> <p>As you can see, when i begin to set <code>$php3</code>, it is interupted by the apostrophe in the login from my first session call. Therefore it can't be set and in turn i can't write it into my new file, also <code>$php2</code> has this same problem. </p> <p>What am i trying to do? In a nutshell: user posts from index.php information posts over onto new page created by this code, after data is checked against sql table to make sure it doesn't already exist, very much like a forum. I really hope this is something complicated and I'm not overlooking something incredibly obvious. Thanks in advance.</p>
php
[2]
3,669,101
3,669,102
javascript count down timer
<p>Im wanting to make this javascript count down timer show 01 instead of 1 and 00 when theres nothing in that part. im basically just trying to make it look like a digital clock, but it looks weird when theres no 0 making it squeeze in.</p> <p>heres the script i found </p> <pre><code>// JavaScript Document CountDownTimer('03/25/2013 9:0 AM', 'countdownSpring'); CountDownTimer('06/10/2013 9:0 AM', 'countdownSummer'); CountDownTimer('11/27/2013 9:0 AM', 'countdownFall'); CountDownTimer('12/23/2013 9:0 AM', 'countdownWinter'); function CountDownTimer(dt, id) { var end = new Date(dt); var _second = 1000; var _minute = _second * 60; var _hour = _minute * 60; var _day = _hour * 24; var timer; function showRemaining() { var now = new Date(); var distance = end - now; if (distance &lt; 0) { clearInterval(timer); document.getElementById(id).innerHTML = 'CAMP IS HERE!'; return; } var days = Math.floor(distance / _day); var hours = Math.floor((distance % _day) / _hour); var minutes = Math.floor((distance % _hour) / _minute); var seconds = Math.floor((distance % _minute) / _second); document.getElementById(id).innerHTML = days + ':'; document.getElementById(id).innerHTML += hours + ':'; document.getElementById(id).innerHTML += minutes + ':'; document.getElementById(id).innerHTML += seconds; } timer = setInterval(showRemaining, 1000); } </code></pre>
javascript
[3]
5,345,002
5,345,003
sort a List<Tuple> from highest to lowest
<pre><code>List&lt;Tuple&lt;String, int[], int&gt;&gt; </code></pre> <p>I want to sort the <code>List</code> by the <code>int</code> from highest to lowest.</p>
java
[1]
3,089,421
3,089,422
C# can an inherited method or property use the derived class members without creating a new method?
<p>I'm coding a simple game using C# to help me learn basic object oriented concepts.</p> <p>In this code below:</p> <pre><code>class entity { int hp; string name; public entity() { hp = 1; name = "entity"; } public string status() { string result; result=name + "#" + " HP:" + hp; return result; } class dragon : entity { new public string name; new int hp; public dragon() { hp = 100; name = "Dragon"; } } </code></pre> <p>I made an object for "Dragon" as such</p> <pre><code>dragon mydragon = new dragon(); </code></pre> <p>The problem is with the following code:</p> <pre><code>mydragon.status(); </code></pre> <p>This returns a string but with the "name" and "hp" of the <strong>entity</strong> class object (i.e. hp=1, name=entity).</p> <p>I'd like to have this return the dragon object's values (hp=100, name=dragon). I'm not sure what I'm doing wrong but it seems dead simple.</p> <p>After fiddling and struggling for hours, the only solution I could come to was to simply copy &amp; paste the <strong>status()</strong> method over to the dragon class. But I'm sure there's a better way to do this.</p> <p>Many thanks in advance.</p>
c#
[0]
5,710,532
5,710,533
get remote image dimensions before accepting it as an upload? getimagesize() too slow
<p>I've been using getimagesize() to get the dimensions of an image a user is uploading, then checking if there is enough memory to process this image. The problem is getimagesize() downloads the file to the server before reading dimensions. So its catch 22. this must be a very common problem but i havent come across a universal solution. Is there a solid way to get a remote images dimensions without downloading it?</p>
php
[2]
3,966,931
3,966,932
How to check application is idle for 1 min?
<p>If my application is idle for 1 min then I want to open the login page (but maintain the activity stack).</p> <p>Can anybody please help me to find the idle of an application</p> <p>Regards, Monali</p>
android
[4]
46,386
46,387
android location detection
<p>So I wanted to detect the user current location when my main activity starts. </p> <p>The way I implemented was to have the GPS location manager and the Wifi location manager and one locationlistener listening to Both. As soon as the locationlistener found the current location. it will stop listening for location change and consider this location the current location. </p> <p>My question is, do you see any danger in using both GPS and Wifi? I used both in case the device don't have the GPS activated or vice versa .... </p> <p>Thanks,</p>
android
[4]
3,997,866
3,997,867
jQuery validate : multiple form, single validation
<p>I have 2 forms, namely (ids mentioned) 'add_product' and 'edit_product'</p> <p>Now I am using jQuery validation plug-in, both the forms have same validation (similar to mentioned in following example)</p> <pre><code>jQuery("#add_product").validate({ rules: { name:"required", price:"number" }, messages: { name:"Please enter Plan Name", price:"Enter a valid number" } }); </code></pre> <p>and </p> <pre><code>jQuery("#edit_product").validate({ rules: { name:"required", price:"number" }, messages: { name:"Please enter Plan Name", price:"Enter a valid number" } }); </code></pre> <p>I want to combine them into 1 rule/function, how can I achieve this?</p> <p>Thanks</p>
jquery
[5]
1,937,300
1,937,301
Jquery; correctly selecting contents of a script tag
<p>I have a single page web application using jquery and a set of embedded templates. A template may contain tag like below:</p> <pre><code>&lt;script type="html/template" id="sample"&gt; &lt;script type="text/javascript" charset="utf-8"&gt;alert('x');&lt;/script&gt; &lt;/script&gt; </code></pre> <p>and a jquery code to retrive the template is</p> <pre><code>$("#sample").html(); </code></pre> <p>The output of above jquery command is</p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt;alert('x'); </code></pre> <p>Instead of</p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt;alert('x');&lt;/script&gt; </code></pre> <p>How can I fix this output ?</p>
jquery
[5]
253,035
253,036
How to install multiple apks at a time?
<p>Am developing one Android application which is using thinkfreeoffice.apk for viewing documents in my application. My requirement is I have to download both my application and thinkfreeoffice apks at a time and also install both these apks at a time.</p> <p>anybody did this one before?</p>
android
[4]
3,423,614
3,423,615
in_array not working explode
<p><img src="http://i.stack.imgur.com/rURln.png" alt="enter image description here"></p> <p>I am not able to figure out why my condition is not working while the ip address is in the array. Why condition is failing as shown in image </p> <pre><code>&lt;?php $valid_ip_list = explode(',',$this-&gt;valid_ips); echo $client_ip = $_SERVER['REMOTE_ADDR']; print('&lt;pre&gt;'); print_r($valid_ip_list); if(in_array($client_ip ,$valid_ip_list)) { echo 'I am here'; } else { echo 'Condition fail'; } ?&gt; </code></pre> <p>Problem solved with the help of <code>array_map('trim', explode(',', $valid_ips))</code></p>
php
[2]
3,294,166
3,294,167
Android app not running in AVD
<p>I have an android app which is not getting launched in AVD. The app was working fine till yesterday but now when i am running it, the AVD gets launched but the app is not starting. Console just shows 'Waiting for HOME ('android.process.acore') to be launched... '. It is not throwing any error but not starting..</p> <p>Pls help..Thanks</p>
android
[4]
1,437,679
1,437,680
What does $1, $2, etc. mean in Regular Expressions?
<p>Time and time again I see $1 and $2 being used in code. What does it mean? Can you please include examples?</p>
javascript
[3]
4,739,932
4,739,933
How to replace " and \ from text files using Java?
<p>I'm using <code>replace</code> and <code>replaceAll</code> Java functions to replace strings in text files.</p> <p>I've some issues with some symbols occurring in my text file, such as <code>"</code> and <code>\</code></p> <p>Let's say I have to remove the " from "blablabla", what should i use ? I'm currently using this line but it doesn't work:</p> <pre><code>fields[i] = fields[i].replaceAll("\\"blablabla\\"", ""); </code></pre> <p>thanks</p>
java
[1]
2,547,566
2,547,567
Running an ASP.net Website from the root
<p>I have an ASP.net Website. the project' content is in a folder called MyWebSite. When I run my application from Visual Web developer 2008, the browser displays the following address in the address bar: http: // localhost/ MyWebSite /Default.aspx I want to be able to run my Website from the following address: <a href="http://localhost/" rel="nofollow">http://localhost/</a></p> <p>Can anyone help me please? Thanks in advance.</p>
asp.net
[9]
3,506,952
3,506,953
comma separated value in php adding space and small square
<p>I have a text area in a form im writing pasting the comma separated value in the text area</p> <p>like</p> <pre><code>1,2,3,4,5 6,7,8,9,10 11,12,13,14,15 </code></pre> <p>when i submit from its creating a csv file but the csv file in the row 1 contains header </p> <p>its appending the 1 st row with the first row value of the comma separated value</p> <p>i get like this ,iget the small square and the first row of comma separated value is </p> <p>appended to the header</p> <pre><code>id, grpname, grpid,code,name1,2,3,4,5 6,7,8,9,10 11,12,13,14,15 </code></pre> <p>heres the code</p> <pre><code>$csvdata = $_REQUEST['csvdata']; $arr = explode(",", $csvdata); $fname = 'file.csv'; $fp = fopen($fname, 'w'); $heading_row = array('id', 'grpname', 'grpid', 'code', 'name'); fputcsv($fp, $heading_row); foreach ($arr as $val) { $v = trim($val); $v .= ','; fwrite($fp, $v, strlen($v)) || die("not written"); } fclose($fp); </code></pre>
php
[2]
3,741,388
3,741,389
is it really wrong to release resources in onDestroy?
<p>Android documentation says (in <a href="http://developer.android.com/training/basics/activity-lifecycle/stopping.html" rel="nofollow">http://developer.android.com/training/basics/activity-lifecycle/stopping.html</a>):</p> <blockquote> <p>In extreme cases, the system might simply kill your app process without calling the activity's final onDestroy() callback, so it's important you use onStop() to release resources that might leak memory.</p> </blockquote> <p>Sounds like it is wrong. How could killed process leak memory?</p>
android
[4]
159,771
159,772
Android File.delete not working
<p>Im trying to delete an image file after I saved it to SD card, but the delete function is not working. Any help will be appreciated. Here is my code:</p> <pre><code>// Save image to SD card String path = Environment.getExternalStorageDirectory().toString(); File file = new File(path, "tmpimage" + ".jpg"); .... .... .... // Delete image from SD card file.delete(); </code></pre> <p>Later on I found out that I was actually deleting the file. The File.delete function actualy was working ok. I was saving the image also to the Gallery and was expecting the file.delete to remove it from Gallery. Thanks everyone for answering my question.</p>
android
[4]
4,717,881
4,717,882
Java Calendar.add in giving inconsistent results
<p>I am having the following code</p> <pre><code> Calendar calendar = Calendar.getInstance(); calendar.set(2011, 7, 29); //case 1 // calendar.set(2011, 7, 30); //case 2 // calendar.set(2011, 7, 31); //case 3 System.out.println("===After seting the date== "+calendar.getTime()); System.out.println("================================================================="); calendar.add(Calendar.MONTH, 6); System.out.println("===result after adding 6 months== "+calendar.getTime()); </code></pre> <p>and for the case 2 and case 3 also i am getting the same results. it should overflow to next month and show the new date. but its not happening.</p>
java
[1]
5,930,436
5,930,437
Javascript quirks
<p>I was playing around with Chrome's Javascript console recently, and I discovered this oddity: </p> <pre><code>[] == true false [0] == true false [0] == [] false </code></pre> <p>This doesn't seem to make any sense at first glance (false != false), but I think the real reasoning lies in the polymorphism of the == operator. Comparing an array to a boolean isn't the same thing as comparing an array to another array.</p> <p>With that said, what are other Javascript quirks you've discovered?</p>
javascript
[3]
4,147,595
4,147,596
how to merge two images iphone with one image variable height
<p>I have two images.I want to display like where the first image end the next one should start.</p> <p>both have same width but the height of the first one is variable .</p> <p>I am not getting perfect code for it .</p> <p>please help me I am using one above another its displayed as a overlapped ??</p>
iphone
[8]
2,493,196
2,493,197
Python - TypeError: (function) takes exactly 2 arguments (3 given) - but I only gave 2!
<p>I'm parsing a list of patient visits (csv file). To deal with this, I have a custom set of classes:</p> <pre><code>class Patient: def __init__(self,Rx,ID): .... class PtController: def __init__(self,openCSVFile): self.dict=DictReader(openCSVFile) self.currentPt = '' .... def initNewPt(self,row): Rx = row['Prescription'] PatientID = row['PatientID'] self.currentPt = Patient(Rx,PatientID) ... </code></pre> <p>So, I'm using the csv.DictReader to process the file; built into the PtController class. It iterates through, but to set values for the first patient does the following:</p> <pre><code>firstRow = self.dict.next() self.initNewPt(self,firstRow) ... </code></pre> <p>The error: </p> <pre><code>TypeError: initNewPt() takes exactly 2 arguments (3 given) </code></pre> <p>If I print(firstRow) before calling initNewPt, it prints the row in dictionary form as expected. </p> <p>Using python2.7, and this is my first time working with objects. Thoughts? </p>
python
[7]
3,875,035
3,875,036
am cmd in sh script file does not work
<p>the sh file looks as follows</p> <pre><code>#!/system/bin/sh am start -a android.intent.action.MAIN -n com.android.settings/.Settings echo hello,world exit 1 </code></pre> <p>but it reports error like </p> <pre><code>Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.Sett }gs Error type 3 } does not exist.lass {com.android.settings/com.android.settings.Settings hello,world exit: Illegal number: 1 </code></pre> <p>but when i type it in sh shell directly, like in adb shell prompt, type <code>am start -a android.intent.action.MAIN -n com.android.settings/.Settings</code>, it works,and runs the activty</p> <p>so, what's the problem?</p>
android
[4]
2,712,962
2,712,963
can anybody tell how to take picture from camera and set in image view in android
<p>if user click take picture button . can anybody tell how to take picture from camera and set in image view can anybody give example</p> <p>Thanks</p>
android
[4]
1,740,111
1,740,112
JavaScript current URL check
<p>I am wondering how I would get JavaScript to check if a user is on a certain URL so i can build an if statement from the result. </p> <p>My reasoning is that if a user clicks on a link in the menu and they are currently on trucks.php the javascript will redirect them to a certain page. If they are not on trucks.php they will be directed to a different page.</p> <p>Cheers guys. </p>
javascript
[3]
5,794,595
5,794,596
how to get 100 links from google search in java
<p>I have been used google custom search engine api but after 100 request google block me to perform request.</p> <p>I only want 100 link from google search without any api, Is there any soultion. Please help me. If any api is available then please tell me about that api.</p> <p>Thnak you.</p>
java
[1]
4,580,940
4,580,941
handling function key press
<p>I have a C# form with 5 buttons. The users enters the information and depending on the press of a function key, a specific action is performed. <kbd>F9</kbd>-Execute Order, <kbd>F6</kbd>-Save, <kbd>F3</kbd>-LookUp.</p> <p>I have added the foolowing code:</p> <p>OnForm_Load</p> <pre><code>this.KeyUp += new System.Windows.Forms.KeyEventHandler(KeyEvent); </code></pre> <p>and </p> <pre><code>private void KeyEvent(object sender, KeyEventArgs e) //Keyup Event { if (e.KeyCode == Keys.F9) { MessageBox.Show("Function F9"); } if (e.KeyCode == Keys.F6) { MessageBox.Show("Function F6"); } else MessageBox.Show("No Function"); } </code></pre> <p>but nothing happens</p> <p>Thanks</p>
c#
[0]
4,520,508
4,520,509
PHP and Timer events
<p>I would like to use a Timer in php, sending messages after a certain period of time (no player activity)? This is for a multi-player game through sockets.</p> <p>I have googled and stackoverflew and found the following</p> <ul> <li>could use a cron (will need to synronize my php classes (socket based) with the cron... ), No I guess.</li> <li>could use sleep ... if it could wait for less than one second, I will have given a try, No again, I guess</li> <li>could use register_tick_function ... not applicable I think</li> </ul> <p>Any ideas? Thanks!</p>
php
[2]
3,603,541
3,603,542
String.IsNullOrEmpty() Check for Space
<p>What is needed to make <code>String.IsNullOrEmpty()</code> count whitespace strings as empty?</p> <p>Eg. I want the following to return <code>true</code> instead of the usual <code>false</code>:</p> <pre><code>String.IsNullOrEmpty(" "); </code></pre> <p>Is there a better approach than:</p> <pre><code> String.IsNullOrEmpty(" ".Trim()); </code></pre> <p><em>(Note that the original question asked what the return would be normally hence the unsympathetic comments, this has been replaced with a more sensible question).</em></p>
c#
[0]
2,453,745
2,453,746
What is difference between int.class and Integer.TYPE in java?
<p>I want to know the difference between int.class and Integer.TYPE in Java?</p>
java
[1]
5,671,668
5,671,669
problem with HelloMapView in android
<p>I am trying to write a mapView application .When i extend my class with MapActvity it will ganerates an error force to close application. And in log chat i got an runtime error like classNotFoundException.</p> <p>plz solve my problem. ThanQ.</p>
android
[4]
4,707,381
4,707,382
C# Daylight saving DateTime switch
<p>I have events that get triggered whenever the daylight switches happen.</p> <p>I get when the spring/fall switches are going to happen using </p> <pre><code>TimeZone.CurrentTimeZone.GetDaylightChanges(year) </code></pre> <p>This returns me 2 datetimes: 1. Start Datetime which is Spring cutover 3. End Datetime which is the Fall cutover.</p> <p>The Spring forward works fine.</p> <p>But for the Fall one the End Time I get is 2.00 AM CST. So when I subtract a second from I get 1.59.59 AM CST. So the event gets fired an hour later. I need to set the trigger for 1.59.59 CDT. How do I construct this Datetime?</p>
c#
[0]
3,210,576
3,210,577
Java-Instance Method Call
<p>When I call as instance method of a class as follows : object_name.function_name(); how the compiler knows that the "function_name" has to be called for that "object_name" behind the scenes ? </p>
java
[1]
2,736,837
2,736,838
How do you store the contents of a POJO in the preference store?
<p>I am looking to find a way to store the value of a POJO (containing Strings, booleans, ints) in a preference variable that I can then retrieve by the key used when I store it. The POJO contains many String / boolean / int attributes, so I don't want to store them each individually. The problem I'm running into is that the only preference variable types are String, boolean, float, and int. Is there some way to convert the POJO to a String that I could then retrieve back per it's key and convert back to the POJO, sort of like casting it> 1) Populate the POJO 2) Convert the POJO to a String 3) Store the String in the preference Store with a key value (normal preference store stuff) 4) When needed, retrieve the data back from the preference store as a String and convert it back to the POJO. </p>
android
[4]
5,179,098
5,179,099
Loop through all td of next() table
<p>I want to loop through each td of a table which is next of $this button clicked </p> <pre><code>&lt;input type="button" class='btn'&gt; &lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;......&lt;/table&gt; &lt;input type="button" class='btn'&gt; &lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;......&lt;/table&gt; &lt;input type="button" class='btn'&gt; &lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;......&lt;/table&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $()ready(function(){ $(".btn").click(function(){ //loop through each td of next table?????? }); }); &lt;/script&gt; </code></pre>
jquery
[5]
1,474,519
1,474,520
getting the full name of an assembly
<p>Suppose I want to display the full name of an assembly, given only a path to the assembly file.</p> <p>I know I could write a command line program or powershell script easily enough, but does the runtime include a command that I could use? (I've seen gacutil do it for assemblies that are in the gac, but about assemblies that are not registered?)</p>
c#
[0]
2,150,300
2,150,301
how to get position from Spinner adapter
<p>i fill spinner with generic Arraylist of cat Categeory type </p> <p>now i want to get position of Specific Item from it , i try code below but it always return S</p> <p>if (Singleton.getCategory() != null) {</p> <pre><code> cat item =new cat(); String cat= Singleton.getCategory().toString(); int catid= Singleton.getCategoryid(); item.setName(cat); item.setcatId(catid); int spinnerPosition=selcategaryadapter.getPosition(item); //set the default according to value selCategary.setSelection(spinnerPosition); } </code></pre> <p>here is how i fill spinner </p> <pre><code> JSONArray jsonarray=JSONFunction.getJSONCategary(); JSONObject json1=null; ArrayList&lt;eexit&gt; listCategory= new ArrayList&lt;eexit&gt;(); try { for(int i=0;i&lt; jsonarray.length();i++) { json1=jsonarray.getJSONObject(i); arrayCategary[i]=json1.getString("Name") cat item=new cat(); item.setName(json1.getString("Name")); item.setcatId(Integer.parseInt(json1.getString("CategoryID"))); listCategory.add(item); } } catch (Exception e) { // TODO: handle exception } ArrayAdapter&lt;eexit&gt; selcategaryadapter = new ArrayAdapter&lt;eexit&gt;(Activity.this,R.layout.spinner_layout, listCategory); selcategaryadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); selCategary.setAdapter(selcategaryadapter); selCategary.setPrompt("Select Category"); </code></pre>
android
[4]
1,751,993
1,751,994
What is the correct way to deal with texts outside the tag?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/298750/how-do-i-select-text-nodes-with-jquery">How do I select text nodes with jQuery?</a> </p> </blockquote> <p>What is the correct way to deal with texts outside the tags</p> <p>I tried all the methods, but all failed</p> <p>And I experimented with this</p> <pre><code> &lt;script&gt; $(function(){ var A = $(".A").text(); var B = $(".B").text(); var C = $(".C").text(); var D = $(".D").text(); $("#BD").text(A+B+C+D); }); &lt;/script&gt; &lt;body&gt; &lt;div&gt; &lt;span class="A"&gt;&lt;/span&gt;6 &lt;span class="B"&gt;&lt;/span&gt;8 &lt;span class="C"&gt;&lt;/span&gt;3 &lt;span class="D"&gt;&lt;/span&gt;9 &lt;/div&gt; &lt;div id="BD"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre> <p>As well as this</p> <pre><code>&lt;script&gt; $(function(){ var A = $(".A").text(); var B = $(".B").text(); var C = $(".C").text(); var D = $(".D").text(); alert(A+B+C+D); }); &lt;/script&gt; </code></pre> <p>But they all didn't work</p> <p>How can I collect the numbers correctly?!</p>
jquery
[5]
5,174,991
5,174,992
Link to a page then execute a Javascript request
<p>Does anyone know if it is possible to link to a page using href and then calling a javascript function?</p> <p>Ex: href="http://www.mywebsite.com/Details.aspx?javascript:__doPostBack('INFO','')</p> <p>How would I go about this?</p> <p>Thanks for your help!</p>
javascript
[3]
3,748,677
3,748,678
Can't display mssql image in a http table using php
<p>I know there are many post about displaying a image from mssql, but they seems dont work in my case if i want it display with other table items.</p> <p>I can display the binary image indivially by the following code </p> <p><code>echo $image=base64_decode($MyBinImg);</code></p> <p>then when i wanted to display the image into a table using smarty, it doesnt work</p> <p>php side:</p> <pre><code>$smarty-&gt;assign("Photo",$image); $smarty-&gt;assign("SomeText","hello world"); </code></pre> <p>tpl side:</p> <pre><code>&lt;some tags&gt; .. ... &lt;tr&gt; &lt;td style="background-color: #d0d0d0;"&gt;&lt;b&gt;TEXT&lt;/b&gt;&lt;/td&gt; &lt;td style="background-color: #f0f0f0;"&gt;{$SomeText}&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="background-color: #d0d0d0;"&gt;&lt;b&gt;Photo&lt;/b&gt;&lt;/td&gt; &lt;td style="background-color: #f0f0f0;"&gt;&lt;img src="{$Photo}"/&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>The table can display SomeText but not the Photo. Can someone tell me how to display it.Thanks.</p>
php
[2]
1,429,252
1,429,253
How can i call a web service without using KSOAP2 in Android?
<p>I can call a webservice with KSOAP2 from android,now i want to know is it possible to call it without using KSOAP.If anyone knows the answer please help me.</p>
android
[4]
195,711
195,712
Why doesn't Android API publicly allow to listen for incoming SMS?
<p>Recently a question here on SO ported this to my attention. Android doesn't have a public API for listening to incoming SMS. There used to be an action <code>android.provider.Telephony.SMS_RECEIVED</code>, but it has been removed from the official API and even if it still works, it's obviously not future-proof. I don't need this feature right now, but I may in the future, and I find it very strange it's not available because:</p> <ol> <li>Android has always encouraged the deep customization of every little part of the system (think of tha launcher, the dialer, the contact app)</li> <li>There are plenty of alternatives to the standard SMS app already in the Market (not to mention the vendors' ones)</li> </ol> <p>Maybe I am missing something or maybe there's a technical reason - I admit not know how SMS works</p>
android
[4]
4,786,445
4,786,446
Is it possible to get detailed help on a given function using the command line?
<p>I am a new Python user :) Is it possible to get detailed help on a given function using the command line ?</p>
python
[7]
2,124,680
2,124,681
Using HBase as L2 Cache for Ehcache
<p>As per our design, i am trying to use HBase as level2 cache of Ehcache. Normally, ehcache employs Terracotta Server Array as level 2 cache. </p> <p>Please can you show a direction and code ASAP. its very urgent! Thanks for your patience!</p> <p>Shouvanik SCJP 1.5</p>
java
[1]
651,324
651,325
How do i save logs in php
<p>How do i save logs in PHP? Is there any "magical" function available in php for doing so, or any library? Or should i have to <code>fopen</code> file everytime and dump in it? I want to save my logs in text file.</p> <p>Thanks in advance :)</p>
php
[2]
2,063,486
2,063,487
Defining Safe zone
<p>I am developing an application which will send a alert message when that particular person goes out of the safe zone. I am using GPS to track the location information. Can anyone suggest me some ideas on how to set the safe zone. </p>
android
[4]
976,429
976,430
iPhone: Handle action event from webview page
<p>I am loading a html page using loadHTMLString.</p> <pre><code>[myWebview loadHTMLString:myHtmlStr baseURL:nil]; </code></pre> <p>Its loading properly. In this html web page, i'm also adding buttons, drop down(with selection) etc. I want to catch the action events in my code now for these web page controls. For example, from the drop down if user chooses an option, i need to add another 'textarea' dynamically in the same web page. and, if user clicks on a button(button from the webview), i need to handle some events. I would like to know, how to do some tasks under the events triggered for controls in web view which is generated by my string. </p> <p>Could someone please advise me.</p>
iphone
[8]
3,058,192
3,058,193
How can i use switch to have a checkbox checked in jQuery?
<p>I am trying to use switch() if the check box is checked,but it does not work. What is the probem here i could not figure out. Could you help plz. here is what i tried </p> <pre><code>&lt;input type="checkbox" class="che" value="1" /&gt;age &lt;input type="checkbox" class="che" value="2" /&gt;sex $(".che").click(function(){ var chek= $(this).is(":checked") ; alert(chek); switch(chek){ case 1: alert ('ok'); $('.myTableRow').show(); break; case 2: alert('hora'); $(".myTableRow").hide(); break; } }); </code></pre>
jquery
[5]
996,815
996,816
strange xrange() behavior in Python 2
<p>I am familiar with the difference between <code>range()</code> and <code>xrange()</code>. I noticed something weird with <code>xrange()</code>:</p> <pre><code>&gt;&gt;&gt; xrange(1,10,2) xrange(1, 11, 2) &gt;&gt;&gt; xrange(1,10,4) xrange(1, 13, 4) </code></pre> <p>Functionally, it is correct:</p> <pre><code>&gt;&gt;&gt; for item in xrange(1,10,4): ... print item ... 1 5 9 &gt;&gt;&gt; </code></pre> <p>However, as you can see, the stop value in the returned <code>xrange</code> object is the next higher value after the last legal value. Any reason why?</p> <p><code>range()</code> which now provides the same functionality in Python 3 as <code>xrange</code> in Python 2 behaves as expected:</p> <pre><code>&gt;&gt;&gt; range(1,10,4) range(1, 10, 4) &gt;&gt;&gt; range(1,10,2) range(1, 10, 2) &gt;&gt;&gt; </code></pre>
python
[7]
4,136,515
4,136,516
highchart xaxis value on dot
<p>I'm using Highcarts for my charts and I want to know if it's possible to have only an xaxis value where there is a dot. Now I have a dot between two dates so it is not very clear on which date it is.</p>
jquery
[5]
2,173,642
2,173,643
Intent constructor syntax
<p>I am just starting to develop Android (being a .Net developer)</p> <p>I am following the code from a book, and to start a new 'form' (screen) they show this code</p> <pre><code>Intent i = new Intent("net.learn2develop.ACTIVITY2"); </code></pre> <p>The class definition is this:</p> <pre><code>package net.learn2develop.Activities; //imports removed public class Activity2 extends Activity { </code></pre> <p>My question is: i presume that the string in the constructor in the Intent is the classname. But why is it <code>'net.learn2develop'</code> and not <code>'net.learn2develop.Activities'</code> and why is the classname all caps?</p>
android
[4]
3,421,235
3,421,236
Python data structure similar to dictionary where key is two values?
<p>I am looking for a data structure in Python that is similar to a dictionary. The difference is that there is two keys. I want to be able to access the value in constant time. Like:</p> <pre><code>dict.get(dog, smurf) {(dog, smurf): 40} </code></pre> <p>Is this possible?</p> <p>If this doesn't exist, I would just do a dictionary in a dictionary. But, the above would be more convenient.</p> <pre><code>{dog: {(smurf: 40)}} </code></pre>
python
[7]
5,475,458
5,475,459
How to make a diagram from arrays in java?
<p>My program needs to draw a diagram like this:</p> <pre><code> --- --- xxx --- xxx +++ --- xxx +++ --- ooo xxx +++ --- ooo xxx +++ --- ooo xxx +++ --- *** ooo xxx +++ --- *** ooo xxx +++ --- *** ooo xxx </code></pre> <p>From this data: </p> <pre><code>private static final int[] DATA = {15, 21, 7, 12, 18}; private static final int MAX_HEIGHT = 10; private static final int COLUMN_WIDTH = 3; private static final int SPACE_BETWEEN_COLUMNS = 2; private static final char[] FILLER = {’+’, ’-’, ’*’, ’o’, ’x’}; </code></pre> <p>I really need some guidlines on how to make it.</p> <p>Thanks</p>
java
[1]
5,234,971
5,234,972
Open a new page using HTML Response/JS ASP
<p>Alright, I have decided to go about this by opening a new page (newPage.aspx) which will then initiate the download and close after the download is completed. I am opening newPage.aspx using javascript by writing it to the response of the current page. For some reason, however, the window is not being opened before the original page is re-directed. Is their a method to be called before I redirect? Maybe I have a syntax issue?</p> <pre><code>Response.Write("&lt;script type='text/javascript'&gt;window.open('~/newPage.aspx', '', ''); &lt;/script&gt;") Response.Redirect("~/oldPage.aspx") </code></pre> <p><strong>EDIT:</strong></p> <p>I tried the following but it did not work... (I am working in an Update Panel)</p> <pre><code>ScriptManager.RegisterStartupScript(udpMain, udpMain.GetType(), "openExcel", "window.open('~/newPage.aspx', '' , '');", True) </code></pre> <p><strong>EDIT 2: So Close</strong></p> <p>Ok, so this only works if I comment out the Response.Redirect. It seems that the RegisterStartupScript method takes place on the page load after the Response.Redirect method. Is there any known fix for this?</p> <pre><code>ScriptManager.RegisterStartupScript(udpMain, udpMain.GetType(), "openExcel", "window.open(NewPage.aspx'); location.href='OldPage.aspx';", True) Response.Redirect("~/OldPage.aspx") </code></pre>
asp.net
[9]
441,253
441,254
How to convert JSON Array to Javascript Object Array
<p>I have the following JSON value pushed from the server.</p> <pre><code> result=[{"id":1492,"name":"Delhi"}, {"id":109,"name":"Coimbatore"}, {"id":576,"name":"Konni"}, {"id":525,"name":"Kottayam"} ] </code></pre> <p>I know how to convert JSON Array to Javascript Array.Here is the code below(got from stackoverflow)</p> <pre><code> var locations = []; $.each(result, function(i, obj) { locations.push([obj.id,obj.name]); }); </code></pre> <p>I want to convert this JSON Array to a JavaScript Object Array so that I can access the values as <code>jarray[0].id</code> which will give me the value 1492. Please advice</p>
javascript
[3]
4,951,124
4,951,125
name of uploaded file in title field
<p>I have seen on youtube when we upload any videos automatically, the title field of form gets filled with the name of the video file. How can i achieve this?</p> <p>my form is </p> <pre><code>&lt;form enctype="multipart/form-data" method="post" action="http://youshare.ca/music/writestorypost"&gt;&lt;p&gt; &lt;span class="form_label"&gt;Title&lt;/span&gt;&lt;input type="text" value="" name="title" style="width:400px" class="inputText required"&gt;&lt;/p&gt; &lt;p&gt;&lt;label&gt;Upload&lt;/label&gt;&lt;input type="file" name="song"&gt; &lt;p&gt;&lt;input type="submit" value="Submit" class="button"&gt;&lt;/p&gt;&lt;input type="hidden" value="935" name="page_id"&gt; &lt;/form&gt; </code></pre>
javascript
[3]
1,692,218
1,692,219
Java BufferedImage increase width
<p>I have managed to load in an image using:</p> <pre><code>BufferedImage image = ImageIO.read(out); </code></pre> <p>and place text over it however, I want the text to appear next to the image. How can I increase the image width on the right to allow for space for the text to be drawn on. Or do I have to create a new empty image and insert the existing one?</p> <p>Thanks</p>
java
[1]