Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
5,848,831 | 5,848,832 | Convert an android acreen as Jpeg image | <p>Hi everyone
I am creating a greeting card application wherein the user can choose from a set of backgrounds and add text to it.Now my question is how can I convert this screen as a JPEG image which can be sent as a mail to someone.That is the entire greeting card (image+text) is a jpeg image for the viewer.</p>
<p>Thanks everyone in advance</p>
| android | [4] |
5,919,601 | 5,919,602 | Does Android EditText has input type with clear button? | <p>Does Android EditText has input type with clear button?</p>
<p>It should work like html 5 search input type.</p>
<p><img src="http://i.stack.imgur.com/2IijV.png" alt="enter image description here"></p>
| android | [4] |
5,971,134 | 5,971,135 | How to use php to replace periods with bullets (li)? | <p>I have a string in php with multiple periods. I am trying to figure out to replace each of the periods in the string into a bullet (<code><li></code>) on a new line. Does anyone have advice on how to do this?</p>
<pre><code>$desc= "Petite Jeans. Petite Fit Guide,Tall Fit Guide Explore our 1969 denim boutique for fit facts, fabric notes, style tips, and more. Fabrication: Premium stretch denim. Wash: Faded dark blue. Hardware: Double button closure, zip fly. Features: Five pocket styling. Cut: Mid rise. Fit: Slim through the hip and thigh. Leg opening: Boot cut. Inseams: regular: 33\', tall: 37\', petite: 30\'";
echo $desc;
</code></pre>
<p>The above string should look like:</p>
<pre><code><li>Petite Jeans.
<li>Petite Fit Guide,Tall Fit Guide Explore our 1969 denim boutique for fit facts, fabric notes, style tips, and more.
<li>Fabrication: Premium stretch denim.
<li>Wash: Faded dark blue.
<li>Hardware: Double button closure, zip fly.
<li>Features: Five pocket styling.
<li>Cut: Mid rise.
<li>Fit: Slim through the hip and thigh.
<li>Leg opening: Boot cut.
<li>Inseams: regular: 33\', tall: 37\', petite: 30\'
</code></pre>
| php | [2] |
3,122,620 | 3,122,621 | async web calls php | <p>I have a db with over 5 million rows and for each row i have to do a http post to a server with some parameters at maximum rate of 500 connections. each post request takes 12 secs to process. so as old connections are completed i have to do new ones and maintain ~500 connection. I have to then update DB with values returned from these webcalls.
How do I make the webcalls as above?</p>
<p>My App is in PHP. Can I use PHP or should I switch to something else for this.</p>
| php | [2] |
3,701,159 | 3,701,160 | jQuery: how do I slide pages, but use only one nav? | <p>I found this tutorial:
<a href="http://www.queness.com/post/356/create-a-vertical-horizontal-and-diagonal-sliding-content-website-with-jquery" rel="nofollow">http://www.queness.com/post/356/create-a-vertical-horizontal-and-diagonal-sliding-content-website-with-jquery</a></p>
<p>And I like the way this site does their sliding: <a href="http://dknewmedia.com" rel="nofollow">http://dknewmedia.com</a> </p>
<p>How do I do the sliding effect like dk new media, but with only a single nav?</p>
| jquery | [5] |
964,403 | 964,404 | Path Tracing in Android | <p>i want to add such feature in my Application that App will recognize letters, numbers etc tracing (with finger).</p>
<p>For Example if i want to define path for 'A', then at first i need to define the Nodes to which the child will merge through drawing straight line, but i don't know that how to define path for each object.</p>
<p>Kindly give your suggestions or refer me helping material.</p>
| android | [4] |
1,426,992 | 1,426,993 | How to display model popup at first time page load only | <p>I used the following code to display model popup for the first time page load,</p>
<pre><code><script type="text/javascript">
function pageload() {
var chkPostBack = '<%= Page.IsPostBack ? "true" : "false" %>';
if (chkPostBack == 'false') {
var popup = $find('ModalPopupExtender1');
if (popup != null) {
popup.show();
}
}
}
</code></pre>
<p>
I got the following error, Please help me.</p>
<pre><code>The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
</code></pre>
| asp.net | [9] |
153,755 | 153,756 | comparing select option value | <p>By using the following code I am able to get the matched items. How to find the unmatched items from this:</p>
<pre><code>$('#list1 option').each(function (i, option)
$('#list2 option').each(function (j, option) {
if ($('#list1 option').val() ==$('#list2 option').val())
matchedList= $('#list1 option').val()
});
});
});
</code></pre>
| jquery | [5] |
953,850 | 953,851 | how to implement code for display the alert message for every 5 minutes? | <p>hi all how to implement code for display the alert message for every 5 minutes (i mean for every 5 minutes we can able to see resent alert messages and previous alert message when we open the alert information list) so kindly help to solve the problem.</p>
| android | [4] |
3,651,853 | 3,651,854 | Troubleshooting "Undefined offset" error | <p>It's show following error:</p>
<blockquote>
<p>Notice: Undefined offset: 1 in C:\xampp\htdocs\evantechbd\secure\content\feature_link_process.php on line 28.</p>
</blockquote>
<p>Why it's show the error...? Can anyone tell me... Here is the code: </p>
<pre><code>$row = explode("|", $_POST['coun_name']);
$coun_id = $row[1]; // cat_id
$coun_name = $row[0];
if(isset($coun)){
$errors = array();
if(empty($coun))
$errors[] = 'Country Name require<br>';
}
</code></pre>
| php | [2] |
5,816,446 | 5,816,447 | Force to call a parent class method when the child class method is invoked - C#.NE | <p>We have two classes say 'Parent' and 'child' as shown below :</p>
<pre><code>class Parent
{
parent_AddUser()
{
// add user code for parent
}
abstract child_AddUser();
}
// child class
class Child : Parent
{
child_AddUser() // implementing the abstract method
{
// child addUser code
}
}
</code></pre>
<p>We would like to know whether we can force calling the parent_AddUser() method whenever the child_addUser() is invoked wihout making an explicit call.</p>
| c# | [0] |
39,470 | 39,471 | Using the Ends With jquery selector and get the options of a listbox | <p>I have the following code:</p>
<pre><code>$("input[id$=UserField_hiddenSpanData],input[title=Title]").each(function(){
var rb = $('#ctl00_m_g_c6ae303a_6013_4adb_8057_63a214bcfd24_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00_SelectResult option').length;
var val = $(this).val();
if(val != 0 && val.length != 0 && rb != 0) {
//add one to the counter
controlsPassed += 1;
}
});
</code></pre>
<p>It works fine but I don't want to have the ID hardcoded so I thought I could use</p>
<pre><code>var rb = $('id$=SelectResult option').length;
</code></pre>
<p>but it doesn't work, what's wrong with my syntax?</p>
<p>Thanks in advance.</p>
| jquery | [5] |
2,048,789 | 2,048,790 | How to make the UIWebView scroll smooth? | <p>In my application ,I use the UIWebView to load a website's content,such is "http://www.apple.com",but i sroll the webview is not smooth, how can i to makt it more
smooth ?</p>
| iphone | [8] |
3,314,432 | 3,314,433 | How to select all images inside any element whose class starts with "pajina" in jQuery? | <p>I need to select like this</p>
<pre><code>var imgs = $('.pajina* img');
</code></pre>
<p>Then I will do something else with the images variable later on....mas tarde</p>
| jquery | [5] |
2,637,131 | 2,637,132 | How To play Local and Server URL Video in Iphone | <p>I wants to play mp4 or mov video from Server URL and locally in IPHONE.</p>
<p>so please help me.</p>
<p>Thanks in advance!!</p>
| iphone | [8] |
401,700 | 401,701 | Javascript Math Calculation | <p>Hoping someone can assist but I need to perform a math calculation in javascript that I am unsure how to do.</p>
<p>The formula is as follows: </p>
<pre><code>result = (scale * weighting) / 2
</code></pre>
<p>where the result I will need to two decimal places.</p>
<p>Example formula that I need to do in javascript might be:</p>
<pre><code>result = ((3 * 2) + (2 * 1.5)) / 2
</code></pre>
<p>I am also unsure if I have to also convert this to int</p>
<p>Would really appreciate some guidance on this.</p>
<p>Thanks.</p>
| javascript | [3] |
680,522 | 680,523 | get cmyk values from image in visual c# 2010 | <p>I searched for a whole week to find a solution for this, but no luck.
I've created programs in Python for manipulating images at pixel level and in Python I can read pixel values in rgb and cmyk. Now I need (for my student research) to do same stuff in visual c# 2010.
c, m, y, k = im.getpixel((i,j)) is all what is need to be done in Python for getting cmyk values, so my question is can this be done in visual c#? Can I load cmyk image, make changes to it (I'm doing GCR, UCA) and save it like cmyk?</p>
<p>Thanks for any help!</p>
| c# | [0] |
5,329,186 | 5,329,187 | PHP code to user to another page which associated with the link | <p>I am following this <a href="http://stackoverflow.com/questions/14704556/how-do-i-create-a-link-that-sends-the-user-to-another-page-which-is-then-diverte">tutorial</a> - it is to redirect a user a URL based on the link in the previous page.</p>
<p>and I am trying this solution:</p>
<p>HTML</p>
<pre><code><a href="inter.php?target=1">Some page</a>
<a href="inter.php?target=2">Some page</a>
<a href="inter.php?target=something_else">Some page</a>
</code></pre>
<p>inter.php</p>
<pre><code><?php
session_start();
$link='#';
switch($_GET['target']) {
case 1:
$link = "http://nexttarget.com";
break;
case 2:
$link = "http://nexttarget2.com";
break;
case "something_else":
$link = "http://nexttarget3.com";
break;
}
$_SESSION['prev_link'] = "http://source_url";
?>
<form action="<?php echo $link; ?>" method="post" id="tc_form" >
<p>Your T&amp;C here</p>
<input type="checkbox" name="agree" value="agreed" onclick="javascript: this.parentNode.submit();" id="check" />
<label for="check">I agree to the T&amp;C.</label>
</form>
</code></pre>
<p>The above code works perfectly fine. Though I don't want my users to agree with the Terms and Conditions. I just want them to click the link and be diverted. When I remove the HTML code not to have the terms and conditions. This is not working. What am I doing wrong?</p>
<p>I know I can have a URL directly to that page but I would like it to be done through the inter.php please.</p>
| php | [2] |
2,645,954 | 2,645,955 | Chrometophone example | <p>Hello all I was looking to implement a C2DM Android program, I have found about chrometophone and tried to check the source from the svn. I have checked out the source from eclipse, I also have installed the app engine sdk but eclipse complains about errors in the project,the error is in the XMPPSender when the doSendToDevice method is called, the error is "the method is not applicable for the arguments" but the arguments are correct and when I try to run the project locally I can deploy it, but when I deploy it to the app engine it doesn't work.</p>
<p>I have also applied 2 days earlier to projects forum for membership but no responce yet.</p>
<p>I would like to know if someone hash managed to import the project to eclipse, and if this is a known proble, also is there any special library I have to import? in the build path there's no error.</p>
<p>regards maxsap</p>
| android | [4] |
3,851,220 | 3,851,221 | DIV disabled or greyed out | <p>I have a webpage with a form. Depending on user selections at the top of
the page, the page will disable sections of the form. My plan is to put
each section between a <code><div></div></code>. Each section contains some collection
of form elements.</p>
<p>So if the user does not select some criteria, the related section of the
form gets disabled. In a typical Windows type of application these elements
get disabled and greyed out. What's the best way to do this in a webpage?
Can Javascript determine what form elements are in a div section and
disable these elements through a loop for example? I know I can disable
each element if I know its it but is there a way to find out all the IDs of
elements for some div section?</p>
<p>Is it possible to gray out in page load event based on flag variable in c#?</p>
| asp.net | [9] |
661,253 | 661,254 | update incoming messages in my messageapp automatically | <p>For that, I am writing following code:</p>
<pre><code> arrayList = new ArrayList<Messagegetter>();
smsListView = (ListView) findViewById(R.id.listView);
o = new Messagegetter();
if(number!=null && msgNew!=null){
o.setMsg(msgNew);
o.setSender(number);
arrayList.add(o);
customAdapter = new MessageAdapter(getBaseContext(), R.layout.sms_list, arrayList);
customAdapter.notifyDataSetChanged();
smsListView.setAdapter(customAdapter);
}
</code></pre>
<p>And also created a different class <strong>extending</strong> <code>broadcastReceiver</code> class for receiving new messages.Following is the code:</p>
<pre><code> public class SmsReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent)
{
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
String sender= msgs[i].getOriginatingAddress();
str = msgs[i].getMessageBody().toString();
intent1 = new Intent(context, MainActivity.class);
intent1.putExtra("body", str);
intent1.putExtra("sender", sender);
//i.putExtra("sentbody", msg);
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent1);
}
//---display the new SMS message---
Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
}
}
</code></pre>
<p>But I am unable to update my <code>listView</code>. Please help me out.</p>
| android | [4] |
1,973,222 | 1,973,223 | How to change the view at runtime | <p>I currently using a layout named "ax",
Now I have to switch to full screen view and for some time with some button on it which is there in linear layout , on click of one of the view I want to come back to normal view ("ax"),
How can I do that ?
if i do <code> setContentView(ax); </code> then it redraws the view , which is not permitted.</p>
| android | [4] |
5,996,514 | 5,996,515 | Interesting output in a simple PHP webpage | <p>Here is a very simple PHP page with one javascript function in it. I am seeing the output differently. I am not able to understand why is it behaving that way.</p>
<p>In the code below, x echoes as 012012, but when I pass it into a javascript function and display it in an innerHTML, it displays differently as 5130 ??!!</p>
<p>Can anyone help ?</p>
<pre><code><?php
$x= date("mY");
echo $x;
?>
<html>
<head>
<script>
function myfunc1(y)
{
div1 = document.getElementById("mydiv1")
div1.innerHTML = y;
}
</script>
</head>
<body <?php echo "onload='myfunc1(".$x.")'>";?>
<div id="mydiv1" style="background:#efefef;border:1px solid green;height:100px;width:100px;text-align:center">
</div>
</body>
</html>
</code></pre>
<p>HTML output</p>
<pre><code>012012<html>
<head>
<script>
function myfunc1(y)
{
div1 = document.getElementById("mydiv1")
div1.innerHTML = y;
}
</script>
</head>
<body onload='myfunc1(012012)'> <div id="mydiv1" style="background:#efefef;border:1px solid green;height:100px;width:100px;text-align:center">
</div>
</body>
</html>
</code></pre>
<p>HTML output (screenshot)
<img src="http://i.stack.imgur.com/xkRrH.png" alt="Screenshot"></p>
| php | [2] |
5,163,562 | 5,163,563 | ASP.NET Request Lifecycle | <p>say I have a folder in my web app, with an <code>index.html</code> inside it:</p>
<pre><code>/test
/test/index.html
</code></pre>
<p>and the following <code>Module</code></p>
<pre><code>public class TestModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.ReleaseRequestState += context_ReleaseRequestState;
}
static void context_ReleaseRequestState(object sender, EventArgs e)
{
var application = sender as HttpApplication;
// foo
}
}
</code></pre>
<p>If I make a request to <code>/test/index.html</code>, <code>context_ReleaseRequestState</code> fires and the response is returned, great.</p>
<p>If I make a request to <code>/test/</code>, <code>context_ReleaseRequestState</code> fires as above, the response is returned, but then <code>context_ReleaseRequestState</code> fires again!</p>
<p>The response has already been returned (and the connection closed, etc).
The <code>HttpContext.Response</code> object has the followng properties set on it:</p>
<pre><code>HeadersWritten: true
Headers: Server=Microsoft-IIS%2f7.5
</code></pre>
<p>What is causing this second invocation?</p>
<p>on the <code>Request</code>the <code>FilePath</code> property for the first invocation is <code>/test/index.html</code>, and for the second its <code>/test/</code></p>
<p>Is there some property on the <code>HttpApplication</code> or <code>HttpRequest</code> that I can check that identifies this 2nd request for whatever it is? The <code>HeadersWritten</code> property is internal :(</p>
<p>Thanks</p>
| asp.net | [9] |
4,640,585 | 4,640,586 | Android app Crash | <p>Why is this:</p>
<pre><code> public class HelpTab extends Activity
{
LinearLayout helpLayout; //was changed to LinearLayout helpLayout = new LinearLayout(this);
TextView helpText = new TextView(this);
Button tips = new Button(this);
Button walkThrough = new Button(this);
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
buttonCreator();
setContentView(helpLayout);
}
public void buttonCreator()
{
//Button featuress defined in here (setText("") and adding them to the layout, addView();)
}
</code></pre>
<p>Causing my program to crash?
I have looked at the code extensively and I can't put my finger on it, and the debugger also says source not found when it opens the new page tab thing to tell me what is happening.</p>
| android | [4] |
3,826,829 | 3,826,830 | JavaScript console prints assigned value of variable before it has been assigned? | <p>I'm deeply confused by the behaviour of either JavaScript, or the Chrome console. Can someone help me understand?</p>
<p>Basically I have the following JavaScript code, not nested inside any function or other scope: </p>
<pre><code>var initial_array = [];
function initialiseArray() {
initial_array = [2, 9, 8, 6, 0, 2, 1];
}
function copyToNewArray() {
var copied_array = [];
console.log("COPIED 1", copied_array);
for (var i = 0; i < initial_array.length; i++) {
var copy = initial_array[i];
copied_array.push(copy);
}
console.log("COPIED 2", copied_array);
}
initialiseArray();
copyToNewArray();
</code></pre>
<p>I would expect <code>COPIED 1</code> to print <code>[]</code> - as the variable hasn't been assigned yet - but instead it prints <code>[2, 9, 8, 6, 0, 2, 1]</code> - ie the value after it has been assigned.</p>
<p>Why? </p>
<p>Incidentally, if you replace lines 8-11 with <code>initial_array = copied_array</code>, then <code>RESULTS 1</code> does indeed print as <code>[]</code>. Is it something to do with using <code>.push</code>?</p>
| javascript | [3] |
4,118,214 | 4,118,215 | How to tell whether a variable is null or undefined in php | <p>Is there a <strong>single</strong> function that can be created to tell whether a variable is NULL or undefined in PHP? I will pass the variable to the function (by reference if needed) but I won't know the name of the variable until runtime.</p>
<p><code>isset()</code> and <code>is_null()</code> do not distinguish between NULL and undefined.<br>
<code>array_key_exists</code> requires you to know the name of the variable as you're writing your code.<br>
And I haven't found a way to determine the name of a variable without defining it.</p>
<h3>Edit</h3>
<p>I've also realized that passing a variable by reference automatically defines it.</p>
<h3>Elaboration</h3>
<p>Through the collection of these answers and comments I've determined that the short answer to my question is "No". Thank you for all the input.</p>
<p>Here are some details on why I needed this:</p>
<p>I've created a PHP function called <code>LoadQuery()</code> that pulls a particular SQL query from an array of queries and then prepares it for submission to MySQL. Most-importantly I scan the query for variables (like <code>$UserID</code>) that I then replace with their values from the current scope. In creating this function I needed a way to determine if a variable had been declared, and was NULL, empty, or had a value. This is why I may not know the name of the given variable until runtime.</p>
| php | [2] |
2,417,364 | 2,417,365 | Fascinate Device Web view go back() method Issue | <p>I am developing an app in android. In the app i am using a web view and i am saving the web view history.When user clicks on device back button i am loading the previous url(using web view goback() method) if web view history is not empty.It is working fine in all the devices except the Samsung Fascinate device. In this device web view goback() method is not working.
Any suggestions??</p>
<p>Thanks,
Ram.</p>
| android | [4] |
4,857,667 | 4,857,668 | converting date and time string to unsigned __int64 in C++ | <p>I have a requirement in <a href="/questions/tagged/c%2b%2b" class="post-tag" title="show questions tagged 'c++'" rel="tag">c++</a>, which I have to read a file which consists date and time and convert it to <code>unsigned __int64</code>.</p>
<p>For example I have a file "mytime.txt" with following data.</p>
<pre><code>2012-06-25 05:32:06.963
</code></pre>
<p>How do I convert it to <code>unsigned __int64</code>, and how do I convert back from <code>unsigned __int64</code> to the above string to write to file and also to verify it is converted to <code>unsigned __int64</code> correctly.</p>
<p>I am working on windows in VS.NET C++ compiler.</p>
<p>I am not supposed to use <code>boost</code>.</p>
| c++ | [6] |
4,024,129 | 4,024,130 | How to compare the byte array and byte array list? | <p>I have a byte array and a byte list, they both contains same numbers.
how should I compare them.</p>
<p>code i am using, but not working:</p>
<pre><code>if (portBuffer.Equals(ret_bytes))
status = 0;
</code></pre>
<p>The following image is captured when i was debugging. they basicly contains same bytes. I know they are belonging to different object, but how to cast them? thanks</p>
<p><img src="http://img29.imageshack.us/img29/5769/33818425.jpg" alt="a busy cat">
!</p>
| c# | [0] |
1,212,361 | 1,212,362 | PHP5 object instances are in server RAM or on client's computer RAM | <p>PHP5 object instances while the application is running are in server RAM or on client's computer RAM ?!</p>
<p>what about sessions ?!</p>
<p>sorry for this dumb question, I need to know this so I know how to manage memory.</p>
<p>If I'm getting the idea of PHP applications wrong plz correct me.</p>
<p>Thank you.</p>
| php | [2] |
2,458,756 | 2,458,757 | Why thread.stop deprecated and timer.cancel is not? | <p>What is the difference between stopping a java Thread and stopping an instance of Timer ?</p>
<p>Why is timer.cancel thread safe or is it ?</p>
| java | [1] |
1,223,876 | 1,223,877 | (C#) download embedded flash from a given URL | <p>I have a desktop forms application . I want to fetch any flash file embedded from a given html page. I used this approach: parse the html page(using htmlagilitypack) to get hold of direct url of any embedded flash, then fetch the file. But this approach wouldn't work if relative paths are used.
How else can a flash file embedded in an html page be downloaded ?</p>
<p>ty</p>
| c# | [0] |
1,185,176 | 1,185,177 | Android files manipulation | <p>Through the housekeeping stuff my android application has to do is to read and write some files and sometimes to delete others and create new ones. The files in cause have all "sdcard/" as root. Is it safe if I perform all this task using Java style functions ?
To me it is very handy to do it this way but I've read that not always the java functions can be applied when it comes to files in Android.</p>
| android | [4] |
4,099,937 | 4,099,938 | How to iterate over case insensitive sorted dictionary items? | <p>Example:</p>
<pre><code>>>> d = {'answer':1, 'Question':2}
>>> for i, j in sorted(d.items()): print i
Question
answer
</code></pre>
<p>I would like case insensitive list:</p>
<pre><code>answer
Question
</code></pre>
<p>and I believe it can be done in simple Pytonic way</p>
| python | [7] |
1,835,270 | 1,835,271 | Get/Set info to html with data() jquery | <p>I am trying to use data() for the first time. I have a list. I want to attach info to the li elements</p>
<p>My html is basic. I am not using ids for anything but the div container. This is done to allow multiple ul on the page without having id conflicts.</p>
<p>html</p>
<pre><code> <div id="container">
<ul>
<li><input type="checkbox"></input><label>Radio</label></li>
<li><input type="checkbox"></input><label>Cable</label></li>
</ul>
</div>
</code></pre>
<p>In my jquery I want to find the li elements of the container and attach a name corresponding to the text.</p>
<pre><code>//BaseElement is my div
$(this.BaseElement).find('li').each(function () {
var key = $(this).text();
if (key == "Radio")
$(this).data({ 'name' : 'Radio' });
if (key == "Cable")
$(this).data({ 'name' : 'Cable' });
});
</code></pre>
<p>I am firing a function base off checkbox selection or label click. This may not be the most efficient way of doing that but it works (not the data part but the function firing) </p>
<pre><code>$(this).find('li input[type="checkbox"]').change(function () {
$.data($(this).parent().get('name'));
});
$(this).find('li lable').click(function () {
$.data($(this).parent().get('name'));
});
</code></pre>
<p>There is more going on with the jquery in the page then this code, but this should be all that's necessary to see what is occurring. </p>
| jquery | [5] |
58,832 | 58,833 | generate 10 digits alphanumeric value in php with first,third,fourth digit must be alphabet | <p>I need php code to generate 10 digits alphanumeric value with first,third and fourth digit must be Capital alphabet and alphabet 'o' or 'O' should not be in generated code.</p>
| php | [2] |
5,542,460 | 5,542,461 | Shortest encoding, Hexadecimal | <p>Hi guys i would like to send the shortest possible string/value.
If i have the following</p>
<pre><code>1)l23k43i221j44h55uui6n433bb4
2)124987359824369785493584379
3)kla^askdjaslkd3AS423$#ksala
</code></pre>
<p>What is the terminology for shortening strings,
Encoding? Encrypting? </p>
<p>At the same time, what is the best method to shorten a string of text, taking into consideration that i have only sms 255 limit</p>
| c# | [0] |
2,317,543 | 2,317,544 | Android Animation XML example files? | <p><em>Hiya!</em></p>
<p>I was wondering if anyone knows of some good Android Animation XML examples so that I could take a look at how they work?</p>
<p>Please and Thanks</p>
| android | [4] |
4,111,921 | 4,111,922 | Java online training? | <p>I wanted to do my 6-weeks online training on java ,so i have searched a lot and came across <a href="http://www.wiziq.com/course/12145-the-6-week-complete-java-primer-with-training-certificate" rel="nofollow">http://www.wiziq.com/course/12145-the-6-week-complete-java-primer-with-training-certificate</a>. I hope it works for me and also wanted to know weather anyone has studied from this website please let me know or tell me any other guidance…
would really appreciate help…</p>
| java | [1] |
5,135,369 | 5,135,370 | Thread returns error in android 4.0.3 version | <p>I have a question that I have a splash screen in my android app in which I am using thread to wait for 8 seconds, it is running fine in 1.6,2.1,2.2,2.3.3, 3.0, 3.1 but returns error when I want to run the same in 4.0.3 version of android, I don't know why? Please suggest me the right solution for the same. Below I mentioned error stack and my code also.</p>
<p><strong>Error Stack:</strong></p>
<pre><code>01-05 10:16:06.417: E/AndroidRuntime(589): FATAL EXCEPTION: Thread-75
01-05 10:16:06.417: E/AndroidRuntime(589): java.lang.UnsupportedOperationException
01-05 10:16:06.417: E/AndroidRuntime(589): at java.lang.Thread.stop(Thread.java:1076)
01-05 10:16:06.417: E/AndroidRuntime(589): at java.lang.Thread.stop(Thread.java:1063)
01-05 10:16:06.417: E/AndroidRuntime(589): at com.shipface.common.SplashScreen$1.run(SplashScreen.java:34)
</code></pre>
<p><strong>Code:</strong></p>
<pre><code>public class SplashScreen extends Activity {
/** Called when the activity is first created. */
Thread splash;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
splash = new Thread(){
@Override
public void run(){
try {
synchronized(this){
// Wait given period of time or exit on touch
wait(4000);
Intent intent = new Intent(SplashScreen.this,HomeActivity.class);
startActivity(intent);
finish();
}
}
catch(InterruptedException ex){
}
finish();
stop();
}
};
splash.start();
}
}
</code></pre>
| android | [4] |
673,289 | 673,290 | install wkhtmltoimage on MAMP | <p>I feel like an idiot, everyone seems to be able to setup wkhtmltoimage fine but nothing is working for me. There is no clear setup guide so I thought Id ask here. So how do I setup wkhtmltoimage in MAMP on osx??</p>
<p>Link here: <a href="http://code.google.com/p/wkhtmltopdf/" rel="nofollow">http://code.google.com/p/wkhtmltopdf/</a></p>
| php | [2] |
3,594,229 | 3,594,230 | Changing heading into textbox dynamically | <pre><code><div id="form_title">
<h1>Form Title</h1>
</div>
</code></pre>
<p>This is my HTML code. I want to make a text box appear whereby user can change the value of h1 and save it.</p>
<p>Here is my attempt.</p>
<pre><code>$('#form_title').click(function() {
$(this).html('<input id="form_title_value" name="form_title_value"
type="text" placeholder="Enter Form Title..."> ');
});
</code></pre>
<p>The problem is that the textbox looses focus when I click on it.</p>
| jquery | [5] |
4,486,464 | 4,486,465 | Logging into a website using c# | <p>I am trying to log into a website using the webbrowser class, here is what I did:</p>
<pre><code> //Fetch the username input
HtmlElement usernameElement = Utilites.extractElementFromBrowserByName("user", browser);
usernameElement.SetAttribute("value", userName);
//Fetch the email input
HtmlElement emailElement = Utilites.extractElementFromBrowserByName("email", browser);
emailElement.SetAttribute("value", userEmail);
//Fetch the submit buttom
HtmlElement submitElement = Utilites.extractElementFromBrowserByValue("Login Action", browser);
submitElement.InvokeMember("submit"); //Simulates a click on the login button
browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(getMe);
</code></pre>
<p>I fetched the elements and filled them, then found the submit button and clicked it. I then subscribed to the document loaded event, but this event is never fired.</p>
<p>Did I do something wrong?</p>
<p>Thanks.</p>
<p>Edit: I already tried submitElement.InvokeMember("click"), still didn't work.</p>
| c# | [0] |
866,614 | 866,615 | javascript Regular expression for validating arithmetic expression | <p>I have an arithmetic expression
((20+30)-25)/5
I want to validate by using regular expression. The expression can only have integers, floating point numbers, operands and parenthesis.</p>
<p>How can I generate regular expression to validate please help or suggest any other way to validate that string using javascript.</p>
| javascript | [3] |
443,172 | 443,173 | Variable Div height with toggle slide | <p>this link is a part of a website I'm designing. <a href="http://jsfiddle.net/studioband/Y29em/30/" rel="nofollow">http://jsfiddle.net/studioband/Y29em/30/</a></p>
<p>I managed to get the slide/toggle working thanks to help of @Tats_innit. I have tried to get a slide toggle on the container and an fade animation on the text, this works initially but then falls over. You can see this when you click on project info and subscribe. </p>
<p>What I'm trying to achieve is that the height for the grey background reveal is variable, so if one div is open and the other is clicked the height of the div slides up or down to suit the amount of content, not go all the way up over the text, I have separated the info and background div. I have also tried to achieve this through .toogleClass. I have added the same classes onto the subscribe area and it keeps falling over. </p>
<p>I have looked into if and else states, variable animation and toggle class, but not sure how to integrate it all. If anyone can help me it would be greatly appreciated. </p>
| jquery | [5] |
305,458 | 305,459 | Jquery selector for getting combox value is not working in IE 8.0.7... version | <p><code>$("select#promoProductList_length").val();</code></p>
<p>The above code is working fine in all browsers (Firefox, chrome, IE) except some specific version of IE 8.</p>
<p>This is giving value as undefined in those browsers.</p>
<p>So I implemented some work around fix.</p>
<p>i.e., </p>
<pre><code>$("#promoProductList_length option:selected").text();
</code></pre>
<p>It is working fine.</p>
<p>What will be the reason that, first line is not working in some specific version of IE?</p>
| jquery | [5] |
1,099,076 | 1,099,077 | How to re-type pointer to a class and be able to reach classes functions based on it's type? | <p>I'm writing a C++ code which should populate a screen (and it's behaviour) based on a function from the object pointer was initiated with. Let's better show it on a code:</p>
<pre><code>class A:parentClass {
public:
int X () {return 5;}
}
class B:parentClass {
public:
int X () {return 3;}
}
class C:parentClass {
public:
int X () {return 1;}
}
main {
parentClass *p;
p = new A;
printf("%d\n,p.x); //to return 5
delete p;
p = new B;
printf("%d\n,p.x); //to return 3
}
</code></pre>
<p>I'm getting something like this on compilation: </p>
<pre><code>‘class parrentClass’ has no member named ‘x’
</code></pre>
<p>I know that this is wrong, as parrentClass simply doesn't have that member, but I don't have an idea how to solve this. I tried to go through templates, but I'm not getting anywhere. </p>
<p>I also tried to replace "parentClass *p;" with "int *p;", but then I'm getting:</p>
<pre><code>cannot convert ‘CardsFrame*’ to ‘int*’
</code></pre>
<p>Thanks for your suggestions in advance,</p>
<p>Jan</p>
| c++ | [6] |
2,548,626 | 2,548,627 | Creating an accurate php search engine to search database | <p>Ok, I attempted at making my own search function which doesnt work very well. </p>
<p>It consists of eliminating useless words such as "how" "you" "to" then using a premade Stemmer class that reduces words to their root so "Appointments" searches "appoint"</p>
<p>However in the end I'm really only searching keywords and the results are not very accurate.</p>
<p>Are there open source search engines that i can implement for free?</p>
| php | [2] |
4,557,208 | 4,557,209 | Tabindex not getting highlighted | <p>I have 2 text boxes inside a panel control, when i give tabindex (winforms)</p>
<pre><code> txtBox1.TabIndex = 1;
txtBox2.TabIndex = 2;
txtBox1.Focus();
</code></pre>
<p>tabindex doesn't work, when i press tab key the cursor doesn't move to txtBox2 from txtBox1 & also i have set panel's tabindex to 50(a large number, not to mix up with the textbox tab indexes).</p>
<p>Thanks.</p>
| c# | [0] |
3,807,615 | 3,807,616 | How to use Python files spread out over many folders, or: how to organize a project | <p>I am looking to make my project fulfill the guidelines described here: <a href="http://infinitemonkeycorps.net/docs/pph/" rel="nofollow">http://infinitemonkeycorps.net/docs/pph/</a>. I currently have the following directories:</p>
<pre><code>src/
test/
doc/
</code></pre>
<p>I would really like to organize my <code>src/</code> file as follows:</p>
<pre><code>src/
similar_files/
other_files/
helpers/
etc
</code></pre>
<p>However, I'm not familiar with how I could have my modules and classes interact the same way, i.e. if some module in one folder needs access to one in another folder. Is this a bad way to organize my project? If not, how can I accomplish what I want?</p>
<p>Thanks!</p>
| python | [7] |
4,677,044 | 4,677,045 | javascript use for getting element | <pre><code><li class="even">
<a href="www.google.com">Click here </a>
</li>
</code></pre>
<p>I want to change anchor tag text "Click here" using javascript. How can i accomplish this ? </p>
| javascript | [3] |
5,505,557 | 5,505,558 | Specific php document for a page | <p>I'm Doing a site with some content that can be updated by Wordpress, but, It would be a lot times if I could write a php document for one page and other php document for another page, Like front-page.php. Is it somehow possible?</p>
<p>Thanks a lot in advance.</p>
| php | [2] |
145,773 | 145,774 | Getting all of the items from an ArrayAdapter | <p>I have a <code>ListFragment</code> backed by an <code>ArrayAdapter</code> that gets populated by a <code>Loader</code>. When the user clicks on one of the items, I want to pass a reference to the selected item, as well as the rest of the list items to another fragment. My question is how should I get all of the items from the adapter? Here are the possibilities that I see:</p>
<p><strong>1. Keep a reference to the backing <code>List</code></strong></p>
<p>Create the adapter like so:</p>
<pre><code>List<DomainObject> items = new ArrayList<DomainObject>();
listAdapter = new ArrayAdapter<DomainObject>(getActivity(), R.layout.mine, items);
</code></pre>
<p>and then simply pass <code>items</code> or a copy of it to the next activity.</p>
<p>The downside I see of this is that I'm relying on the undocumented fact that the same list that I pass to the constructor contains the items later on.</p>
<p><strong>2. Iterate through the adapter</strong></p>
<p>When an item is clicked, iterate through the adapter and build up the list. This seems like an unnecessary amount of work. The items are contained in a <code>List</code> in the adapter and I'm manually copying each item to a new list.</p>
<p><strong>3. Keep a separate list of items when adding to adapter</strong></p>
<p>Before adding an item to the adapter, add it to a separate list that I maintain in the fragment. This is also wasteful as the list of items is copied in the <code>ArrayAdapter</code> and the fragment.</p>
| android | [4] |
5,264,410 | 5,264,411 | How to validate Guid in .net | <p>Please tell me how to validate GUID in .net and it is unique for always?</p>
| c# | [0] |
677,693 | 677,694 | jquery not just write a lot of click function | <p>I have a question about jquery <code>onclick</code> function, the question is not bug;
when i write some button click functions that use jquery, i have write a lot of jquery, for example:</p>
<pre><code>$(document).ready(function(){
$('#dp1').datepicker({
format: 'yyyy-mm-dd'
});
$('#dp2').datepicker({
format: 'yyyy-mm-dd'
});
$("#addNewQ").on('click', function(){
.......
});
$('#addNew').on('click', function(){
.......
});
$('#addText').on('click', function(){
.......
});
});
</code></pre>
<p>My question is how to write this better. I don't want to write a lot of click functions.</p>
<p>I have try to google, but I don't know the keyword. Thanks !</p>
| jquery | [5] |
2,612,599 | 2,612,600 | apply jquery function to multiple divs/elements with .click | <p>hello very basic question</p>
<p>I have a number of divs (containing images) that I'd like to apply the same scaling function to (with a .click). But I'm not sure how to go about it. I think I need to use ".this" or ".target"?</p>
| jquery | [5] |
1,306,086 | 1,306,087 | Get attribute of all items in container python | <p>I have the following (obviously simplified) class</p>
<pre><code>class A(object)
def __init__(self, a):
self.a = a
self.b = 'b'
# Other class attributes are added
class B(list):
"""
Some customization of this class...
"""
pass
BB = B([A(i) for i in range(10)])
</code></pre>
<p>I want to do</p>
<pre><code>B.a
</code></pre>
<p>and get a list of all the <code>a</code> attributes from every contained item in <code>B</code>. I know in order to do this, I need to overwrite <code>__getattr__</code>, but I'm not sure the best way to implement this. This needs to be generic as <code>B</code> doesn't know any of the attributes of <code>A</code> that may need to be accessed.</p>
<p>Can someone offer some advice on the implementation of this idea?</p>
| python | [7] |
649,221 | 649,222 | keycode not work in chrome | <p>I am trying to execute some code of js when user press key "enter" or "tab". When I alert keycode then showing correct, but when press key "enter or tab" then not showing any response.
I tried following code.</p>
<pre><code><input id="to" onkeypress="checkemail(event);">
function checkemail(evt)
{
var keycode = evt.keyCode? evt.keyCode : evt.charCode;
//alert(keycode);
if(keycode=='13'|| keycode=='9')
{
//MyCode
}
}
</code></pre>
<p>This code is work properly in FireFox, but not showing any result in Google Chrome.
Please tell me any solution if have.
Thanks in advance.</p>
| javascript | [3] |
1,981,113 | 1,981,114 | Java and SwingSet | <p>I have seen some libraries call swingset. But I am new to java and don't have any Idea what is it. Can anyone tell me what is it. I have heard about swing but no swingset</p>
<p>Thank you</p>
| java | [1] |
1,763,730 | 1,763,731 | HDF4 python map reader error (hdfmr.py) | <p>I'm using a Python utility, HDF4MapReader, that reads an XML file generated from an HDF4 file. I think the error I'm getting may be recognized by someone who uses Python (my version is 2.6.1):</p>
<pre><code>~/Desktop/HDF4MapReader/src$ python hdfmr.py
Traceback (most recent call last):
File "hdfmr.py", line 72, in <module>
from Reader import Reader
File "/Users/chuck/Desktop/HDF4MapReader/src/Reader.py", line 7, in <module>
import XMLparser
File "/Users/chuck/Desktop/HDF4MapReader/src/XMLparser.py", line 7, in <module>
from RIS import RIS
File "/Users/chuck/Desktop/HDF4MapReader/src/RIS.py", line 7, in <module>
from Image import FLIP_TOP_BOTTOM
ImportError: No module named Image
</code></pre>
<p>Line 7 from the respective modules:</p>
<p>line 7 from Reader.py:</p>
<pre><code>from XMLparser import XMLparser
</code></pre>
<p>line 7 from XMLparser.py:</p>
<pre><code> from RIS import RIS
</code></pre>
<p>line 7 from RIS.py:</p>
<pre><code> from Image import FLIP_TOP_BOTTOM
</code></pre>
<p>In the directory with hdfmr.py I have RIS.py and XMLparser.py</p>
<p>Any ideas on what's wrong? TIA... </p>
| python | [7] |
2,350,955 | 2,350,956 | C# API for Task Scheduler 2.0 | <p>Does anyone have any recommendations for a .NET c# wrapper for the (COM based) Task Scheduler 2.0 API ?</p>
<p>Couldnt find anything using Google.</p>
<p>(I am aware there are .net based schedulers such as Quartz.net, but I need the fully functioned GUI in the windows Scheduler)</p>
<p>Thanks,</p>
<p>Matt</p>
| c# | [0] |
5,813,735 | 5,813,736 | Access this in jquery each function | <p>How can I acces my object variables within a $.each function?</p>
<pre><code>function MyClass()
{
this.mySetting = 'Hallo';
this.arr = [{caption: 'Bla', type: 'int'}, {caption: 'Blurr', type: 'float'}];
}
MyClass.prototype.doSomething = function() {
$.each(this.arr, function() {
//this here is an element of arr.
//...but how can I access mySetting??
});
}
</code></pre>
| jquery | [5] |
1,793,391 | 1,793,392 | putting mysql query into array and using more than once error | <p>I have a real big problem that normally doesn't happen. For some reason on this occasion it errors...</p>
<p>Ok I put in a mysql query IE </p>
<pre><code>$query = mysql_query("SELECT * from tablename");
</code></pre>
<p>Then i say</p>
<pre><code>$row = mysql_fetch_array($query,MYSQL_BOTH)
</code></pre>
<p>When I put (even a blank loop in it gives me an error) a loop in...
IE</p>
<pre><code>foreach ($row as $rowme){
// do nothing
echo $rowme['id'] . "<br />";
}
</code></pre>
<p>I get invalid argument supplied for foreach()</p>
<p>Never before has this happened - any ideas why it is now?</p>
<p>Running PHP 5.2.11 on the server</p>
<p><code>while($row = mysql_fetch_assoc)</code> = works fine, but I can use this only once on the page... another question why can't I use the same loop again somewhere else? (Coldfusion you can use the same loop from a query repeatedly? why does not PHP do this using <code>mysql_fetch_assoc</code>???)</p>
<p>I'm using a jQuery photo gallery, which populates some repeated javascript to write the descriptions on the images via the class and repeats the list items they are in, hence I need two loops of the same query. So obviously putting the query results into an array and using the array repeatedly should work right?</p>
<p>The only other option is to create two queries exactly the same. Seems inefficient however.</p>
<p>Can anyone answer these questions or shed some light. I'm desperate and very very behind putting in this gallery, (why I'm still here at work at 1.22 am) - Would be most grateful.</p>
<p>Thanks</p>
<p>A.</p>
| php | [2] |
4,569,313 | 4,569,314 | Can I make jQuery's load(); appear slowly? | <p>jQuery code:</p>
<pre><code>$(document).ready(function() {
$("#post_submit").click(function(event) {
event.preventDefault();
$("#show").load("post.php", {
submit: $("#post_submit").val(),
title: $("#title").val(),
body: $("#body").val(),
tags: $("#tags").val()
});
});
});
</code></pre>
<p>This works fine, and the information is displayed in without the page reloading (yay), but it's not very smooth. I was wondering how I could make it appear slowly, like <code>$(div).show("slow");</code> or <code>$(div).toggle("slow")</code>.</p>
| jquery | [5] |
4,873,603 | 4,873,604 | Asp.net, directly assigning properties from value? | <p>Is there a way to express </p>
<pre><code><% objControl.ObjProp=ObjVar; %>
<my:Control ID="objControl" runat="server" />
</code></pre>
<p>As something like this, in one line? And without passing ObjVar as a string?</p>
<pre><code><my:Control ID="objControl" runat="server" ObjProp=ObjVar />
</code></pre>
| asp.net | [9] |
2,938,413 | 2,938,414 | Place a hyperlink in the text of a checkbox? | <p>I have a checkbox that has this text: "I agree to the terms and conditions". I need "terms and conditions" to be blue, underlined, and open a webpage when touched.</p>
<p>I did find the Linkify class (http://developer.android.com/reference/android/text/util/Linkify.html), but this seems to turn URLs already in text into to links.</p>
<p>How can I do this?</p>
| android | [4] |
4,503,350 | 4,503,351 | Detect if an image is in the same hosting | <p>I have the following problem whichI don't know how to solve.</p>
<p>I have a string taken from a different site with html code. What I want is to delete all the images from this string which are not hosted in that source. How can I do that ?</p>
<p>Example of the string :</p>
<pre><code><h1>Titlte<h1/>content of the url <a href=""><img ... /></a>
</code></pre>
<p>The original url of the site is in a variable called $link</p>
<p>Thanks in advance!</p>
| php | [2] |
1,343,896 | 1,343,897 | Asp.net request.querystring | <p>iam using request.querystring just to access a parameter which iam passing from one page to other.</p>
<p>it is giving me eror
Non-invocable member 'System.Web.HttpRequest.QueryString' cannot be used like a method. </p>
<p>iam using C#</p>
<p>any help would be appreciated</p>
| asp.net | [9] |
3,336,071 | 3,336,072 | Why doesn't IllegalAccessError have two-argument constructor? | <p>The IllegalAccessError class has two constructors, <code>IllegalAccessError()</code> and <code>IllegalAccessError(String s)</code>.</p>
<p>Why doesn't IllegalAccessError have a two-argument constructor like <code>IllegalAccessError(String s, Throwable cause)</code>?</p>
| java | [1] |
5,996,933 | 5,996,934 | jQuery Delegation with Facebox | <p><strong>hi, i am not sharing code. the problem is in this code please take a look. (problem: I want to open facebox every time when post even come from ajax facebox is not working properly. I want to ask how to use jQuery delegation event with this event? )</strong></p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="facebox/facebox.css" type="text/css" />
</head>
<body>
<ul id="items">
<li> <a href='#'> Clone Object </a> </li>
<li> <a href='#test' rel='facebox'> Click to open facebox </a> </li>
</ul>
<div id="test" style="display:none;">this is my test div</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="facebox/facebox.js"></script>
<script type="text/javascript">
jQuery('a[rel*=facebox]').facebox();
$("#items li").delegate('a', 'click', function(){
$(this).parent().append('<li><a href="#test" rel="facebox"> New Element ( problem: it should open facebox) </a></li>');
return false;
});
</script>
</bdoy>
</html>
</code></pre>
| jquery | [5] |
3,356,028 | 3,356,029 | how to write code in javascript to link the checkboxes in row with the checkboxes in another row | <p>I have a table containing 128 checkboxes.</p>
<p>The table has 2 columns and 8 rows.</p>
<p>Each row contains 2 sub-rows having 8 checkboxes.</p>
<p>How to link the checkboxes of the 2 sub-rows using javascript code.</p>
<p>Can i have some suggestions.</p>
| javascript | [3] |
1,757,818 | 1,757,819 | Exclude .cs from project through code? (Visual Studio) | <p>I need to exclude .cs files from project through code, for example with T4 template. I know that you can modify the .csproj file, but this doesn't work properly if the project is opened with Visual Studio, so is there any way to exclude/add .cs files through code(for example, with T4 templates)?</p>
<p>Thanks</p>
| c# | [0] |
989,104 | 989,105 | Cloning a form dynamically during run-time | <p>Say I have a form called "FormA" with two textboxes text1_a and text2_a.How can I create a form dynamically during runtime called "FormB" with the same objects that are in FormA having the same layount only with different names for the textboxes such as text1_b and text2_b</p>
| c# | [0] |
2,624,900 | 2,624,901 | How to clamp an integer to some range? (in Python) | <p>I have the following code:</p>
<pre><code>new_index = index + offset
if new_index < 0:
new_index = 0
if new_index >= len(mylist):
new_index = len(mylist) - 1
return mylist[new_index]
</code></pre>
<p>Basically, I calculate a new index and use that to find some element from a list. In order to make sure the index is inside the bounds of the list, I needed to write those 2 <code>if</code> statements spread into 4 lines. That's quite verbose, a bit ugly... Dare I say, it's quite <em>un-pythonic</em>.</p>
<p><strong>Is there any other simpler and more compact solution?</strong> (and more <em>pythonic</em>)</p>
<p>Yes, i know I can use <code>if else</code> in one line, but it is not readable:</p>
<pre><code>new_index = 0 if new_index < 0 else len(mylist) - 1 if new_index >= len(mylist) else new_index
</code></pre>
<p>I also know I can chain <code>max()</code> and <code>min()</code> together. It's more compact, but I feel it's kinda obscure, more difficult to find bugs if I type it wrong. In other words, I don't find it very straightforward.</p>
<pre><code>new_index = max(0, min(new_index, len(mylist)-1))
</code></pre>
| python | [7] |
5,456,906 | 5,456,907 | Filtering duplicates out of an IEnumerable | <p>I have this code:</p>
<pre><code>class MyObj {
int Id;
string Name;
string Location;
}
IEnumerable<MyObj> list;
</code></pre>
<p>I want to convert list to a dictionary like this:</p>
<pre><code>list.ToDictionary(x => x.Name);
</code></pre>
<p>but it tells me I have duplicate keys. How can I keep only the first item for each key?</p>
| c# | [0] |
1,767,530 | 1,767,531 | How to select individual items in a table view row? | <p>What's the best way to create a table view with thumbnails (like the iPhone Photos app)?</p>
<p>The problem I have is the selection part. How do I get information about the selected thumbnail of a selected row? A delegate method like:</p>
<pre><code>- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath atPoint:(CGPoint)touchedPointInCell
</code></pre>
<p>...would have made it easy. But how do I do this when I don't get the x or column of a table view selection?</p>
<p>Thanks in advance,</p>
<p>/ Påhl</p>
| iphone | [8] |
3,604,283 | 3,604,284 | NavigateURl leads to HTTP Error 400 - Bad Request | <p>Ok I have a gallery with thumbnail images that is sorrounded with a tags like this</p>
<pre><code><asp:Repeater ID="Repeater" runat="server">
<ItemTemplate>
<asp:HyperLink NavigateUrl= '<% String.Format("?name = {0}", Container.DataItem) %>'
runat="server">
<asp:Image CssClass="images" ImageUrl= '<%# String.Format("~/pictures/thumbs/{0}",
Container.DataItem) %>' runat="server">
</asp:Image>
</asp:HyperLink>
</ItemTemplate>
</asp:Repeater>
</code></pre>
<p>But when I click an image I just get the HTTP Error 400 - Bad Request error.</p>
<p>Can anyone help me?</p>
| asp.net | [9] |
1,331,528 | 1,331,529 | Place tabs inside a tabhost in android | <p>I have an application in which i have 5 tabs which is at the bottom.
Now inside the first tab I need 4 tabs that is aligned at the top.
How can I do that? PLease help.
I only managed to create the first 5 tabs and when I tried to place an activity inside the first one the app crashes.
I am extending the TabActivity for the first 5 tabs.</p>
| android | [4] |
1,631,641 | 1,631,642 | Cursor Adapter with multi select | <p>I've written an APP the uses has a small SQL lite DB and using a cursor adapter I can retrieve the records and populate a list view with them. from there I can get the Id of a selected item and delete it from the DB which works great. the issue I have is that as the DB grows deleting one row at a time would be slow and frustrating so I wanted to know if there was any way to allow multiple selections possibly with check boxes or by even changing the text color of the items selected so that I can retreiving their relative ID's.</p>
<p>I have read some posts that talk about custom cursor adapters but I am not sure how to adapt them to my code. I have posted my code below.</p>
<pre><code>enter code here private void fillData() {
Cursor c = mDbHelper.fetchAllNotes();
startManagingCursor(c);
String[] from = new String[] {DBHelper.KEY_FIELD0,
DBHelper.KEY_FIELD1,
DBHelper.KEY_FIELD2,
DBHelper.KEY_FIELD3,
DBHelper.KEY_FIELD4};
int[] to = new int[] {R.id.text,R.id.text2,R.id.text3,R.id.text4,R.id.text5};
SimpleCursorAdapter dblist = new SimpleCursorAdapter(this, R.layout.row, c, from, to);
setListAdapter(dblist);
}
</code></pre>
<p>Thanks.</p>
| android | [4] |
1,010,401 | 1,010,402 | How to create a range of IP addresses? | <p>Suppose the input is:</p>
<p><code>222.123.34.45</code> and <code>222.123.34.55</code></p>
<p>then I need to output the ip address in between them:</p>
<pre><code>222.123.34.45 222.123.34.46 ... 222.123.34.55
</code></pre>
| php | [2] |
3,487,187 | 3,487,188 | JQuery Modal true with dialog is not working | <p>I want to have only one window opened so i am uisng modal", true , but still when a popup window is opened , multiple operations are being done </p>
<pre><code> $("#fileuploadfun").attr('title',"Upload");
$("#fileuploadfun").dialog( "option", "modal", true );
</code></pre>
| jquery | [5] |
3,522,317 | 3,522,318 | jQuery - How to slide the bottom part up after the top part is fadeout? | <p>I have a page as follows:</p>
<pre><code><div id="warning_msg">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo.
<span id="closeerrordiv" class="notify-close">×</span>
</div>
<div id="bigForm2">
Lots of content here
</div>
<div id="bigForm...">
</div>
<div id="footer">
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#closeerrordiv').click(function() {
$(this).parent().fadeOut('slow');
});
});
</script>
</code></pre>
<p>After the user clicks 'closeerrordiv', the span content will fadeout.
Now, I need to move all the bottom parts move up.</p>
<p>Howe can I do this?</p>
| jquery | [5] |
4,753,160 | 4,753,161 | jquery img and desc swap | <p>I'm trying to swap an img src and a text description with jquery. This is what i have so far but now working of course :)</p>
<pre><code>$(document).ready(function(){
$("#slideShow a").click(function() {
var imgTitle = $(this).children('img').attr('title'); // Find the image title
$("#thecap").html(' ' + imgTitle + ' ');
$("#lgImage").attr('src', $(this).children('img').attr('rel'));
});
});
</code></pre>
| jquery | [5] |
2,032,519 | 2,032,520 | Write to a file that is already used | <p>i want to write to a File, that is already in use by an other process.</p>
<p>My Question is: is there a way to avoid the FilenotfoundException, and to write to the file although it is in use?</p>
<p>Thank you!</p>
| java | [1] |
2,163,666 | 2,163,667 | RSS feed parse from html file | <p>i have url of RSS feed <a href="http://www.oxfordtimes.co.uk/news/yourtown/bicester/9628857.Golf_centre_will_become_caravan_park/r/?ref=rss" rel="nofollow"><strong>Click here</strong></a> in the context of url you can see title and description over there. now i need to parse it in to android i have try to search on it but all help is regarding xml format. but here i want something like "HTML parse" and based on that perticular news description i can parse.. so is there any idea regarding those parse if yes then please help me on this...</p>
<p>one more thing in my searching i found that <a href="http://stackoverflow.com/questions/1253788/simple-rss-parser-for-android">this link</a> may be usefull for me and it guide me or attract to use "Apache Feedparser" so is this right way ??</p>
| android | [4] |
2,930,170 | 2,930,171 | How to extract every possible values of python Dict's values to list | <pre><code>DICTA={'bw':['BW','VW'],'b':['BB','VV'],'a':['AA']}
DICTB={'yn':['$YN','$YNN'],'ye':['$YE','A$Y'],'y':['Y$']}
</code></pre>
<p>How to extract every possible values of that 2 Dict to</p>
<pre><code>["BWYN","VWYN","BBYN","VVYN","AAYN","BWYNN","VWYNN","BBYNN","VVYNN","AAYNN",
"BWYE","VWYE","BBYE","VVYE","AAYE","ABWY","AVWY","ABBY","AVVY","AAAY",
"YBW","YVW","YBB","YVV","YAA"]
</code></pre>
<p>PS: Order does not matter</p>
<p>PPS: Not homework, but like to know how it can be implemented in efficient way.</p>
| python | [7] |
1,917,362 | 1,917,363 | jQuery autocomplete on 500 error page | <p>I need to make autocomplete for search field on 500 error page.
Autocomplete for this field on other pages works good, but on 500 error page i get nothing - no js error no autocomplete.</p>
<p>The question is: can i make autocomplete work on page whith http status code 500?</p>
<p>Thanks!</p>
| jquery | [5] |
5,810,093 | 5,810,094 | Help with the onmouseover function | <p>I am having trouble getting the onmouseover function working in jquery. What I want to do is when you hover over the word "here" the image pops up. The plugin is working fine just dont know how to handle the onmouseover or hover event?</p>
<p>HOVER ISNT WORKING IN MY CODE</p>
<pre><code>('a.lightbox').hover(function(){
$('a.lightbox').lightBox();
});
<body>
<form id="form1" runat="server">
<div id="outer">
<a href="image1.jpg" class="lightbox">here</a>
</div>
</form>
</body>
</code></pre>
<p>This doesnt work either.....</p>
<pre><code> $('a.lightbox').hover(function() {
$(this).lightBox();
});
</code></pre>
<p>Isnt there something where I can simply hover over a word and an image pops up?</p>
| jquery | [5] |
2,083,256 | 2,083,257 | Css display:none is not applied in HTML mail generated in c# | <p>In my code I use the <code>MailMessage</code> class of .Net to generate mails.</p>
<p>I have set <code>msg.IsBodyHtml = true;</code>. Still in the mail the CSS is not applied at all.. </p>
<p>I want to hide some tags in mail. For that I have used <code>Display</code> property, But It doesn't work...</p>
<p>What should I do?</p>
| asp.net | [9] |
2,200,796 | 2,200,797 | android and itext | <p>I want to display pdf in android with next/previous and zoom effect,i check out the already exits the lib for that but it is too slow then, I move to itext.
I install the jar file and code to get the total number pages.
But question how i can display the pdf,i mean to say take the text view,then how i will manage the background of the pdf,so there are many query.
Can anybody help me out if some-one have gone through the steps</p>
<p>Thanks in advance and every suggestion wel come here.</p>
| android | [4] |
3,151,899 | 3,151,900 | Any problems with ob_start? | <p>Should we always use ob_start in our applications? </p>
| php | [2] |
5,389,578 | 5,389,579 | how to learn Java | <p>This question I am asking because I couldn't find any source which gives complete overview of java development. I just want to know where java technology currently in market & what is preferable for development !</p>
<p>Java always remain top programming language for development point of view. However, java is combo of, j2ee, j2me, jsp, jsf, spring, other frameworks, ui components, jndi, networking tools and various other "J" are there !</p>
<p>However, learning java is definitely dependent on the development requirement, but still, to be a well-experienced java developer, what is the organised way of learning java? What is preferable in current technology ? and what is deprecated, currently ?</p>
| java | [1] |
4,868,316 | 4,868,317 | How can I use a for or while loop with an int declared outside the body? | <p>I have a loop, like so:</p>
<pre><code> for (i < splitted.Length; i++ != 0)
{
key += '\\' + splitted[i];
}
</code></pre>
<p>Depending on an if condition above, i, decdlared outside of the loop's body, may need to be incremented (I am splitting a string into a string[] and then need to join parts of it, but maybe from the 5th index, 6th, etc, depending on the condition in the if clause).</p>
<p>However, C# does not let me write a loop like the above. Can I have a loop like the above?</p>
<p>Thanks</p>
| c# | [0] |
3,039,177 | 3,039,178 | Android WebViewClient, onErrorReceived not being called when there is a 404 | <p>I've got a WebView, with a WebViewClient that defines onErrorReceived, and onPageFinished. </p>
<p>The onPageFinished gets called correctly, so I know that the WebViewclient is attached to the WebView correctly. However, there's some javascript in the WebView that calls:</p>
<p><code>location.href="http://kernel.org/asdf/asdf/asdf/asdf";</code></p>
<p>And the onErrorReceived listener is not called, even though it's a 404. Does it not work with javascript calls?</p>
<p>Edit: After some testing, I have found that NO 404s are reported to this function whatsoever. I have a test project set up here: <a href="http://vimtips.org/media/WebViewTest.zip" rel="nofollow">http://vimtips.org/media/WebViewTest.zip</a></p>
<p>It appears that this method cannot be used to test for 404s. Anyone know of a way to do this?</p>
| android | [4] |
4,682,622 | 4,682,623 | Using jQuery multiple selector (comma) with XML context argument | <p>I've been using jQuery selectors to grab data from an XML document. This generally works as expected, but I've found that one thing I can't do is use the multiple (comma) selector.</p>
<p>The comma works when the context argument is a DOM object, but when it's an XML document, I get an empty jQuery object back.</p>
<pre><code>$('one, two', xml) --> []
</code></pre>
<p>I can get the intended result by using jQuery's add:</p>
<pre><code>$('one', xml).add('two', xml) --> [<one></one>, <two></two>]
</code></pre>
<p>Not a huge deal, but I'm wondering: is this expected behavior?</p>
<p>Edit: I've just discovered that this is only true when the elements have a namespace prefix. Yet it picks them up fine individually, and adding the namespace prefix (with or without the multiple selector) gives me [].</p>
| jquery | [5] |
3,001,696 | 3,001,697 | How do I convert timespan method to decimal? | <p>Here is my code:</p>
<pre><code>TimeSpan span1 = TimeSpan.FromHours(dtmIn.Value.Hour);
TimeSpan span2 = TimeSpan.FromHours(dtmOut.Value.Hour);
TimeSpan span3 = TimeSpan.FromMinutes(dtmIn.Value.Minute);
TimeSpan span4 = TimeSpan.FromMinutes(dtmOut.Value.Minute);
TimeSpan span5 = span2.Subtract(span1) + span4.Subtract(span3);
lblTotal.Text = Convert.ToDecimal(span5).ToString("#.00");
</code></pre>
<p>I get a formatting error for the last line. I can get the label to return as time obviously, but I need it to return as a decimal.</p>
| c# | [0] |
304,617 | 304,618 | Passing multiple parameters through the image URL property | <blockquote>
<p>I need to pass multiple parameters dynamically to my ascx file
through the image url property.
I tried <code><%# "ImageHandler.ashx?uid="+ Eval("PlantId") %></code>. Similarly, how can I send three parameters?</p>
</blockquote>
| c# | [0] |
5,157,397 | 5,157,398 | Jquery add event handler | <p>For Eg if i have the following code:</p>
<pre>
$(document).ready(function({
$(".click").click(function(){
alert(' The Button Was Clicked !');
});
}));
</pre>
<p>This works fine.<br />But If i add a element to the web page with the same class like shown here:</p>
<pre>
$('#clicked').click(function(){
$("#area").append("<button class='click'>Click me</button>");
});
</pre>
<p>Now I know That the event handler added before to the .click class won't work for the new elements that are added dynamically. <br />
Whats that best way to add event handlers to elements that are added dynamically ?</p>
| jquery | [5] |
4,244,685 | 4,244,686 | What's the name of the view that presents modal info to the user? | <p>This ugly blue one with one or two buttons, that takes a title and needs to be tapped away before the user can proceed...</p>
| iphone | [8] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.