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 |
|---|---|---|---|---|---|
936,631 | 936,632 | Indexing State Changes in Python nparray | <p>I have steps taken from walkers and increases in pressure for each step. I want to determine the start and stop of each step and the time it occurred. This code works great so far to determine when the pressure rises or falls below a threshold (foot lands and lifts off). Now I have true/false states in the above_threshold array. </p>
<pre><code>data = np.loadtxt('junk.csv',delimiter=',',skiprows=1)
Fz = data
sigma = 5
threshold = 30
above_threshold = gaussian_filter(Fz, sigma=sigma) > threshold
</code></pre>
<p>I am new to Python, and am wondering if there is an efficient way to build a new array that tells me the index of when the state change from false to true (for the first step start), then true to false (for the end of the first step). And, for the start and stops for the next steps that follow.</p>
<p>Thanks in advance,
Scott</p>
| python | [7] |
5,387,585 | 5,387,586 | Login encrypt password to compare | <p>Updated code still not working?</p>
<pre><code><?php
$host="localhost";
$username="root";
$password="power1";
$db_name="members";
$tbl_name="users";
string sha1 ( string $Password [, bool $raw_output = false ] )
$link = mysql_connect("$host", "$username", "$password")or die("cannot connect. Please contact us");
mysql_select_db("$db_name")or die("cannot select DB. Please contact us");
$Email=$_POST['Email'];
$Password=$_POST['Password'];
$Email = stripslashes($Email);
$Password = stripslashes($Password);
$Email = mysql_real_escape_string($Email);
$Password = mysql_real_escape_string($Password);
$sql="SELECT * FROM $tbl_name WHERE Email='$Email' AND password ='$Password'";
$result=mysql_query($sql, $link) or die ('Unable to run query:'.mysql_error());
$count=mysql_num_rows($result);
if($count==1){
session_register("Email");
session_register("Password");
header("location:login_success.php");
}
else {
echo "Wrong Email or Password. Please Wait.<meta http-equiv='REFRESH' content='1;url=login.php'>";
}
?>
</code></pre>
| php | [2] |
1,334,997 | 1,334,998 | Retriving unique set of elements from different Sets | <p>What method can be used to return a set of elements that can be found only in set a or set b,
but not in both Sets ?</p>
| java | [1] |
3,652,692 | 3,652,693 | C# String Comparison | <p>I am making an application i have to compare two strings for a specific word</p>
<p>for eg </p>
<pre><code>string a="abc";
string b="abcController";
</code></pre>
<p>I have to compare <code>a</code> and <code>b</code> to match abc</p>
<p>I am using <code>Equals</code> or <code>CompareTo</code> but these are not working </p>
| c# | [0] |
1,711,330 | 1,711,331 | jquery status box pop up and hide after a short while | <p>sorry if I did show you the code because I am not sure how to implement it, I am try to develop a status box using jquery, so I have a button so when the button get clicked, the status box will pop up show message like "button is clicked" and disappear after 10 seconds, but I am not sure how to do it, any one could help me, thanks a lot.
I think the code might be like:</p>
<pre><code> <input type="button" id="status" value = "show status box"/>
<script>
$("#status").click(function(){
//not sure what should be inisde?
}
</script>
</code></pre>
<p>thanks for the help! </p>
| jquery | [5] |
2,271,565 | 2,271,566 | Create comma-delimited string | <p>I'm looking to find a neat way to create a comma-delimited string from an array. This is how I'm doing it now...</p>
<pre><code>for(i=0;i<10;i++)
{
str = str + ',' + arr[i];
}
str=str.substring(1)
return str;
</code></pre>
<p>... but it feels a bit untidy.</p>
| javascript | [3] |
5,306,287 | 5,306,288 | How to find in which container tree resides | <p>I have dhtmlx tree. In one div i placed that tree. I have multiple divs and in each div I have one tree which will generate dynamically. When i click on the any node of tree i can get the id of that node. Now how to find in which div that tree resides by using jquery. </p>
| jquery | [5] |
3,495,041 | 3,495,042 | How to print one character at a time on one line? | <p>How would one print the string "hello world" onto one line, but one character at a time so that there is a delay between the printing of each letter? My solutions have either resulted in one character per line, or a delayed printing of the entire string at once. This is the closest I've gotten. </p>
<pre><code>import time
string = 'hello world'
for char in string:
print char
time.sleep(.25)
</code></pre>
| python | [7] |
3,411,315 | 3,411,316 | Create Script Tag Within Javascript and Call Function Right After | <p>I have some code where I am trying to include a script file and then call a function inside the script file. The code is:</p>
<pre><code>function includeJS(p_file) {
var v_js = document.createElement('script');
v_js.type = 'text/javascript';
v_js.src = p_file;
document.getElementsByTagName('head')[0].appendChild(v_js);
}
function checkFlash(){
includeJS('/scripts/swfobject.js');
var playerVersion = swfobject.getFlashPlayerVersion();
return playerVersion.major;
}
alert(checkFlash());
</code></pre>
<p>The problem is it is failing at checkFlash() where it tries to get the player version. I checked firebug and it shows the script is loaded and its reading the file correct, so its not a path issue.</p>
<p>I thought that maybe it was a delay issue in the includeJS function, but when I would that code in before the alert without it being a function, it still gives the same problem. </p>
<p>Any ideas on how I would accomplish something like this?</p>
<p>Thanks.</p>
| javascript | [3] |
334,371 | 334,372 | after deploy the site need exact domain name with jquery | <p>I am going to deploy my site and I need to get the domain name after deploying the site.
It is very simple if the address was <code>www.domain.com</code> then the domain name is <code>domain.com</code>
but if the client deploys the site as a sub domain like <code>subdomain.domain.com</code> then how can I get exact domain name? I have already get host name with</p>
<pre><code>window.location.hostname
</code></pre>
<p>I need exact domain name after deploying the site to set a cookie
I don't know what domain the client will be use</p>
<ul>
<li>option 1 www.domain.com</li>
<li>option 2 domain.com</li>
<li>option 3 subdomain.domain.com</li>
<li>option 4 subdomain.domain.com.us</li>
<li>option 5 domain.com.us
etc</li>
</ul>
<p>What function do I write to apply for all conditions and get exact domain name
in jQuery?</p>
| jquery | [5] |
343,565 | 343,566 | Remove restore button from maximized tabs in .NEt | <p>i am developing an application in C#.Net in which i have implemented mdi.all mdi childs are opened in maximized state in tabs. i want tabs to have only the "close" button. but whenever a child is opened minimize ad restore buttons appear with it.. i CAN disable the minimize button but what to do with RESTORE button. i haven't found any way to tackle this problem. Can anyony please help me </p>
| c# | [0] |
5,088,817 | 5,088,818 | Android SDK platforms between Linux and Windows | <p>I'm dual booting Windows 7 and Ubuntu 12.04 Linux. Can I just copy my existing Android SDK platforms from my windows partition to the linux partition? Or are the platforms different? I don't want to waste time redownloading all the packages again. </p>
| android | [4] |
3,705,533 | 3,705,534 | I want my SlideToggle() Slow or add the Time | <p>Hello I want my animate SlideToggle() it slide up and slow or I can put the time, when I click the link please help. please See Code Below. I try to put the .slideToggle("slow") but dont' work.</p>
<pre><code>$(function() {
$('#bottom_menu li a').click(function(e) {
e.preventDefault();
animateSlider(this.hash);
});
function animateSlider(hash) {
if (!$('#container div.open').length) {
if (hash == '#about') {
openPopup(hash);
}
if (hash == '#contact') {
openPopup(hash);
}
} else {
if (hash == '#about') {
openAndClose(hash)
}
if (hash == '#contact') {
openAndClose(hash)
}
}
}
function openPopup(hash) {
$(hash + '_popup').slideToggle().addClass('open');
}
function openAndClose(hash) {
if ($(hash + '_popup').hasClass('open')) {
$($(hash + '_popup')).slideToggle().removeClass();
} else {
$('#container div.open').slideToggle().removeClass();
$(hash + '_popup').slideToggle().addClass('open');
}
}
});
</code></pre>
| jquery | [5] |
2,091,518 | 2,091,519 | HOw can i remove the uiview background black color | <p>I am developing one application.In that i set the one image as background for uiview like below </p>
<pre><code>projectview=[[UIView alloc]initWithFrame:CGRectMake(200, 0, 640, 700)];
UIGraphicsBeginImageContext(projectview.frame.size);
[[UIImage imageNamed:@"board.png"] drawInRect:projectview.bounds];
UIImage *lblviewimage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
projectview.backgroundColor=[UIColor colorWithPatternImage:lblviewimage];
[self.view addSubview:projectview];
</code></pre>
<p>It's working fine in simulator.But when i run this one in device,that image is added to uiview and the remaining space other than that image will be appeared as black.So please tell me how can i remove that black color.</p>
| iphone | [8] |
4,771,843 | 4,771,844 | Web Site Thumbnail? | <p>I posted a link of my website on facebook, but it uses an image for a thumbnail that
I don't want(it is an image inside my website). How can I govern which thumbnail is used for my web site on any web page(facebook etc) ?</p>
<p>Thank You</p>
| asp.net | [9] |
2,459,736 | 2,459,737 | Set permissions in binary | <p>I saw in school a system that set permissions using binary string.</p>
<p>Let's say 101001 = 41</p>
<p>So : </p>
<ul>
<li>1 can be permission to page 1</li>
<li>2 can be permission to page 2</li>
<li>4 can be permission to page 3</li>
<li>8 can be permission to page 4</li>
<li>16 can be permission to page 5</li>
<li>32 can be permission to page 6</li>
</ul>
<p>So let's say I got the above binary string (101001). I have access to page 1, 4 and 6.</p>
<p>How can I do this in PHP ? Let's say I got a field in MySQL named <code>perms</code> stored in dec so 101001 will be 41. <strong>How can I know that 41 is equal to 1, 8 and 32 in PHP ?</strong></p>
<p>Thanks.</p>
| php | [2] |
80,571 | 80,572 | how to create an application that creates the resource files dynamically reading from an excel sheet using c#? | <p>My requirement is create an application that creates the resource files dynamically reading from an excel sheet . </p>
<p>In that i have done with reading values from excel. and I know how to create resource file dynamically .But I am not getting any idea how to create resource file dynamically by reading values from excel sheet .</p>
<p>In my project localization concept is there. We need to create multiple resource files from the excel sheet.</p>
| c# | [0] |
58,288 | 58,289 | More Pythonic conversion to binary? | <p>Here is a contrived example of how a lot of our classes return binary representations (to be read by C++) of themselves.</p>
<pre><code>def to_binary(self):
'Return the binary representation as a string.'
data = []
# Binary version number.
data.append(struct.pack('<I', [2]))
# Image size.
data.append(struct.pack('<II', *self.image.size))
# Attribute count.
data.append(struct.pack('<I', len(self.attributes)))
# Attributes.
for attribute in self.attributes:
# Id.
data.append(struct.pack('<I', attribute.id))
# Type.
data.append(struct.pack('<H', attribute.type))
# Extra Type.
if attribute.type == 0:
data.append(struct.pack('<I', attribute.typeEx))
return ''.join(data)
</code></pre>
<p>What I dislike:</p>
<ul>
<li>Every line starts with <code>data.append(struct.pack(</code>, distracting from the unique part of the line.</li>
<li>The byte order (<code>'<'</code>) is repeated over and over again.</li>
<li>You have to remember to return the boilerplate <code>''.join(data)</code>.</li>
</ul>
<p>What I like:</p>
<ul>
<li>The format specifiers appear near the attribute name. E.g., it's easy to see that <code>self.image.size</code> is written out as two unsigned ints.</li>
<li>The lines are (mostly) independent. E.g., To remove the Id field from an 'attribute', you don't have to touch more than one line of code.</li>
</ul>
<p>Is there a more readable/pythonic way to do this?</p>
| python | [7] |
5,372,766 | 5,372,767 | getting data from edittext placed in listview | <p>I created a list with textview & edittext using holder... it looks like</p>
<pre><code> Textview Edittext
---------------------------------
Textview Edittext
---------------------------------
Textview Edittext
---------------------------------
</code></pre>
<p>but I cant get the data from each every Edittext...
can any one assist me.. how to achieve it... assist with sample code...</p>
| android | [4] |
2,367,219 | 2,367,220 | How can I set the value of C# Custom Attibutes? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2160476/how-to-set-attributes-values-using-reflection">How to set attributes values using reflection</a> </p>
</blockquote>
<p>How can I set the value of custom attribute, this custom attribute is used in the member of class object. Consider below member with its attribute.</p>
<pre><code>[DataMember]
[Decorater(false, false)]
[DecroraterUpdt(false, false)]
[PricingSchema(false, false)]
public string UniqueID
{
get { return uniqueId; }
set { uniqueId = value; }
}
</code></pre>
<p>I want to set Pricing schema attribute's value. </p>
<p>Thanks</p>
| c# | [0] |
626,809 | 626,810 | Err sequence number mismatch while i receive data from Recv() in socket programming C++? | <p>Sending some data through socket programming and waiting for the acknowledgement through receiving the data from the socket. But i receive lot of <strong>Err sequence number mismatch</strong>. I am new to C++ and really don't know what does it mean, can anyone please describe why this is coming? And how do i know that i have received everything from the acknowlegment?</p>
| c++ | [6] |
1,375,062 | 1,375,063 | Can I use Dependency Injection for All Dependencies? | <p>All my PHP is Object Orinted and I want to use dependency injection for all dependencies ( i.e. classes that need other classes to work ). Is this O.K?</p>
<p>I think I posted to much information to be readable...but if you want specifics there are <a href="http://stackoverflow.com/questions/10237028/code-library-design-dependency-injection-vs-making-maps-is-dependency-inj">here.</a></p>
<p>Also, if this does not over-complicate the problem, can I use the Factory Pattern for all dependency injection? - Specifics are in the link above.</p>
| php | [2] |
659,674 | 659,675 | Response Code From Server | <pre><code>public static boolean testConnection() {
try {
// TODO add your handling code here:
System.setProperty("http.proxyHost", "some proxy name");
System.setProperty("http.proxyPort", "some port");
URL a = new URL("http://" + Variables.serverName + ":" + Variables.serverPort + "/DeviceCloud");
urlString = a.toExternalForm()+"/";
System.out.println(urlString);
System.out.println("http://" + Variables.serverName + ":" + Variables.serverPort + "/DeviceCloud");
URLConnection conn = a.openConnection();
int respCode = ((HttpURLConnection) conn).getResponseCode();
System.out.println(respCode);
if (respCode >= 500) {
return false;
} else {
return true;
}
} catch (Exception ex) {
return false;
}
}
</code></pre>
<p>It works fine if server reachable. But if server not reachable means its taking long time.
Its not showing any output.But actually the server machine is pinging from client also.
what could be right solution to get the status</p>
| java | [1] |
777,263 | 777,264 | Java array initialization | <p>What happens when we print reference variable of array initialization?</p>
<pre><code>int[] it=new int[10];
sop(it);
</code></pre>
<p>What is the result? </p>
| java | [1] |
1,166,828 | 1,166,829 | can cURL operations be inside the API server side code? | <p>I see an example server side API that has cURL operations, I thought cURL is supposedly client side request. The following class API is the server side code but inherited from newtwork class which has a bunch of uCurls operations.</p>
<blockquote>
<p>class Api extends Api\Network</p>
<pre><code>abstract class Network {
const GET = 'GET';
const POST = 'POST';
const HTTP_OK = 200;
const HTTP_CREATED = 201;
protected function curl($type, $url, $queryString = array())
{
$s = curl_init();
switch (strtoupper($type)) {
case self::POST:
echo "$url\n";
echo \http_build_query($queryString) . "\n";
die();
curl_setopt($s, CURLOPT_URL, $url);
curl_setopt($s, CURLOPT_POST, true);
curl_setopt($s, CURLOPT_POSTFIELDS, $queryString);
break;
case self::GET:
curl_setopt($s, CURLOPT_URL, $url . '?' .
</code></pre>
<p>http_build_query($queryString));
break;
}</p>
<pre><code> curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
$_out = curl_exec($s);
$status = curl_getinfo($s, CURLINFO_HTTP_CODE);
curl_close($s);
switch ($status) {
case self::HTTP_OK:
case self::HTTP_CREATED:
$out = $_out;
break;
default:
throw new \Exception("http error: {$status}",
</code></pre>
<p>$status);
}
return $out;
} }</p>
</blockquote>
| php | [2] |
1,193,668 | 1,193,669 | Finding midnight from a stored variable | <p>I have a web page that will allow customers to enter a date/time and I want to be able to stored that variable and then add to that time until Midnight, store that as a second variable and pass it to my sql server. Is there an easy way to do that?</p>
| asp.net | [9] |
3,651,348 | 3,651,349 | c++ code review | <pre><code>if (ad && (etag = strrcasestr_len(ad,strlen(ad),
"</XHTML-STRIPONREPLY>", 21))) {
</code></pre>
<p>here ad and etag are const char*</p>
<p>when the custom function strrcasestr_len returns NULL</p>
<p>will the expression evaluate to (ad && null)</p>
| c++ | [6] |
1,221,434 | 1,221,435 | What substitute should we use for layerX/layerY since they are deprecated in webkit? | <p>In chrome canary, layerX and layerY are deprecated, but what should we use instead ?</p>
<p>I've find offsetX but it doesn't work with Firefox. So to get layerX without warning on webkit, I've done that :</p>
<pre><code>var x = evt.offsetX || evt.layerX,
y = evt.offsetY || evt.layerY;
</code></pre>
<p>But this seem quite complex ! Is that really what we should do to get layerX working in all browsers ?</p>
| javascript | [3] |
4,634,126 | 4,634,127 | Get visual graph of heap memory usage in Java over a span of time | <p>I am currently using Visual VM to monitor the heap memory usage of my Java application. However I would like to somehow see the heap memory usage over a span of time and not just get a snapshot. Is there a way to do this using Visual VM? If yes, how? If not, what tool can I used to do this? </p>
| java | [1] |
3,661,586 | 3,661,587 | Having trouble assigning to a generic delegate in C# | <p>My problem is as follows:</p>
<pre><code>public abstract class A {}
public class B : A {
public static IList<B> MyMethod(){ return new List<B>();}
}
public delegate IList<T> MyDelegate<T>() where T : A;
...
public static void CalledMethod<T>() where T : A{
MyDelegate<T> del = B.MyMethod; // This doesn't work
}
</code></pre>
<p>Can anyone explain the best way to get this to work?</p>
<p>Thanks for any help.</p>
<p><strong>edited</strong> to fix example.</p>
| c# | [0] |
1,938,186 | 1,938,187 | How to import package modules as __main__ aliases inside __init__.py? | <p>I would like to import all modules inside a package as aliases in __main__ using __init__.py so they can be called simply from interactive mode. For example, here is a sample file tree:</p>
<pre><code>foobar/
__init__.py
foo.py
bar.py
</code></pre>
<p>and from the python interpreter I want to be able to import the package and have access to all modules using defined aliases like this:</p>
<pre><code>>>> import foobar
>>> <module 'foobar' from 'C:\...'>
>>> f.func()
>>> b.func()
</code></pre>
<p>This will require __init__.py to contain something along the lines of:</p>
<pre><code># __init__.py
from . import foo as f
from . import bar as b
# these will not work
__main__.f = f
__main__.b = b
</code></pre>
<p>How can I make this work?</p>
<p><strong>EDIT</strong></p>
<p>I don't want to use <code>from foobar import *</code> because it will not allow me to use aliasing.</p>
<p>Typing <code>from foobar import foo as f</code> for every module, every time I start interactive mode is not efficient because there could be hundreds of modules.</p>
| python | [7] |
5,740,947 | 5,740,948 | Printing answers for FizzBuzz using winforms | <p>I have tried to do the FizzBuzz question using the C# and I could do it as the message boxes. But I need to print the answers one by one in a text box using winforms. How can I do this. I have stated the code with this. Please can you help me.</p>
<pre><code>private void button8_Click(object sender, EventArgs e)
{
int x;
for (x = 1; x < 16; x++)
{
if (x % 3 == 0 && x % 5 ==0)
{
MessageBox.Show("FizzBuzz");
}
else if (x % 3 == 0)
{
MessageBox.Show("Fizz");
}
else if (x % 5 == 0)
{
MessageBox.Show("Buzz");
}
else
{
MessageBox.Show(x.ToString());
}
}
}
</code></pre>
| c# | [0] |
4,306,884 | 4,306,885 | Getting a StackOverflowError after updating project to use JDK1.7.0 | <p>I'm working on a collaborative java project and we had to upgrade to jdk1.7.0 due to some problems with generic types. I installed 1.7 and setup my environment variables and when I tried to compile the code using jdk1.7 I ended up with a nasty StackOverflowError and I'm not sure why. The code compiled fine in 1.6 (minus the one generics error that caused us to upgrade).</p>
<p>I know I'm not providing a lot of information since parts of the project are confidential and I can't provide any source but I can give the error list and the information above. I'm hoping I just have something stupid I did when updating to jdk1.7.0 which somebody will be able to point out easily with the limited information. If that's not possible I'll have to plug away at it myself until I find out what's wrong.</p>
<p>Anyways here is the output from the build that shows the error:</p>
<p><a href="http://pastebin.com/7mMpFsej" rel="nofollow">http://pastebin.com/7mMpFsej</a></p>
<p>Thanks in advance to anyone who can help me out!</p>
<p>Edit: To clarify in case anyone gets confused, the error above is all I get so I even if I were allowed to provide source I have no reference whatsoever as to where the problem may lie since its a fairly large project. The best I'm hoping for is something simple I messed up when upgrading to 1.7 or some sort of indication as to what sort of code implementation might cause this.</p>
| java | [1] |
124,100 | 124,101 | Java stop word library | <p>Is there any stop words library in java ?</p>
<p>Example:Write a java program to read input from a file, and then sort the characters within each word. Once you have done that, sort all the resulting words in ascending order and finally followed by the sum of numeric values in the file.</p>
<ul>
<li>Remove the special characters and stop words while processing the data</li>
<li>Measure the time taken to execute the code</li>
</ul>
<p>Please provide any stop word library for solving the above puzzle</p>
| java | [1] |
5,541,561 | 5,541,562 | PHP - styling code efficiently | <p>I'd need an advice.</p>
<p>After 4 months working on a project (after another developer), fixing bugs and upgrading, the main developer asked me to rechange coding style to what he prefers.
I'm working with the framework he developed.
The style he prefers (and I wasn't warned before about that) is if(): .. endif; :</p>
<pre><code><?php if($this):?>
this is an echo
<?php endif;?>
</code></pre>
<p>After years of development, I decided the best way of keeping code error-prone-ness is using </p>
<pre><code>if($this){
echo "this is a statement";
}
</code></pre>
<p>Of course, I told him ok, but I have concerns: </p>
<p>I think that this style is</p>
<p>1- more error prone</p>
<p>2- it is difficult to debug</p>
<p>3- and also change the code now - all over the project, can be risky - I mean - I could easily make a mistake and things will start to crash - and I'm the one who has the main responsibility - I'm asked to fix possible bugs, re-change things, etc, mainly - the only one working here.</p>
<p>The question is: is there an editor - which can help me to keep track of all 'endif', 'endforeach', etc? Or - how to make this style easier to debug?</p>
<p>Thanks.</p>
| php | [2] |
2,358,667 | 2,358,668 | How to get each file's extension in a given folder in PHP on Windows XP? | <p>E.g:</p>
<p>folder name:</p>
<pre><code>myFonlder
</code></pre>
<p>files in myFolder</p>
<pre><code>myFolder.01.mkv
myFolder.02.mkv
myFolder.03.avi
myFolder.04.mts
...
// each file's extension may be different.
</code></pre>
<p>So,how can I extract the extension of each file?</p>
<p>Thank you very much!!</p>
<p><strong>[update]</strong></p>
<p>my own solution; want to know is it fast enough!?</p>
<pre><code>foreach (glob("d:\\myFolder\\*.*") as $filename) {
//echo "$filename size " . filesize($filename) . "\n";
$path_parts = pathinfo($filename);
echo $path_parts['dirname'], "\n";
echo $path_parts['basename'], "\n";
echo $path_parts['extension'], "\n";
echo $path_parts['filename'], "\n"; // since PHP 5.2.0
}
</code></pre>
| php | [2] |
2,955,281 | 2,955,282 | javascript associative array initialization error? | <pre><code><script>
var tids = {
308: 1,
312: 1,
313: 1,
314: 1
};
</script>
</code></pre>
<p>results in "missing } in XML expression with an arrow pointing to the first colon in the JS error console. Isn't this a valid declaration?</p>
| javascript | [3] |
2,822,459 | 2,822,460 | Highlight only selected text using jQuery | <p>so I'm trying to highlight user selected text. Essentially the user can drag the mouse (while clicked) to select some random text on the page (anything within<code><p></code> tags). On mouseup I want to change that text to be highlighted and bold.</p>
<p>The requirements for this are that the text selected and ONLY the text selected gets highlighted. So no matching text in another <code><p></code> tag, and no matching text within the same <code><p></code> tag.</p>
<p>Now, this is what I have thus far for CSS:</p>
<pre><code>span.highlight {
background-color: yellow;
font-weight: bold;
}
</code></pre>
<p>And what I have for jQuery:</p>
<pre><code>function getSelected() {
var selected = '';
if (window.getSelection) {
selected = window.getSelection().toString();
} else if (document.getSelection) {
selected = document.getSelection();
} else if (document.selection) {
selected = document.selection.createRange().text;
}
}
$(document).ready(function() {
$('p').live('mouseup', function() {
var selected = getSelected();
$(this).html($(this).html().replace(selected, '<span class="highlight">' + selected + '</span>'));
});
});
</code></pre>
<p>Now this works almost. However it will select the first instance of the selected text and highlight that, which isn't what I want, I want it to select the actual selected text. And it has one more problem, once some text is highlighted, if I select more text that includes part of the highlighted text, it won't change it.</p>
<p>I'm wondering if anyone can help with either of these issues? Thanks in advance.</p>
<p>EDIT:</p>
<p>Sorry, I should have also mentioned that I can't use a plugin. I've taken a look at them and most of them work for my needs quite well, but I can't use them.</p>
| jquery | [5] |
4,802,546 | 4,802,547 | uninstall a software programatically in java | <p>I want to know if there is a way to uninstall a software programatically using java. <br/>
Suppose if I have Firefox installed on my windows machine then how could I use java program to uninstall it.</p>
<p>Thanks.</p>
| java | [1] |
4,031,823 | 4,031,824 | How to disable tab key globally except for all forms in a page with JavaScript? | <p>I'm making a single page app that is launching next week, for a pretty huge client, and going live for a pretty big event and well, there's still a ton to finish before then.</p>
<p>There's 100+ 'pages' which are all loaded within a single 700px x 600px window, and I had learned not long ago you could tab through the page/sections, which in-turn would break the app because it would bring focus to hidden off-screen elements, so for this reason, I disabled the tab key for the entire app.</p>
<p>But now there are a couple places where we have a form with a handful of input fields which you are not able to tab through as you fill in the form. It's a pain in the ass.</p>
<p>I need to make it so you can tab through the form fields, but only the form fields. I have the tabindex attribute set for the form, and have tried to make inputs tab enabled but was not able to make it work without causing the app to jump to hidden sections.</p>
<p>Here's the function I need to change so it will disable tab key except from input to input fields in a form.</p>
<pre><code>window.onkeydown = function(e) {
if (e.keyCode === tab) {
return false;
}
}
</code></pre>
<p>I tried to do this, which obv didnt work lol</p>
<pre><code>$('input').keydown(function(e) {
if (e.keyCode === tab) {
return true;
}
});
</code></pre>
<p>Thanks :)</p>
| javascript | [3] |
1,688,043 | 1,688,044 | Using RandomFileAccess to temporarly cache audio data | <p>I'm currently using a simple byte array buffer to cache live audio data and than playback this data. So it's constant reads and writes on this buffer. My problem is that I sometimes need this buffer to be atleast 1MB and I know that allocating that much memory is most likely not a good idea. So therefore I'm looking into caching data temporarily under the cache folder.</p>
<p>Are there any pitfalls when using RandomFileAccess to continuously seek->read and seek->write? </p>
<p>Are there perhaps better methods to cache temporarily data?</p>
<p>My main concerns are to maximize performance and battery life.</p>
| android | [4] |
4,993,256 | 4,993,257 | change large image when we click on small image | <p>There is a link give below open this and then click <code>table styles</code>.Its show all samples of tables when we click these small size table images then its shows in large image area.</p>
<p><a href="http://www.pooltables.com/coventry-pool-table/?icid=in00007" rel="nofollow">http://www.pooltables.com/coventry-pool-table/?icid=in00007</a></p>
<p>I want to create some thing like this or if you guys have any reference regard this then please reply me.Or if there is any script something like.</p>
<p>If there is any link that provide me any help then please reply.Its very urgent. </p>
<p>I shall be very thankful to u guys
Thanks </p>
| javascript | [3] |
4,279,083 | 4,279,084 | jQuery .each() this and element | <p>Inside a .each() callback, is there any difference between <code>this</code> and the second argument of the callback function?</p>
<p>For example, in the following code:</p>
<pre><code>$("example").each( function(index, element) {
// body
});
</code></pre>
<p>is there any difference between <code>this</code> and <code>element</code>? Is the second argument just provided so you can choose a name?</p>
| jquery | [5] |
5,046,049 | 5,046,050 | how to delete written data from external storage? | <p>I'm using following function to write a object to external storage.</p>
<p>After using it i want to delete that object from external storage to free memory.
Can any one guide me what should i do?</p>
<pre><code>public boolean saveObject(List<DalCategories> obj) {
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
cacheDir=new File(android.os.Environment.getExternalStorageDirectory(),"MyCustomObjectForSearchFilter");
} else {
cacheDir= getCacheDir();
if(!cacheDir.exists()) {
cacheDir.mkdirs();
}
final File suspend_f = new File(cacheDir, "test");
FileOutputStream fos = null;
ObjectOutputStream oos = null;
boolean keep = true;
try {
fos = new FileOutputStream(suspend_f);
oos = new ObjectOutputStream(fos);
oos.writeObject(obj);
} catch (Exception e) {
keep = false;
} finally {
try {
if (oos != null) {
oos.close();
}
if (fos != null) {
fos.close();
}
if (keep == false) {
suspend_f.delete();
}
} catch (Exception e) {
keep = false;
}
}
return keep;
}
</code></pre>
| android | [4] |
4,223,256 | 4,223,257 | URL querystring with a php include | <p>I'm trying to include a file to output in a tab on a page. The file itself will pull up just fine, but when I try to add the required querystring to it, it gives me a "failed to open stream: No such file or directory" error.</p>
<p>I've tried just a straight include and tried setting the querystring as a variable. Here's where I'm at right now.</p>
<p><code>$listingVars = '?mls=' . $_REQUEST['mlid'] . '&lid=0&v=agent';include("agentview.php$listingVars");</code></p>
<p>Has anyone successfully done this?</p>
| php | [2] |
3,227,826 | 3,227,827 | Extract domain from link | <p>I'm looking for a bullet proof way to extract domain (with tld) from any given link - an eqivalent of <code>dirname($path)</code> let's call it domainname($link).</p>
<pre><code>echo domainname("http://example.com/index.html?a=123%1231");
</code></pre>
<p>should print "example.com"</p>
| php | [2] |
2,953,377 | 2,953,378 | Property is getting set to null after I set it to something? | <p>I've got a custom control and one of the properties is:</p>
<pre><code>public List<SelectionBox> Boxes { get; set; }
</code></pre>
<p>In the control constructor I have:</p>
<pre><code>this.Boxes = new List<SelectionBox>();
this.Boxes.Add(new SelectionBox("", Color.Red));
</code></pre>
<p>Before InitializeComponent(), if I do a breakpoint here it shows that Boxes is a list of SelectionBox with 1 element. But then inside of my OnPaint override it has been set to null with some weird behaviour, if I do the following:</p>
<pre><code>foreach (SelectionBox box in Boxes) {}
</code></pre>
<p>It doesn't throw an error it just exits the function by there. What am I doing wrong?</p>
<p>Selection box struct:</p>
<pre><code>[Serializable]
public struct SelectionBox
{
public string Name;
public Color Colour;
public Rectangle BoxRectangle;
public bool IsActive;
public SelectionBox(string name, Color colour)
{
this.Name = name;
this.Colour = colour;
this.IsActive = false;
this.BoxRectangle = new Rectangle(0, 0, 0, 0);
}
}
</code></pre>
| c# | [0] |
5,936,881 | 5,936,882 | Web interface for a C++ program | <p>I am developing a project for the end of my studies. This project is basically acting as a server, is cross-platform and developed in C++.</p>
<p>I was wondering if it was possible to make a web interface that could be used like for instance the <code>listener</code> design pattern to log what the program does. This would be cross platform, and is ideal since the program is supposed to run on a distant server.</p>
<p>My question is: is there any web technology to could let me update my web page live when the program logs something. I know this is something unusual and I'm not an expert in web technos, that's why I am asking.</p>
<p>Would Erlang do it ?</p>
<p>Thanks for your help</p>
<p><strong>EDIT:</strong> To give a more concrete example, I would like to be able to follow the execution of my program live and see the logs of my program appear on the page. The idea would be to use a web page like I would use WPF on Windows or GTK on Linux for instance. Like someone said, it would be some kind on monitor for my application.</p>
| c++ | [6] |
4,280,222 | 4,280,223 | Multiple foreach statements in PHP script | <p>Here is my current code:</p>
<pre><code>foreach ($swears as $bad_word)
$body = str_ireplace($bad_word, "", $body);
</code></pre>
<p>It's filtering bad words, but I'd like to also filter a ":" to a "-" in the body. How can I have multiple foreach statements in my script?</p>
| php | [2] |
4,979,767 | 4,979,768 | Diagnose issues in .NET code deployed to a production environment, C# .NET | <p>I want to find out what methods or tools in general can be used diagnose issues in .NET code deployed to a production environment. </p>
<p>Thanks!</p>
<p><strong>Update</strong></p>
<p>The types of application on live: Web application, WCF application.</p>
| c# | [0] |
2,847,831 | 2,847,832 | Asyc Task return Arraylist retrieve it? | <pre><code>new DownloadFilesTask().execute(myPrefs.getString("IP", ""), null, null);
</code></pre>
<p>I returns an Arraylist from the dobackground method..how to put it into my arraylist?</p>
<pre><code>Arraylist al=null;
al=new DownloadFilesTask().execute(myPrefs.getString("IP", ""), null, null);
</code></pre>
<p>not working.</p>
| android | [4] |
954,421 | 954,422 | How to open a Excel file using a command button in C# | <p>I want to create a button so that when pressed it opens a excel document.
the name of the excel file is Solution.xls and it is placed in the desktop</p>
| c# | [0] |
5,167,451 | 5,167,452 | How to access internet from android emulator? | <p>i have used below steps for setup the my emulator </p>
<p>1.C:\Program Files\android-sdk-windows\tools>adb shell
2. # sqlite3 /data/data/com.google.android.providers.settings/databases/settings.db
3. sqlite> INSERT INTO system VALUES(99,’http_proxy', '10.10.8.1:8080');</p>
<p>after that i closed adb shell command prompt and my emulator. and then opened my emulator but webbrowser is not opening any page(web page not available messaage) .</p>
<p>Please any one tell me the solution for this problem.
is any other way to connect net in android emulator?</p>
<p>Regards,
Jeyavel N</p>
| android | [4] |
3,849,580 | 3,849,581 | Fade out text at special width | <p>I have a div which is 200px in width and 60 in height. I want to show some text in that div. As long as it is shorter than 200px everything is fine. But when it is wider I want the text to fade out, so it has maybe 100% black at 180px and is completely invisible at 200px width.</p>
<p>Can I achieve this with jQuery? Is it an easy task? Thanks in advance!</p>
| jquery | [5] |
5,478,569 | 5,478,570 | Screen Flicker and bad resizing on window Resize | <p>Please see this jsFiddle for reference: <a href="http://jsfiddle.net/Surfer/Gk8FS/" rel="nofollow">(jsFiddle) Div Resizing</a> <em>[to see what I'm having the problem with, resize the <strong>Results</strong> pane]</em></p>
<p>Here is my jQuery code for this example:</p>
<pre><code>function resizeRightLeftDivs() {
$('div.left, div.right').css('height',
$('div.container').outerHeight(false) -
$('div.header').outerHeight(false));
$('div.left').css('width',
$('div.container').outerWidth(false) -
$('div.right').outerWidth(false));
}
$(document).ready(function() {
resizeRightLeftDivs();
$(window).resize(function() {
resizeRightLeftDivs();
});
});
</code></pre>
<p>As you can see from the fiddle and my code, what I'm trying to do here is resize the <code><div /></code> elements appropriately when the browser window is resized.</p>
<p>But for some reason in FireFox there is extreme flicker. Not to mention half the time the left div isn't resized correctly (there's a gap between left and right divs).</p>
<p>And in IE it is too big by one pixel and the <code>div</code>s don't sit side by side.</p>
<p>How can I prevent this flicker, and the gap (FireFox)? Is this even the best way to go about resizing elements when the browser window size changes?</p>
| jquery | [5] |
1,269,927 | 1,269,928 | How can I achieve this effect with jQuery | <p>I really like the effect of the blocks moving towards you and slight animation in this effect, this developer seems to be using Mootools, and ideas on how to achieve this or a similar effect in jQuery?</p>
<p><a href="http://ultranoir.com/en/#!/blog/home/" rel="nofollow">http://ultranoir.com/en/#!/blog/home/</a></p>
| jquery | [5] |
4,350,321 | 4,350,322 | how to access contents of Object If I dont know the structure in c#? | <p>I have an object and I dont know its structure until runtime. so is there any way to access data from the object ?</p>
<p>thanks.</p>
<p>ps: I cant think of any other details to provide, please ask me if this isnt enough!</p>
| c# | [0] |
3,212,908 | 3,212,909 | What is the diifference between ScriptManager.RegisterStartupScript() and ScriptManager.RegisterClientScriptBlock(), as both does the same thing? | <p>Hi
I am just wondering why some people suggest RegisterStartupScript() to call client side js while some suggests RegisterClientScriptBlock(). </p>
<p>Please make me clear whats the difference between the two as they doing the same operations, for using js statement calls and which one is preferable if I only use js statements like alert, return confirm from codebehind.</p>
| asp.net | [9] |
1,902,577 | 1,902,578 | Defauly Bit rate while record audio by Android phone | <p>I am working on one Android Application, In this app I like to record audio.
And for Information I used these parameter :- </p>
<pre>
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
</pre>
<p>But now I like to know what is the default bit rate to record an audio in android . Can anybody help me?</p>
<p>Thanks In Advance
Vaibhav Singh</p>
| android | [4] |
72,694 | 72,695 | string class disposable method | <pre><code>private void test()
{
string tst = null;
try
{
tst = "abc";
}
catch (Exception)
{
throw;
}
finally
{
tst = null;
}
}
</code></pre>
<p>My query is - Is it meaningful to type <code>tst = null;</code> in the finally block as the string class doesn't have the disposable method ?</p>
| c# | [0] |
5,893,099 | 5,893,100 | Is there anything more efficient than an array of objects in javascript to store large amounts of data? | <p>My application gathers acceleration 10 times a second, therefore I have a need to store thousands of rows of data. Currently I have an object which is a list of other objects to store it all - anything more efficient than that?</p>
<pre><code>var arr = [];
function dataPoint(x, y, z, tstamp) {
this.xAccel = x;
this.yAccel = y;
this.zAccel = z;
this.epoch = tstamp;
}
var dp = new dataPoint( acceleration.x, acceleration.y, acceleration.z, acceleration.timestamp );
arr.push(dp);
</code></pre>
| javascript | [3] |
3,949,492 | 3,949,493 | get current device location after specific interval | <p>I want to capture current location (latitude and longitude) of android device after specific interval (say 30 mins).. My class (or service ?? not sure what to use ) will start listening to <code>LocationManagerListener</code> when device booting completed. What is the best way of implementing this? how we can make use of <code>locationChanged()</code> method in this scenario? </p>
<p>This is what i think it can go:</p>
<p>Listen for boot completed event and set alarm service:</p>
<pre><code>public class OnBootReceiver extends BroadcastReceiver {
private static final int PERIOD=1800000; // 30 minutes
@Override
public void onReceive(Context context, Intent intent) {
AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i=new Intent(context, OnAlarmReceiver.class);
PendingIntent pi=PendingIntent.getBroadcast(context, 0,
i, 0);
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime()+60000,
PERIOD,
pi);
}
}
</code></pre>
<p>Listen for alarm service and initiate the location capture class or service:</p>
<pre><code> public class OnAlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
WakefulIntentService.acquireStaticLock(context);
context.startService(new Intent(context, locationCapture.class));
or
new locationCapture().classmethod();
}
}
</code></pre>
<p>I am not sure how <code>locationCapture</code> class should be implemented. Should it be normal Java class or Service class?</p>
<p>Any help will be appreciated.</p>
| android | [4] |
26,688 | 26,689 | Resources on iPhone | <p>I just want to know how this works out. I made a folder and placed it inside of my xcode project. I placed images inside of these folders. What I am wondering is if even though this folder is on my xcode project is it calling to all the resources inside to where they are on the computer instead of being in the project? Because when I edit an image on my computer it is updating it inside the project as well. I just don't want to submit this project when it is done and find out that none of the images went with it. I suppose it isn't like android where I can just drag and drop the images in the res/drawable and that app has the image to itself?</p>
<p>Any info on this would be great.</p>
| iphone | [8] |
854,078 | 854,079 | Can hashCode() have dynamically changeable content? | <p>In my implementation, I have a class A which overrides equals(Object) and hashCode(). But I have a small doubt that is, while adding the instance of A to HashSet/HashMap the value of the hashCode() is x, after sometime the value of the same hashCode() changed to y. Will it effect anything?</p>
| java | [1] |
5,154,854 | 5,154,855 | Include File Vulnerability | <p>I try to read Claroline source code to learn from their coding.<br>
In index.php file, at the first line of code, they write</p>
<pre><code>unset($includePath); // prevent hacking
</code></pre>
<p>You can see full claroline source code from <a href="http://phpxref.free.fr/claroline/nav.html?index.php.source.html" rel="nofollow">here</a>.</p>
<p>They commented that the line is used to prevent hacking..<br>
I have no idea why should they unset <code>$includePath</code> while the variable is never defined before that line.. </p>
<p>What is the purpose of that line of code do actually, and what hacking type that they means?</p>
| php | [2] |
1,657,194 | 1,657,195 | how to parse xml in this formate | <pre><code><?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
</CATALOG>
</code></pre>
<p>How to parse it.....</p>
| iphone | [8] |
31,772 | 31,773 | For loop in jQuery. How to? | <p>How can I replace this for-each loop with jQuery?</p>
<pre><code>$(document).ready(function(){
hidebutton = $("#hideall");
hidebutton.click(function(){
for(i=1;i<=6;i++){
var countrylist = document.getElementById("Country-"+i);
countrylist.style.display = "none";
}
});
});
</code></pre>
<p>The HTML is</p>
<pre><code><input id="hideall" type="button" value='Hide Countries' /><br /><br />
<div id="Country-1">USA</div>
<div id="Country-2">UK</div>
<div id="Country-3">UAE</div>
<div id="Country-4">China</div>
<div id="Country-5">India</div>
<div id="Country-6">Japan</div>
</code></pre>
| jquery | [5] |
1,557,225 | 1,557,226 | jQuery vertical text scroll | <p>I have the following code, and it's behaving differently in <strong>CodePen</strong>, <strong>JSFiddle</strong> and in my browser. It only works perfectly in CodePen.</p>
<p>Essentially I would like it to infinitely scroll from top to bottom without stopping. </p>
<p>Here are both examples of the code in action, <a href="http://jsfiddle.net/qmFD3/" rel="nofollow">http://jsfiddle.net/qmFD3/</a> and <a href="http://codepen.io/anon/pen/fiaql" rel="nofollow">http://codepen.io/anon/pen/fiaql</a></p>
<pre><code>function scroller() {
$('#honor-roll ul').animate({
top: '-=' + $('#honor-roll ul li:last').height()
}, 1000, 'linear', function () {
var offset = $('#honor-roll ul li:last').offset().top;
console.log(offset);
if (offset <= 2000) {
$('#honor-roll ul').css("top", 0);
$('#honor-roll ul li:last').after($('#honor-roll ul li:first').detach());
}
});
}
$(document).ready(function () {
setInterval('scroller()', 200)
});
</code></pre>
| jquery | [5] |
1,134,558 | 1,134,559 | C#. How to start | <p>Like, the real post was about VisualBasic. But it seem I looked on "Questions that may already have you answer" and I noticed answer, that C# application are seen more likely than VB.net, so... I am turning question around because you can do more in C# than in VB.net . So my question is.</p>
<ol>
<li>Is there program for C#? Like XAMPP for PHP or VisualBasic for VB.net?</li>
<li>Are there any simple tutorials I could use? I mean more tutorials like ifs, math operators, echo, variables etc. ?</li>
</ol>
| c# | [0] |
674,911 | 674,912 | Java Concurrent API's | <p>Can some one please explain how <strong>CAS(compare swap)</strong> machine instructions are leveraged by <strong>java concurrent API's</strong>?</p>
| java | [1] |
1,332,584 | 1,332,585 | Do i need the soft keyboard .java files in project? | <p>I've copied the soft keyboard .java files into my project. I've got the keyboard to pop up in my view, but something tells me that i don't need the keyboard src files directly in my project unless I want to change the keyboard. I've commented out some of these files and the keyboard still pops up. do you just use the keyboard like any other class that ships with android. </p>
<pre><code>public void record() {
int frequency = 44100;
int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/reverseme.pcm");
// Delete any previous recording.
if (file.exists())
file.delete();
// Create the new file.
try {
file.createNewFile();
} catch (Exception e) {
throw new IllegalStateException("Failed to create " + file.toString());
}
try {
// Create a DataOuputStream to write the audio data into the saved file.
os = new FileOutputStream(file);
bos = new BufferedOutputStream(os);
dos = new DataOutputStream(bos);
// Create a new AudioRecord object to record the audio.
//int bufferSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
int bufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfiguration, audioEncoding);
audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
frequency, channelConfiguration,
audioEncoding, bufferSize);
short[] buffer = new short[bufferSize];
audioRecord.startRecording();
while (isRecording) {
int bufferReadResult = audioRecord.read(buffer, 0, bufferSize);
for (int i = 0; i < bufferReadResult; i++)
dos.writeShort(buffer[i]);
}
} catch (Exception e) {
Log.e("AudioRecord","Recording Failed");
e.printStackTrace();
}
InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
im.showSoftInput(this.findViewById(R.id.editText1), InputMethodManager.SHOW_FORCED);
}
</code></pre>
| android | [4] |
3,672,800 | 3,672,801 | run javascript when opening another page | <p>I'd like to open another web page from javascript (like default navigating, not fullscreen iframe or window.open) and run some javascript code upon loading it.</p>
<p>Steps:</p>
<ol>
<li>Define a javascript function</li>
<li>Navigate to another page</li>
<li>Browser runs function in new page context</li>
</ol>
<p>is there any way to achieve this? the only way I remember would be emulating this by loading the page using ajax, and replacing document.body.innerHtml, then running the function, but that would not change location.href, so e.g. the back button or bookmarks wouldn't work. also relative links had to be rewritten at loading, etc...</p>
<p>PS: I know that would be some ugly XSS, but it's needed for example when writing bookmarklets that load a page and fill in a form automatically.</p>
| javascript | [3] |
2,939,456 | 2,939,457 | Encoding of string in java | <p>I am actually confused regarding encoding of string in a language. I had some of these questions .... Please help me if you know the answer to them....</p>
<p>1) What is the native encoding of java strings in memory ie when I write <code>String a = "Hello"</code> in which format will it be stored. Since java is machine independent so I don't think it will be the encoding done by the system ??</p>
<p>2) I read this on the net that "UTF-16" is the default encoding but I got confused because say when I write that <code>int a = 'c'</code> the default answer gives me ASCII so are ASCII and UTF-16 same ??</p>
<p>3) Also I had this doubt that on what factors the storage of a string in the memory depend os , language ??</p>
| java | [1] |
5,160,512 | 5,160,513 | problem with update panel in internet explorer | <p>i am using my usercontrol in Updatepanel.
i think thats why it is giving me error </p>
<p>Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near '</p>
<p>when i remove update panel it is working fine.But i want update panel compulsory.
I kept my updatepanel as it is,but tried to call function from usercontrol(Homescroll.ascs) for scrolling as</p>
<p><%ScriptManager.RegisterStartupScript(this, this.GetType(),"ale", scroll(),true); %></p>
<p>in which scroll() is written in Homescroll.ascs.cs.</p>
<p>the function is getting called but is not getting displayed.</p>
<p>how to use ScriptManager for calling function which is written in .cs
is there any error in this or any other way to do this.</p>
<p>please suggest me.</p>
| asp.net | [9] |
4,508,198 | 4,508,199 | Bad practice in php? | <p>I have some PHP code that generates a calendar and then outputs html to display it. </p>
<p>To display it on a page all I need to do is <code><?php include('calendar.php'); ?></code>. </p>
<p>Is this bad practice?</p>
| php | [2] |
2,241,416 | 2,241,417 | On C++ global operator new: why it can be replaced | <p>I wrote a small program in VS2005 to test whether C++ global operator new can be overloaded. It can.</p>
<pre><code>#include "stdafx.h"
#include "iostream"
#include "iomanip"
#include "string"
#include "new"
using namespace std;
class C {
public:
C() { cout<<"CTOR"<<endl; }
};
void * operator new(size_t size)
{
cout<<"my overload of global plain old new"<<endl;
// try to allocate size bytes
void *p = malloc(size);
return (p);
}
int main() {
C* pc1 = new C;
cin.get();
return 0;
}
</code></pre>
<p>In the above, my definition of operator new is called. If I remove that function from the code, then operator new in C:\Program Files (x86)\Microsoft Visual Studio 8\VC\crt\src\new.cpp gets called.</p>
<p>All is good. However, in my opinion, my implementations of operator new does NOT overload the new in new.cpp, it CONFLICTS with it and violates the one-definition rule. Why doesn't the compiler complain about it? Or does the standard say since operator new is so special, one-definition rule does not apply here?</p>
<p>Thanks.</p>
| c++ | [6] |
4,700,734 | 4,700,735 | using jquery.noConflict() | <p>I have two files. HTML and .js files. in code.js, I have written jquery code and in HTML file, I am including code.js as following:</p>
<pre><code><script src="jquery-1.4.2.js"></script>
<script src="jquery.interval.js"></script>
<script src="code.js">
jQuery.noConflict();
var $jcode = jQuery;
</script>
</code></pre>
<p>in code.js, I have written following:</p>
<pre><code>jcode(document).ready(function() {
jcode.interval(checkForms, 2000);
});
</code></pre>
<p>When I run it, it gives me error as can not read property of interval undefined.
I think there is something wrong with my usage of noConflict. Can you please help?</p>
<p>Thanks</p>
| jquery | [5] |
1,748,513 | 1,748,514 | Package Installer misbehavoir | <p>I am unable to understand and fix the following behavior displayed by the Package Installer : in my application when I press on a "update application" button I download from a web server un update apk (in case there is) and start the Package Installer afterwards to install the package. Everything goes well and after the installation finishes there is displayed a view with two buttons "open" and "done" . However pressing the "open" button fails to open the installed update as it should even if the intent to the startup activity is sent as I observed in logcat . Pressing on menu button and going through the applications installed I am able to find the updated app and start it from here . What should I do to start the update by pressing open in the final Package Installed view ?</p>
| android | [4] |
2,303,982 | 2,303,983 | Raw folder url path? | <p>How can I get the url of the raw folder? I do not want to access my asset via id but by path instead.</p>
<p>Thanks for any help that you can provide!</p>
| android | [4] |
2,080,984 | 2,080,985 | jQuery Slide Right/Left | <p>I have the following JS:</p>
<pre><code>$(document).ready(function () {
$(".LeftColumn").hide();
$(".SidebarToggle").toggle(function () {
$(this).addClass("active");
$(this).text("Hide Sidebar");
$(this).attr("title", "Hide Sidebar");
//$(".LeftColumn").fadeIn("fast");
$(".LeftColumn").show("slide", { direction: "left" }, 100);
return false;
},
function () {
$(this).removeClass("active");
$(this).text("Show Sidebar");
$(this).attr("title", "Show Sidebar");
//$(".LeftColumn").fadeOut("fast");
$(".LeftColumn").hide("slide", { direction: "left" }, 100);
return false;
});
</code></pre>
<p>Which basically shows and hides a div with a class of LeftColumn. The problem I have is that LeftColumn floats left and I have another div called Middle Column that floats left next to it. But when I do the animation the LeftColumn does a nice easing slide but the MiddleColumn will snap in and out to fill the void. How can I get the MiddleColumn to ease back and forth in relation to the LeftColumn (baring in mind that the MiddleColumn has no defined width).</p>
<p>Thanks</p>
| jquery | [5] |
2,671,485 | 2,671,486 | scrollView issue in android | <p>Hello
In my android appl;ication I am using a table inside a scrollview and below that there is a footer.
Now the issue is the last row of the table is covered by the footer and is not visible.
Is there any solution for this.
My layout xml is</p>
<pre><code> <ScrollView
android:id="@+id/Scroll"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout
android:id="@+id/SubTable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
</TableLayout>
</ScrollView>
</code></pre>
<p>Please let me know your valuable suggestions.
Thanks in advance :)</p>
| android | [4] |
5,945,760 | 5,945,761 | iPhone: NSAttributedString | <p>Is there any way to concat two NSAttributedString ? Or NSAttributedString and NSString ?
I tried something like this:</p>
<pre><code> NSAttributedString *attr = [NSString stringWithFormat:@"...%@",
attributedString];
NSLog (@"%@", [attr string]);
</code></pre>
<p>But thats not work...Any suggestions ? Thanks...</p>
| iphone | [8] |
1,814,822 | 1,814,823 | Call to a member function on a non-object | <p>Have a cycle, it often works function Clear. But sometimes I get an error </p>
<pre><code>Call to a member function on a non-object
</code></pre>
<p>I do not care because of what is happening to me important that the cycle is not interrupted to do this?</p>
<pre><code>$html->clear();
</code></pre>
| php | [2] |
5,104,940 | 5,104,941 | How do I make a TwoLineListItem? | <p>I want to make a setings menu like this:<br><br><img src="http://i.stack.imgur.com/GqSiS.png" alt="enter image description here"></p>
<p>Is there a definitive guide on how to make <code>TwoLineListItem</code>'s anywhere?</p>
| android | [4] |
4,387,141 | 4,387,142 | Why does a javascript object property assignment via the dot notation NOT trigger a setter defined for that property? | <p>Any Javascript ninjas or people who have read ECMA-262 5th care to explain the following behavior?</p>
<pre><code>var obj = {
p: {},
set prop(val){
for (var key in val){
this.p[key] = "Set: " + val[key];
}
},
get prop(){
return this.p;
}
}
obj.prop = { // Assignment triggers setter
foo: "Foo"
}
obj.prop.bar = "Bar"; // Assignment does not trigger setter
console.log(obj.prop.foo); // Set: Foo
console.log(obj.prop.bar); // Bar
</code></pre>
<p>I found the above behavior a bit confusing because I expected the two assignment notations to be functionally equivalent.</p>
| javascript | [3] |
2,848,228 | 2,848,229 | Extracting content from Jar file | <p>I'm looking for a way to extract data from a jar file.
What i need is information about a certain class file including:
- Constructor name
- Public methods (getters, setters and actions.)
- Perhaps if included the javadoc</p>
<p>For example, in Eclipse, when you type your variable and you press '.' behind it, it gives a complete list of methods, so i'm guessing there should be a way to find this data out. (I'd only need the names of the methods, not the actual code.)</p>
<p>Some actual code, pseudocode, instructions or anything else is appreciated.</p>
| java | [1] |
5,812,909 | 5,812,910 | JQuery - $(this).attr('name') | <p>I have a name attribute assigned to a hyperlink.
When I do the following in my JQuery link_name does not return anything.
Am I doing something wrong? </p>
<pre><code> $("body").delegate("a", "click", function (event) {
var link_name = $(this).attr('name');
alert(link_name);
</code></pre>
| jquery | [5] |
4,982,583 | 4,982,584 | "The type B cannot be a superinterface of C; a superinterface must be an interface" error | <p>Let's assume I got this interface A:</p>
<pre><code> interface A
{
void doThis();
String doThat();
}
</code></pre>
<p>So, I want some abstracts classes to implement the method doThis() but not the doThat() one:</p>
<pre><code> abstract class B implements A
{
public void doThis()
{
System.out.println("do this and then "+ doThat());
}
}
abstract class B2 implements A
{
public void doThis()
{
System.out.println(doThat() + "and then do this");
}
}
</code></pre>
<p>There error comes when you finally decide to implement de doThat method in a regular class:</p>
<pre><code> public class C implements B
{
public String doThat()
{
return "do that";
}
}
</code></pre>
<p>This class leads me to the error aforementioned:</p>
<blockquote>
<p>"The type B cannot be a superinterface of C; a superinterface must be an interface"</p>
</blockquote>
<p>Anyone could now if this hierarchy of classes is valid or should I do other way round?</p>
| java | [1] |
4,417,648 | 4,417,649 | Possibly silly question about strings and references in C# | <p>Good afternoon,</p>
<p>I'm sorry if this question is too silly, but I don't know much (almost anything) about .Net's memory management system, and I really need to clear up this doubt... I have a <code>Dictionary<String, Int32></code> which I need to use, and now I need a tree whose nodes are labeled with the strings in that same dictionary. Since, of course, I don't want to store redundant information, how can I make sure the node's label point to the same references as the dictionary's keys?</p>
<p>Thank you very much,</p>
| c# | [0] |
4,548,014 | 4,548,015 | jQuery access "previous" div | <p>Here's my scenario.</p>
<p>I have a DIV </p>
<pre><code><div class="first"></div>
</code></pre>
<p>if I click on an element inside this div, it generates another div, call it</p>
<pre><code><div class="second"></div>
</code></pre>
<p>now, can I click on an element inside second div to access the first div? does second DIV know that the first div exists?</p>
| jquery | [5] |
233,012 | 233,013 | FilterQueryProvider, filter and ListView | <p>I have a database as follows:</p>
<pre><code>------------------------------
BOOK NAME | BOOK FORMAT | COUNT |
------------------------------
Android | HTML | 1
WPF | PDF | 10
Symbian | PS | 2
Windows | HTML | 2
</code></pre>
<p>I am showing this database to the user
by making use of a CustomSimpleCursorAdapter.</p>
<p>CustomSimpleCursorAdapter extends SimpleCursorAdapter
implements Filterable</p>
<p>with getView() & runQueryonBackgroundThread() being overriden.
The Grid view of books is properly shown.</p>
<p>The user has the following options:</p>
<p>HTML | PDF | PS | DELETE </p>
<pre><code>Constraint: BOOK FORMAT
[HTML - 1, PDF - 2, PS - 3]
</code></pre>
<p>When the user presses HTML menu option, the books with HTML
type has to be shown.</p>
<p>inside MenuOption handler(), I wrote as follows:</p>
<pre><code>adapter.getFilter().filter("1");
runQueryonBackgroundThread(){
if(mCursor != null)
mCursor.close();
mCursor = query(using the constraint)
return mCursor;
}
</code></pre>
<p>This constraint reaching my overriden runQueryonBackgroundThread()
method. But its not updating the grid view and throws an exception.</p>
<p>"FILTER: android.view.ViewRoot$CalledFromWrongThreadException: Only the
original thread that created a view hierarchy can touch its views"</p>
<p>Please help me.</p>
<p>Thank you,</p>
<p>Ram</p>
| android | [4] |
896,867 | 896,868 | xml parser problem? | <p>i have tabbar controller, first tab is for Tableview controller.but i do xml parsing in appldidfinish method , in the xml parse didEndElement, i calculate items count and i give
it into first tab's Tableview controller's numberOfRowsInSection,but after xml parsing finished, the following method wont be called. tableview is empty....?
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{</p>
<pre><code>return [myParser.items count];
</code></pre>
<p>}</p>
<p>i have declared in view did load method of that table view controller</p>
<pre><code>myParser = [[XMLMyParser alloc] init]; any help please.....
</code></pre>
| iphone | [8] |
1,149,478 | 1,149,479 | Splitting Data Based on Data Value | <p>I have a Data like below.</p>
<pre><code>OrderDate OrderID TotalOrderPrice
*********************************
1/10/2010 ABC 100
1/10/2010 ABC 200
1/20/2010 ABC 150
1/26/2010 ABC 100
1/10/2010 EDF 200
1/20/2010 EDF 110
1/26/2010 EDF 120
****************************
</code></pre>
<p>I want the final output so that I can see how much is the sum of <code>OrderPrice</code> for the particular <code>OrderID</code> on a particular <code>OrderDate</code> as shown below</p>
<pre><code>OrderDate ABC EDF
************************
1/10/2010 300 200
1/20/2010 150 110
1/26/2010 100 120
</code></pre>
<p>Can anyone guide me on how to achieve this? How can I query the DataTable to get this result?</p>
| c# | [0] |
3,602,981 | 3,602,982 | How come this variable echo's as 16? | <pre><code>$body = "Artist: " + $artist + "Size: " + $size + "Time: " + $time + "Concept: " + $concept + "Time: " + $time + "Mod: " + $mod + "Details: " + $details;
</code></pre>
<p>When I try to echo this variable, all that comes out is '16.' </p>
<p>Can you guys help?</p>
| php | [2] |
4,278,237 | 4,278,238 | how to change the font size using jquery from the dropdown list | <pre class="lang-html prettyprint-override"><code><div class="card">
<div id="name" class="badge">
<div id="address" class="badge">
</div>
<select id="font-size">
<option value="12">12</option>
<option value="14">14</option>
<option value="18">18</option>
</select>
</code></pre>
<p>I have the main div with class "card" which has many other divs inside. I want to change the div's font size from the dropdown.</p>
<p>jQuery code is:</p>
<pre class="lang-js prettyprint-override"><code>$(".badge").click(function(){
var id = this.id;//get clicked id
$("#font-size").change(function(){
$("#"+id).css('font-size', $(this).val()+"px");//change font according to the clicked element
});
});
</code></pre>
<p>My problem is that when first div (name) is clicked everything works fine. But when the second div is clicked then first is also bound. And font size is changed for both. I want the font size to change independently according to the div clicked.</p>
| jquery | [5] |
224,000 | 224,001 | Lucene SpellChecker.Net dll | <p>I have added spellchecker.net dll to my application but it throws this error message:</p>
<p>The type name 'Net' does not exist in the type 'SpellChecker.Net.Search.Spell.SpellChecker'</p>
<p>Any help is appreciated.</p>
<p>Thank You.</p>
| asp.net | [9] |
5,373,482 | 5,373,483 | Algorithm used by C# MACTripleDES.ComputeHash() | <p>can any one provide me with references on how this function is internally implemented.</p>
| c# | [0] |
3,391,159 | 3,391,160 | android.R.id.empty broken in Xoom/Honeycomb? | <p>I have been trying to make radio buttons without the dot which toggles. I have been successful by doing this:</p>
<pre><code>myRadioButton.setButtonDrawable(android.R.id.empty);
</code></pre>
<p>this works fine in all devices before Honeycomb 3.0.x. When I try and use the "empty" resource on the Xoom i get an error:</p>
<pre><code>ERROR/AndroidRuntime(xxxxx): Caused by: android.content.res.Resources$NotFoundException: File from drawable resource ID #0x1020004
</code></pre>
<p>so, I was wondering if there was a reason why the <a href="http://developer.android.com/reference/android/R.id.html#empty" rel="nofollow" title="empty resource">empty resource</a> suddenly doesn't work on the Xoom. Any help would be appreciated. If you want to take a look at the radioButton related post it can be found <a href="http://stackoverflow.com/questions/5821669/android-dynamic-radiogroup-radiobuttons-as-flat-buttons%20%60here%60">here</a></p>
<p>Thanks! </p>
| android | [4] |
2,017,467 | 2,017,468 | .position() and .offset returning NULL off my target | <p>Im trying to check the position of an element on this page, and if its below a certain point I want to change the font color to something readable, but .position and .offset(which is what I should be using) are both returning NULL.</p>
<p>Here is my jquery, the alert is in there for testing purposes:</p>
<pre><code> var position = $("#about_tattoo").offset();
alert("top: "+ position.top);
if(position.top >= 1000){
$("#about_tattoo").css("color","white");
}
</code></pre>
<p>and there is a div on the page: <code><div id="about_tattoo"></code></p>
| jquery | [5] |
3,216,100 | 3,216,101 | convert a line of python code list comprehension / cross product (create a poker deck as a list of two characters strings: rank, suite) to C# | <p>how would you convert this code</p>
<pre><code>poker_deck = [r+s for r in '23456789TJQKA' for s in 'SHDC']
</code></pre>
<p>to C#?</p>
<p>I came out with this:</p>
<pre><code>char[] figures = "23456789TJQKA".ToCharArray();
char[] suites = "SHDC".ToCharArray();
List<string> deck = new List<string>();
foreach (var figure in figures)
{
foreach (var suite in suites)
{
deck.Add(string.Format("{0}{1}", figure, suite));
}
}
</code></pre>
<p>what do you think?
I would like to do the same in one simple and readable line</p>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.