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,741,801 | 4,741,802 | Best practice for sending data updates to iPhone app? | <p>I'm currently in the middle of developing an iPhone app with a big reference database (using Core Data backed with a pre-populated sqlite database). Once the app is live and deployed to a client's iPhone, I need the facility to update/insert a small amount of data. What are best practices / methods for doing this?</p>
<p>There may be occassions when the frequency of updates will be daily for a month or so. Other occassions when a data update happens once every few months. </p>
<p>What is the recommended way of doing this? Note, I don't anticipate any data model changes for these updates -- this is purely an insert/update of data.</p>
<p>At the moment I'm starting to research the use of push data notifications (q:payload size restrictions?), app store updates (q:code/data model only, not data updates?) and the use of my own ad hoc data server (which the app connects to routinely to check for updates). </p>
<p>Can anyone please provide me any pointers on the above? </p>
<p>Thanks in advance</p>
| iphone | [8] |
847,753 | 847,754 | Read database GeoIPASNum.dat with PHP | <p>How can I got informations from GeoIPASNum.dat with PHP? There is no buildin function probably.</p>
| php | [2] |
3,674,258 | 3,674,259 | Socket communication not happening between components after JRE upgrade | <p>I have two components: one is a gateway and the other is the Application which has been deployed in the Jboss-5.0 GA Application Server. Our old code base was developed in jdk 1.4 and after migrating to jdk 1.6 there are some issues with socket timeout.</p>
<p>Initially we have a service which initiates timeout. This socket timeout is not happening in our timeoutscenario after migrating to 1.6 version.</p>
<p>But after developing the my socket based client in 1.6 and fire a request on the server which is on 1.4 this timeout works fine. But when i build my sources in 1.6 and up my server the same hit is not working.</p>
<p>Any ideas why i am facing this problem?
Please provide your valuable inputs, thanks in advance.</p>
<p>RMISocketFactory.setSocketFactory(new RMISocketFactory()
{</p>
<pre><code>public Socket createSocket(String host, int port) throws IOException {
Socket socket = new Socket();
socket.connect(new InetSocketAddress(host, port), connectionTimeout);
socket.setSoTimeout(readTimeout);
socket.setSoLinger(false, 0);
return socket;
</code></pre>
<p>}</p>
<p>public ServerSocket createServerSocket(int port) throws IOException {</p>
<pre><code>return new ServerSocket(port);
</code></pre>
<p>}</p>
<p>});</p>
<p>The above is the code......</p>
<p>We have also given security permission also in this manner:</p>
<pre><code>if(System.getSecurityManager() == null)
{
System.setSecurityManager(new RMISecurityManager());
}
grant {
permission java.security.AllPermission;
};
</code></pre>
| java | [1] |
5,980,579 | 5,980,580 | Android: app incompatible with Huawei? | <p>I have two apps listed on the marketplace. One of them is a free demo application, and the second is a second key application that unlocks the full version of the first application. I received a report from a user that the demo installs on their Huawei, but the market lists they application as "incompatible". I haven't received any other reports of this, and can't find anything useful on Google. The two manifest xmls are below, the demo app first and the key app second. Could this be caused by the check license permission? In android market developer console, the "supported devices" section is the exact same for both apps:</p>
<blockquote>
<p>Supported Devices [Learn More] This
application is only available to
devices with these features, as
defined in your application manifest.</p>
<p>Screen layouts: SMALL NORMAL LARGE
XLARGE </p>
<p>Required device features
android.hardware.touchscreen</p>
</blockquote>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="..."
android:versionCode="3"
android:versionName="1.1">
<application ...>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=...
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7"/>
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<application ...
</application>
</manifest>
</code></pre>
| android | [4] |
1,169,050 | 1,169,051 | Fading Background Images | <p>I'm using a simple script to change the background image of my website every X seconds. What I'd like to do is incorporate some sort of fade animation or a transition from one image to the next. What is the best way to achieve this?</p>
<p>I'm not very good with Javascript so PLEASE, bear with me. :)</p>
<pre><code><script type="text/javascript">
var images = ['bg1.png', 'bg2.png', 'bg3.png'];
var curImage = 0;
function switchImage()
{
curImage = (curImage + 1) % images.length
document.body.style.backgroundImage = 'url(images/' + images[curImage] + ')'
}
window.setInterval(switchImage, 5000);
</script>
</code></pre>
<p>I read over and over and dont understand please so please someone give me a working code so i can copy and paste and get rid of this annoying job.
example here <a href="http://preferredmerchantservices.net/" rel="nofollow">http://preferredmerchantservices.net/</a></p>
| javascript | [3] |
5,105,291 | 5,105,292 | php regex too strict | <p>Just wondering why this is too strict, I can send very simplified emails to say tim@yahoo.com or two@google.com</p>
<p>but if I make the email any longer (sacagawea@gmail.com) it does not get sent.</p>
<p>Instead it echos back my error message:Invalid Email Address Supplied</p>
<pre><code> // Create a function to check email
function checkEmail($email)
{
// Add some regex
return preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email) ? TRUE : FALSE;
}
</code></pre>
| php | [2] |
415,365 | 415,366 | Validate dynamically added form | <p>I am working on a form for people to fill in and wanted to have a checkbox when if checked more forms appeared, this was not an issue but when the forms appear I want to validate them which requires a class="" to be set how can I do this? </p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Show div on check for checkbox</title>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<form>
Check me <input name="checkbox" type="checkbox" id="checkbox" onclick="$(this).is(':checked') && $('#checked').slideDown('slow')|| $('#checked').slideUp('slow');"
/>
<p id="checked" style="display: none; margin: 10px; height: 100px; background-color: #f5f5f5; padding: 10px" >
<label for="form">input?</label>
<input class="" type="text" name="form" id="form">
</p>
<script>
$("input.checkbox").click(function(){
if($(this).is(":checked")){
$("input.form").addClass("required");
Else
$("input.form").removeClass("required");
}
});
</script>
</form>
</body>
</html>
</code></pre>
<p>This is my code that does not seem to work, when I check the source code before and after its the same.</p>
<p>Az</p>
| jquery | [5] |
1,484,887 | 1,484,888 | Building a dict using zip | <p>I have a list of names:</p>
<pre><code>['john smith', 'sally jones', 'bob jones']
</code></pre>
<p>I want to build a dict in the following format:</p>
<pre><code>{'john smith': [], 'sally jones': [], 'bob jones': []}
</code></pre>
<p>This is what happens when I try using zip </p>
<pre><code>zip((all_crew_names, [[] for item in all_crew_names]))
[(['john smith', 'sally jones', 'bob jones'],), ([[], [], []],)]
</code></pre>
<p>What am I doing incorrectly here, and how would I properly zip this up?</p>
| python | [7] |
5,529,384 | 5,529,385 | Adding multiple ImageViews to a layout | <p>I need to load several ImageViews into a layout. The ImageViews are used to show a rating using 'star' icons. The number of stars (i.e. the rating is determined during loading by reading a configuration file.</p>
<p>The ImageViews are sitting inside a RelativeLayout layout.</p>
<p>Currently I am using something like this:</p>
<pre><code>RelativeLayout l = ((RelativeLayout)(findViewById(R.id.RelativeLayout01)));
for (int nStarCount = 0; nStarCount < config.getAsInt("stars", 1); nStarCount ++) {
ImageView image = new ImageView(this);
image .setImageResource(R.drawable.star);
image .setAdjustViewBounds(true);
l.addView(i);
}
</code></pre>
<p>My quesions are:</p>
<p>1) Is doing the loading dynamically (not using an xml) is the 'right' way of doing this ?</p>
<p>2) If it is, how do I make the stars display in a line, currently they get placed one on top of the other.</p>
<p>Any help would be appreciated.</p>
<p>RM</p>
| android | [4] |
5,834,897 | 5,834,898 | How do I implement proper Exception handling in Java? | <p>I am currently writing a simple program in Java in response to a question. The question says :</p>
<blockquote>
<p>You are fixing a bug where documents (represented as a String) are failing to be converted to proper xml. This problem can occur because either:<br>
A. Certain characters fail in the xml, or<br>
B. Documents passed in have a length > 100 characters (they’re small documents)</p>
</blockquote>
<p>It then lists 5 characters that need escaping (e.g. replace '">'" with the escape sequence;). </p>
<p>I've coded the part to replace special characters with escapes, but I'm not sure what to do about the length.</p>
<pre><code>if (length of string > 100) {
do what?
}
</code></pre>
<p>I was thinking of maybe implementing a try catch statement, but that's used for runtime exceptions correct? (null pointer, etc). In a design standpoint, what would be the best way to avoid this bug while at the same time completing the job of the function?</p>
| java | [1] |
3,414,817 | 3,414,818 | How to search for a specific string in an array and remove it in java | <p>I have an array filled with a hundred strings. I would like to be able to use an input given by the user, pass it through a method parameter, search for that exact string, and remove it. How would I go about doing this? Furthermore, how would I do the same thing but add it instead? </p>
| java | [1] |
1,925,326 | 1,925,327 | Does Google restrict distributing Android apps to BETA customers outside of the marketplace | <p>We are developing iOS and Adroid apps for a service we are building. Apple has specific rules and limitations associated with distributing apps outside of the App store for use in BETA testing. I know how to distribute the apk file to our BETA customers outside of the Google marketplace, however are there any legal limitations or requirements for registering BETA customers when using this approach? </p>
| android | [4] |
5,690,188 | 5,690,189 | Server and Client Dual Communication IPhone | <p>After coding a simple multi player game to be played on the same device I'm interested in writing a server for the game so it could be played across several devices.</p>
<p>Which technologies do you use to write a server, which allows dual communications between the client and server?</p>
| iphone | [8] |
3,917,976 | 3,917,977 | Why wouldn't a global object's property accept a new assignment? | <p>I'm trying to assign a new value to the 'notes' property of the 'attendee' object in this global session object... whenever I try the assignment though, the value doesn't keep.</p>
<p>From the console in webkit:</p>
<pre><code>> session['attendee']['notes']
null
> session['attendee']['notes'] = "test"
"test"
> session['attendee']['notes']
null
> window.session['attendee']['notes'] = "test"
"test"
> session['attendee']['notes']
null
> window.session['attendee']['notes']
null
</code></pre>
<p>Session is set like so in a global scope:</p>
<pre><code>window.session = {};
</code></pre>
<p>And then later on I'm assigning an object pulled from the browser's sql database like this;</p>
<pre><code>window.session['attendee'] = {'name':'mike' ..etc..}
</code></pre>
<p><strong>Update:</strong></p>
<p>Here's some more console info:</p>
<pre><code>> window.session['attendee']
Object
address_1: null
address_2: null
app_id: 1
badge_id: null
budget: null
city: null
company: null
decision_maker: null
email: null
first_name: "Anonymous"
followup: null
id: null
is_influencer: null
is_purchaser: null
is_user: null
last_name: ""
notes: null
phone: null
rating: null
scanned: 1
state: null
synced: null
zip: null
__proto__: Object
> window.session['attendee'].notes
null
> window.session['attendee'].notes = "TEST"
"TEST"
> window.session['attendee'].notes
null
</code></pre>
<p>So there's an object in session.attendee and "notes" is a property in that object, but assigning a value to it doesn't stick.</p>
| javascript | [3] |
5,429,158 | 5,429,159 | Can I set the size attribute of StructLayout at runtime? | <p>Im trying to use SendInput to simulate keyboard presses in my app and want to support both 32-bit and 64-bit.</p>
<p>I've determined that for this to work, I need to have 2 different INPUT structs as such</p>
<pre><code> [StructLayout(LayoutKind.Sequential)]
public struct KEYBDINPUT
{
public ushort wVk; // Virtual Key Code
public ushort wScan; // Scan Code
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Explicit, Size = 28)]
public struct INPUT32
{
[FieldOffset(0)]
public uint type; // eg. INPUT_KEYBOARD
[FieldOffset(4)]
public KEYBDINPUT ki;
}
[StructLayout(LayoutKind.Explicit, Size = 40)]
public struct INPUT64
{
[FieldOffset(0)]
public uint type; // eg. INPUT_KEYBOARD
[FieldOffset(8)]
public KEYBDINPUT ki;
}
</code></pre>
<p>I wanted to know if there was a way to set the <code>StructLayout</code> size and <code>FieldOffsets</code> at runtime so I could use just one <code>INPUT</code> struct and determine the size and fieldoffset depending on the machine.</p>
<p>I have tried the code below but I would like to know if the same is possible at runtime instead of compile time. </p>
<pre><code>#if _M_IX86
[StructLayout(LayoutKind.Explicit, Size = 28)]
#else
[StructLayout(LayoutKind.Explicit, Size = 40)]
#endif
public struct INPUT
{
[FieldOffset(0)]
public uint type; // eg. INPUT_KEYBOARD
#if _M_IX86
[FieldOffset(4)]
#else
[FieldOffset(8)]
#endif
public KEYBDINPUT ki;
}
</code></pre>
| c# | [0] |
564,196 | 564,197 | REST uri calls using get | <p>Stupid questions I guess but how do I do a REST uri call. Do I use jquery ajax() or just plain $get()
All the REST uri does is return an image.</p>
| jquery | [5] |
5,664,394 | 5,664,395 | Open a URL in Android's web browser from application | <p>How can I open a url in the android web browser from my application on clicking a button.</p>
<p>I tried this :</p>
<pre><code>Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(strURL));
startActivity(myIntent);
</code></pre>
<p>but I am getting exception:</p>
<p>but I got an Exception :</p>
<pre><code> "No activity found to handle Intent{action=android.intent.action.VIEW data =www.google.com"
</code></pre>
| android | [4] |
616,283 | 616,284 | how do I button clicked before outputting the results? | <p>So there're 2 radio items and I want the user to choose which one to execute, after the user chooses one of them, he/she will click on the button "Draw!" and will output the result from one of the function of the radio item they chose. But I can't figure out how to call either function and wait until the user clicks on the "Draw!" button to actually calls the function.</p>
<p>I have in my HTML:</p>
<pre><code><p>
Do you want to <input type="radio" name="draw" id="draw" value="drawTriangle">Draw Triangle
or
<input type="radio" name="draw" id="draw" value="drawZigZag">Draw ZigZag<br>
<input type="button" value="Draw!" onclick="drawEither()">
</p>
<pre id="outputTriangle">
</pre>
<pre id="outputZigZag">
</pre>
</code></pre>
<p>and Javascript: </p>
<pre><code>function makeZigZag () {
var sizeTextField = document.getElementById('sizeTextField')
//block of codes
drawButton.onclick = function () {
outputTri.innerHTML = makeTriangle(sizeTextField.value);
};
}
function makeTriangle () {
var sizeTextField = document.getElementById('sizeTextField')
//block of codes
drawButton.onclick = function () {
outputZZ.innerHTML = makeTriangle(sizeTextField.value);
};
}
function drawEither () {
outputTri = document.getElementById('outputTriangle');
outputZZ = document.getElementById('outputZigZag');
}
</code></pre>
| javascript | [3] |
2,584,626 | 2,584,627 | Get the decimal point | <p>How to get decimal point of a number? For example:<br>
If I have 1.5 how to get the 5 number?</p>
| c++ | [6] |
728,797 | 728,798 | jQuery getting new objects | <p>When using jQuery functions like <code>replaceWith</code>, the function return-value is (as clearly documented), the <em>original</em> jQuery object. However, I commonly want to chain with the <em>replacement</em> jQuery object. How do I do this?</p>
<p>For example:</p>
<pre><code>$("#original").replaceWith("<span id='replacement'></span>").someFn()
# this calls someFn() on #original, NOT as desired on #replacement.
</code></pre>
<p>What's the nicest way to fix this? Clearly I could do <code>$("#replacement").someFn()</code>, but that's not the point, as (for example) I may not know the id of the replacement element in advance.</p>
<p>NOTE: I'm also interested in feedback about the premise. eg, am I missing the point of jQuery and is there some idiom I'm missing?</p>
| jquery | [5] |
2,265,184 | 2,265,185 | C#: How do you control the current item index that displays in a ComboBox? | <p>I have set a list of items in a combobox, but when I debug the application, I have to select an item from the drop down to display an item by default. Is there a property? that you can set so that the combobox itemindex will always begin at 0 meaning the first item in the list at startup of the application?</p>
| c# | [0] |
4,147,002 | 4,147,003 | Best practice for class field having different values in subclasses | <p>I have some abstract class, in one of its method I use a string field which is supposed to be specific to the subclasses. I wonder what is the bect practice to implemnet this? via field and setting the field value in a consructors of the subclasses? via a static field and changing the value in every subclass?</p>
<p>What would you suggest?</p>
| java | [1] |
3,064,485 | 3,064,486 | Get Textbox text details from Java/Oracle Forms applet using Windows application | <p>I have one Java/Oracle Forms applet application. It has many Textboxes, DataGrids and Other controls. I am not using all these data information on daily basis.</p>
<p>So what I want is , Copy only required information from Java application(copy textbox details,data-grid detail) to another notepad using Windows application.( using concept of application interoperability).</p>
<p>I can do that if both are windows application using win32 api functions.</p>
<p>But how can we do that with Java applets..</p>
<p>Is there any specific api that I need to use for that???</p>
| c# | [0] |
1,967,840 | 1,967,841 | Read/Write at the same time | <p>What I am doing is opening my file using fstream at the start of the main and closing it at the end. In between I am writing "Hello World" and after that reading what I wrote but the result is always weired charecters and not the "Hello World". I did do a cast to char but that didnt help. Any way I can do this?</p>
| c++ | [6] |
49,897 | 49,898 | Uploading Files with different formats to a URL using Java client | <p>I need to write some code in Java to upload a file(.tz format) to a URL(prqs@vks.com) by using HTTP PUT/POST and SMTP.I have no idea how to do this and my application is not a web based application i have to write a pure java client to do this. I searched the net but could not find a suitable tutorial on how to do this also i found a lot of stuff where in they are uploading file using a HTML form to a server. but that is not what i want.</p>
<p>Can you please let me know how this is to be done. If you can direct me to a tutorial or provide any sample code then it would be very helpful. I am scratching my head on this for a long time now.</p>
<p>Thanks
vikeng21</p>
| java | [1] |
5,652,625 | 5,652,626 | Android content provider | <p>i want to get the website name from contact list in android application.i have already get contact photo,contact name, contact address.. but i have problem in getting contact website name.please give me whole query for to getting website name.
Thank you. </p>
| android | [4] |
3,518,393 | 3,518,394 | How to .remove() by count | <p>Here is the HTML:</p>
<pre><code><div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</code></pre>
<p>Here is the Jquery:</p>
<pre><code> if ( $( ".line" ).length > 2 ) {
//remove all other div.lines but keep the first 2
}
</code></pre>
<p>How do you do this?</p>
| jquery | [5] |
791,375 | 791,376 | How does one disable the success message once the requied field message is shown? | <p>I have a form with two text boxes. Once I enter the data and click the save button, I get a message in label: indicating that it saved successfully.</p>
<p>Then I show the form again, but when I click on the save button, I get a message telling me that it cannot be blank "as textbox value is empty this time" from the required field validator.</p>
<p>But I am still showing the message "data saved successfully," which should not happen.</p>
<p>How do I solve this issue?</p>
<p>Thank you.</p>
| asp.net | [9] |
2,948,779 | 2,948,780 | do searching in a very big ARPA file in a very short time in java | <p>I have an ARPA file which is almost 1 GB. I have to do searching in it in less than 1 minute. I have searched a lot, but I have not found the suitable answer yet. I think I do not have to read the whole file. I just have to jump to a specific line in the file and read the whole line. The lines of the ARPA file do not have the same length. I have to mention that ARPA files have a specific format.</p>
<h2>File Format</h2>
<pre>
\data\
ngram 1=19
ngram 2=234
ngram 3=1013
\1-grams:
-1.7132 puluh -3.8008
-1.9782 satu -3.8368
\2-grams:
-1.5403 dalam dua -1.0560
-3.1626 dalam ini 0.0000
\3-grams:
-1.8726 itu dan tiga
-1.9654 itu dan untuk
\end\
</pre>
<p>As you see in the sample file I have 19 lines of 1-grams, 234 lines of 2-grams and 1013 lines of 3-grams. I give the string part of the line to the program and get the numbers which are at the left and at the right side of the string. The input string can help me to know in which part of the file I have to do searching.I have to find a way not to read the file completely, because my file is very big and reading the whole file takes a lot of time. I think it is a good way to jump to the specific line in the file without using the index file and access to the whole line.</p>
<p>It will be great if you can help me to do my assignment.</p>
| java | [1] |
2,303,272 | 2,303,273 | Display database fields as checkboxes | <p>I'm trying to display all my database fields like radio buttons. For example I have this database fields :</p>
<pre><code>hostess_id
hostess_name_en
hostess_surname_en
... etc ...
</code></pre>
<p>I want to display them as radio buttons, in order to select them, then display data information only for the selected buttons.</p>
<p>How can I do that?
I have something like this:</p>
<pre><code><?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect to MySQL server: ' . mysql_error());
}
$dbname = 'db_up';
$db_selected = mysql_select_db($dbname, $link);
if (!$db_selected) {
die("Could not set $dbname: " . mysql_error());
}
$res = mysql_query('select * from hostess', $link);
while ($row = mysql_fetch_assoc($result)){
echo "<td><input type=\'checkbox\' name=\'hostess[]\' value=\'" . $row['hostess_id'] . "\'>" . $row['hostess_firstname_en'] . "<br />";
}
?>
</code></pre>
| php | [2] |
4,141,724 | 4,141,725 | .(dot) access to static method | <p>Following is a popular code:</p>
<pre><code>class A
{
public:
static const string TYPE = "AEvent";
const string& getType() { return TYPE; }
};
</code></pre>
<p>Above code could be use like this:</p>
<pre><code>if (aInstance.getType() == A::TYPE)
{
...
}
</code></pre>
<p>It's fine. But it's not intuitiveness. Did not? Look at the next code:</p>
<pre><code>class A
{
public:
static const string& getType()
{
static const string TYPE = "AEvent";
return TYPE;
}
}
//Usage
if (aInstance.getType() == A::getType())
....
</code></pre>
<p>Of course, getType is static method but it's possible to access dot operator and It's more intuitively see to me. </p>
<p>How do you think about?</p>
| c++ | [6] |
26,319 | 26,320 | PHP call function from parent in child best practice | <p>I have a trick question regarding PHP calling a function from parent in child class.
We have 3 scenarios, and I want pros and cons.</p>
<pre><code><?php
class test{
private $var ;
public function __construct(){
$this->var = 'Hello world';
}
public function output(){
echo $var.'<br>';
}
}
//scenario 1
class test1 extends test{
public function __construct(){
parent::__construct();
}
public function say(){
parent::output();
}
}
//scenario 2
class test2 extends test{
public function __construct(){
test::__construct();
}
public function say(){
test::output();
}
}
//scenario 3
class test3 extends test{
private $handle ;
public function __construct(){
$this->handle = new test();
}
public function say(){
$this->handle->output();
}
}
//finally I can call any 3 cases by one of the below codes
$test1 = new test1();
$test1->say();
//or
$test2 = new test2();
$test2->say();
//or
$test3 = new test3();
$test3->say();
?>
</code></pre>
<p>Is there a best practice or is there any of the 3 scenarios better than other?</p>
<p>Thank you in advance.</p>
| php | [2] |
3,156,424 | 3,156,425 | Insert and Edit Template show in Devexpress in aspxGridview | <p>In Insert Mode I want to show one kind of Template and Edit Mode I want to show another Kind of Template in Devexpress Control in C#.NET</p>
| c# | [0] |
3,474,326 | 3,474,327 | Javascript function variables issue | <p>What is the problem with my script? When I execute it, the alert (line 2) gives me "100,200,300undefinedundefined", so is seems like 100,200,300 is interpreted as h1 when I would like it to be h1, h2 and h3 (with the commas).</p>
<pre><code>function myanimation(h1,h2,h3) {
alert(h1 + h2 + h3);
$("#h1").animate({"left": h1});
$("#h2").animate({"left": h2});
}
var moves = new Array()
moves[1] = [100,200,300];
moves[2] = [300,200,100];
moves[3] = [-500,-300,0];
var i = 1;
function animatenow(){
myanimation(moves[i]);
i++;
}
$('#launch').click(function() {
setInterval(animatenow, 5000);
});
</code></pre>
| jquery | [5] |
5,151,595 | 5,151,596 | String is not equal to itself | <p>But why?</p>
<pre><code>if ('i' == 'і')
echo 'good';
else
echo 'bad';
</code></pre>
<p>echos:</p>
<pre><code>>> bad
</code></pre>
<p>You should copy this snippet. If you write it by hand, it will work.<br>
It drives me crazy. </p>
| php | [2] |
5,936,006 | 5,936,007 | Get LastWriteTime of a decimal value | <p>What is the date of a value lastwritetime like this 347681594.3 ? This doesn't look like a epoche right ? </p>
| c# | [0] |
2,780,697 | 2,780,698 | Find pairs of numbers in a list that add up to 10 | <p>Given a list of numbers, I would like to find all pairs of numbers that add up to 10.</p>
<p>How can I write a function to do this in Python?</p>
| python | [7] |
1,341,197 | 1,341,198 | Android: how to catch the event when the soft keyboard pops up? | <p>When the user presses editText, the soft keyboard pops up. I want to hide a view or 2 while it is on. How to do that?</p>
| android | [4] |
339,194 | 339,195 | UIImageWriteToSavedPhotosAlbum saves to wrong size and quality | <p>I'm trying to take a screen shot of my app's current view and save it to photo album (to then be emailed or MMS'ed). </p>
<pre><code>UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil);
</code></pre>
<p>This works but the resulting image apears to be larger (533x800px) and heavily compressed when I email it from the photo library.</p>
<p>I've tried first writing the UIImage to file and then saving to album but still get the same issue. </p>
<p>If I used the in-built screenshot functionality on the iPhone the view saves correctly to photo album at 320x480 but the above code appears to save a larger image for some reason?</p>
<p>Thanks!</p>
| iphone | [8] |
3,633,260 | 3,633,261 | Searching for strings in files along with using os.walk | <p>I have written a Python Script to find out lines containing a particular script from each of the files within a directory. It works fine if i make this script run in the directory having those files. </p>
<pre><code>#!/usr/bin/env python
import os
def searchthis(location, searchterm):
for fname in os.listdir(location):
fullpath = os.path.join(location, fname)
for line in file(fullpath):
if searchterm in line:
print line
searchthis(os.getcwd(), "mystring")
</code></pre>
<p>Is there any way I could do this with <code>os.walk</code> and search for recursively in each of the files present in all the directories as well as subdirectories. </p>
| python | [7] |
2,998,774 | 2,998,775 | Android: Why does adding minSdkVersion to manifest cause bitmaps to be cropped/masked | <p>I throw myself at your mercy, I have been pulling my hair out with this...</p>
<p>I have developed a simple android game: a thread writes bitmaps onto a Canvas provided by a SurfaceView. In the manifest I HAD NOT included a "uses-sdk" element in the manifest.</p>
<p>The game worked fine on my HTC Desire (2.2 SDK level 8)</p>
<p>When testing on a tablet (Samsung Galaxy Tab 8.9) the game worked but was rendered with wide black borders to the left/right and bottom: a screen compatability issue.</p>
<p>I searched for information on this and found a page in the Android Developement docs (http://developer.android.com/guide/practices/screen-compat-mode.html) that said that adding</p>
<pre><code><uses-sdk android:minSdkVersion="8"/>
</code></pre>
<p>to the manifest is the simplest way to fix the "rendering with large black borders on a large screen" issue and yes it worked - the game rendered perfectly on the tablet. Hurrah!</p>
<p>BUT!! When I loaded the game back onto the (2.2 level 8) phone, <em>with the minSdk specified</em>, all of the bitmaps appear to have been cropped to only show the top left corner or masked somehow.</p>
<p>So a bitmap like</p>
<pre><code>12
34
</code></pre>
<p>rendered as</p>
<pre><code>--
-1
</code></pre>
<p>Please advise</p>
| android | [4] |
466,962 | 466,963 | Could not get the display property. Invalid argument | <p>i write a jquery code and when i test page in IE 7 i found this Error</p>
<p>Could not get the display property. Invalid argument.</p>
<p>my code:</p>
<pre><code> var $insert = $(item).css({ height: 0, display:'' }).prependTo($list);
$insert.animate({ height: 35 }, 600).animate({ display: '' }, 600);
if ($list.children().length > 8) {
$list.find('> li:last').animate({ filter: alpha(opacity = 50) }, 600).remove();
}
</code></pre>
| jquery | [5] |
345,068 | 345,069 | How to calulate the height of one div and increase another in jquery? | <p>I have the following problem.</p>
<p>I have a paneldiv1 which contains come content - as I decrease the browser size the content bunches up and increase the height of the div which is fine.</p>
<p>As paneldiv1 increase is height I would like paneldiv2 to recalculate its size depending on the size of paneldiv1.</p>
<p>SO if paneldiv1 is 100px height and increase by 20px to 120px </p>
<p>and paneldiv2 has a height of 150px - i'd want paneldiv2 to increase by 20px = to 170px</p>
<p>how can I do this in jquery??</p>
<p>Example: <a href="http://jsfiddle.net/zidski/9CvzV/" rel="nofollow">http://jsfiddle.net/zidski/9CvzV/</a></p>
| jquery | [5] |
1,828,920 | 1,828,921 | Difficulty accessing contents of JQuery Array | <p>I am adding controls to an array in JQuery like this:</p>
<pre><code>$('#tblControls tr').each(function () {
var radioButtonText = $(this).find("#td2").find("#chxBxValue").val();
var isSelected = $(this).find("#td2").find("#chxBxSelected");
var $newRdBtn = '';
if (isSelected == 1) {
$newRdBtn = $('<input />').attr({ id: 'rdBtn', type: 'radio', name: 'rdBtngrp', selected: 'true' }) +'<label for="rdBtn">' + radioButtonText + '</label>';
} else {
$newRdBtn = $('<input />').attr({ id: 'rdBtn', type: 'radio', name: 'rdBtngrp' }) + '<label for="rdBtn">' + radioButtonText + '</label>';
}
rblArray.push($newRdBtn);
});
</code></pre>
<p>Later on in another function I try to add the contents of rblArray to a like so</p>
<pre><code>$.each(rblArray, function (intIndex, objValue) {
$("#myPlaceHolder").append(rblArray[intIndex]);
$("#myPlaceHolder").append('<br/>');
});
</code></pre>
<p>But this returns </p>
<pre><code>[object Object]Test Control 1
[object Object]Test Control 2
</code></pre>
<p>instead of</p>
<pre><code><input type="radio" name="rdBtngrp" id="rdBtn" />Test Control 1
<input type="radio" name="rdBtngrp" id="rdBtn" />Test Control 2
</code></pre>
<p>?? What am I missing ??</p>
| jquery | [5] |
1,906,632 | 1,906,633 | Select item in the list of item using jquery | <p>I have a list of div with the same class name. I wonder how to catch exactly which div client click on it by using jquery. I try many way in many times but I couldn''t figure out. Please help me because I''m newbie in jquery.</p>
| jquery | [5] |
5,729,503 | 5,729,504 | What is the proper use of strpos and or stripos? (Is this a bug?) | <p>This has me thrown for a loop:</p>
<pre><code>$s = "ERROR: 5 - [RecordN...blah blah blah";
print stripos($s, 'error') . "\n";
print strpos($s, "ERROR") . "\n";
print $s . "\n";
</code></pre>
<p>results in:</p>
<pre><code>0
0
ERROR: 5 - [RecordN...blah blah blah
</code></pre>
<p>Huh? All right I'll try something from <a href="http://php.net/manual/en/function.strpos.php" rel="nofollow">here</a>: </p>
<pre><code>$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
print $pos . "\n";
</code></pre>
<p>result is:</p>
<pre><code>0
</code></pre>
<p>what? </p>
<p>I'm running:</p>
<pre><code>php --version
PHP 5.3.6-13ubuntu3.6 with Suhosin-Patch (cli) (built: Feb 11 2012 03:26:01)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
</code></pre>
<p>Am I looking at a bug?</p>
<p>Thanks in advance.</p>
<p>EDIT:</p>
<p>Clearly lost my senses there. Thanks for all the responses. </p>
| php | [2] |
2,831,602 | 2,831,603 | HyperLinkField not showing as link | <p>I have the following column in a <code>GridView</code>, and my problem is that it only renders the text "Download", not a URL.</p>
<pre><code><asp:HyperLinkField DataNavigateUrlFields="ArchiveLocation" Text="Download" DataNavigateUrlFormatString="{0}" />
</code></pre>
<p>When I bind a <code>DataTable</code> with one row to the grid, the <code>ArchiveLocation</code> in that row contains the value:</p>
<blockquote>
<p>"~/Common/Forms/ExportStream.aspx?path=C:\Development\Chase\Exports\ChaseExport-090312073930.zip".</p>
</blockquote>
| asp.net | [9] |
703,869 | 703,870 | PHP explode() function issue | <p>Please help me out on this explode() function issue. I am getting unexpected results for the third scenario, what's the explanation?</p>
<p><strong>EDIT:</strong> The value $page_string is actually from the database. This time I did the tests using var_dump instead of echo. The strings, How does php count them? How is "15&page" count 11?</p>
<pre><code>var_dump($page_string);//string(11) "15&page"
</code></pre>
<p><strong>1.</strong> Pop out ampersand ... fine. </p>
<pre><code> $page_id_array = explode("&",$page_string);
$page_id = $page_id_array[0];
var_dump($page_id);
// string(2) "15"
</code></pre>
<p><strong>2.</strong> Pop out number ... fine</p>
<pre><code> $page_id_array = explode("15",$page_string);
$page_id = $page_id_array[1];
var_dump($page_id);
//string(9) "&blog"
</code></pre>
<p><strong>3.</strong> Pop out '&page' ... why?</p>
<pre><code> $page_id_array = explode("&page",$page_string);
$page_id = $page_id_array[0];
var_dump($page_id);
//string(11) "15&page"
var_dump($page_id_array[1]);
//NULL
</code></pre>
<p><strong>EDIT:</strong> After answer and comments from jasonbar I did the test which confirms his answer:</p>
<pre><code> $page_id_array = explode("&amp;page",$page_string);
$page_id = $page_id_array[0];
var_dump($page_id);
//string(2) "15"
</code></pre>
| php | [2] |
794,689 | 794,690 | Validating a form for ONLY letter inputs | <p>Im validating a form but im struggling to get it to only accept letters for firstname and lastname fields</p>
<p>hope u can help</p>
<p>heres my code:</p>
<pre><code>$(document).ready(function(){
// Place ID's of all required fields here.
required = ["firstname", "lastname", "email"];
// If using an ID other than #email or #error then replace it here
email = $("#email");
errornotice = $("#error");
// The text to show up within a field when it is incorrect
emptyerror = "Please fill out this field.";
emailerror = "Please enter a valid e-mail.";
onlyletters = "Only letters allowed.";
$("#theform").submit(function(){
//Validate required fields
for (i=0;i<required.length;i++) {
var input = $('#'+required[i]);
if ((input.val() == "") || (input.val() == emptyerror)) {
input.addClass("needsfilled");
input.val(emptyerror);
errornotice.fadeIn(750);
} else {
input.removeClass("needsfilled");
}
}
// Only Letters.
if (!/^([a-zA-Z])+$/.test(errornotice.val())) {
errornotice.addClass("needsfilled");
errornotice.val(onlyletters);
}
// Validate the e-mail.
if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
email.addClass("needsfilled");
email.val(emailerror);
}
//if any inputs on the page have the class 'needsfilled' the form will not submit
if ($(":input").hasClass("needsfilled")) {
return false;
} else {
errornotice.hide();
return true;
}
});
// Clears any fields in the form when the user clicks on them
$(":input").focus(function(){
if ($(this).hasClass("needsfilled") ) {
$(this).val("");
$(this).removeClass("needsfilled");
}
});
});
</code></pre>
| javascript | [3] |
2,149,749 | 2,149,750 | Convert COleVariant to CString | <p>I have a COleVariant which is set to VT_NULL, when i try and convert the bstrVal member to a CString I get garbage. In older versions of my program however I do not get garbage, I get an empty CString which is my desired behaviour. Here is a simplified version of the offending code: </p>
<pre><code> COleVariant myCOleVariant;
myCOleVariant.vt = VT_NULL;
CString myCString = myCOleVariant.bstrVal;
</code></pre>
<p>myCOleVariant is set from a database field which can contain a string or could contain NULL. The databse contains mixed types hence using COleVariant. In the specific case which is causing my problems, the database field is NULL and the COleVariant before the conversion to CString is set as VT_NULL.</p>
<p>A simple workaround is to add a function:</p>
<pre><code> CString COleVariantAsCString(COleVariant pVar)
{
CString retval;
if(pVar.vt == VT_NULL || pVar.vt == VT_EMPTY)
retval = _T("");
else
retval = pVar.bstrVal;
return retval;
}
</code></pre>
<p>My question is this: Has anything changed in recent versions of visual studio or in windows 7 that would affect the way that COleVariants work? I use COlevariants a lot in my program and am worried that there could be other changes which will cause bugs like this.</p>
<p>I am using VS 2008 professional edition. Any input or ideas would be appreciated as I am quite perplexed by this unexplained change in behaviour. Apologies for the vaugue question. If i knew enough to ask it properly, I probably wouldnt need to ask it.</p>
| c++ | [6] |
4,592,600 | 4,592,601 | posting variables between windows in php | <p>my title may not be clear. But basically what I want to do is:</p>
<p>There will be a link in my php form</p>
<pre><code><a href="somepage.php" target=_blank>Update</a>
</code></pre>
<p>when the user clicks on the link, a new browser window opens and allows him to select some options. There will be close button in that window. When he clicks on that 'close' button, there is a post form from where the parent window should get the selected value.
When I get that selected value from that child browser window, how I am going to refresh parent browser window to reflect what user has selected in child window?</p>
<p>Environment : PHP</p>
<p>Can anyone give me some idea?</p>
| php | [2] |
4,550,976 | 4,550,977 | jquery error on page without any scripts | <p>getting the following error with jquery.</p>
<p>getting this without any jquery syntax in the head sections. </p>
<p>any ideas?</p>
<p>jquery 1.9.1</p>
<pre><code>TypeError: a is undefined
[Break On This Error]
...function(b,d){var f=d.nextPage,g,h=new a.Event("pageremove");d.nextPage&&(g=f.jq...
</code></pre>
<p>my head is:</p>
<pre><code> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
</code></pre>
<p>Thanks in advance...</p>
| jquery | [5] |
2,514,108 | 2,514,109 | Convert Type Decimal to Hex (string) in .NET 3.5 | <p>I am trying to convert a Decimal to Hex as a string. I've looked all over for a solution to this, but all I can find is Int or long to Hex. When using the code below I receive a "Format specifier was invalid" error.</p>
<pre><code> Decimal decValue = 18446744073709551615
string hexValue = decValue.ToString("X");
</code></pre>
<p>I've also looked into converting the decimal to a byte array and then converting to Hex, but I'm coming up short on that also.</p>
| c# | [0] |
2,708,925 | 2,708,926 | deque vs. queue in C++ | <p>Queue and Stack are a structures widely mentioned. However, in C++, for queue you can do it in two ways:</p>
<pre><code>#include <queue>
#include <deque>
</code></pre>
<p>but for stack you can only do it like this </p>
<pre><code>#include <stack>
</code></pre>
<p>My question is, what's the difference between queue and deque, why two structures proposed? For stack, any other structure could be included?</p>
| c++ | [6] |
539,758 | 539,759 | How to make exe file with c# | <p>i have one program in c#. this program get parameters(file for example *.jpg) from user and finally after click user on build button my program create one other program in windows application (cs:Form) that is has one viewer for images and store app in one exe file. i need help for how to create exe file from form class.</p>
<p>step 1 : </p>
<p>User run app1 </p>
<p>step 2 :</p>
<p>app1 get parameter from user and create app2 on save on hard drive </p>
<p>step 3:
user run app2</p>
| c# | [0] |
5,695,210 | 5,695,211 | Check if element has been removed JQuery | <p>I have script that removes an h4 element then animates a hidden form in its place.
I am trying to check if the h4 element has been removed so that if the same button is pressed ,while the form is visible, it will then animate out.</p>
<p>Here is the first part of my code</p>
<pre><code>$('#editMapItem h4').remove();
</code></pre>
| jquery | [5] |
1,444,370 | 1,444,371 | c# handling keypresses | <pre><code>private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar < '0' || e.KeyChar > '9')
if (e.KeyChar != '\b')
e.Handled = true;
}
</code></pre>
<p>i am not understanding how this code is not allowing anything except backspace and numbers. </p>
<ol>
<li>the first if statement is saying if it is not 0 - 9 then dont do anything?</li>
<li>the second one is saying if it's not backspace dont do anything?</li>
<li>what does <code>e.Handled=True</code> do?</li>
</ol>
| c# | [0] |
3,656,348 | 3,656,349 | How to traverse into CDATA in XML using Java | <p>I have an XML file like this</p>
<pre><code> <params>
<param index="0">
<value>
<![CDATA[value1]]>
</value>
</param>
<param index="1">
<value>
<![CDATA[value2]]>
</value>
</param>
<param index="2">
<value>
<![CDATA[value3]]>
</value>
</param>
<param index="3">
<value>
<![CDATA[value4]]>
</value>
</param>
</params>
</code></pre>
<p>I want to get Value1 only. Can anyone please help in finding the solution for this </p>
| java | [1] |
5,060,324 | 5,060,325 | how to fix my connection class? | <p>Im newbie in C#</p>
<p>I put my database connection to a class: </p>
<pre><code>public class Connection
{
public string SetConnection()
{
string connectionstring = "server=SURI-PC;database=cms;Integrated Security=True";
return connectionstring;
}
}
</code></pre>
<p>then, I call it in main class:</p>
<pre><code>public static void Main(string[] args)
{
Connection conObject = new Connection();
SqlConnection scon = new SqlConnection(conObject.SetConnection());
String sql = "insert into category(cat_id, cat_name) values('C03', 'Browser')";
SqlCommand cmd = new SqlCommand(sql, scon);
cmd.ExecuteNonQuery();
}
</code></pre>
<p>But it isnt work. </p>
<p>How to create a connection class and call it in others class?</p>
<p>Please help me!</p>
<p>thanks.</p>
| c# | [0] |
292,271 | 292,272 | How to retrieve a field array from an object array? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5174115/sorting-a-vector-of-objects-by-a-property-of-the-object">Sorting a vector of objects by a property of the object</a> </p>
</blockquote>
<p>I have a structure like below:</p>
<pre><code>strcut Point
{
int x;
int y;
int z;
};
</code></pre>
<p>I also have a generic sorting function for integers:</p>
<pre><code>void sort(vector<int>);
</code></pre>
<p>In my program, I need to sort an array of points std::vector frequently using different fields (i.e. x, y, or z). What can I do to convert an array of Points into an an array of integers efficiently?</p>
| c++ | [6] |
562,899 | 562,900 | Remove JavaScript code from HTML | <p>I'm looking for C# regular expression to replace/remove all JavaScript from HTML. Can someone please help me with the code?</p>
| javascript | [3] |
5,192,238 | 5,192,239 | why is nbsp converted before using indexof? And what does $(<html_section_id>).select... do? | <p>I wanted to ask 2 questions about below code:</p>
<pre><code>var tabName = 'Resolution';
var tabSection = $('tabs2_section').select('h3[class="tab_header"]');
var indexOfTabName = 0;
for (i = 0; i < tabSection.length; i++) {
var inner = tabSection[i].innerHTML.replace(/\x26nbsp;/g, ' ');
if(inner.indexOf(tabName) > -1) {
indexOfTabName = i;
break;
}
}
</code></pre>
<p>Above code finds the index of a tab within a section.</p>
<p>The questions I wanted to ask are:</p>
<ol>
<li><p>what does the following line do:</p>
<pre><code>var tabSection = $('tabs2_section').select('h3[class="tab_header"]');
</code></pre></li>
<li><p>why does it seem necessary to replace <code>&nbsp;</code> <code>(\x26nbsp;)</code> with a regular space, as done on following line:</p>
<pre><code>var inner = tabSection[i].innerHTML.replace(/\x26nbsp;/g, ' ');
</code></pre></li>
</ol>
<p>cheers</p>
| javascript | [3] |
646,138 | 646,139 | Web service call timer | <p>I have a PHP script that sends a request to a web service via soap. I expect to get a response back in just a few seconds, but if I do not receive a response within 30 seconds I need to send another request voiding my first request.</p>
<p>Any suggestions on the best way to handle this timer feature? Should I be looking at PHP's set<code>_time</code>_limit setting? Looking for any insight or general ideas.</p>
<p>Thanks.</p>
| php | [2] |
4,105,094 | 4,105,095 | Unwrap t.co links with Python | <p>I'm new to python, and I'm searching for a solution to expand t.co shorten urls into full ones. Can someone give me a hint?</p>
<p>thanks in advance,
m.</p>
| python | [7] |
3,726,036 | 3,726,037 | Error with a simple Animation | <p>I tried to start an AlphaAnimation for a ImageView with this code:</p>
<pre><code> ImageView view;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.prueba);
view=(ImageView)findViewById(R.id.icon);
view.setAlpha(0x00);
view.setVisibility(View.VISIBLE);
view.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.i("Down v", "x:" + e.getX() + " y:" + e.getY());
view.startAnimation(new AlphaAnimation(0x22, 0xFF));
// break;
case MotionEvent.ACTION_MOVE:
Log.i("Move", "x:" + e.getX() + " y:" + e.getY());
break;
case MotionEvent.ACTION_UP:
Log.i("Up", "x:" + e.getX() + " y:" + e.getY());
view.setAlpha(0x00);
break;
case MotionEvent.ACTION_OUTSIDE:
Log.i("Out", "x:" + e.getX() + " y:" + e.getY());
break;
default:
Log.i("None", "nada");
}
return false;
}
});
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.i("Click", "es un click");
}
});
}
</code></pre>
<p>this code should be make the ImageView appear when is touched, but nothing happend.
Any solution?</p>
| android | [4] |
4,053,194 | 4,053,195 | PHP script display as text in browser | <p>I have installed PHP, Apache in my Linux server. <a href="http://localhost/index.htm" rel="nofollow">http://localhost/index.htm</a> displaying correctly. To test the PHP I have created test PHP file phpinfo.php. Here is the code in that file</p>
<pre><code><?php phpinfo(); ?>
</code></pre>
<p>But when try to <a href="http://localhost/phpinfo.php" rel="nofollow">http://localhost/phpinfo.php</a>, browser displays script in the file. Apache did not execute the script in the file. What would be reason for this?</p>
| php | [2] |
3,050,573 | 3,050,574 | Back key not fully killing app, notification persists | <p>Min SDK is 7</p>
<p>I have a little notification on the top of the screen, but when you press the back key on the main activity, it doesn't go away. What do I need to add to my back button override to fix this?</p>
<pre><code>@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK))
{
finish();
}
return super.onKeyDown(keyCode, event);
}
</code></pre>
| android | [4] |
5,558,828 | 5,558,829 | Recursive/iterative functions | <p>I'm having a bit of a hard time creating a function, using iteration and recursion to find the sum of all even integers between 1 and the number the user inputs. The program guidelines require a function to solve this three ways:</p>
<ol>
<li>a formula</li>
<li>iteration</li>
<li>recursion</li>
</ol>
<p>This is what I have so far:</p>
<pre><code>#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
void formulaEvenSum(int num, int& evenSum)
{
evenSum = num / 2 * (num / 2 + 1);
return;
}
void loopEvenSum(int num, int& evenSum2)
{
}
int main()
{
int num, evenSum, evenSum2;
cout << "Program to compute sum of even integers from 1 to num.";
cout << endl << endl;
cout << "Enter a positive integer (or 0 to exit): ";
cin >> num;
formulaEvenSum(num, evenSum);
loopEvenSum(num, evenSum2);
cout << "Formula result = " << evenSum << endl;
cout << "Iterative result = " << evenSum2 << endl;
system("PAUSE");
return 0;
}
</code></pre>
| c++ | [6] |
880,613 | 880,614 | Accessing $(this) within a callback function | <p>I'm working on changing prompt() to jPrompt() since IE blocks prompt() from running. The problem is $(this) no longer works correctly because jPrompt() doesn't return a value, but uses a callback function.</p>
<p>So lets say I have something like this, which works:</p>
<pre><code>$("a.foo").click(function(){
$(this).text(prompt("Type Something",""));
}
</code></pre>
<p>When I convert it to this it breaks:</p>
<pre><code>$("a.foo").click(function(){
jPrompt("Type something:","","", function(r) {
$(this).text(r);
}
}
</code></pre>
<p>How do I access $(this) properly?</p>
| jquery | [5] |
783,165 | 783,166 | In android, how do you modify this code to populate two textviews instead of one? | <p>I am trying to modify the sample code below. It currently populates a View that contains an imageview and a textview. I have added an additional textview to my XML layout and am trying to figure out how to replace the simple array with a hash map or even a multidimensional array to populate not just the imageview and the first textview but also the second one.</p>
<p>I would appreciate sample code that shows the entire process. Thanks!</p>
<pre><code>public class DynamicDemo extends ListActivity {
TextView selection;
private static final String[] items={"lorem", "ipsum", "dolor",
"sit", "amet"}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
setListAdapter(new IconicAdapter());
selection=(TextView)findViewById(R.id.selection);
}
public void onListItemClick(ListView parent, View v,
int position, long id) {
selection.setText(items[position]);
}
class IconicAdapter extends ArrayAdapter<String> {
IconicAdapter() {
super(DynamicDemo.this, R.layout.row, R.id.label, items);
}
public View getView(int position, View convertView,
ViewGroup parent) {
View row=super.getView(position, convertView, parent);
ImageView icon=(ImageView)row.findViewById(R.id.icon);
if (items[position].length()>4) {
icon.setImageResource(R.drawable.delete);
}
else {
icon.setImageResource(R.drawable.ok);
}
return(row);
}
}
}
</code></pre>
| android | [4] |
1,170,195 | 1,170,196 | Java BufferedWriter IOException "Too many open files" | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4289447/java-too-many-open-files">Java Too Many Open Files</a> </p>
</blockquote>
<p><strong>This is not a duplicate, the referred question is different, only the title is same, please read carefully</strong></p>
<p>This is my file write function</p>
<pre><code> public static void WriteLog(String LogLine) {
String filePath = CommonClass.ReadPropertiesFile("LogFilepath");
BufferedWriter out = null;
try {
// Create file
FileWriter fstream = new FileWriter(filePath, true);
out = new BufferedWriter(fstream);
out.write(LogLine + "\r\n");
} catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e.getMessage());
} finally {
//Close the output stream
if (out != null) {
try {
out.write("Closing stream\r\n");
out.close();
} catch (IOException ex) {
System.err.println("Error Closing stream: " + ex.getMessage());
Logger.getLogger(LogWritter.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
</code></pre>
<p>i have also seen <a href="http://stackoverflow.com/questions/2960427/java-bufferedwriter-close">this question</a> but it doesn't seem to help, if close is a blocking call then it shouldn't give this problem.</p>
<p>but when i call WriteLog function too frequently i.e. in a loop i get this error:</p>
<pre><code>Error: (No such file or directory)
Could not load properties File, Exception: (Too many open files),
Error: (No such file or directory)
Could not load properties File, Exception: (Too many open files),
</code></pre>
<p>After some specific number of calls, on every subsequent call i keep on getting this error and no more text is written in the file. Can anybody tell me the reason I am totally confused.</p>
<p>Thanks in advance</p>
| java | [1] |
5,618,868 | 5,618,869 | How to view images based on tab selection in android | <p>Hi
I have created a program to fetch and display some images in gridview inside tabview stored on device.</p>
<ol>
<li><p>MyAppfolder</p>
<p>1.1. Fruitsfolder</p>
<p>1.1.1.apple.jpg</p>
<p>1.1.2.Grapes.jpg</p>
<p>2.1. Vegetablefolder</p>
<p>2.1.1.tomato.jpg</p>
<p>2.1.2.cucumber.jpg</p></li>
</ol>
<p>This is the folder structure of my application . My main folder is MyApp. It contains subfolder named Fruitfolder and Vegetable folder.These name are used for creating tabs(dynamically).What i need is to display images in gridview from the folder when i select the folder named tab .
ie when i click on vegetable folder tab view its corresponding gridview with images tomato.jpg and cucumber.jpg.</p>
<p>These folders are currently saved inside sdcard.</p>
<p>Any idea to accomplish this.please reply .thanks in advance</p>
| android | [4] |
2,574,766 | 2,574,767 | How to resize image after overlapping in asp.net | <p>I have a problem that I have two downloaded images on my webpage(second image is overlapped with first image), I have to resize second image which is overlapped, programmatically.
I don't know how to achieve this?</p>
<p>Please suggest me the right result.</p>
| asp.net | [9] |
4,064,905 | 4,064,906 | How to increase the labels at runtime | <p>i am accessing the web services, which return me data in a string array.
now i am creating a label at runtime, and adding it to the view of the application.
but for eg if there are 3 recodrs, only the third value is displayed in the label.
i mean to say i want to add labels one below the other.
how am i to do it...</p>
<p>i declared NSInteger *y=172;
and created a label
UILabel * l1=[[UILabel alloc]initWithFrame:CGRectMake(11,y+50,302,98)];
I dont know...whether it is correct .... but it surely gives me an error incompatible type for argument 2 of CGRextMake</p>
| iphone | [8] |
5,635,012 | 5,635,013 | Explain post back please | <p>Hello friends it may sound awkward but i am novice to asp dotnet web development realm, so my question is genuine. Please explain me about what is postback in asp.net. I want it's practical meaning and how does it work in the page life cycle while i dp understand ispostBack and i use it as well.</p>
<p>But i am not getting good meaning of post back please explain it to me with good example. </p>
| asp.net | [9] |
1,562,834 | 1,562,835 | android Notification PendingIntent problem | <p>i'm try to implement notification in android.</p>
<p>now i have a problem , i don't want to have a PendingIntent that user will open any Activity.</p>
<p>how can i do ?</p>
| android | [4] |
2,241,566 | 2,241,567 | HTML form values be used with PHP script | <p>I wanted to know if there is a better way to layout my form without having to create four check-boxes for the user to input 4 quarters as 25+25+25+25 = 1.00 to buy a drink.</p>
<p>Currently, I just have one check-box for each denomination(Nickles, Dimes and Quarters) I want to use.</p>
<p>I was wondering if there is better way in php and html that I can set a button, so that the user can only click a button for just quarters such that one click equates to 25 on the php side, and two clicks equates to 50 on the php side.</p>
<p>For example a user can click the quarters button once, and the value sent to the php script should be 25, and if the user clicks on nickles twice the value should be 5+5 = 10.</p>
<pre><code><form>
<label>Input Money Denominations</label>
<br />
<LABEL><INPUT TYPE="checkbox" NAME="money1" VALUE="Quarters">Quarters</LABEL>
<LABEL><INPUT TYPE="checkbox" NAME="money2" VALUE="Dimes"> Dimes</LABEL>
<LABEL><INPUT TYPE="checkbox" NAME="money3" VALUE="Nickles"> Nickles</LABEL>
</form>
<!--They are distinguished by their unique VALUEs
Only the value of the checked checkboxes will be passed to the php script.-->
<!--End Checkboxes for money option-->
<!--Submit button-->
<INPUT TYPE="submit" NAME="money" VALUE="Submit Denomination">
<!--The type of button tells what it does. The name is optional unless you are using a script that requires it(php).
</code></pre>
| php | [2] |
4,696,504 | 4,696,505 | change file extension in php? | <p>How do I change a files file-extension name in php?</p>
<p>example: $filename='234230923_picture.bmp'
and I want the extension to change to 'jpg'.</p>
<p>Thanks</p>
| php | [2] |
823,579 | 823,580 | how to set the cursor position in a non textbox component | <p>I am working with a component named SpinEdit that has a text property. how would I set the cursor position in this component ?</p>
| c# | [0] |
3,809,756 | 3,809,757 | Interpreting return value of function directly as an array | <p>Is there a way in PHP to interpret the return value of a function directly as an array?</p>
<p>lets say i have a function:</p>
<pre><code>function getArray() {
return array("foo", "bar");
}
</code></pre>
<p>instead of writing:</p>
<pre><code>$array = getArray();
$var = $array[1];
</code></pre>
<p>i want to access "bar" directly somewhat like:</p>
<pre><code>$var = getArray()[1]; //this causes an error
</code></pre>
| php | [2] |
2,046,539 | 2,046,540 | Jquery version conflicts | <p>I just posted a question regarding using 2 different plugins that use the UI library but didn't get a meaningful response. I'm not sure what it takes to get help in this JQ arena but this seems to me to be a common problem; at least amongst noobs.</p>
<p>How about someone be charitable and explain to me what I need to do to resolve this. I am very new to JQ and am seeking help.</p>
<p>I am using jquery.editinplace.js as well as datepicker. The version of the UI library that the datepicker uses is 1.8.5 and the version that the editor uses is 1.7.5</p>
| jquery | [5] |
4,186,289 | 4,186,290 | Why does window.location.toString() report the same as window.location.href? | <p>The window.location is an object. But when you execute window.location.toString() it converts the object to the equivalent to window.location.href.</p>
<p>My question is how? And can I set up objects to a similar behaviour?</p>
| javascript | [3] |
2,412,181 | 2,412,182 | detecting button without touch sense in android | <p>I have 8 buttons I would like the app to detect the buttons by just scrolling on the screen and not by touching? like the accessibility feature in Jelly bean? I am not sure how to call that feature as? Gesture? Motion sense?</p>
<p>Is this possible? What should I look for?</p>
<p>Thanks!</p>
| android | [4] |
1,781,286 | 1,781,287 | convert NSString to NSDate | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1353081/nsstring-to-nsdate">NSString to NSDate</a> </p>
</blockquote>
<p>Hi I want to convert the string "<code>OCT 1, 2011 18:30</code>" into <code>NSDate</code> format <code>2011-05-13 19:00:00 +0800.</code>
I have tried with the many formatters but what I am getting is a null value each time.
Can any body help me on this?</p>
| iphone | [8] |
3,032,195 | 3,032,196 | Convert a string to datetime object in python | <p>I have a date string defined as followed:</p>
<pre><code>datestr = '2011-05-01'
</code></pre>
<p>I want to convert this into a datetime object so i used the following code</p>
<pre><code>dateobj = datetime.datetime.strptime(datestr,'%Y-%m-%d')
print dateobj
</code></pre>
<p>But what gets printed is: 2011-05-01 00:00:00. I just need 2011-05-01. What needs to be changed in my code ?</p>
<p>Thank You</p>
| python | [7] |
2,823,711 | 2,823,712 | Problems outputting an image over http using Python | <p>I'm trying to load an image file from my local disk and output it over http when the script is accessed on my webserver via cgi.</p>
<p>For example I want <a href="http://example.com/getimage.py?imageid=foo" rel="nofollow">http://example.com/getimage.py?imageid=foo</a> to return the corresponding image. Just opening the file and printing imgfile.read() after the appropriate content headers, however, causes the image to be scrambled. Clearly the output isn't right, but I have no idea why.</p>
<p>What would be the best way to do this, using the built-in modules of 2.6?</p>
<p>Edit:</p>
<p>The code essentially boils down to:</p>
<pre><code>imgFile=open(fileName,"rb")
print "Content-type: image/jpeg"
print
print imgFile.read()
imgFile.close()
</code></pre>
<p>It outputs <em>an</em> image, just one that seems to be random data.</p>
| python | [7] |
5,633,352 | 5,633,353 | object oriented programming | <p>what is statically type and statically weak type.</p>
| javascript | [3] |
2,874,229 | 2,874,230 | Root Directory Information Included in Compiled Jar File? | <p>I have a simple 'Hello World' command line Java application. I build the .jar from the command line - no IDE is used. I find that if the root directory is different (i.e., /hello/ vs. /hello/with/more/dirs/), the final .jar files are not exactly the same. (I compared the two with a Unix diff utility). It appears that the root directory is encoded into the .jar file. </p>
<p>Can anyone verify that is true? </p>
<p>Is there anything else encoded in the .jar file, such as timestamps? </p>
<p>Is there any way to prevent the path from being encoded?</p>
| java | [1] |
427,995 | 427,996 | Searching Specific Data From a File | <p>I have a File having text and few numbers.I just want to extract numbers from it.How do I go about it ???</p>
<p>I tried using all that split thing but no luck so far.
My File is like this:</p>
<p>*AT+CMGL="ALL"
+CMGL: 5566,"REC READ","Ufone"
Dear customer, your DAY_BUCKET subscription will expire on 02/05/09
+CMGL: 5565,"REC READ","+923466666666"*</p>
<p><strong>KINDLY TELL ME THE WAY TO EXTRACT NUMBERS LIKE +923466666666 from this File so I can put them into another File or textbox.</strong></p>
<p>Thanks</p>
| c# | [0] |
4,441,083 | 4,441,084 | How to crop a rectangle from an image in android | <p>i'm using <a href="http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/" rel="nofollow">this</a> example to crop an image that was selected from the gallery but the problem is that example only crop squares. Would it be possible to crop rectangles instead of only squares? In that example if I move one side the adjacent side moves along, keeping it a square selection.</p>
<p>Thanks.</p>
| android | [4] |
17,262 | 17,263 | Is there a search engine for C++ commands? | <p>I do C++ and R programming since last 3 years. </p>
<p>I wish to know is there a search engine for C++ commands where I can find all the details regarding the command.</p>
<p>This is the example of what I am looking for:
This is a search engine for R commands:
<a href="http://www.rseek.org/" rel="nofollow">http://www.rseek.org/</a></p>
| c++ | [6] |
4,963,398 | 4,963,399 | jquery tooltip probelm in IE8 | <p>i have linkbuttons inside table columns and want to display tooltip even if it is disabled..This worked fine in FF and Chrome but not in IE8 as IE8 disabled elements don't receive any events i tried this workaround</p>
<p>i create a span outside the linkbutton if it is disabled and find the parent of the linkbutton i.e table cell.....then clear the table cells contents,add the span to it and then add the link button to the span and apply the tooltip to the span.</p>
<p>but again IE8 applies the jquery generated code to the table cell as well as the span and so my tooltip generates 2 times making it appear bolder.......i don't want this.this works fine in FF and chrome</p>
<p>i am using the simple tooltip jquery plugin which you can find here</p>
<p><a href="http://dev.mariusilie.net/content/simple-tooltip-jquery-plugin" rel="nofollow">http://dev.mariusilie.net/content/simple-tooltip-jquery-plugin</a></p>
<p>and here my code</p>
<pre><code>$(document).ready(function (){
var $elems=$(".with-tooltip");
$elems.each(function(){
var state=$(this).attr("disabled");
if(state==true || state=="disabled")
{
var $child=$(this);
var newElem= $(document.createElement('span'));
newElem.attr("title","privacy requested by owner");
var parentElement=$child.parent();
parentElement.empty();
newElem.append($child);
newElem.simpletooltip();
parentElement.append(newElem);
}
});
});
</code></pre>
<p>you can view this problem at <strong>www.sandesh4u.com/default2.aspx</strong></p>
<p>if you do a view source you will see what is the problem..</p>
<p>please help.i dont know much jquery...</p>
| jquery | [5] |
5,781,284 | 5,781,285 | Problem compiling C++ class | <p>I am running a C++ program which uses a class from another .cpp file. The class only has a constructor. It works when I test it separately. The main program compiles,but when I run it, I have a bug in the constructor. Any one can think of any situation that could happen? Thanks. </p>
<p>I guess I just run the code in terminal, and it is fine. But when I try to build a project in eclipse, it shows following code has multiple definition error:</p>
<pre><code>class model
{
public:
int textures [];
float vertices[][3];
float triangles[][13];
public:
model(const char*); // constructor
};
model::model(const char* filename)
{
</code></pre>
<p>error message is: multiple definition of `model::model(char const*)'</p>
<p>any idea?</p>
| c++ | [6] |
3,727,912 | 3,727,913 | eliminate return function | <p>how can i eliminate multiple number of return statements to one statement. example: i hav one if clause, the result of the if clause is true it will return 0. or return 1, the else of the same if contains another if clause. it has also the return value. how can i eleiminate this four return statement to one?</p>
<p>this is the program</p>
<pre><code>if (IgC == true)
{
if (val1.ToUpper() == val2.ToUpper())
{
return 0;
}
else
{
return 1;
}
}
else
{
if (val1 == val2)
{
return 0;
}
else
{
return 1;
}
}
</code></pre>
| c# | [0] |
158,518 | 158,519 | jQuery jHTMLArea character count | <p>I am trying to build an interactive character left feature but I am having problems attaching it to jHTMLArea.</p>
<p>I am guessing this is because the plugin hides the actual textarea.</p>
<p>I tried Keith Woods character count but that didnt work.</p>
<p>Any suggestions on how to attach something like this to jHTMLArea?</p>
| jquery | [5] |
2,611,689 | 2,611,690 | Jquery - accessing an element is giving null | <p>I have page a where product and its image are loaded in a table.The image is initially hidden,and onmouseover I want to display the image.The image is inside a div tag,and productname is shown as a link.In the onready function,I attach event handler to the link,</p>
<pre><code>$('a').each(function()
{
if( $(this).attr('id').match(/prod/))
{
$(this).mouseover(display());
}
});
</code></pre>
<p>and in the eventhandler(a function called display) I am calling</p>
<pre><code>function display()
{
$('div').each(function()
{
if( $(this).attr('id').match(/sx/))
{
alert("hi")
}
});
}
</code></pre>
<p>But, I am getting an error $("div") is null</p>
<p>HTML is:</p>
<pre><code> <table>
<tr><td><a href="link">product name</a></td>
<td><div class='.hidden'><table><tr><td><img src=""></img></td></tr></table></div></td></table>
</code></pre>
| jquery | [5] |
2,769,214 | 2,769,215 | Infinite PHP Look in Xampp | <p>If I do an infinite loop or a loop so big it's going to take days, will the process stop if I restart xampp? I coded something which made requests to Google and me and other people on the network started getting the search captcha. I stopped xampp and it seemed to stop but when I restarted xampp it started happening again.</p>
<p>It was hard to tell but it seemed to coincide.</p>
| php | [2] |
512,441 | 512,442 | Check if multiple conditions are all false or all true - java | <p>This sounds simple but my mind is drawing a blank</p>
<p>say i have this </p>
<pre><code>bool evaluator
for each form element{
if (element.name = 'fname')
{
perform some op
evaluator = true
}else evaluator false
if (element.name = 'city')
{
perform some op
evaluator true
}else evaluator false
if (element.name='shipcity')
{
perform some op
evaluator true
}else evaluator false
}
return evaluator
where evaluator :
if((t/f) && (t/f) && (t/f))
| | |-----------------evaluation of condition 3
| |-----------evaluation of condition 2
|--------------evaluation of condition 1
</code></pre>
<p>so at the end i get the '&&' of the 3 conditions. or does java have a built in method which will do this for me</p>
| java | [1] |
3,251,851 | 3,251,852 | Adding dot between two characters in java string | <p>I have a string :</p>
<pre><code>String x = "10";
</code></pre>
<p>i want to print it like this
1.0</p>
<p>I want to add "." between numbers </p>
<p>how??</p>
| java | [1] |
621,877 | 621,878 | Calculation of Latitude and Longitue from given point and radius | <p>I have latitude, longitude and a radius. Can you please help me in finding the
another latitude and longitude from given points (latitude and longitude) and radius.</p>
<p>Thanks in Advance</p>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.