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,608,872 | 3,608,873 |
Single word Palindrome Checker (True or False)
|
<p>Right now, what I have is a code that I can test a single word whether it is a Palindrome or not. I have to input the word, and it will tell me whether it is a Palindrome (True) or if it is not (False)</p>
<p>I need to create one that Asks for a single word, then provides a True of False based on the word that is typed. This is what i have so far. </p>
<p>I really have no idea how to do this, any help would be greatly appreciated. </p>
<pre><code>def isPalindrome(s):
if len(s) <= 1:
return True
else:
if s[0] != s[len(s)-1]:
return False
else:
return isPalindrome(s[1:len(s)-1])
print(isPalindrome("poop"))
</code></pre>
|
python
|
[7]
|
495,750 | 495,751 |
c# instantiating custom objects
|
<p>Hey so far I have and I'm getting a null pointer error in my for loop
anybody know why?
thanks</p>
<p>here is the error message</p>
<p>Object reference not set to an instance of an object.</p>
<pre><code> board = new BoardSquare[15][];
String boardHtml = "";
for (int i = 0; i < 15; i++) {
for (int k = 0; k < 15; k++) {
//if (board[i][k] == null)
board[i][k] = new BoardSquare(i, k);
boardHtml += board[i][k].getHtml();//null pointer error here
}
}
/**
* A BoardSquare is a square on the FiveInARow Board
*/
public class BoardSquare {
private Boolean avail; //is this square open to a piece
private String color;//the color of the square when taken
private int x, y; //the position of the square on the board
/**
* creates a basic boardSquare
*/
public BoardSquare(int x, int y) {
avail = true;
this.x = x;
this.y = y;
color = "red";//now added (thanks)
}
/**
* returns the html form of this square
*/
public String getHtml(){
String html = "";
html = "<div x='" + x + "' y='" + y + "' class='" + (avail ? "available" : color) + "'></div>";
return html;
}
/**
* if true, sets color to red
* if false, sets color to green
*/
public void takeSquare(Boolean red){
if(red)
color = "red";
else
color = "green";
}
}
</code></pre>
|
c#
|
[0]
|
4,261,672 | 4,261,673 |
How to go from last row to first row direstly in uitableview?
|
<p>iam making one application.In that iam using UITableview.In that i places one button at the last row of the tableview.How we go to first row when we click on that button.So please tell me how to solve this one.</p>
|
iphone
|
[8]
|
4,706,717 | 4,706,718 |
jQuery: how to add onlick event to a dynamic generated div?
|
<p>I want to add a onclick event to a div which generated using folowing code:</p>
<pre><code>$("<div />").attr("city", $(this).attr("city"))
.attr("state", $(this).attr("state"))
.html($(this).attr("city") + ',' + $(this).attr("state"))
.appendTo($('#cityList'));
</code></pre>
<p>Should I write onlick event in html()?</p>
|
jquery
|
[5]
|
5,516,407 | 5,516,408 |
What is the name of the "onload" event?
|
<p>I've a textarea that has <code>keyup</code> event to show a preview of rendered input. However, I want to display the same preview immediately after the element is loaded.</p>
<pre><code>$('textarea[name="ay[description]"]').on('keyup', function(e){
</code></pre>
<p>The simplest of all is to initiate <code>.trigger('keyup')</code> at the end of the declaration. However, isn't there event such as <code>load</code>, <code>onload</code> or <code>ready</code> that I've missed under different name?</p>
|
jquery
|
[5]
|
5,119,855 | 5,119,856 |
Printing a square - cant find the error
|
<p>The work I am currently doing requires me to 'draw' a square by printing '*' as the outline and '.' to fill it in. My code seems to work but it still isn't accepting it. I am a beginner, thanks. </p>
<pre><code>class Main {
public static void main(String args[]) {
int square = 5;
int line = 1;
int stars = 1;
int startLine = square / square;
while (line <= startLine) {
while (stars <= square) { // first line prints out dots for the value of square, in this case 5
System.out.print("*");
stars = stars + 1;
}
System.out.println();
line = line + 1; //prints new line and adds 1 to line. Meaning it will move to the next section as it is now greater than startLine
}
stars = 1; //resets stars
while (line <= square - 1) {// line will keep looping until its value is greater than square - 1
while (stars <= startLine) {
System.out.print("*"); // First character to print is *
stars = stars + 1;
}
while (stars <= square - 1) {
System.out.print("."); //prints 3 dots
stars = stars + 1;
}
while (stars <= square) {
System.out.print("*"); // stars is equal to square so 1 star is printed
stars = stars + 1;
}
stars = 1;
System.out.println();
line = line + 1; // adds a value and loops around again
}
stars = 1;
while (line <= square) {
while (stars <= square) {
System.out.print("*");
stars = stars + 1;
}
System.out.println();
line = line + 1;
}
}
}
</code></pre>
<p>It seems to make up the square and if I change the value of 'square' the size changes too. I cant see the problem.</p>
|
java
|
[1]
|
2,444,319 | 2,444,320 |
error in parsing json url in iphone application
|
<p>i am new bie in iPhone application.I want to implement json parsing.I have tried out the samples that are provided on net.But can't find out the exact way how to get index value of url while doing json parsing.has anyone done it earlier.As a beginner can anyone guide me.</p>
<p>Waiting for a positive response </p>
<p>Thanks in advance
Iphone developer</p>
|
iphone
|
[8]
|
716,660 | 716,661 |
SmsManager NullPointer Exception. Confused... so simple, should work
|
<p>If I send the following.</p>
<pre><code>SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("2064035760", null, "Message", null, null);
</code></pre>
<p>It throws the following exception.</p>
<p>I have the proper permissions.</p>
<pre><code>java.lang.NullPointerException
at android.telephony.SmsMessage$SubmitPdu. (SmsMessage.java:140)
at android.telephony.SmsMessage.getSubmitPdu(SmsMessage.java:624)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:228)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:109)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1027)
</code></pre>
|
android
|
[4]
|
4,317,114 | 4,317,115 |
does android 1.5 saves fpu regs on context switch
|
<p>i'm asking 1.5 and up</p>
<p>or is it dependant on what's in ".config" when compiled for my phone?</p>
<p>(and yes, i know that android has to support processors with soft-float, but several libm on different phones do have hard-float libm)</p>
<p>(please provide -if possible- any link to/file name of context switching function for msm 7200A/7201A)</p>
|
android
|
[4]
|
5,594,093 | 5,594,094 |
Android's RGBToHSV method doesn't work
|
<p>According to <a href="http://developer.android.com/reference/android/graphics/Color.html#RGBToHSV%28int,%20int,%20int,%20float%5b%5d%29" rel="nofollow">the document</a>, android.graphics.Color has a method called <code>RGBToHSV</code> which can convert RGB values to HSV, this is what the document tells me:</p>
<pre><code>public static void RGBToHSV (int red, int green, int blue, float[] hsv)
</code></pre>
<blockquote>
<h3>Convert RGB components to HSV.</h3>
<ul>
<li><code>hsv[0]</code> is Hue [0 .. 360)</li>
<li><code>hsv[1]</code> is Saturation [0...1] </li>
<li><code>hsv[2]</code> is Value [0...1]</li>
</ul>
<h3>Parameters</h3>
<ul>
<li><em>red</em>: red component value [0..255]</li>
<li><em>green</em>: green component value [0..255]</li>
<li><em>blue</em>: blue component value [0..255]</li>
<li><em>hsv</em>: 3 element array which holds the resulting HSV components.</li>
</ul>
</blockquote>
<p>But when I write a program to test it, it doesn't work any way.</p>
<pre><code>float[] hsv = new float[3];
RGBToHSV(255, 255, 0, hsv);
Log.i("HSV_H", "" + hsv[0]); // always output 0.0
</code></pre>
<p>Is it a bug ? </p>
|
android
|
[4]
|
3,666,493 | 3,666,494 |
How to use Google MapView in android apllication?
|
<p>I am trying to use MapView provided by Google API. I am not able to import the package i saw in google page we need to get a key for using google API do anyone know how to use Google API.
Thanks in advance...</p>
|
android
|
[4]
|
4,822,273 | 4,822,274 |
Best way to propagate opener variable across page navigation?
|
<p>Application that I'm working on has multiple modules. Two are of a concern - main module and module that I write. And I have to call a function on window that contains main module and the problem is that I have to call that function not from page that is opened by parent webmodule, but from page to which user navigates from this page. </p>
<p>Basically first page presents just some query forms, lets user to make some query, and second holds query results, and I am supposed to update contents of parent page based on these results. </p>
<p>Navigation goes like that</p>
<ul>
<li>Main module </li>
<li>First page of my module (i have main module page as an <code>window.opener</code> variable. </li>
<li>Second page of my module (and I would like to be able to open this page in the same browser window that the first one is opened)</li>
</ul>
<p>And I would like to have as free navigation as possible - like opening query results in new tab, going back changing query parameters, making new query, etc. I would also like to present user query forms on page that displays results and let them to refine this query, and still be able to update main module. </p>
<p>I was thinking of following solutions: </p>
<ol>
<li>Using AJAX to load query results to first window, but I would like to have this app as simple as possible, and AJAX is not simple ;)</li>
<li>Spawning new window on every request and doing code like <code>var mainModule = opener.mainModule</code>. Which is evil. </li>
<li>Embedding query results in a frame or iframe, but I havn'e got the slightest idea on how to inject main module window javascript variable into frame or iframe.</li>
</ol>
|
javascript
|
[3]
|
4,607,965 | 4,607,966 |
Handle Browser close in JavaScript?
|
<p>Is there a way to trap the browser closing event from JavaScript? I don't want to do this in Page Unload event or anything. It must be handled on clicking the browser close button.</p>
<p>Is it possible?</p>
|
javascript
|
[3]
|
3,906,402 | 3,906,403 |
learning Objective C,iphone
|
<p>In Android we can use intent to send (putextras) and receive (getextras) from 1 to another activity. I would like to ask there are any techniques like this in Iphone because I want to send a content of UITextField from First.m to Second.m
All comments are welcomed here. </p>
|
iphone
|
[8]
|
3,483,098 | 3,483,099 |
how do i know what parameters a python function takes with wingware IDE
|
<p>in visual studio all you had to do was type the first parenthesis and it showed you the parameters required.</p>
<p>It's not doing that in python / wingware, what is the best / easiest way to do this?</p>
|
python
|
[7]
|
2,124,970 | 2,124,971 |
Showing different view on button click and then pass data from child view to parent view in Android
|
<p>I am creating an application in which I want to have Alarm like functionality. I mean on my parent view there will be a button which on click will show a view where user can take action, then when he clicks on save then the data from the child view is passed to parent view and is shown in listview on parent view. The same functionality how we add new alarm in Android. I am new to android development, so please can somebody point me to some article explaining similar functionality or help me with some code?</p>
<p>Thanks
Ashwani</p>
|
android
|
[4]
|
4,477,564 | 4,477,565 |
Set Typeface for CheckboxPreference
|
<p>I want to set font for <code>CheckBoxPreference</code>. I know that we can set font for <code>CheckBox</code> using <code>setTypeface</code> method. But, CheckBoxPreference class has not typeface method.</p>
<p>Could any one please guide me to solve my problem ?</p>
<p>Thanks in advance :)</p>
|
android
|
[4]
|
4,486,652 | 4,486,653 |
What are the pitfalls of executing jQuery without $(document).ready();?
|
<p>Self-explanatory, I hope.</p>
|
jquery
|
[5]
|
5,637,282 | 5,637,283 |
How does Android decide which layout folder to use?
|
<p>In my application I have 3 different layout folders:</p>
<pre><code>layout
layout-large
layout-xlarge
</code></pre>
<p>I did this according to the available Android device screens, described <a href="http://developer.android.com/guide/practices/screens_support.html#range" rel="nofollow">here</a>. So I thought that the screen size in inches is the only thing that is used to decide which layout folder to use. But recent tests with various 7 inch emulator showed that sometimes the <code>layout</code> and sometimes the <code>layout-large</code> folder is used. So can anybody tell me which other factors are used?</p>
|
android
|
[4]
|
5,569,828 | 5,569,829 |
Image thumbnail and resize
|
<p>I have a code of picture resizing and image thumbnail working fine but it only support 3MB maximum file size. I want to increase the file size limit to atleast 10 to 12MB. anyone can do for me ? Thanks </p>
<pre><code> using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Upload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(MapPath("Image/" + FileUpload1.FileName));
System.Drawing.Image img1 = System.Drawing.Image.FromFile(MapPath("image/") + FileUpload1.FileName);
System.Drawing.Image bmp1 = img1.GetThumbnailImage(50, 50, null, IntPtr.Zero);
bmp1.Save(MapPath("thumbnail/S/") + FileUpload1.FileName);
System.Drawing.Image bmp2 = img1.GetThumbnailImage(100, 100, null, IntPtr.Zero);
bmp2.Save(MapPath("thumbnail/L/") + FileUpload1.FileName);
NormalImage.ImageUrl = "Image/" + FileUpload1.FileName;
ThumbnailImageS.ImageUrl = "thumbnail/S/" + FileUpload1.FileName;
ThumbnailImageM.ImageUrl = "thumbnail/L/" + FileUpload1.FileName;
}
}
</code></pre>
|
asp.net
|
[9]
|
2,997,580 | 2,997,581 |
Deleting files in folder with python
|
<p>I have one folder with one geodatabase and two other files (txt). I used zip and zipped them. So now in this folder i have gdb, txt,txt, and new zip file. Now I need to delete those files that were zipped, so that will be only zip file in the folder.
I wrote the following code:</p>
<pre><code>def remove_files():
for l in os.listdir(DestPath):
if l.find('zipped.zip') > -1:
pass
else:
print ('Deleting ' + l)
os.remove(l)
</code></pre>
<p>But got:</p>
<pre><code>Error Info:
[Error 2] The system cannot find the file specified: 'geogeo.gdb'
</code></pre>
<p>Can anyone help me?
Thank you in advance.</p>
|
python
|
[7]
|
3,161,153 | 3,161,154 |
jquery .html function remove part of a text within a div
|
<p>in <a href="http://stackoverflow.com/questions/6263632/jquery-remove-text-partially">my question</a> one suggested to do:</p>
<pre><code>$(".entry").html(function(i, htm){
return htm.split("-")[0];
});
</code></pre>
<p>To remove <strong>Approuved - Expire May 18 th 2012</strong> but this remove <br>Source: SuperSite also and i would like to keep the source</p>
<pre><code><div class="entry">
Published May 18th 2011 - Approuved - Expire May 18 th 2012<br>Source: SuperSite
</div>
</code></pre>
<p>I would like to remove <strong>Approuved - Expire May 18 th 2012</strong></p>
<p>So the result would be:</p>
<pre><code><div class="entry">
Published May 18th 2011 <br>Source: SuperSite
</div>
</code></pre>
|
jquery
|
[5]
|
5,344,188 | 5,344,189 |
are there something like isClicked in jquery?
|
<p>I have a div element, with img element in it.</p>
<p><code>onclick</code> of <code>div</code> i make one function, and <code>onclick</code> on <code>img</code> - another. but when i click on <code>img</code> it make the first function too, because the <code>img</code> is in <code>div</code> element.
so, i think, that if there were something like <code>isClicked</code>, onclick of div i can just verify, if img is <strong>Not</strong> clicked ...</p>
<p>(i can write a logic, and verify it by so,for example onclick of img i can add a class to somebody... but maybe there is a function for it?)</p>
<p>Thanks</p>
<p>Update:</p>
<pre><code><div class="left_expended" style="position: relative;">
Լեզուներ
<img src="images/new_page.gif" id="new_lang" title="Լեզու ավելացնել" />
</div>
</code></pre>
<p>and jquery</p>
<pre><code>$(".left_expended").live('click', function(){
$(this).addClass("left_collapsed");
$(this).removeClass("left_expended");
$(this).next("div .container").slideUp(400);
});
$("#new_lang").click(function()
{
alert("something");
});
</code></pre>
<p>onclick of img it makes first function too.</p>
|
jquery
|
[5]
|
722,097 | 722,098 |
PHO Variable and arrays, Client or serverside?
|
<p>In the HEAD section of a page, mySQL data is loaded into a PHP array.</p>
<p>Where would this array data be stored, Client or Server-side?</p>
<p>Any help with this would be appreciated.
Thanks</p>
<p>MikeRG</p>
|
php
|
[2]
|
2,144,991 | 2,144,992 |
Creating a PDF reader in C++
|
<p>So I wanna make a PDF reader using C++ as a hobby project. The problem is I am not finding much of head start so if anyone has worked on similar project please guide me, a few web links would be great! I will be using windows environment and Visual studio.</p>
|
c++
|
[6]
|
2,683,743 | 2,683,744 |
Failed to create Android Engine Connected Android Project
|
<p>I have installed Eclipse (Eclipse IDE for Java EE Developers 3.7.2) + latest version of Android SDK + ADT Plugin + GPE (Google Plugin for Eclipse). When I created <strong>Android Engine Connected Android Project</strong> I got "Creation of Element Failed Reason: C:\Android...\tools\lib\proguard.cfg (The system cannot find the file specified)" and " Creation of element failed. Reason: Resource '/myc2dm.project.test-AppEngine/war/WEB-INF/appengine-web.xml' already exists. I repeated the same installations on different PC (Window 7) and got the same problems. I created Android "Hello World" project fopr test and it worked well. Did I use wrong Eclipse version or I miss some configurations? Really apprciate your help, thank you in advance. </p>
|
android
|
[4]
|
629,261 | 629,262 |
ProgressBar.setProgressDrawable not working for Android 2.3
|
<p>I am currently working with a dynamically updating <code>ProgressBar</code>. Through certain percentages, the progessbar sets a drawable of a different color. We currently have various colored clip drawable defined in a drawable xml. The one entitled <code>progressbar_blue_states</code> is detailed as follows: </p>
<pre><code><layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background"
android:drawable="@drawable/progressbar_grey">
</item>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/progressbar_blue" />
</item>
</layer-list>
</code></pre>
<p>Whenever we need to update the dialog, we call the following code:</p>
<pre><code>progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_blue_states));
</code></pre>
<p>However, not only does this not update the ProgressBar, but also it takes out the progress bar altogether where whitespace is left in it's place. However, if I set <code>android:progressDrawable="@drawable/progressbar_blue_states"</code> in the xml and take out this <code>setProgressDrawable()</code> call, it loads correctly. We need the setProgressDrawable to update the colors as needed. </p>
<p>This call works fine in Android 4.0+ however in Android 2.3 we're running into some trouble. Any ideas?</p>
<p><strong>Edit</strong></p>
<p>This is how we set up the ProgressBar in the xml:</p>
<pre><code><ProgressBar android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginBottom="2dp"
android:indeterminate="false"
android:indeterminateOnly="false"
android:progress="24"
android:max="100"
android:progressDrawable="@drawable/progressbar_red_states" />
</code></pre>
|
android
|
[4]
|
791,043 | 791,044 |
How to use Substring function in C#
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/10901880/how-to-break-a-string-at-each-comma">How to break a string at each comma?</a> </p>
</blockquote>
<p>I want to split this string in C#.</p>
<pre><code>string str= "ahmad,ehsan,mohmmad,sss";
</code></pre>
<p>The result must be as below:</p>
<pre><code>ahmad
ehsan
mohmmad
sss
</code></pre>
|
c#
|
[0]
|
3,596,230 | 3,596,231 |
c# make a connection between a windows service and a c# project
|
<p>I have a c# project that prints or take some values from the keyboard to a console application. Can someone tell me how could I start this <strong>application from a windows service</strong>? I mean..when the computer is turned on I would like to pop up on my desktop the console application in which i can write values and see the result? Need some help. Please print a little code if you have one. Thx!</p>
|
c#
|
[0]
|
530,602 | 530,603 |
Is main thread the same as UI thread?
|
<p>The Android doc says "Like activities and the other components, services run in the main thread of the application process."</p>
<p>Is the main thread here the same thing as UI thread?</p>
|
android
|
[4]
|
614,008 | 614,009 |
VirusTotal Api Usage?
|
<p>So i got this</p>
<pre><code>public class VirusTotal
{
public string APIKey;
string scan = "https://www.virustotal.com/api/scan_file.json";
string results = "https://www.virustotal.com/api/get_file_report.json";
public VirusTotal(string apiKey)
{
ServicePointManager.Expect100Continue = false;
APIKey = apiKey;
}
public string Scan(string file)
{
var v = new NameValueCollection();
v.Add("key", APIKey);
var c = new WebClient() { QueryString = v };
c.Headers.Add("Content-type", "binary/octet-stream");
byte[] b = c.UploadFile(scan, "POST", file);
var r = ParseJSON(Encoding.Default.GetString(b));
if (r.ContainsKey("scan_id"))
{
return r["scan_id"];
}
throw new Exception(r["result"]);
}
public string GetResults(string id)
{
Clipboard.SetText(id);
var data = string.Format("resource={0}&key={1}", id, APIKey);
var c = new WebClient();
string s = c.UploadString(results, "POST", data);
var r = ParseJSON(s);
foreach (string str in r.Values)
{
MessageBox.Show(str);
}
if (r["result"] != "1")
{
throw new Exception(r["result"]);
}
return s;
}
private Dictionary<string, string> ParseJSON(string json)
{
var d = new Dictionary<string, string>();
json = json.Replace("\"", null).Replace("[", null).Replace("]", null);
var r = json.Substring(1, json.Length - 2).Split(',');
foreach (string s in r)
{
d.Add(s.Split(':')[0], s.Split(':')[1]);
}
return d;
}
}
</code></pre>
<p>But were do i input the url i would awsume its the scan, but how do i retrive the scans back and that and start the scan proccess</p>
<p>sorry but im new in apis and i dont really get webclient thx for ur help</p>
|
c#
|
[0]
|
1,724,013 | 1,724,014 |
How to get a file from ressource
|
<p>I know it seems like my question has been answered before, but I can't find an answer for my case.</p>
<p>What I am trying to do, is to get a File type from resource, so when it's packaged, it can be accessed. The answers I found were trying to read that file, but what I really need, is to construct a File object, because I have a third party library that is expecting that object.</p>
<p>Here is a the code I tried:</p>
<pre><code> String xslFilePath = new Test().getClass().getResource("/com/test/decision_template.xsl").getPath();
System.out.println(xslFilePath);
File xsltfile = new File(xslFilePath);
System.out.println(xsltfile.getAbsolutePath()+", exist:"+xsltfile.exists());
</code></pre>
<p>I got this result:</p>
<pre><code> C:\>java -jar test.jar
file:/C:/test.jar!/com/test/decision_template.xsl
C:\\file:\C:\test.jar!\com\test\decision_template.xsl, exist:false
java.io.FileNotFoundException: file:\C:\test.jar!\com\test\decision_template.xsl
(Syntaxe du nom de fichier, de rÚpertoire ou de volume incorrecte)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at com.test.Test.main(Test.java:30)
</code></pre>
<p>I need a way to get that file so the .exists() return true.</p>
|
java
|
[1]
|
5,571,676 | 5,571,677 |
C# functions and optional parameters
|
<p>I know that in C# it is possible to define optional parameters. My question is directed at how flexible this is.</p>
<p>Let f be a function as below, with <strong>a</strong> mandatory and <strong>b</strong>, <strong>c</strong> optional :</p>
<pre><code>class Test {
public void f(int a, int b = 2, int c = 3) {
//...
}
}
</code></pre>
<p>Now, I know I can call the function in the following ways :</p>
<p>f(1) -> a equals 1, b equals 2, c equals 3</p>
<p>f(11,22) -> a equals 11, b equals 22, c equals 3</p>
<p>f(11,22,33) -> a equals 11, b equals 22, c equals 33</p>
<p>How do I do to not specify <strong>b</strong>, but <strong>a</strong> and <strong>c</strong> ?</p>
|
c#
|
[0]
|
1,335,478 | 1,335,479 |
C# standard class (enumeration?) for Top, Bottom, Left, Right
|
<p>Is there a standard c# class that defines a notional Left, Right, Top and Bottom? </p>
<p>Should I just use my own?</p>
<pre><code>enum controlAlignment
{
left = 1,
top,
right,
bottom,
none = 0
}
</code></pre>
|
c#
|
[0]
|
1,722,301 | 1,722,302 |
Get selected element's outer HTML
|
<p>I'm trying to get the HTML of a selected object with jQuery. I am aware of the <code>.html()</code> function; the issue is that I need the HTML including the selected object (a table row in this case, where <code>.html()</code> only returns the cells inside the row).</p>
<p>I've searched around and found a few very ‘hackish’ type methods of cloning an object, adding it to a newly created div, etc, etc, but this seems really dirty. Is there any better way, or does the new version of jQuery (1.4.2) offer any kind of <code>outerHtml</code> functionality?</p>
|
jquery
|
[5]
|
4,074,522 | 4,074,523 |
Reading file with C#
|
<p>I want to read php text file using c#. The file looks like:</p>
<pre><code>2.20:2.20:2.20:2.20:2.20:
2012-07-12:2012-07-11:2012-07-10:2012-07-09:2012-07-08:
</code></pre>
<p>I would like to get all lines to listboxes. In real situation there is six lines, but first I should have read these two lines. My code:</p>
<pre><code>void web_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
try
{
int i;
string price_line = "";
string date_line = "";
List<decimal> prices = new List<decimal>();
List<string> dates = new List<string>();
using (var reader = new StreamReader(e.Result))
{
price_line = reader.ReadLine();
date_line = reader.ReadLine();
string[] bit_1 = price_line.Split(':');
string[] bit_2 = date_line.Split(':');
for (i = 0; i < 2; i++)
{
prices.Add(decimal.Parse(bit_1[i]));
dates.Add(bit_2[i]);
}
listBox1.ItemsSource = prices;
listBox2.ItemsSource = dates;
}
}
catch
{
MessageBox.Show("Can't read!");
}
}
</code></pre>
<p>Now I get "NullException". How to fix this?</p>
|
c#
|
[0]
|
3,653,507 | 3,653,508 |
Dynamic HtmlSelect options not posting back
|
<p>I have cascading dropdowns (country/province/city). when the page posts back I lose the selected option for province and city. The options for country are loaded through .net code but the province and city options are populated through javascript.</p>
<p>I think this has something to do with viewstate but can't quite wrap my head around why the selected values aren't posting back.</p>
|
asp.net
|
[9]
|
3,640,294 | 3,640,295 |
creating an object and initializing an object - Difference
|
<pre><code> ////Creating Object
var Obj;
// init Object
Obj= {};
</code></pre>
<ol>
<li>What's the difference between these
two?</li>
<li>Is it possible to make it into a
single line?</li>
<li>Any Advantages of using like this?</li>
</ol>
|
javascript
|
[3]
|
3,315,824 | 3,315,825 |
Using str_replace to remove spaces for exec()
|
<p>I'm running into an issue with the function <code>str_replace()</code> while trying to create a shell command in PHP. In shell, when I tab-finish a line that has spaces, it comes up like this:</p>
<pre><code>tar cvfz destination/filename.zip source/Name\ Of\ The\+\ Folder
</code></pre>
<p>So to me, this says that in order to run this command via <code>exec()</code>, I need to replace any spaces I would have in a string in PHP. To remedy this problem, I'm using</p>
<pre><code>$q = str_replace(' ', '\ ' , $q);
</code></pre>
<p>at the start of my string parse, in order to format the spaces into "\ " instead of " ". The issue I'm having is that for this particular folder, it's also removing the plus symbol as well, and it formats it like this:</p>
<pre><code>tar cvfz destination/Name\ Of\ The\ \ \ Folder.tgz source/Name\ Of\ The\ \ \ Folder
</code></pre>
<p>How can I set this up so <code>str_replace()</code> doesn't remove the plus sign? From my limited tests so far, it isn't removing anything out of these: <code>-, %, @, !, (, *, ), ^, =</code></p>
|
php
|
[2]
|
5,344,894 | 5,344,895 |
Can't resolve WindowsError: [Error 2] The system cannot find the file specified
|
<p>I'm trying to rename all the pictures in a directory. I need to add a couple of pre-pending zero's to the filename. I'm new to Python and I have written the following script.</p>
<pre><code>import os
path = "c:\\tmp"
dirList = os.listdir(path)
for fname in dirList:
fileName = os.path.splitext(fname)[0]
fileName = "00" + fname
os.rename(fname, fileName)
#print(fileName)
</code></pre>
<p>The commented print line was just to verify I was on the right track. When I run this I get the following error and I am at a loss how to resolve it.</p>
<blockquote>
<p>Traceback (most recent call last): File
"C:\Python32\Code\add_zeros_to_std_imgs.py", line 15, in
os.rename(fname, fileName) WindowsError: [Error 2] The system cannot find the file specified</p>
</blockquote>
<p>Any help is greatly appreciated. Thnx.</p>
|
python
|
[7]
|
4,180,205 | 4,180,206 |
error C2062: type 'int' unexpected, unable to solve this error
|
<p>I am getting the following errors when i run my program</p>
<pre><code>(61): warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
(63): error C2062: type 'int' unexpected
(69): warning C4129: 'm' : unrecognized character escape sequence
</code></pre>
|
c++
|
[6]
|
891,636 | 891,637 |
What is the difference between $("<tag></tag>") and $('<tag>')?
|
<p>From the context of the code I am reading, it seems like <code>$("<tag></tag>")</code> creates a tag, where as <code>$('<tag>')</code> is a selector that searches for a tag. What's going on here? Actually I might not have the syntax of the second one right, but I'm sure I've done <code>$('idName')</code> like this before.</p>
<p>What's going on? </p>
|
jquery
|
[5]
|
4,292,696 | 4,292,697 |
How to make my app full screen on Galaxy Tab
|
<p>I've been trying everything I can think of to get my app to display full screen on the Galaxy Tab.</p>
<p>Basically, it works like the Lunar Lander example app that comes with the Android SDK. What would you do to make that Lunar Lander app display in full screen on Large screen devices like the Galaxy Tab?</p>
<p>I'm not concerned about the quality of the graphics at this point, but just how an app created like this can fill the screen. It was basically designed to work on a 320x480 MDPI screen with images in the drawable folder and it uses a SurfaceHolder and view to draw the individual bitmaps.</p>
<p>Any advice?</p>
<p>CLARIFICATION: Sorry, I don't mean full screen as in removing the notification and title bar, I mean that everything has a giant black border around it and it the graphics don't take up the whole screen.</p>
|
android
|
[4]
|
1,799,002 | 1,799,003 |
Extending javascript object
|
<p>I already have this:</p>
<pre><code>var myVar = { appName: 'Test' };
</code></pre>
<p>I want to add this:</p>
<pre><code>myVar = {
exec: function()
{
console.log('do stuff');
}
}
</code></pre>
<p>And have this:</p>
<pre><code> myVar = {
appName: 'Test',
exec: function()
{
console.log('do stuff');
}
}
</code></pre>
<p>Actually, I want to be able to access myVar.appName and myVar.exec();</p>
<p>So, I can:</p>
<pre><code>myVar.exec = function(){};
</code></pre>
<p>But if I have many more functions and variables.</p>
<p>Do I have to keep doing this:</p>
<pre><code>myVar.func1 = function(){ // stuff 1 };
myVar.func2 = function(){ // stuff 2 };
myVar.func3 = function(){ // stuff 3 };
</code></pre>
<p>Are there a better way?</p>
<p>Thanks :)</p>
|
javascript
|
[3]
|
3,445,288 | 3,445,289 |
How do I change, replace or deleting a line in a text file using c++?
|
<p>How do I change, replace or deleting a line in a text file using c++?</p>
<p>I have a text file that contains login information for users ( username and password ) , for example : </p>
<pre><code>//file
Jimmy jim1236
tom tommy545
</code></pre>
<p>Now how can I write a program that allows users to change their own password after they log into the system? I have already done the login part. </p>
|
c++
|
[6]
|
280,498 | 280,499 |
How to implement password protected PDF file in iPhone SDK
|
<p>Is any one have an idea to how to implement a password protected PDF file in iphone sdk. I mean to I need to create a password pdf file from my application.Please help me.</p>
<p>Any one's help will be much appreciated.</p>
|
iphone
|
[8]
|
1,405,750 | 1,405,751 |
How to correctly read attributes from android namespace in custom Preference?
|
<p>I am writing a custom <code>Preference</code>. I can easily read attribute values in my private namespace:</p>
<pre><code>public MyPreference(Context context, AttributeSet attrs)
{
super(context, attrs);
TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.MyPreference);
mDefaultValue = styledAttrs.getInt(R.styleable.MyPreference_defaultValue, 0);
}
</code></pre>
<p>But I do not know, how to read android attributes, e.g. <code>android:defaultValue</code>. In all examples on the web attributes contain values, but I use resources like <code>@integer/my_number</code> so simply reading <code>attrs</code> does not work - attribute contains resource reference but not the value. android.R.styleable is not accessible, so I do not understand how to do it.</p>
|
android
|
[4]
|
2,168,769 | 2,168,770 |
Error while writing to file
|
<blockquote>
<pre><code>package test_package2;
import java.io.*;
public class File_Directory_Operations {
public void FileOperation() {
try {
byte[] bWtite = { 11, 12, 13, 14, 15 };
OutputStream objOS = new FileOutputStream("F:/Shiju/Test Programmes/Eclipse/testjava.txt");
for (int iCount = 0; iCount < bWtite.length; iCount++) {
objOS.write(bWtite[iCount]);
}
objOS.close();
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
</code></pre>
</blockquote>
<p>I am new to Java.I am able to create the file and write into it, but instead of the expected byte array I am getting series of characters inside the file. Why am I not able to print the array?</p>
|
java
|
[1]
|
3,795,849 | 3,795,850 |
Problem with Audio/Video
|
<p>In my code i am using VideoView and MediaController for playing my audio/video files. The problem is that I need to place my audio/video files in assets folder but i am not able to play the audio/video files when placed in assets folder and give path as "file:///android_asset/audio.mp3". I get this error "Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported". But the same code runs when i place my audio/video files in sdcard and give its path(/sdcard/audio.mp3). Does this mean that i cannot play audio/video files when placed in assets folder? Thanks in advance.</p>
|
android
|
[4]
|
2,939,465 | 2,939,466 |
Weird prototype pointing
|
<p>I am reading this: <a href="http://killdream.github.com/blog/2011/10/understanding-javascript-oop/index.html" rel="nofollow">http://killdream.github.com/blog/2011/10/understanding-javascript-oop/index.html</a></p>
<p>and i've encountered some code that i can't understand:</p>
<pre><code>function Person(first_name, last_name) {
this.first_name = first_name
this.last_name = last_name
}
// Defines the `name' getter/setter
Object.defineProperty(Person.prototype, 'name', { get: get_full_name
, set: set_full_name
, configurable: true
, enumerable: true })
</code></pre>
<p>Why is he using <code>Object.defineProperty</code> on <code>Person.prototype</code> and not simply on <code>Person</code>?
Why not simply include <code>name</code> in the definition or make <code>Person.name = bla...</code>?</p>
<p>(EDIT: SOLVED)
also, why am i seeing this endless loop of prototype reference??</p>
<p><img src="http://i.stack.imgur.com/BWXfl.jpg" alt="why am i seeing this endless loop of prototype reference?"></p>
|
javascript
|
[3]
|
1,696,304 | 1,696,305 |
Is it possible to save image in assets folder from application
|
<p>I want to save image from a url in assets folder. I can save image in internal memory or sd card but I want to save in the assets folder. </p>
<p>I searched about it online but some results are saying that the assets folder is not writable. Is it possible to write image in that folder?</p>
|
android
|
[4]
|
5,202,306 | 5,202,307 |
Better way to find all iframes on the page
|
<p>I am developing iPad application in that more than 6 iframes are available. After fully loaded the page, the page scroll went to the some where in the middle. So I decided to get page scrolltop written JavaScript code like this:</p>
<pre><code>$(document).ready(function() {
try {
var iframecompleted = [];
$("iframe[id*='iframe']").each(function(eli, el) {
$(this).bind("load", iframeinit);
});
function iframeinit() {
iframecompleted.push($(this).id);
$(this).unbind("load", iframeinit);
}
var timer = setInterval(function() {
if ($("iframe[id*='iframe']").length == iframecompleted.length) {
clearInterval(timer);
$('html, body').animate({
scrollTop: 0
}, 500);
if (FrameID != "") {
var j = 0;
var ss = FrameID.split(",")
for (j = 0; j < ss.length; j++) {
var collPanel = $find("pane" + ss[j]);
if (collPanel != null)
collPanel.set_Collapsed(true);
}
FrameID = "";
}
}
}, 10);
}
catch (e) {
alert(e);
}
});
}
</code></pre>
<p>I would like to find a better way to achieve this task. Your ideas are more welcome.</p>
|
javascript
|
[3]
|
3,239,340 | 3,239,341 |
Issue with upload data in android
|
<p>I need to upload icon image file to server here i have try it but when i print response ::
i have use <code>HTTP POST</code> method ::</p>
<pre><code>11-09 08:13:10.953: INFO/System.out(15034): entityorg.apache.http.conn.BasicManagedEntity@44eebcf8
11-09 08:13:10.953: INFO/System.out(15034): entityorg.apache.http.message.BasicHttpResponse@44eea688
11-09 08:13:10.953: INFO/System.out(15034): isorg.apache.http.conn.EofSensorInputStream@44eec600
</code></pre>
<p><strong>Here is my code ::</strong> </p>
<pre><code>Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.icon);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, bao);
byte [] ba = bao.toByteArray();
String ba1=Base64.encodeToString(ba, 1);
ArrayList<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("Content-Type","application/soap+xml"));
nameValuePairs.add(new BasicNameValuePair("ImgIn",ba1));
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://192.168.1.20/Webservices/Service.asmx/PutImage");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
System.out.println("entity"+entity);
System.out.println("entity"+response);
is = entity.getContent();
System.out.println("is"+is);
} catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
}
</code></pre>
|
android
|
[4]
|
2,319,177 | 2,319,178 |
Array class in C++: How to use one method in another
|
<p>I have a class for performing various array operations. I like to use my insert method in my populate method.
Can someone guide me on that? Here is the code:</p>
<pre><code>#include <iostream>
#include <cstdlib>
using namespace std;
const int MAX=5;
class array
{
private:
int arr[MAX];
public:
void insert(int pos, int num);
void populate(int[]);
void del(int pos);
void reverse();
void display();
void search(int num);
};
void array::populate(int a[])
{
for (int i=0;i<MAX;i++)
{
arr[i]=a[i];
}
}
void array::insert(int pos, int num)
{
for (int i=MAX-1;i>=pos;i--)
{
arr[i] = arr[i-1];
arr[i]=num;
}
}
void array::del(int pos)
{
for (int i=pos;i<MAX;i++)
{
arr[pos]=arr[pos + 1];
}
}
void array::display()
{
for (int i=0;i<MAX;i++)
cout<<arr[i];
}
void array::search(int num)
{
for (int i=0;i<MAX;i++)
{
if (arr[i]==num)
{
cout<<"\n"<<num<<" found at index "<<i;
break;
}
if (i==MAX)
{
cout<<num <<" does not exist!";
}
}
}
int main()
{
array a;
for (int j=0;j<MAX;j++)
{
a.insert(j,j);
}
a.populate(a);
a.insert(2,7);
a.display();
a.search(44);
system("pause");
}
</code></pre>
|
c++
|
[6]
|
4,159,589 | 4,159,590 |
Getting an error in C++
|
<p>So <a href="http://ideone.com/9riAm" rel="nofollow">This</a> is my code and I keep on getting <a href="http://i.imgur.com/1OoXD.png" rel="nofollow">this error</a>.
I don't know what it is.
What I was doing before getting the error: Adding constructors and destructors to my classes.
What the error seems to be: The error windows points to line 52, <code>unsigned int _size; // number of account stored</code> however I do not see anything wrong with the code.</p>
|
c++
|
[6]
|
3,067,372 | 3,067,373 |
iphone - preventing attachments from showing
|
<p>I am using MFMailComposeViewController to compose a message on a view. If I attach a PDF or an PNG, JPEG or GIF image to the message, the image is shown on the mail composition view. If the image is huge it is very difficult for the user to type the message.</p>
<p>Is there a way to attach a known document to a MFMailComposeViewController view and prevent the attachment from being opened? I want to be able to show the attachment as an attached file icon. I don't want to see its contents opened on the window.</p>
<p>Is this possible?</p>
<p>thanks</p>
|
iphone
|
[8]
|
4,932,379 | 4,932,380 |
What does the function then() mean in JavaScript
|
<p>I've been seeing code that looks like:</p>
<pre><code>myObj.doSome("task").then(function(env) {
// logic
});
</code></pre>
<p>Where does then() come from?</p>
|
javascript
|
[3]
|
5,009,418 | 5,009,419 |
string concatenation problem
|
<p>Please how this string concatenation taking place?
i am really confuse what is happening why that slash i there and how the double quotes are used</p>
<pre><code>SessionStateItemCollection items = new SessionStateItemCollection();
items["LastName"] = "Wilson";
items["FirstName"] = "Dan";
foreach (string s in items.Keys)
Response.Write("items[\"" + s + "\"] = " + items[s].ToString() + "<br />");
//here i am looking for explanation please elaborate me on this please
Response.Write("items[\"" + s + "\"] = " + items[s].ToString() + "<br />");
</code></pre>
|
asp.net
|
[9]
|
192,744 | 192,745 |
Fast CSV reading from network drive
|
<p>I have a csv flat file system on a network drive from which at any point of time I read about 500-600 csv files each with several thousand lines. I'm currently using the following piece of code to do the reading,</p>
<pre><code>var parser = new TextFieldParser(fileName) {TextFieldType = FieldType.Delimited};
parser.SetDelimiters(",");
while (!parser.EndOfData)
{
var fields = parser.ReadFields();
}
</code></pre>
<p>But even this takes pretty long. I'm looking to speed things up significantly. Can anyone suggest something.</p>
|
c#
|
[0]
|
3,718,268 | 3,718,269 |
Sending Email Through localhost asp.net
|
<pre><code> public ActionResult Index(EmailModel model)
{
MailMessage message = new MailMessage();
message.From = new MailAddress("sheikh.abm@gmail.com");
message.To.Add(new MailAddress(model.To));
message.Subject = model.Subject;
message.Body = model.Message;
return View();
}
</code></pre>
<p>this is my controller action. And in web.config .</p>
<pre><code> <system.net>
<mailSettings>
<smtp from="sheikh.abm@gmail.com">
<network host="\localhost:"/>
</smtp>
</mailSettings>
</system.net>
</code></pre>
<p>The problem i got is that the mail didn't send and it didn't show me any error kindly help me.</p>
|
asp.net
|
[9]
|
1,383,810 | 1,383,811 |
To Add Name,Email and Number to Contact Database
|
<p>I am using autocomplete textview to pick contacts which is in contact list, and I want to save the name,email ,number which is not in contact list which should be displayed like form and when i click some "Add" button it should save in the contacts. How to do this thing?</p>
<p>Could any one help me please!</p>
<p>Thanks in Advance.</p>
|
android
|
[4]
|
3,221,338 | 3,221,339 |
Abstract getter with concrete setter in C#
|
<p>I'm trying to write an abstract base class for read-only collections which implement <code>IList</code>. Such a base class should implement the set-indexer to throw a <code>NotSupportedException</code>, but leave the get-indexer as abstract. Does C# allow such a situation? Here's what I have so far:</p>
<pre><code>public abstract class ReadOnlyList : IList {
public bool IsReadOnly { get { return true; } }
public object this[int index] {
get {
// there is nothing to put here! Ideally it would be left abstract.
throw new NotImplementedException();
}
set {
throw new NotSupportedException("The collection is read-only.");
}
}
// other members of IList ...
}
</code></pre>
<p>Ideally <code>ReadOnlyList</code> would be able to implement the setter but leave the getter abstract. Is there any syntax which allows this?</p>
|
c#
|
[0]
|
1,797,539 | 1,797,540 |
When i develop my codes under Sun JDK and run my codes in Oracle JRockit JVM, am i using libraries from JRockit?
|
<p>When i develop my codes under Sun Standard JDK, and run my codes in Oracle JRockit JVM, am i using the implementation of the <code>String</code> class provided by Hotspot VM or JRockit VM?</p>
|
java
|
[1]
|
4,095,296 | 4,095,297 |
Python: Cut and Paste Data on Text File.
|
<p>I have a text file that contains numbers.</p>
<p>I need to move some of the numbers from the beginning of the file to the end in the correct order. </p>
<p>For example, the Original <code>TEXT</code> file has the following content: <code>0123456789</code>.</p>
<p>I need to move the <strong>first 4 numbers</strong> to the end in the same order so it'll look like this:</p>
<p><code>4567890123.</code> </p>
<p>Unfortunately i have no idea how to do this with Python,
I don't know even where to start. </p>
<p>Any pointers to solving this problem would be highly appreciated.</p>
|
python
|
[7]
|
4,162,943 | 4,162,944 |
javascript: object property is array, but append isn't working
|
<pre><code>var objs = {
'prop': []
}
objs['prop'].append('q');
</code></pre>
<p>Error: <code>TypeError: objs.prop.append is not a function</code></p>
<p>Why this code is not working ? <br >
Why <code>console.log(typeof(objs['prop']));</code> is <code>object</code> not <code>array</code> ?</p>
|
javascript
|
[3]
|
5,864,085 | 5,864,086 |
How to write a subprocess.Popen line of code
|
<p>I have used</p>
<pre><code> self.session.open(MoviePlayer, sref)
</code></pre>
<p>to start playing a file with MoviePlayer in my python 2.6 code,
I have been advised that i should use </p>
<pre><code> subprocess.Popen()
</code></pre>
<p>but am unsure how I should convert the above line to use this.</p>
|
python
|
[7]
|
4,299,955 | 4,299,956 |
android updateThread draw() method and touchEvent interference
|
<p>I have a game which displays an array of colored blocks. The user can move these blocks around the screen. When a touch event occurs, I take note of the cell that has been touched (<code>cell[i][j].isMoving = true</code>). If the user moves the block around I draw the rectangle relative to an offset value. When a touch up event is detected, I check whether or not the user has dragged the block far enough to signify a moving of a block.</p>
<p>My basic draw loop is as follows:</p>
<pre><code>for(int i = 0; i < xCells, i++){
for(int j = 0; j < yCells; j++){
if(cell[i][j].isMoving)
canvas.drawRect(...) // draw with offsets
else
canvas.drawRect(..)
}
}
</code></pre>
<p>The problem I am having is when a user releases the block it occasionally flickers briefly.</p>
<p>When a touch up event occurs, the offset must be set to 0, the coordinates of the block changed (if requirements are met) and <code>isMoving</code> has to be set to <code>false</code>.
As I have a thread constantly running that calls the draw code above, it appears that the UI thread is altering the array of blocks, meaning it is in an inconsistent state when the draw method occurs.</p>
<p>Does anyone have suggestions on how to fix this? Could I use a handler? I've tried synchronizing the <code>onTouchEvent</code> method and the <code>onDraw</code> method, but this seems to occasionally block user input</p>
<p>thanks</p>
|
android
|
[4]
|
451,450 | 451,451 |
Reverse ?? operator
|
<p>Is it possible to do something like this in C#?</p>
<p><code>logger != null ? logger.Log(message) : ; // do nothing if null</code></p>
<p>or</p>
<p><code>logger !?? logger.Log(message); // do only if not null</code></p>
|
c#
|
[0]
|
5,265,773 | 5,265,774 |
Using the RecursiveDirectoryIterator
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6218145/displaying-folders-and-making-links-of-those-folders">Displaying folders and making links of those folders</a> </p>
</blockquote>
<p>I'm trying to create a simple file browser using the RecursiveDirectoryIterator but can't seem to figure it out... Any help please?</p>
<pre><code>$cwd = '/path/to/somewhere';
if(isset($_GET['path']) && is_dir($cwd.$_GET['path'])) {
$cwd .= $_GET['path'];
}
$dir = new RecursiveDirectoryIterator($cwd);
$iter = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::SELF_FIRST);
while($iter->valid()) {
// skip unwanted directories
if(!$iter->isDot()) {
if($iter->isDir()) {
// output linked directory along with the number of files contained within
// for example: some_folder (13)
} else {
// output direct link to file
}
}
$iter->next();
}
</code></pre>
<p>Not sure if this is the best approach, but I'm under the impression that the RecursiveDirectoryIterator is faster than both the opendir() and glob() methods.</p>
|
php
|
[2]
|
3,293,633 | 3,293,634 |
How can I mock pirates in obfuscated source code?
|
<p>I am working on a paying app which will have LVL enabled, which means that pirates will probably crack it - even if the app is worthless to them.</p>
<p>Given that I am planning on obfuscating code, is there a 'best practice' for inserting a message in the source code that will not be obfuscated ?</p>
|
android
|
[4]
|
4,611,780 | 4,611,781 |
problem with list return type?
|
<p>my list has value such as</p>
<pre><code>m=[['na','1','2']['ka','31','45']['ra','3','5']
d=0
r=2
t=m[d][r]
print t # this is givin number i.e 2
</code></pre>
<p>Now when I use this value</p>
<pre><code>u=[]
u=m[t]
</code></pre>
<p>I am getting an err msg saying type error list does take str values...</p>
<p>i want to use like this how can i convert that t into a integer??</p>
<p>please suggest..</p>
<p>thanks..</p>
|
python
|
[7]
|
3,952,868 | 3,952,869 |
Call Jquery dialog on dynamically created button
|
<p>I am creating dynamic button on fly, and adding handler to it.
AddHandler btnUpdate.Click, AddressOf ButtonUpdate_Click
i am using below code to call jquery dialog, in buttonupdate_click procedure</p>
<p>lblJavaScript.Text =
"showDialog('Confirm');"</p>
<p>Below is my HTML code,</p>
<pre><code> $(document).ready(function () {
//setup new person dialog
$('#Confirm').dialog({
modal: true,
autoOpen: false,
draggable: true,
width: 'auto',
height: 'auto',
title: "Add New Person",
open: function (type, data) {
$(this).parent().appendTo("form");
$('.ui-widget-overlay').hide().fadeIn();
},
show: "fade",
hide: "fade"
});
});
function showDialog(id) {
$('#' + id).dialog("open");
}
Dim btnUpdate As New Button btnUpdate.ID = "btn+" & GetID(intDynamicAttributeID).ToString
btnUpdate.Text = "Update"
AddHandler btnUpdate.Click, AddressOf ButtonUpdate_Click In ButtonUpdate_Click procedure
</code></pre>
<p>I am not able to open dialog box, any help would be appreciated
When i put button in design mode and call this in button click event it work perfectly.</p>
<p>Regards</p>
|
asp.net
|
[9]
|
2,537,076 | 2,537,077 |
What do i do if javascript is disabled by client?
|
<p>My site heavily depends upon javascript and if i turn off javascript my website looks real ugly. I want to force user and show him notification to turn on javascript else prompt him that site can't be viewed. What do i do to achieve this?</p>
|
javascript
|
[3]
|
5,026,494 | 5,026,495 |
Dynamic iframe onload not firing?
|
<p>I figure this is possible because there are a ton of similar questions (that have been solved) but none seem to deal with dynamically created iframes.</p>
<p>Basically I'm using jquery to create a temp iframe to load files (from a file path served through an ajax call) to then open a file download prompt.</p>
<p>Everything works but to keep my DOM from being populated by a bunch of iframes I would like the iframes to be removed once the file is downloaded.</p>
<p>My iframe creation code:</p>
<pre><code>$('<iframe class="downloadIFrame" src="'+data['url']+'"></iframe>').appendTo('body');
</code></pre>
<p>And the code to destroy it (in the "ready" jquery event callback):</p>
<pre><code>$('.downloadIFrame').live('load', function() { alert('loaded');$(this).remove(); });
</code></pre>
<p>I don't get the alert that the iframe was loaded so it's not called. Any clue?</p>
|
jquery
|
[5]
|
1,897,978 | 1,897,979 |
Jquery sliding element down and up with the same link not working
|
<p>I have the following code, it slides down, but not up. Please could you help me find the error, and also if maybe there is a better way to do this, I have tried slideToggle, but that does not make it possible to check the state of the element, for where using hide and show you can check <code>$('#my_div').is(':hidden')</code>.</p>
<p>Here is my code:</p>
<pre><code>$("a.advanced_search_toggle").click(function() {
if ($("#advanced_search_box").hasClass('closed')) {
$("#advanced_search_box").slideDown(function(){
$("a.advanced_search_toggle").text('Simple Search');
$("a.advanced_search_toggle").removeClass('down_arrow');
$("a.advanced_search_toggle").addClass('up_arrow')
$("a.advanced_search_toggle").removeClass('closed');
$("a.advanced_search_toggle").addClass('open');
});
} else {
$("#advanced_search_box").slideUp(function(){
$("a.advanced_search_toggle").text('Advanced Search');
$("a.advanced_search_toggle").removeClass('up_arrow');
$("a.advanced_search_toggle").addClass('down_arrow');
$("a.advanced_search_toggle").removeClass('open');
$("a.advanced_search_toggle").addClass('closed');
});
}
return false;
});
</code></pre>
<p>Please note that by default I add a class of closed to <code>#advanced_search_box</code></p>
|
jquery
|
[5]
|
2,251,700 | 2,251,701 |
Best practices for dynamically generating JavaScript
|
<p>What is the best way to add dynamic content to JavaScript?</p>
<p>A couple possibilities are:</p>
<ol>
<li>Place the JavaScript in a dynamically generated Ruby/JSP/Python/PHP/etc. file rather than a JS file.</li>
<li>Use a JavaScript literal.</li>
</ol>
|
javascript
|
[3]
|
4,677,046 | 4,677,047 |
python: how to overwrite the previous print to stdout
|
<p>if I had the following code;</p>
<pre><code> for x in range(10):
print x
</code></pre>
<p>I would get the output of</p>
<pre><code>1
2
etc..
</code></pre>
<p>What I would like to do is instead of printing a newline, I want replace the previous value and overwrite it with the new value on the same line.</p>
|
python
|
[7]
|
137,079 | 137,080 |
Android: how to specify question mark in a string resource?
|
<p>Android doesn't allow you to make a string containing '?', because it has special meaning. How do I encode this symbol in a string resource, then?</p>
|
android
|
[4]
|
5,059,438 | 5,059,439 |
Create an .apk progamatically
|
<p>The problem is this:</p>
<p>I make an internet connection to some url
and receive an HttpResponse with an app_example.apk.</p>
<p>Then I want to create a file (an .apk) in the sdcard with this data
so that this downloaded application can be installed later.</p>
<p>How can I convert the HttpResponse to an .apk file?</p>
<p>Thank you all</p>
|
android
|
[4]
|
2,444,280 | 2,444,281 |
Movement in game programming
|
<p>This question may have been asked before, but I'm starting to get into game programming on the Android. I'm having a hard time figuring out the best way to move an object.</p>
<p>To put it simply, lets say I have a bitmap located on 0,0 and i want to move it across the screen. The obvious way to do it would be to simply increment the X position by one every time the Surface View onDraw method gets called.</p>
<p>But what if I wanted to make it move faster? I could increment it by two or three instead of one, but then the movement starts to get really choppy and stupid looking.</p>
<p>What is the best way to go about doing this?</p>
|
android
|
[4]
|
817,970 | 817,971 |
Displaying Images of database in large preview
|
<p>whenever in my app, i take a picture, it shows its thumbnail and stores the image in database. Now i want to do that, when i click on this thumbnail it get the image from database and show it in full size.</p>
<p>I am already acquired the image from database but the problem is ,</p>
<blockquote>
<p>how can i show it in large preview.</p>
</blockquote>
<pre><code>public void onClick(View v) {
// TODO Auto-generated method stub
int id = v.getId();
mDbHelper.open();
Bitmap receivedImage = mDbHelper.getReceiptImage(id);
// How to show this image in full view
}
});
</code></pre>
<p>Best Regards</p>
|
android
|
[4]
|
5,762,112 | 5,762,113 |
What is the Usage of Android Super Class?
|
<p>friends,</p>
<p>any one guide me what is the purpose of Super class in android i have seen in many
@Override methods. for example</p>
<pre><code>@Override
protected void onProgressUpdate(final Object... args)
{ super.onProgressUpdate(args);
}
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
</code></pre>
<p>any help would be appreciated.</p>
|
android
|
[4]
|
613,068 | 613,069 |
Rectangle shape drawable, specify top and bottom stroke colors?
|
<p>Is there any way to define a top and bottom stroke for a gradient, or create a compound shape drawable?:</p>
<pre><code>// option1:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#f00"
android:endColor="#0f0"
/>
<stroke
top=1dip, yellow
bottom=1dip, purple
/>
</shape>
// option2
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<shape
android:shape="rectangle"
height=1dip, color=yellow />
<gradient
android:startColor="#f00"
android:endColor="#0f0"
/>
<shape
android:shape="rectangle"
height=1dip, color=purple />
</shape>
</code></pre>
<p>I don't think either are possible?</p>
<p>Thanks</p>
|
android
|
[4]
|
1,400,862 | 1,400,863 |
Initializing and assigning values,from pass by reference
|
<p>Okay, this is just a minor caveat. I am currently working with the lovely ArcSDK from ESRI. Now to get a value from any of their functions, you basically have to pass the variable, you want to assign the value to.</p>
<p>E.g.:</p>
<pre><code>long output_width;
IRasterProps->get_Width(&output_width);
</code></pre>
<p>Its such a minor thing, but when you have to pick out around 30 different pieces of data from their miscellaneous functions, it really starts to get annoying.</p>
<p>So what i was wondering is it possible to somehow by the magic of STL or C++ change this into:</p>
<pre><code>long output_width = IRasterProps->get_Width(<something magical>);
</code></pre>
<p>All of the functions return void, otherwise the off chance some of them might return a HRESULT, which i can safely ignore. Any ideas?</p>
<p><strong>*EDIT**</strong></p>
<p>Heres the final result i got which works :)!!!!!</p>
<pre><code>A magic(P p, R (__stdcall T::*f)(A *)) {
A a;
((*p).*f)(&a);
return a;
}
</code></pre>
|
c++
|
[6]
|
5,710,244 | 5,710,245 |
iPhone: Changing Deployment Target , don't affect changing Minimum OS in info.plist
|
<p>I am using sdk 4.2 seed 2.
In the project setting's i' am set
Base sdk 4.2
Deployment target iOS 4.0</p>
<p>But after building AdHoc build in info.plist file
MinimumOSVerions set to 4.1 </p>
<p>I added New Run Script to check deployment target from this post
<a href="http://stackoverflow.com/questions/5340117/xcode-ios-deployment-target-check">Xcode iOS deployment target check?</a></p>
<p>Build run ok, but in the end i again have MinimumOSVerions set to 4.1.</p>
<p>What i do wrong?</p>
|
iphone
|
[8]
|
4,729,601 | 4,729,602 |
Evaluate my Python server structure
|
<p>I'm building a game server in Python and I just wanted to get some input on the architecture of the server that I was thinking up.</p>
<p>So, as we all know, Python cannot scale across cores with a single process. Therefore, on a server with 4 cores, I would need to spawn 4 processes. </p>
<p>Here is the steps taken when a client wishes to connect to the server cluster:</p>
<p>The IP the client initially communicates with is the Gateway node. The gateway keeps track of how many clients are on each machine, and forwards the connection request to the machine with the lowest client count.</p>
<p>On each machine, there is one Manager process and X Server processes, where X is the number of cores on the processor (since Python cannot scale across cores, we need to spawn 4 cores to use 100% of a quad core processor)</p>
<p>The manager's job is to keep track of how many clients are on each process, as well as to restart the processes if any of them crash. When a connection request is sent from the gateway to a manager, the manager looks at its server processes on that machine (3 in the diagram) and forwards the request to whatever process has the least amount of clients.</p>
<p>The Server process is what actually does the communicating with the client.</p>
<p>Here is what a 3 machine cluster would look like. For the sake of the diagram, assume each node has 3 cores.
<img src="http://img152.imageshack.us/img152/5412/serverlx2.jpg" alt="alt text" /></p>
<p>This also got me thinking - could I implement hot swapping this way? Since each process is controlled by the manager, when I want to swap in a new version of the server process I just let the manager know that it should not send any more connections to it, and then I will register the new version process with the old one. The old version is kept alive as long as clients are connected to it, then terminates when there are no more.</p>
<p>Phew. Let me know what you guys think.</p>
|
python
|
[7]
|
444,535 | 444,536 |
resending information problem
|
<p>i've a search bar from where users can search for videos..
after the search, the user goes on to click and watch a video(from the search result)..when the user hits the browser's back button it displays the following</p>
<blockquote>
<p>To display this page, Firefox must
send information that will repeat any
action (such as a search or order
confirmation) that was performed
earlier.</p>
</blockquote>
<p>instead of just showing the results..
i just want to display the results of search when the user hits back..is it something related to cache?
thankx..</p>
|
php
|
[2]
|
5,979,991 | 5,979,992 |
Setting a number between tags as a variable
|
<p>I'm trying to get a number (<code>x</code>) inside tags, ie: <code><span id="Number">x</span></code> and set that as a variable.</p>
<p>Am I even on the right track with this? Not even close?</p>
<pre><code>var y = $('#Number').nextUntil('span');
</code></pre>
|
jquery
|
[5]
|
2,839,022 | 2,839,023 |
Selecting a class from appended element with jQuery
|
<p>I'm creating an inline edit input['text'] snippet with jQuery.</p>
<p>the html will be like this : </p>
<pre><code><div id="inline">
<span class="item">Color</span>
</div>
</code></pre>
<p>I got stuck in here (here is my code) :</p>
<pre><code>$('.item').each(function(){
$(this).click(function(){
$(this).hide();
$(this).parent().append(
'<form method="post" action="" id="inline_form">'+
'<input type="text" value="'+ $(this).html() +'"> <input type="Submit" value="update" />'+
' <a href="#" class="cancel">Cancel</a></form>'
);
});
});
</code></pre>
<p>I want to bind a click event to class '.cancel' that I've appended above , so when I click cancel, it will remove the form '#inline_form' and show back '.item'</p>
<p>I tried this </p>
<pre><code>$('.cancel').each(function(){
$(this).click(function(){
$(this).parent('#inline').find('.item').show();
$(this).parent('#inline_form').remove();
});
});
</code></pre>
<p>But it didn't work.
How do I select '.cancel' so I can put a click event on it ??? </p>
|
jquery
|
[5]
|
2,739,262 | 2,739,263 |
How to unlink image in php
|
<p>i upload image to the server and save the path in data base. Now i want to delete that record and also the image with that record
my code is </p>
<pre>$id=$_GET['id'];
$select=mysql_query("select image from table_name where question_id='$id'");
$image=mysql_fetch_array($select);
@unlink($image['image']);
$result=mysql_query("delete from table_name where question_id='$id'");</pre>
<p>when i echo $image['image']; this will give me <pre>http://www.example.com/folder/images/image_name.jpeg</pre>
The record is deleted successfully but the image remains there on server.</p>
|
php
|
[2]
|
3,925,636 | 3,925,637 |
How to tell if item in list contains certain characters
|
<p>I have a script that creates a list of numbers, and i want to remove all numbers from the list that are not whole numbers (i.e have anything other than zero after the decimal point) however python creates lists where even whole numbers get .0 put on the end, and as a result i cant tell them apart from numbers with anything else. I can't use the int() function as it would apply to all of them and make them all integers, and then i'd lose the ones that originally were.</p>
<p>Here is my code:</p>
<pre><code>z = 300
mylist = []
while(z > 1):
z = z - 1
x = 600851475143 / z
mylist.append(x)
print(mylist)
[y for y in mylist if y #insert rule to tell if it contains .0 here]
</code></pre>
<p>the first bit just divides 600851475143 by every number between 300 and 1 in turn. I then need to filter this list to get only the ones that are whole numbers. I have a filter in place, but where the comment is i need a rule that will tell if the particular value in the list has .0</p>
<p>Any way this can be achieved?</p>
|
python
|
[7]
|
2,583,599 | 2,583,600 |
Can an iPhone application relaunch itself when terminated?
|
<p>Thanks for the suggestion well i am writing in detail about it.</p>
<p>I have a requirement to do in my project like this,</p>
<ul>
<li>When the app launch for the first time it should display the device native dialer and then check for callDidConnected in background.</li>
<li>once the callDidConnected is true app should launch itself.</li>
</ul>
<p>Here I tried a logic to do so. please have a look to the pseudo code.</p>
<pre><code> - (void)applicationDidFinishLaunching:(UIApplication *)application {
//i am dialing to a IVR from the native dialer
if (/* A check to validate wether to call or not */)
{
NSLog(@"Dialing");
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:"]];
// A loop check wether the call get connected
while (!callDidConnected){
callDidConnected = // doing a check with server
}
// if call get connected then launching my application
if (callDidConnected){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"MyApp:"]];
}
}
else
{
// normal app
}
}
- (void) applicationWillTerminate:(UIApplication *)application
{
}
</code></pre>
<ul>
<li>I registered the app with URL MyApp.</li>
<li><p>Well I tested this code on simulator(on SDK 3.0/3.2) with opening another app(tried http instead of tel protocol). The check executes in background while other native app(safari) run in foreground.</p></li>
<li><p>So this look a little odd behavior what apple guys says.</p></li>
<li><p>So can any one help me to find whether i can use this code in my work. and will it be acceptable by Apple store.</p></li>
</ul>
<p>Thanks in advance.</p>
|
iphone
|
[8]
|
5,822,283 | 5,822,284 |
Php code ends with blank screen
|
<p>I have this PHP code, I am validating and fetch query accordingly.. but though my query is firing but it ends with blank screen. I have commented the location with <code>die()</code>;</p>
<pre><code>for ($z = 0; $z < count($track); $z++) {
if ( in_array($track[$z], $already_track)) {
$at_key = array_search($track[$z], $already_track);
$a = explode(":", $artist[$z]);
$b = explode(":", $already_artist[$at_key]);
$array_compared = array_diff($a, $b);
if (empty($array_compared)) {
continue;
} else {
$sql = mysql_query("INSERT INTO tracklist(aid, sid, rid, added_by, added_on) VALUES('".$album."', '".$track[$z]."', '".$artist[$z]."', '".$_SESSION["userkey"]."', '" . $time . "' )") or die(mysql_error());
//die("Yes Here"); //My code output blank screen after this query. Though query fired successully.
}
} else {
$sql = mysql_query("INSERT INTO tracklist(aid, sid, rid, added_by, added_on) VALUES('".$album."', '".$track[$z]."', '".$artist[$z]."', '".$_SESSION["userkey"]."', '" . $time . "' )") or die(mysql_error());
}
}
</code></pre>
|
php
|
[2]
|
1,375,843 | 1,375,844 |
Fatal exception related to memory leak
|
<pre><code>Bitmap newImage = Bitmap.createBitmap(wid,hgt, Bitmap.Config.ARGB_8888);
</code></pre>
<p>This gives memory leak fatal exception when I use it in camera overlay second time for capturing image.Provide some code functionality why it occurs</p>
|
android
|
[4]
|
5,362,640 | 5,362,641 |
Application scope in php
|
<p>I need to share same array object across all requests irrespective of requests coming from same browser/user.
Is there any application scope in php where I could store that array object.
I am using php 5.x . </p>
|
php
|
[2]
|
5,602,805 | 5,602,806 |
how to differentiate between events of many controls added during runtime
|
<p>i am adding more than one link button during runtime but they all have the same name. so how can i differentiate between their events because i want everyone to have a different parameter or variable. this is my code:</p>
<pre><code>while(drr.Read())
{
LinkButton lb = new LinkButton();
lb.Click += new EventHandler(lb_Click);
lb.Text = drr[2].ToString();
PlaceHolderQuestions.Controls.Add(lb);
}
</code></pre>
<p>and outside that there is the event handler:</p>
<pre><code>void lb_Click(object sender, EventArgs e)
{
DownloadFile();
}
</code></pre>
<p>how can i know which button is pressed?</p>
|
asp.net
|
[9]
|
2,729,511 | 2,729,512 |
Java split before and stop
|
<p>I have a JTextField and I'm using it to put info into a JTextArea. I want a command that puts text into it, but I'm having to use split to check if it's the /text command. When I do "/text Message To Put", it cuts off at the spaces. How can I get the "Message to put" as a whole to output to the JTextArea?</p>
|
java
|
[1]
|
2,794,594 | 2,794,595 |
JQUERY common function library create script errors. How to avoid?
|
<p>I am building a common function library but the functions inside need to reference different jquery files, which they may need to be referenced in some pages but not in others.</p>
<p>When I called this common function library in one web page which is only going to use one function, and I don't reference the files need it for the other function, then it will create a script error.</p>
<p>My question is if it would be possible to stop this script errors like...</p>
<pre><code>//This if statement is what I was thinking to stop going through
if ($(".objectdate") != null){
//This is the function that is calling other jquery files and creates error.
$(document).ready(function() {
$(".objectdate").datepicker({
//Code inside.
});
});
}
</code></pre>
<p>Thanks. </p>
|
jquery
|
[5]
|
91,892 | 91,893 |
jquery disables all the checkbox in a table
|
<p>How can I disable only a single check box in a table row? I have my for condition in a phtml file. My html has one <code>td</code> for my checkbox, but if I click on one check box it disables all the checkboxes in a table. Below is my for loop with check box.</p>
<pre><code><?php
foreach($this->rows as $record)
{
echo "<tr>";
echo "<td >". $record['firstname'] . "</td>";
echo "<td>".$record['advicetoowners'] . "</td>";
echo"<td>".$record['customdata'] . " <br /> ".$record['reservation'."</td>";
?>
<td class='stylecontent'width='2' >
<input type="checkbox" name="seen" value="" class='chkAll'/>
</td>
<?php
}
?>
</code></pre>
<p>My jQuery is:</p>
<pre><code>$('.chkAll').change(function() {
// This disables all the check box in a table.How to make it to disable only one
$('input:checkbox').attr('disabled', this.checked);
});
</code></pre>
|
jquery
|
[5]
|
4,158,021 | 4,158,022 |
Delet hyperlink is not responding if the row as data with apostrophe in javascript
|
<p>I have Form, which displays 5 column data. The last colum is the delete option, which is an hyperlink.</p>
<p>when i try to delete the row, the row is successfully deleted if the column data is not containing any apostrophe.
But when i have data with apostrophe (eg : test's), the delete link is not responding.
:(</p>
|
javascript
|
[3]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.