Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
4,143,355 | 4,143,356 | How to get all divs below on 1-level with jQuery? | <p>$('#masterDiv div') gets me all the divs below the masterDiv and divs nested in these divs. How to get only 1-level children?</p>
| jquery | [5] |
1,993,797 | 1,993,798 | question about location of variable in memory | <p>we know meaning of pointers for example to get location of variable</p>
<pre><code>int t=9;
</code></pre>
<p>we use following notation</p>
<pre><code>int *p=&t;
</code></pre>
<p>how can i obtain address of variable in memory by bitwise operatos and bits manipulation? can i do it in general or what is equivalent of pointer in bit world?i am using c++</p>
| c++ | [6] |
2,095,613 | 2,095,614 | Access item in list custom class | <p>Ok, I have this code:</p>
<pre><code>URLs.Add(new URL(str.URL, str.Title, browser));
</code></pre>
<p>and this is the URL class:</p>
<pre><code>public class URL
{
string url;
string title;
string browser;
public URL(string url, string title, string browser)
{
this.url = url;
this.title = title;
this.browser = browser;
}
}
</code></pre>
<p>Now, how do I access the URL title..?<br>
ie., Property of URLs[0]...? When I print URLs[0].ToString, it just gives me the Namespace.URL.<br>
How do I print the variables inside of the URL class?</p>
| c# | [0] |
2,821,665 | 2,821,666 | C++ assignment error | <p>I am new to C++ and I have the code below. I am trying to assign <code>int board[] = create_board();</code>, like I would in java, but it gives me the error </p>
<blockquote>
<p>Initializer failed to determine size of board.</p>
</blockquote>
<p>Also when I remove that line of code, my print statement is not shown in the command prompt regardless. </p>
<p>Is there something that I am doing wrong in printing the array as well?</p>
<p><strong>Code:</strong></p>
<pre><code>#include <iostream>
using namespace std;
int* create_board() {
int* pointer;
int board[15];
pointer=board;
for(int i=0; i<16; i++)
board[i] = 1;
return pointer;
}
int main () {
int board[] = create_board();
for (int i; i<16; i++)
std::cout << board[i];
return 0;
}
</code></pre>
| c++ | [6] |
1,341,131 | 1,341,132 | How to go to next Activity in Android | <p>I have three views main1.xml, main2.xml , main3.xml. In main.xml I'm putting three buttons. When the user clicks on first button I want it to show main1.xml, if second button then main2.xml etc.. I am done with the main.xml files.</p>
<p>How to do I change the view? </p>
| android | [4] |
5,542,334 | 5,542,335 | How to convert Double to int directly? | <p>May be this is silly question. I want to get rid of the fractional part of the <strong><code>Double</code></strong> number. But I cant do that. It shows the error that incompatible types. What to do?</p>
<p><code>Double to int</code> conversion in one line....please help thanks</p>
| java | [1] |
2,143,731 | 2,143,732 | Problem with List | <p>I am a java newbie, and having some issue with "java.util.List".Below is my code,where I'm trying to create a list of objects but the result I am getting is undesired.Can you please help me in solving the issue.</p>
<pre><code>import java.util.*;
class testMap
{
public static void main(String[] args)
{
HashMap<String,Object> childRowMap = new HashMap<String, Object>();
List <Object> actList= new ArrayList <Object> ();
for (int x=0;x<2 ;x++ ){
if(x==0){
childRowMap.put("startDate","startDate"+x);
childRowMap.put("endDate","endDate"+x);
childRowMap.put("encodedValue"," enc"+x);
}
else if (x==1){
childRowMap.put("startDate","startDate"+x);
childRowMap.put("endDate","endDate"+x);
childRowMap.put("encodedValue"," enc"+x);
}
System.out.println("Adding object in the postition "+ x);
actList.add(x,childRowMap);
}
System.out.println(actList);
}
}
</code></pre>
<p>Result:</p>
<pre><code>Adding object in the postition 0
Adding object in the postition 1
[{encodedValue= enc1, startDate=startDate1, endDate=endDate1}, {encodedValue= en
c1, startDate=startDate1, endDate=endDate1}]
</code></pre>
<p>===============</p>
<p>Why I am not getting objects with different values.Kindly helping me out in figuring the problem with my code..</p>
| java | [1] |
915,484 | 915,485 | php filter strings before and after specific word with varied lengths | <p>I have a string similar to this....</p>
<pre><code>$string = "order apples oranges pears and bananas from username";
</code></pre>
<p>How can I get it into something like this?</p>
<pre><code>$products = "apples oranges pears and bananas";
$username = "username";
</code></pre>
| php | [2] |
3,891,511 | 3,891,512 | File handling in android | <p>I have created one jar file containing classes of pure java. One of the class does file creation, writing and reading operations. I am using this jar file in android application. It is expected that the files created using java apis should be located in the package of that android application. So I want to hardcode file path while creating it such that it will get created in package of android application that uses my jar file and android application's package name is not known in advance. Package name may vary.</p>
<p>Please help me if any one knows about it.
Thanks in advance
Gauri</p>
| android | [4] |
4,684,741 | 4,684,742 | How to use SOCI C++ Database library | <p>i have an assignment to work with PostGre Database</p>
<p>i have searched and found solution SOCI Library built in C++ . which works fin ewith PostGree database.</p>
<p>i have no idea how to write a Program in Visual Studio or Visual Studio.Net .. an dhow to import and add SOCI header files reference into my project.</p>
<p>i b thankful to you if anybody help me out in thi sregard..</p>
| c++ | [6] |
762,690 | 762,691 | Needed to make a Loading Screen in Android | <p>I am making an application and I want to design a Loading Starting interface in my aplication .
I have an image displaying my application name.
what I want is that I have a .gif aniamted loading icon and I want to display it on the first Screen. I have designed my first screen just I needed. Some help that it should display that .gif animated loading image and then wait for some time after that open my next activity.
Please help me.... </p>
<p>Thanks a bunch in advance.</p>
| android | [4] |
3,218,859 | 3,218,860 | Extract Urls from Mysql Row | <p>People go online and submit an article, with a title and description. And people often include links but they appear as basic text. I want a way in which when people include a url, it is recognized as a working link. I have written a code, but it only scans one row and doesn't seem to work in the actual table, as it is echoed outside of the table.</p>
<p>Basically...i want a table where when a link is submitted, a hyperlink is made. Any ideas?
This updated code below keeps the same thing going on.</p>
<p>My code is below:</p>
<pre><code> $query = "SELECT * FROM rumours ORDER BY id DESC";
$query = mysql_query($query) or die('MySQL Query Error: ' . mysql_error( $connect ));
while ($row = mysql_fetch_assoc($query)) {
$id = $row['id'];
$band = $row['band'];
$title = $row['Title'];
$description = $row['description'];
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
// The Text you want to filter for urls
// Check if there is a url in the text
if(preg_match($reg_exUrl, $description, $url)) {
// make the urls hyper links
preg_replace($reg_exUrl, '<a href="'.$url[0].'">'.$url[0].'</a>', $description);
}
echo "<table border='1'>";
echo "<tr>";
echo "<td> $title </td>";
echo "</tr>";
echo "<tr>";
echo "<td class = 'td1'> $description </td>";
echo "</tr>";
echo "</table>";
}
</code></pre>
| php | [2] |
384,813 | 384,814 | unknown JS obfuscation tool | <p>I have seen many obfuscated codes, however, recently I came across this code: <a href="http://paste2.org/p/1380361" rel="nofollow">paste2.org</a>. The latter uses <code>arguments.callee.toString().replace(/[\s\'\"\)\}\]\[\;\.\{\(]/g, "").length;</code> to prevent programmer from simply replacing <code>eval()</code> with <code>document.write</code> or something similar. I was wondering how do I obfuscate the code this way myself? Is there any tool for that? (p.s. note that <code>arguments.callee.toString().repl[..]</code> is called two times) Going deeper. Even when you get trough this stage, the code is complete mess. Variable/function names are randomized, while the strings are complete mess and look something like this: <code>$(kj49f+4kd+fgdff+hgd25+fh2fg5+adb5)</code> which evaluates to simply <code>$('.wrapper .foo[name"bar"]')</code>. What was used to do that? I have recently came across <code>jscrambler.com</code> which is paid JS obfuscation service. I was wondering if it is the thing that was used to obfuscate the code.</p>
| javascript | [3] |
4,027,797 | 4,027,798 | c# add new namespace to project | <p>How can I add a namespace to a c# project? I am a beginner.</p>
<pre><code>if(!string.IsNullOrEmpty(result))
{
CoderBuddy.ExtractEmails helper = new CoderBuddy.ExtractEmails(result);
EmailsList = helper.Extract_Emails;
}
</code></pre>
<p>My Form1 needs to use the namespace below:</p>
<pre><code>// this is the file that I need to add
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Coderbuddy
{
public class ExtractEmails
{
private string s;
public ExtractEmails(string Text2Scrape)
{
this.s = Text2Scrape;
}
public string[] Extract_Emails()
{
string[] Email_List = new string[0];
Regex r = new Regex(@"[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}", RegexOptions.IgnoreCase);
Match m;
//Searching for the text that matches the above regular expression(which only matches email addresses)
for (m = r.Match(s); m.Success; m = m.NextMatch())
{
//This section here demonstartes Dynamic arrays
if (m.Value.Length > 0)
{
//Resize the array Email_List by incrementing it by 1, to save the next result
Array.Resize(ref Email_List, Email_List.Length + 1);
Email_List[Email_List.Length - 1] = m.Value;
}
}
return Email_List;
}
}
}
</code></pre>
| c# | [0] |
3,380,404 | 3,380,405 | Supporting one build for Android 3.0,4.0 and Android 2.2 | <p>I am facing a problem, I have to use one new API "BluetoothProfile" which is available for Android 3.0+. However if I use it I cant use my app anymore on Froyo or GingerBread.
Can someone suggest what are the options if I want to still support one build for all platforms.</p>
| android | [4] |
5,535,424 | 5,535,425 | Getting numbers after decimal in Javascript | <p>I have a color picker, and the hue values returned are numbers between zero and 1.
To create variations on the hue, I add .2 for 20%, .8 for 80% etc.</p>
<p>How can I keep the numbers going around the circle, so that when the number goes above 1, it subtracts the 1. How can I make this number into this number:
1.73540012511 ---> .7354</p>
<p>I tried using a "cents" javascript, (http://www.irt.org/script/6.htm) but this returned values greater than 1:
<a href="http://jsfiddle.net/Se9Dn/" rel="nofollow">http://jsfiddle.net/Se9Dn/</a></p>
<p>I can't use Math.min, because I want 1.2 to become .2 (not to have the colors all become red when they hit 1). </p>
<p>Thanks. :)</p>
<hr>
<p><strong>Edit:</strong>
Confirming solution, with rounding added. Assuming you have an HSL color (Hue, Saturation, Luminosity) returned from Farbtastic and want to adjust Hue mathematically:</p>
<pre><code>hslcolor = (.73802938, .59832908, .948987);
colorStep = .2;
newcolor[0] = Math.round ( ((1*colorStep +hslcolor[0])%1)*10000 ) /10000;
</code></pre>
<p>Watch out those parenthesis are very tricky in there.</p>
| javascript | [3] |
1,391,319 | 1,391,320 | Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--c | <blockquote>
<p>Fatal error: Uncaught exception 'Exception' with message
'DateTime::_<em>construct() [datetime.--construct]: Failed to parse
time string (Resource id #7) at position 0 (R): The timezone could not
be found in the database' in Z:\home\plati\www\view.php:21 Stack
trace: #0 Z:\home\plati\www\view.php(21):
DateTime-></em>_construct('Resource id #7') #1 {main} thrown in
Z:\home\plati\www\view.php on line 21</p>
</blockquote>
<p>have ithis error what do?
line 20...</p>
<pre><code>$date = mysql_query("SELECT date FROM sondaje WHERE id = '$id'") or die("Error! DataBase Name Incorrect!");
$bdate = new DateTime("$date");
$bdate->modify('+8 day');
$yearz = $bdate->format('Y');
$monthz = $bdate->format('m');
$dayz = $bdate->format('d');
$hourz = $bdate->format('H');
$minutz = $bdate->format('i');
$secndz = $bdate->format('s');
</code></pre>
| php | [2] |
951,563 | 951,564 | Inheritance without containing? | <p>I have class A. And I have class B. And I have many-many classes derived from class B.</p>
<p>I want to achieve this: derivatives of B should have access to the protected variables of A. Whithout each of them containing an instance of A, which would need a lot of memory.
So I guess public inheritance is not a good idea this time. How do I solve this?
Thanks!</p>
| c++ | [6] |
5,483,202 | 5,483,203 | How to name package of my own project? | <p>The common <a href="http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html" rel="nofollow">naming convention</a> is:</p>
<pre><code>[com/org/...].[companyName/organizationName/....].[projectName]
</code></pre>
<p>I used to give whatever package name I like for my own projects. Does any naming convention exists for personal project?</p>
| java | [1] |
3,376,221 | 3,376,222 | how to set forward slash line inside rect | <p>i want to set forward slash line inside my CGRectMake.</p>
<p>please help me out.
Thanks in advance.</p>
| iphone | [8] |
5,865,873 | 5,865,874 | pass value through url | <p>my url is some thing like this</p>
<p><a href="http://www.google.com?to=shishir&from=friend" rel="nofollow">http://www.google.com?to=shishir&from=friend</a></p>
<p>and i hv 2 textfeild from where i m getting value of to and from.</p>
<p>i need to set those values of 2 textfeiilds into the URL
to="values from textfeild" from="value from textfeild"</p>
<p>to create a somewhat called a dynamic URL.</p>
<p>how can i do it</p>
<p>quick reply is always appreciated</p>
<p>regards
shishir</p>
| iphone | [8] |
3,897,802 | 3,897,803 | Zooming lens functionality over UIImage | <p>I am working on an application that has an image and I want a lens (circular shape) that I can move over the image and the area comes under the circular lens will zoom.</p>
<p>Please provide some idea. This functionality is implemented in the app named PimpleEraser in AppStore.</p>
| iphone | [8] |
5,702,797 | 5,702,798 | Different results using atoi | <p>Could someone explain why those calls are not returning the same expected result?</p>
<pre><code>unsigned int GetDigit(const string& s, unsigned int pos)
{
// Works as intended
char c = s[pos];
return atoi(&c);
// doesn't give expected results
return atoi(&s[pos]);
return atoi(&static_cast<char>(s[pos]));
return atoi(&char(s[pos]));
}
</code></pre>
<p><strong>Remark</strong>: I'm not looking for the best way to convert a <code>char</code> to an <code>int</code>.</p>
| c++ | [6] |
2,849,944 | 2,849,945 | YouWave doesn't load apps | <p>I added default "android apps" folder but my application windows is empty. Why?
I can see "localapps.xml" in that folder.</p>
<p><strong>I tried:</strong></p>
<ul>
<li><p>Uninstall YouWave. Delete all relative things.</p></li>
<li><p>Restart. Reinstall. Restart.</p></li>
</ul>
<p>It still doesn't load apps.</p>
<p><img src="http://i.stack.imgur.com/SwYTm.png" alt="enter image description here"></p>
| android | [4] |
5,148,090 | 5,148,091 | JavaScript get file path of file on clipboard on paste event (IE) | <p>How can I use clipboardData.getData to return the file path of a file I have copied to my clipboard? (Internet Explorer)</p>
<p>Example:</p>
<p>1) user copies word document on desktop to clipboard</p>
<p>2) user right clicks on my web page and clicks "paste"</p>
<p>3) web page captures the file path of the document that was on the clipboard</p>
<p>I have tried using clipboardData.getData but it returns "null" when I paste a document</p>
| javascript | [3] |
1,320,945 | 1,320,946 | How to remove CURL time limit in PHP? | <p>I am running a rather long script that fetches the contents of a specified domain and parses the html before running a series of tests on said html. Anyway the script times out after a while. I tried putting this at the top of my page but still no luck:</p>
<pre><code>set_time_limit(0);
</code></pre>
<p>Here is the error in question:</p>
<pre><code>cURL error number:28
cURL error:Operation timed out after 10000 milliseconds with 316183 out of 6476018 bytes received
</code></pre>
| php | [2] |
553,183 | 553,184 | JavaScript Calculation | <p>calculate the difference in array using a looping structure without a sorting function</p>
| javascript | [3] |
2,600,910 | 2,600,911 | C# Sending Data over serial port between 2 PC using own Protocol | <p>i have a assignment where i need to load some data like user(pouzivatel) and some int(stav odberu) through link modem with serial port and store it in my local database. I know how to load data, send data over serial port, but i need to make it happen in a structure on the image. <a href="http://i.stack.imgur.com/L3trZ.jpg" rel="nofollow">http://i.stack.imgur.com/L3trZ.jpg</a></p>
<p>First i dial telephone number of the device with AT command, btw this is working, but i dont know now how to stop and wait for SOH+adresa objektu (SOH+some string about adress). Then send data about confirmation (ACK) and wait for new data to come. </p>
<p>The wait sequence is my biggest problem. How do i stop and wait for data being received. So please help me with that. Sorry for my bad english.</p>
| c# | [0] |
1,403,963 | 1,403,964 | Can you determine the memory footprint of a collection? | <p>I have an in-memory collection that I want to flush to disk once it has reached either a certain size (count wise) or memory footprint.</p>
<p>How can I determine how much memory a collection is using?</p>
<p>It is going to be some sort of Dictionary/Map.</p>
| java | [1] |
2,479,511 | 2,479,512 | How to prevent ENTER key to change line in web form | <p>I want to submit the form by press the ENTER key.
But it also change the line in content.
How to prevent this?</p>
<p>This is my code, but when hit ENTER, the ... run and Cursor moved to the next line:</p>
<pre><code>function postmessage(e) {
if(e) {
e.preventDefault = null || e.preventDefault;
if(e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
}
....
return false;
}
function submitmessage(e) {
if(e.keyCode == 13) {
postmessage(e);
}
return false;
}
function bindEvent(el, eventName, eventHandler) {
if (el.addEventListener){
el.addEventListener(eventName, eventHandler, false);
} else if (el.attachEvent){
el.attachEvent('on'+eventName, eventHandler);
}
}
bindEvent(text, 'keydown', submitmessage);
</code></pre>
| javascript | [3] |
3,701,007 | 3,701,008 | how to use the openadator to send the database's content to socket(netstream) | <p>I want to change the database to the netstream and send it to the sockt, but I have no idea how to change the database to netstream, what should I do</p>
<p>Thanks</p>
| java | [1] |
6,008,594 | 6,008,595 | generate pdf file from html string in asp.net with vb | <p>I want to generate pdf file from html string and that pdf file I have to attach in mail using asp.net.
I try ghtmldoc.exe, it will generate corrupted pdf file.
Can any one help me, its urgent?
waiting for you help</p>
<p>I also use iTextsharp. It generate pdf without format though I dont use css in that html page. Only data in html file is converted in pdf.</p>
<p>Thanks in advance </p>
| asp.net | [9] |
5,671,739 | 5,671,740 | Determine last item clicked | <p>I need to retrieve the DOM element that causes a focusout (blur) event from <strong>WITHIN the blur event</strong>. The following code will give me the ID of the element that lost focus, NOT the element that caused the element to lose focus. It is that second element that I need. </p>
<pre><code>.live('blur', function(e) {
var id = $(this).attr('id');
}
</code></pre>
<p>How do I get the element that caused the blur, not the element the blur is attached to? The only way I can think of is to capture the window.click event and then handle the logic I need there, but that will get tricky so I am hoping there is a way to get the DOM element from within the blur event.</p>
| jquery | [5] |
2,817,057 | 2,817,058 | how to make event in js | <pre><code>chaychu = document.getElementById('chaychu');
chaychu.onMouseOver ="chaychu.stop";
</code></pre>
<p>How to make this code works- what is wrong with it?</p>
| javascript | [3] |
1,184,188 | 1,184,189 | Touch event in UIImageView | <p>How can I determine what UIImageView I touch in the screen? Like for example, I added 10x10 tiled UIImageView in a UIView. Now in touchesBegan, how can I know the image I touch in screen? Should I use hitTest method in this implementation?</p>
<p>Thanks.</p>
| iphone | [8] |
792,315 | 792,316 | Why are these two JavaScript Date objects not the same? | <p>I`m a beginner reading a tutorial about Dates in JavaScript, and it gives this example to compare the time between two events. </p>
<p>I don't really understand why firstDate and var secondDate wouldn't be the exact same time? does the new Date object in var secondDate only take the time once doEvent is triggered, whereas firstDate takes the time with window.onload?</p>
<p>Also, why would the variable firstDate not have the "var" tag, while variable secondDate does? would that be just a typo by the author, or is it significant in some way?</p>
<pre><code>var firstDate;
window.onload=startTimer;
function startTimer(){
firstDate = new Date();
document.getElementById("date").onclick=doEvent;
}
function doEvent() {
var secondDate = new Date();
alert((secondDate - firstDate) / 1000);
}
</code></pre>
| javascript | [3] |
2,807,911 | 2,807,912 | How can i transfer files between websites with the same host? | <p>I have a server with multiple websites running on a virtual host. </p>
<p>I need to copy files from /vhost/example.com/httpdocs to /vhost/example2.com/httpdocs</p>
<p>I previously used the php exec command and ran the cp -rf script in it. But unfortunately this works only with the folder permission of 777 which is bad.</p>
<p>How can I have a directory transfer done over PHP ?</p>
| php | [2] |
5,176,720 | 5,176,721 | Web service call client code | <p>HI,
I want to call a web service from java standalone client. The constraint that is imposed that I have not to make an object of interface (of webservice to ba called). This code should pass few parameters and in return gets a boolean value. Can anyone have an idea?</p>
| java | [1] |
2,220,101 | 2,220,102 | Is there a recommended path to save files on SD Card? | <p>I see files from apps all over in the sd card so there doesn't seem to be an android standard. But when saving app related files externally, is there a recommended directory path to use or a common practice?</p>
<p>ie. (sdcard)/myapp/ or (sdcard)/apps/myapp/</p>
| android | [4] |
5,238,648 | 5,238,649 | Is there an Android utility for storing a static map? | <p>I've got a common use-case wherein a user selects one item out of many (say, on a spinner or autocomplete list), then enters the data. For example, let's say the user selects a country. Ultimately, the data I want is the country code, not the country name; but the users will want to select based on name, not code. To put it another way, user's will select "United States", but I ultimately want that to translate into "US".</p>
<p>There are a lot of countries. Is there an easy way to setup a mapping in Android to hash from the name to the code? I've thought of a few solutions, none of them are quite satisfactory in my mind:</p>
<ol>
<li><p>A database containing country/code, which I can query on.</p></li>
<li><p>Setting up all countries as strings in <code>strings.xml</code>, then retrieving the resource by name.</p></li>
<li><p>Creating a huge Map in code and using that. (This is the least satisfactory answer).</p></li>
</ol>
<p>Anyone have any cleverer solutions?</p>
| android | [4] |
3,993,238 | 3,993,239 | Jquery/Javascript hyperlink Mouse over hyperlink | <p>I have a hyperlink and whenever I do a mouse over it should show other www.abc.com page.
Eg: <code><a href="www.xyz.com">Title</a></code>, on mouse over it should show www.abc.com page. '</p>
<p>I appreciate your response. Either jquery or javascript solution is fine.</p>
<p>Thanks.</p>
| jquery | [5] |
500,765 | 500,766 | Android Seekbar - only allow change with thumb? | <p>I have a seekbar that I want to only allow changing with the thumb/handle portion. If the user taps anywhere else, I'd like that tap to be ignored.</p>
<p>Is there an inherant property to do this? If not, I already know I can set an onTouch listener and return <code>true</code> to "disable" it, but is there a way to detect when the thumb is tapped so that I can tell onTouch to return <code>false</code> in that case?</p>
| android | [4] |
5,561,641 | 5,561,642 | Any tips for improving efficiency in general? | <p>I have been doing simple programming challenges all day, trying to learn and practice. I however, always seems to fail at efficiency. Without using built_in code (such as the encode method), is there anyway that I could improve my program's efficiency (my efficiency in general)?</p>
<pre><code>import string
alph = string.ascii_lowercase
def encrypt(text):
encryption = ""
for character in text:
index = 0
shift = 0
for letter in alph:
if letter == character:
if index > 23:
shift = abs(26 - (index+3))
encryption += alph[shift]
break
shift = index + 3
encryption += alph[shift]
index += 1
return encryption
def decrypt(text):
decryption = ""
for character in text:
index = 0
shift = 0
for letter in alph:
if letter == character:
if index < 3:
shift = abs(26 - (index+3))
decryption += alph[shift]
break
shift = index - 3
decryption += alph[shift]
index += 1
return decryption
</code></pre>
| python | [7] |
1,452,756 | 1,452,757 | Simple Question about NSObject class / Retain Count | <p>If I create an NSObject class with a method that returns an NSMutableArray do I need to release the array inside the class or does the Class never retain? </p>
<p>Not sure on how to explain so here is some code:</p>
<pre><code>@implementation PointsClass
- (NSMutableArray *)pointsForLevel
{
NSMutableArray *_points = [NSMutableArray new];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(521, 279)]];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(321, 491)]];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(419, 477)]];
return _points;
}
@end
</code></pre>
<p>If i call this method from a ViewController like this:</p>
<pre><code>PointsClass *pointsClass = [PointsClass new];
NSMutableArray *points = [pointsClass pointsForLevel];
[pointsClass release];
</code></pre>
<p>Do I only need to release the pointers Array?
Has the _points array been retained at all?</p>
| iphone | [8] |
3,144,105 | 3,144,106 | how to show the progress Dialog in Android? | <p>I need to show the progress Message to the user.But i can't able to show that.Here is my code.What's wrong in my code.Guide me to do.</p>
<pre><code>public class MyProgressDemo extends Activity {
/** Called when the activity is first created. */
private Button clickBtn;
public ProgressDialog progressDialog;
Handler handler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
clickBtn = (Button) findViewById(R.id.Button01);
clickBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
progressDialog = ProgressDialog.show(MyProgressDemo.this, "",
"Please Wait");
processThread();
}
});
}
protected void processThread() {
handler.post(new Runnable() {
@Override
public void run() {
longTimeMethod();
UI();
progressDialog.dismiss();
}
});
}
private void longTimeMethod() {
try {
String strMethod = "MethodName";
String strUrl = "url";
String strResponse = WebserviceCall.Mobileaappstore(strUrl,
strMethod);
Log.d("RES", strResponse);
} catch (Exception e) {
Log.e("Exc", e.getMessage());
}
}
private void UI() {
TextView tv = new TextView(this);
tv.setText("This is new UI");
setContentView(tv);
}
</code></pre>
<p>}</p>
| android | [4] |
840,012 | 840,013 | PHP String Edit - Simple | <p>I am creating a website that pulls data from a CSV file and then displays the album artwork that matches the album and artist however I've hit a snag... the file presents artists as either a band (example: U2) or the artist (Dylan, Bob) the later does not work with the api.</p>
<p>I've tried to no success to edit the string so if it sees "," it will then rearrange the artist from <code>last, first</code> to <code>first last</code></p>
<p>Does anyone know a solution to this?</p>
<p>Cheers!</p>
| php | [2] |
5,135,318 | 5,135,319 | Array Type Declaration C# | <p>I'm declaring an array of 16bit signed integers whose elements may run into the millions. I've been declaring the array as type Long as I was thinking along the terms of element length instead of the limit of each individual element. Is it correct to declare the type of array according to element types?</p>
<p>Thanks</p>
| c# | [0] |
3,299,690 | 3,299,691 | Error Processor type not supported after project converted from Visual Studio 2008 to 2010 | <p>The solution, which retains an installer project, was recently converted from 2008 project to 2010. </p>
<p>However, attempts to run the .msi that is created returns the error </p>
<pre><code> "Processor type not supported....
</code></pre>
<p>If you run the setup.exe, it will error that "the application is designed for a x64 platform but is being installed on an intel" </p>
<p>However, the configuration of the solution, is set to to Any CPU.</p>
<p>I am finding little in the way of possible solutions and have seen where people ran into this converting from 2003 - 2005.</p>
<p>Any suggestions?</p>
| c# | [0] |
5,556,900 | 5,556,901 | The dllmain of c# dll? | <p>I want to create an dll in c# but I need to know what's the main method name called when the dll is injected into a certain process .</p>
<p>For example , the dllmain in c++ </p>
| c# | [0] |
3,376,073 | 3,376,074 | lazy load dictionary | <p>I have a dictionary called <code>fsdata</code> at module level (like a global variable). </p>
<p>The content gets read from the file system. It should load its data once on the first access. Up to now it loads the data during importing the module. This should be optimized. </p>
<p>If no code accesses <code>fsdata</code>, the content should not be read from the file system (save CPU/IO).</p>
<p>Loading should happen, if you check for the boolean value, too:</p>
<pre><code>if mymodule.fsdata:
... do_something()
</code></pre>
<p>Update: Some code already uses mymodule.fsdata. I don't want to change the other places. It should be variable, not a function. And "mymodule" needs to be a module, since it gets already used in a lot of code.</p>
| python | [7] |
4,062,476 | 4,062,477 | get selected element containing specific word on text - jquery | <p>i want to check if selected item contains specific word. Ex:</p>
<pre><code> <select name='project_type' id='type'>
<option value='1'>Interpretation - S</option>
<option value='2'>Interpretation - K</option>
<option value='5'>Editing</option>
<option value='7'>Translation</option>
</select>
</code></pre>
<p>Jquery:</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
//Hide div w/id extra
$("#work1").show();
$("#work2").hide();
// Add onclick handler to checkbox w/id selected
$("#type").live('click', function(){
// If checked
if (!$("#type:selected").text(contains('interpretation')))
{
//show the hidden div
$("#work1").show();
$("#work2").hide();
}
else if ($("#type:selected").text(contains('interpretation')))
{
//otherwise, hide it
$("#work2").show();
$("#work1").hide();
}
});
});
</script>
</code></pre>
<p>I need to get the selected element which contains 'interpretation' on text (i want all elements containing that word). I made this :<code>$("#type:selected").text(contains('interpretation'))</code> but doesn't function.
Please, anybody can help? </p>
| jquery | [5] |
4,698,299 | 4,698,300 | How can i get the Date Difference? | <p>I am calculating difference between two dates in my testapp. It works fine if I don't change the month but when i change the month it doesn't work. Please help me here is code I am using:-</p>
<pre><code>NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
//[df setDateStyle:NSDateFormatterMediumStyle];
df.dateFormat = @"YYYY-MM-DD";
NSDate *date1 = [df dateFromString:@"2011-04-30"];
NSDate *date2 = [df dateFromString:@"2011-05-03"];
NSLog(@"date1=%@",date1);
NSLog(@"date2=%@",date2);
NSTimeInterval secondsBetween = [date2 timeIntervalSinceDate:date1];
int numberOfDays = secondsBetween / 86400;
NSLog(@"There are %d days in between the two dates.", numberOfDays);
</code></pre>
<p>output is -27. I am confuse.</p>
<p>please anyone help me to fix this problem..</p>
| iphone | [8] |
2,800,651 | 2,800,652 | What's the default classpath when not specifying classpath? | <p>Wondering what will be the default classpath wne not specifying classpath option?</p>
| java | [1] |
4,734,527 | 4,734,528 | Picture blurry in android | <p>Picture looks blurry when I get it from gallery. I resize to 250w*300h using the following code: </p>
<pre><code> if(bm!=null)
{
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// recreate the new Bitmap
resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,true);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
</code></pre>
<p>How can I solve this?.</p>
| android | [4] |
2,325,038 | 2,325,039 | Send value to another page | <p>I created a table to show the search results, each row the table is a link and the links have a hidden form with a javascript to send the id to another php page, but the problem is when I click one of this links, the form only sends the first id the sql table. After all What's wrong ?</p>
<pre><code> while ($row = $stmt->fetch()) {
echo("<form id=id_form method=post action=lp_search_system_2.php>
<input type=hidden name=id value=".$row['id_np_outdoor'].">
</form>");
echo ' <tr align="left" class="simple">
<td><a href="#" onclick="id_form.submit()">' . $row['nome'] . '</a></td>
<td><a href="#" onclick="id_form.submit()">' . $row['sobrenome'] . '</a></td>
<td><a href="#" onclick="id_form.submit()">' . $row['tipo'] . '</a></td>
<td><a href="#" onclick="id_form.submit()">' . $row['estado'] . '</a></td>
<td><a href="#" onclick="id_form.submit()">' . $row['país'] . '</a></td>
</tr>
';
}
echo "</table>";
</code></pre>
| php | [2] |
2,905,989 | 2,905,990 | jQuery - Call a function in another frame | <p>jQuery - How to invoke a function defined in a frame from another frame.</p>
<p>Please see the <a href="http://jsbin.com/ajomuc/12/edit#javascript,html" rel="nofollow">jsbin link</a>. I tried the solution mentioned <a href="http://stackoverflow.com/questions/3501080/javascript-jquery-calling-function-in-another-frame">here</a>, but couldn't successfully complete it.</p>
<p><b>EDIT</b></p>
<p>To make it easier to understand, I have put the following code,</p>
<pre><code><frameset rows="25%,*">
<frame src="framea.html" id="framea"/>
<frame src="frameb.html" id="frameb"/>
</frameset>
</code></pre>
<p><b>framea.html</b></p>
<pre><code><html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function() {
var methoda = function() {
alert('in method a');
}
});
</script>
</head>
<body>
Frame 1
</body>
</html>
</code></pre>
<p><b>frameb.html</b></p>
<pre><code><html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function() {
var methodb = function() {
//$('#framea')[0].contentWindow.methoda();
}
methodb();
});
</script>
</head>
<body>
Frame 2
</body>
</html>
</code></pre>
<p>I'm looking for a jQuery way of invoking the function in another frame.</p>
| jquery | [5] |
3,296,318 | 3,296,319 | solving Tower of Hanoi recursively | <p>I know the idea behind the Tower of Hanoi and know the algorithm but I am having trouble implementing it.</p>
<pre><code>class Hanoi:
def __init__(self, n):
== code==
def move(self, src, dst):
=code for moving the disk from source to destination==
def spare(self, src, dst):
==Returns the peg which is not src and dst==
def print_pegs(self):
h = Hanoi(4)
def hanoi(n, src, dst):
if n==1:
h.move(src,dst)
else:
spare=h.spare(src,dst)
hanoi(n-1,src,spare)
hanoi(1,src,dst)
hanoi(n-1,spare,dst)
hanoi(4, 0, 2)
</code></pre>
<p>The problem i am having is I don't know how to combine the recursive definition with the class fuction to move the disks.</p>
| python | [7] |
4,514,168 | 4,514,169 | Android:How to custom the specific Seekbar like this? | <p>pic: </p>
<p><img src="http://i.stack.imgur.com/uPZfG.jpg" alt="enter image description here"></p>
<p>How should I do to custom the specific seekbar like the pic?</p>
<p>I think the point is:</p>
<ol>
<li><p>When finger is moving on the seekbar, how to present a suspended view showing the progress.</p></li>
<li><p>There are some views which layer is same level to parent view of seekbar, these views are near the seekbar, would these views overlap the suspended view?</p></li>
</ol>
| android | [4] |
4,935,053 | 4,935,054 | python syntax - meaning of self._setup | <p>I am new to python and trying to understand the following basic python syntax. Thanks in advance.</p>
<pre><code>foo = self._setup['bar']
</code></pre>
<p>Update: fixed the typo in my earlier code segment.</p>
| python | [7] |
499,533 | 499,534 | Learning Python, Python web Application stay active between requests | <p>I am a PHP programmer learning Python, when ever I get a chance.</p>
<p>I read that Python web Application stay active between requests.
Meaning that data stays in memory and is available between requests, right?</p>
<p>I am wondering how that works.</p>
<p>In php we place a cookie with a unique token, and save data in sessions.
Sessions are arrays, saved on disk or database.
Between requests the session functions, restore the correct session array based on the cookie with the unique token. That means each browser gets it's own unique session, and the session has a preset expiration time. If the user is inactive and the expiration get's triggered then the session gets purged. A new session has to be created when the user comes back.</p>
<p>My understanding is Python doesn't need this, because the application stays active between requests. </p>
<p>Doesn't each request get a unique thread in Python?</p>
<p>How does it distinguish between requests, who the requester is?</p>
<p>Is there a handling method to separate vars between users and application?</p>
<p>Lets say I have a dict saved, is this dict globally available between all requests from any browser, or only to that one browser. </p>
<p>When and how does the memory get cleared. If everything stays in the memory. What if the app is running for a couple years without a restart. There must be some kind of expiration setting or memory handling?</p>
<p>One commenter says it depends on the web app. So I am using Bottle.py to learn.</p>
| python | [7] |
249,257 | 249,258 | Changing margin-top and background image with jQuery | <p>It's me again.</p>
<p>Now I try to change the margin-top of three images. I've already tried it with this:</p>
<pre><code> function runIt() {
$("#switcher .active").delay(2000).animate({'margin-top':'-18px'},1000).delay(3000).animate({'margin-top':'6px'},1000,runIt);
$("#switcher .item").delay(3000).animate({'margin-top':'-18px'},1000).delay(4000).animate({'margin-top':'6px'},1000,runIt);
$("#switcher .item.last").delay(5000).animate({'margin-top':'-18px'},1000).delay(4000).animate({'margin-top':'6px'},1000,runIt);
}
runIt();
</code></pre>
<p>The margin is changing but it's a little bit cunfused. I'd like to get the following things. When the left images moves down the other ones are up. When the middle image moves down the left one should go up and the right is still on top. When the middle image moves up the right one should move down and the left one is still on top. At the small image is down the background with the big picture should change to the according small one.</p>
<p>Is it solvable with jQuery? Ahh, here is the link to the problem page:
<a href="http://seo.web-kiste.com" rel="nofollow">http://seo.web-kiste.com</a>, user and pass are testshop.</p>
<p>Greetz
Ron</p>
<p>P.S: How is it possible to show the jQuery snippet correctly here on SO?</p>
| jquery | [5] |
4,407,955 | 4,407,956 | android get latitude and longitude on emulator of android | <p>hi iwant to check lat long of current position in android emulator how to achive this..??it is possible to get current position latitude and longitude on emulator???if yes then what setting is required in emulator?</p>
<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener ll = new Mylocationlistener();
boolean isGPS = lm
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// If GPS is not enable then it will be on
if(!isGPS)
{
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
}
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
}
private class Mylocationlistener implements LocationListener {
@Override
public void onLocationChanged(Location location) {
if (location != null) {
Log.d("LOCATION CHANGED", location.getLatitude() + "");
Log.d("LOCATION CHANGED", location.getLongitude() + "");
float speed = location.getSpeed();
double altitude = location.getAltitude();
Toast.makeText(currentlatlong.this,"Latitude = "+
location.getLatitude() + "" +"Longitude = "+ location.getLongitude()+"Altitude = "+altitude+"Speed = "+speed,
Toast.LENGTH_LONG).show();
}
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
</code></pre>
| android | [4] |
2,589,811 | 2,589,812 | Need help making this small javascript 'game' | <p>Trying to use javascript to make a game/script that:<br>
- each number from 0-20 equal a specific word. Ex: 0=saw, 1=tie, 2=noah.<br>
- a number pops up on the screen and the user needs to type in the word that = that number.<br>
- Then the program says if I was correct or not and adds to my points. </p>
| javascript | [3] |
1,440,882 | 1,440,883 | How can I pass up an exception | <p>How can I handle an expected exception?</p>
<p>I have code in my MVC controller that calls the following:</p>
<pre><code>u.RowKey == new SimplerAES().Dec(HttpServerUtility.UrlTokenDecode(id)));
</code></pre>
<p>In my other SimplerAES class:</p>
<pre><code> public string Dec(byte[] encrypted)
{
return encoder.GetString(Decrypt(encrypted));
}
public byte[] Decrypt(byte[] buffer)
{
try {
MemoryStream decryptStream = new MemoryStream();
using (CryptoStream cs = new CryptoStream(decryptStream, decryptor, CryptoStreamMode.Write))
{
cs.Write(buffer, 0, buffer.Length);
}
return decryptStream.ToArray();
} catch(CryptographicException e){
//... do something with it ...
return null; // I put the return null here as I got a syntax message saying
// not all code returns
}
}
</code></pre>
<p>Can someone please explain how I get the message that decrypt failed all the way up
to the point where I first try to get the RowKey. Do I have to put u.RowKey within
a try catch as well?</p>
| c# | [0] |
3,281,544 | 3,281,545 | handle info from select box | <p>i have the following code:</p>
<pre><code><form name="votos" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php $categorias=mysql_query("SELECT * FROM categoria") or die (mysql_error()); ?>
<?php while($cat=mysql_fetch_array($categorias)){
echo "<h5>".$cat[0]." - ".$cat[1]."</h5>";
$nomeados=mysql_query("SELECT * FROM nomeados WHERE cod_categoria='$cat[0]'") or die(mysql_error());
?>
<div class="styled-select">
<select name="voto">
<option value=""></option>
<?php
while($nom=mysql_fetch_array($nomeados)){
$nomes=mysql_fetch_array(mysql_query("SELECT nome FROM logins WHERE cod_login='$nom[0]'")) or die (mysql_error());
?>
<option value="<?php echo $nom[0]; ?>"><?php echo $nomes[0]; ?></option>
<?php
}
?></select></div>
<?php }
?>
<input type="submit" class="botao" value="" name="submit" />
</form>
</code></pre>
<p>the code shows all the categories with the nomenies in a select box.
the thing is that the select box goes to post with the same name. I don't know how to get the information from all of the select boxes. Maybe with a foreach?
Thank you for the help</p>
| php | [2] |
2,637,622 | 2,637,623 | I can't update my database through textbox | <p>I can't update my database through textbox. In the database <code>prt</code> is declared as a char datatype. It didn't show any error message.</p>
<p>My coding is...</p>
<pre><code>SqlCommand cmdup= new SqlCommand("UPDATE [port1] SET [prt1]=@prt1 WHERE [no]= 1",cn);
cmdup.Parameters.Add("@prt1", TextBox1.Text);
cmdup.ExecuteNonQuery();
</code></pre>
| asp.net | [9] |
4,464,622 | 4,464,623 | JS element event, refresh the element | <p>If for example I have the next event:</p>
<pre><code>document.getElementById('TagSearchInput').onkeyup = function(e)
{
//Code...
}
</code></pre>
<p>Inside the event, there is a condition where I recreate the element (<code>TagSearchInput</code>). How can I refresh the event selector, from within the event?</p>
| javascript | [3] |
4,132,325 | 4,132,326 | Python code for calculating number of an alphabet | <p>I need to find the number of an alphabet in the range of alphabets ie a = 1, b=2 , c =3....
So if i get a then the returning value should be 1</p>
<p>Is there a shorter method provided in python(inbuilt) to find it other than declaring a dictionary of 26 alphabets with their respected values. </p>
<p>Please help if you know of such a function.....</p>
| python | [7] |
3,425,257 | 3,425,258 | SimpleDateFormat and 2013-01-17T00:00:00-06:00 | <p>What would be the correct format to use in SimpleDateFormat to parse incoming dates that look like this: "2013-01-17T00:00:00-06:00"?</p>
| java | [1] |
4,794,092 | 4,794,093 | Keep data from jquery getjson | <p>I have this code:</p>
<pre><code>$.getJSON(fupurl, function(data) {
ups = data[url+forup].shares;
console.log(ups);
});
$.getJSON(fdownurl, function(data) {
downs = data[url+fordown].shares;
if(!downs)
downs = 0;
console.log(downs);
});
console.log(ups);
</code></pre>
<p>The above code it's inside of a function and variables downs and ups are defined before it.
I want to keep data inside those two variables to use it later.</p>
| jquery | [5] |
5,729,759 | 5,729,760 | page.opener.location.reload with #anchor | <p>I have a dynamic class registration page that provides registration links that open popup forms. It's possible that the dynamic data may have changed between the time when it was loaded and the popup form is submitted. In that case I want to provide a link that will reload the parent window (to update class offerings) and close the popup, so I used the following.</p>
<pre><code> onclick="window.opener.location.reload();window.close();"
</code></pre>
<p>So that works fine except I'd like the reloaded parent page to return to the particular class listing via an anchor tag. Unfortunately, the code as written reloads the page and remains at the top of the page - even though the anchor tag is listed in the URL.</p>
<p>Is this doable?</p>
<p>Thank you for your kind consideration.</p>
| javascript | [3] |
542,644 | 542,645 | combining javascript files in asp.net | <p>I have several javascript files and I'd like to combine them into one file but only when the page is rendered, and still keep my files separate because it's easier to code with multiple files than one giant one.</p>
<p>How do I do this? I saw some tutorials on how to do it but they're dated. I'm using VS 2012 and I was wondering if there's a newer way.</p>
<p>Thanks.</p>
| asp.net | [9] |
2,668,796 | 2,668,797 | know of a good tutorial for posting status updates to facebook? | <p>I'm looking for a tutorial for updating Facebook status in PHP. Any suggestions?</p>
| php | [2] |
3,200,595 | 3,200,596 | Do you have to pay for the iPhone SDK for each developer? | <p>Is there a link to how I can get the 3.0 SDK without having to pay a second time? I'm joining another guy at my company on a project.</p>
| iphone | [8] |
833,681 | 833,682 | how to navigate from a menu to tab activity | <p>I have a tab application which contains four tabs for ex home, contacts, friends, office, send message. Also my app contains a menu at botton which is invoked when the user clicks on the menu button on device, the menu again consists of home, logout and send message, Does any one know to navigate from menu to the same tab</p>
<p>Thanks
Max</p>
| android | [4] |
2,242,100 | 2,242,101 | Can we ON or OFF the device programatically? | <p><em>I know there is a way where we can reboot the device. And it shows immediate result.</em></p>
<p>But my need is as :- </p>
<p>I want that when I will be in my class-room my phone automatically goes to OFF. (Lets say at 2:00 PM), and when I will end my class, my phone will automatically ON (Lets say at 5:00 PM).</p>
<p>So I am looking for the ways where I can ON/OFF the device automatically. </p>
<p><em><strong>Is this possible? If yes how can I do it?</em></strong> </p>
| android | [4] |
3,444,808 | 3,444,809 | What are the language features of C# that distinguish good code from great code? | <p>Until recently I didnt <em>properly</em> understand the power of interfaces. Now that I do and have used them properly I noticed the quality of my code has increased significantly. </p>
<p>What other language features (correctly implemented) are essential for writing great code? </p>
| c# | [0] |
1,034,543 | 1,034,544 | howto sort an array with objects by property value length? | <p>In javascript I have the following array with objects:</p>
<pre><code>var defaultSanitizer = [
{"word": "large", "replaceWith":"L"},
{"word": "os", "replaceWith":"One Size"},
{"word": "xlarge", "replaceWith":"XL"},
{"word": "o/s", "replaceWith":"One Size"},
{"word": "medium", "replaceWith":"M"}
...
];
</code></pre>
<p>(in reality this array is much larger)</p>
<p>I want to make a function so I can order the array by the length of a property value e.g. the property "word" of the objects.</p>
<p>Something like this:</p>
<pre><code>function sortArrByPropLengthAscending(arr, property) {
var sortedArr = [];
//some code
return sortedArr;
}
</code></pre>
<p>If I were to run the function sortArrByPropLengthAscending(defaultSanitizer, "word") it should return me a sorted array that looks like this:</p>
<pre><code>sortedArr = [
{"word": "os", "replaceWith":"One Size"},
{"word": "o/s", "replaceWith":"One Size"},
{"word": "large", "replaceWith":"L"},
{"word": "xlarge", "replaceWith":"XL"},
{"word": "medium", "replaceWith":"M"}
...
]
</code></pre>
<p>How would you do this?</p>
| javascript | [3] |
4,972,678 | 4,972,679 | How to clear the activity stack in android? | <p>I'm having a requirement where i can press a logout button from any activity in the application,the thing is when I press the logout button I need to get the <code>login</code> screen without showing the previous activities. I am using:</p>
<pre><code>intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP )
</code></pre>
<p>I am starting the activity like this:</p>
<pre><code>public void onClick(View v) {
try
{
Intent intent = new Intent(getContext(), Login.class);
v.getRootView().getContext().startActivity(intent);
intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP );
removeSessionFiles();
//startActivity (new Intent(getApplicationContext(), Activity1.class));
}
catch (Exception e)
{
String str = e.toString();
}
}
</code></pre>
<p>I get to the <code>login</code> screen when I press the <code>logout</code> button, but when I press <code>back</code> button on the device it is showing the previous activities - I should go to the Android home screen when I press back button in the <code>login</code> screen. Please can you suggest a solution for this?</p>
| android | [4] |
5,041,767 | 5,041,768 | How do you return the actual matched results of a php regex | <p>I have a string and need to get a specific chunk of text out of it. That chunk is always going to be wrapped in a known quantity of of other text, so its easy to use a regular expression to find the desired chunk via its surroundings. In php, what is the best way to do this? I've read through the man pages of various functions that deal with regular expressions, but almost all of them seem to return the number of matches, but not the match itself.</p>
<p>My goal is to get the results of the match, then use preg_replace to get rid of the known quantity and leave me with the desired text. </p>
| php | [2] |
2,780,563 | 2,780,564 | how we hide and show table on radio bullton clicking | <p>I have two tables. I want to show one table when the first radio button is clicked. Then show a different table when I click on the second radio button.</p>
| javascript | [3] |
3,628,230 | 3,628,231 | how to load image from web? | <p>hello all i have image url getting from web and now i want to display that in may imageview.</p>
<p>pls helm me out.</p>
<p>Thanks In Advance.</p>
| android | [4] |
1,086,014 | 1,086,015 | how can i add another object to an already defined IQueryable object? | <p>I have IQueryable Products.
now i want to add new product to this IQueryable object.
so how do i do this?</p>
| c# | [0] |
4,172,043 | 4,172,044 | Event when checkbox is checked by removeAttr('checked') | <p>I have a function that unchecks a checkbox by doing this:</p>
<pre><code>$('[name = destination]').removeAttr('checked');
</code></pre>
<p>Now I want an event to fire on the checkbox, the same as if I had checked it manually. Is there an event for this?</p>
<p>I've tried change and click. Both work when I check/uncheck the box manually, but not when it's done like this.</p>
| jquery | [5] |
2,040,667 | 2,040,668 | can we convert value type to referance type in c# or .net supported language | <p>hi can we convert value type to referance type in c# or .net supported language
like int is value type ...so can we convert it referance type</p>
| c# | [0] |
2,087,147 | 2,087,148 | Get Uri of All Images in SDCard in Android | <p>I want to get <strong>URI</strong> or <strong>Path</strong> of all the <strong>Images</strong> of <strong>SDCARD</strong>.</p>
<p>How I can achieve this ?</p>
<p>Thanks.</p>
| android | [4] |
2,405,671 | 2,405,672 | PHP: Erratic behaviour of functions? | <p>What on earth is PHP doing here?</p>
<p>This first line works perfectly, but when I try to check whether the return of the <code>parse_url</code> is empty or not, my whole execution is stopped and the infamous White screen appears:</p>
<p><strong>Working:</strong></p>
<pre><code>$subFolderCheck = ( strlen( parse_url('http://www.example.com', PHP_URL_PATH)) >1 ? true : false);
</code></pre>
<p><strong>Making my script go bananas:</strong></p>
<pre><code>$subFolderCheck = ( empty( parse_url('http://www.example.com', PHP_URL_PATH)) ? true : false);
</code></pre>
| php | [2] |
939,868 | 939,869 | OpenSubKey not working for Registry value I need | <p>I have SQL Server installed.</p>
<p>In the registry, the key <strong>MSSQLServer</strong> at *HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft* looks like this:
<img src="http://i.stack.imgur.com/Ena08.jpg" alt="enter image description here"></p>
<p>All of the following lines of code return values from the registry:</p>
<pre><code> var mainKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("MSSQLServer");
var subKey1 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("MSSQLServer").OpenSubKey("Client");
var subKey2 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("MSSQLServer").OpenSubKey("MSSQLServer").OpenSubKey("CurrentVersion");
</code></pre>
<p>However, this one does not:</p>
<pre><code>var subKey3 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("MSSQLServer").OpenSubKey("Setup");
</code></pre>
<p>"Setup" looks to be the same type of value as the other keys. Any thoughts why this command returns null?</p>
| c# | [0] |
2,098,560 | 2,098,561 | getting checked checkbox display name | <p>I have a set of checkboxes:</p>
<pre><code><input type="checkbox" value="111" name="checkbox" id="1">india
<input type="checkbox" value="121" name="checkbox" id="21">pak
<input type="checkbox" value="131" name="checkbox" id="31">china
<!-- ... -->
<input type="checkbox" value="141" name="checkbox" id="10">srilanka
</code></pre>
<p>I want to get the display name of checked check boxes like if india , pak ... I tried with following code which gives me value 111,121, ....</p>
<pre><code> field= document.form.checkbox;
for(var i=0; i < field.length; i++)
{
if(document.getElementById(i).checked==true)
Cities+=document.classifiedForm.checkbox[i].value + ",";
}
</code></pre>
| javascript | [3] |
3,554,288 | 3,554,289 | nivo slider pause on last slide | <p>Client has 5 sliders that will switch over at random times, but pause for two or three seconds when the last one has changed over. There are only 2 images per "slider"</p>
<p>I figured I would use nivo slider as it looked promising.</p>
<p>I have set up the different divs and sizing for each slider and got positioning right, but I'm not sure what i'm doing with the Jquery.</p>
<p>I've tried other effects that people have posted up on here, but no help.
one example...</p>
<pre><code>$(window).load(function(){
$('#slider').nivoSlider({
animSpeed: 500,
pauseTime: 4000,
effect : 'fade',
directionNav : false,
controlNav: false,
});
jQuery('#slider').data('nivoslider').stop();
setTimeout("jQuery(#slider').data('nivoslider').start()",5000);
});
</code></pre>
<p>This is how I'm thinking it should work.</p>
<p>slider1 - switch after .5 seconds (pause)
slider 4 - switch after .75 seconds (pause)
slider 3 - switch after 1 second (pause)
slider 2 - switch after 1.25 seconds (pause)
slider 5 - switch after 1.5 seconds (pause)
They all start random switch again after 2 or 3 second pause.</p>
<p>Sorry if this is long, hope somebody can help</p>
<p>Thanks</p>
<p>Vic</p>
| jquery | [5] |
259,854 | 259,855 | Android Support Library is not recognized | <p>I'm having an issue with the Android Support Library. I've downloaded and it shows up in my SDK (under Extras). However, when I try to import <code>android.support.v4.content.CursorLoader</code> to an Activity it gives an error: </p>
<blockquote>
<p>The import android.support cannot be resolved</p>
</blockquote>
<p>How can I solve this issue?</p>
| android | [4] |
255,384 | 255,385 | Rewrite asp.net response before it gets cached with dynamicCompressionBeforeCache | <p>My ASP.NET library installs a response filter to parse and alter the HTML output of pages. This is working until the following is enabled in web.config:</p>
<pre><code><system.webServer>
<urlCompression doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
</system.webServer>
</code></pre>
<p>My response filter is still called, but is passed what seems to be compressed data, not the original HTML.</p>
<p>How can I ensure my rewriting occurs before the page is stored in the output cache?</p>
<p>Setting dynamicCompressionBeforeCache to false is not an option, since this library is designed to be used in other people's web applications who may have good reason to enable compression.</p>
| asp.net | [9] |
3,134,718 | 3,134,719 | Autopostback textbox not retaining the values across postbacks with nested form tags | <p>Here the textbox with id as "a" retains the value after postbacks while textbox with id as "b" not retains the value.Why this happens? </p>
<pre><code><form id="form1" runat="server">
<div>
<asp:TextBox ID="a" runat="server" AutoPostBack="true" ></asp:TextBox>
<form action="javascript:myFunc();">
<p>
<input type="text" id="city-field" name="city" " />
<input type="submit" value="Find" /></p>
</form>
</div>
<asp:TextBox ID="b" runat="server" AutoPostBack="true" ></asp:TextBox>
</form>
</code></pre>
| asp.net | [9] |
5,545,244 | 5,545,245 | How can I detect whether a browser window is focused or not? | <p>My page should make notification sounds only when the window is in the background. I can track the <code>window.onfocus</code> and <code>window.onblur</code> events to notice when the focus state changes. However, I don't know whether the window will load focused or not, since it might load in a background tab, for instance.</p>
<p>How do I decide whether to play sounds or not before I get an <code>onfocus</code>/<code>onblur</code> event?</p>
| javascript | [3] |
1,988,054 | 1,988,055 | jQuery effect repeating | <p>I created a menu on my site which has a repeating problem.</p>
<p>Here is example of the problem <a href="http://www.screenr.com/qc78" rel="nofollow">http://www.screenr.com/qc78</a> and here is my <code>.js</code> file <a href="https://gist.github.com/2003403" rel="nofollow">https://gist.github.com/2003403</a></p>
<p>Does someone know better solution for my <code>.js</code> code?</p>
| jquery | [5] |
5,243,251 | 5,243,252 | Adding a column dynamically in to a grid view using linq | <p>i have a grid view and i bind data s in to the grid view using the linq query.i need to add a separate column to that grid view how can i add it.now i used the query shown below</p>
<pre><code>DataTable dt = Common.dc.TblIssueDetails.Where(id => id.AssetId ==
LeAsset.EditValue.getInteger()).Select(id => new
{
Select=false,
id.TblStoreStock.TblStock.TblItem.ItemName,
id.TblIssueMaster.IssueDate,
Quantity=0
}).getDataTable();
</code></pre>
<p>give me a repaly pleaseeeeee</p>
| asp.net | [9] |
2,229,820 | 2,229,821 | 'Google Docs like ' functionality in python | <p>What I have is a UI which allows users to enter info about, say toys.<br>
Now the UI is accessible to multiple users at the same time and the info stored by the user gets stored in a file, which may cause accidental overwriting of toy info.<br>
The file will contain info of multiple toys but same toy info can not show up again which is quite possible in multi user environment.<br>
I am fairly new to web dev. and python too.<br>
What should be my first steps to resolve this problem?<br></p>
<p>Any help is highly appreciated.<br>
Thanks</p>
| python | [7] |
380,092 | 380,093 | Adding elements to a C# array | <p>I would like to programmatically add or remove some elements to a string array in C#, but still keeping the items I had before, a bit like the VB function <a href="http://msdn.microsoft.com/en-us/library/w8k3cys2%28v=vs.71%29.aspx" rel="nofollow">ReDim Preserve</a>.</p>
| c# | [0] |
4,964,294 | 4,964,295 | Does JavaScript recreates functions which are after return | <p>Following code:</p>
<pre><code>a = function(b) {
return alfa() + b;
function alfa() {
return 7;
}
}
console.log(a(4));
console.log(a(5));
</code></pre>
<p>Does function alfa() is created on each call to a()?</p>
| javascript | [3] |
888,030 | 888,031 | PHP - count specific post variables | <p>I am having several input fields with same name (there are several others input fields but this ones are important):</p>
<pre><code><input type=text name=title1 id=title1/>
<input type=text name=title2 id=title2/>
<input type=text name=title3 id=title3/>...
</code></pre>
<p>How can I count them (just input with name titlex)? </p>
| php | [2] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.