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 |
---|---|---|---|---|---|
2,482,258 | 2,482,259 |
jquery animate and step function usage
|
<p>i tried to fadeout my div with the help jquery animate and step function but my logic is not working. i want to fadeout div when animate function decrease my div height & width is 50%. i mean when div's height & width becomes almost half then i want to fadeout div very smoothly.</p>
<p>my code is working but the effect i want not being possible. so please have a look at my code and rectify it if possible. here is the url where u can see the implementation.
<a href="http://jsfiddle.net/Sj4eG/12/" rel="nofollow">http://jsfiddle.net/Sj4eG/12/</a></p>
<p>just need to modify this below portion</p>
<pre><code> grower.animate({width:0, height:0, left:(windowWidth/2 - $('#grower').width()), top:(windowHeight/2 - $('#grower').height())},
{
duration: 1000,
step: function(now, fx) {
alert(now);
if (fx.prop == "height") {
var threshold = fx.start / 2;
if (now < 150) {
$(fx.elem).css("opacity", now / threshold);
}
}
}
});
</code></pre>
|
jquery
|
[5]
|
3,921,390 | 3,921,391 |
Unlock Content with Stumbleupon
|
<p>I've worked with unlock (perform an action to view content) scripts using Facebook, Twitter etc. I was wondering if anybody knew a way of accomplishing this with a StumbleUpon like.</p>
<p>I can't seem to get my head around it, any help would be very much appreciated.
It seems they do have a working API: <a href="http://www.stumbleupon.com/help/business-tools/supr/supr-api/" rel="nofollow">http://www.stumbleupon.com/help/business-tools/supr/supr-api/</a></p>
<p>Thanks :)</p>
|
php
|
[2]
|
1,375,752 | 1,375,753 |
Problem adding custom view to navBarItem
|
<p>Can anyone explain to me why the code below does not work correctly on iOS 3.1.3? On 4.0 it works great however on earlier versions the image is not respecting the size of the frame and is displaying in its original size leaving a huge image where my navItem should be???</p>
<pre><code>flipView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
flipView.contentMode = UIViewContentModeScaleAspectFit;
detailFlipButton = [UIButton buttonWithType:UIButtonTypeCustom];
detailFlipButton.frame = CGRectMake(0, 0, 30, 30);
[detailFlipButton setImage:self.myImage forState:UIControlStateNormal];
detailFlipButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
[detailFlipButton addTarget:self action:@selector(flipAction) forControlEvents:UIControlEventTouchUpInside];
[flipView addSubview:detailFlipButton];
UIBarButtonItem *flipBarButton = [[UIBarButtonItem alloc] initWithCustomView:flipView];
self.navigationItem.rightBarButtonItem = flipBarButton;
[flipBarButton release];
</code></pre>
<p>Basically i am trying to accomplish something similar to the navItem in the top right corner of the iPod app which flips the view when tapped.</p>
|
iphone
|
[8]
|
5,411,581 | 5,411,582 |
How to use multiple langauges in android
|
<p>I want to give my user an option to select his language and according to his selection i want to display language.
Can my android app support multiple languages.How to do that?</p>
|
android
|
[4]
|
5,874,428 | 5,874,429 |
How can I avoid "IllegalStateException :Scollview can host only one direct child"?
|
<p>I am using <code>ScrollView</code> in my android Layout but it shows <code>IllegalStateException "Scollview can host only one direct child"</code>. How can I avoid this exception? Please help.</p>
<p>Thank You.</p>
|
android
|
[4]
|
2,194,050 | 2,194,051 |
statement requires expression of scalar type ('void' invalid)
|
<p>I am getting warning message in red <code>statement requires expression of scalar type ('void' invalid)</code> at the if statement.</p>
<pre><code> - (void)displayviewsAction:(id)sender
{
FirstViewController *viewController = [[FirstViewController alloc] init];
viewController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:viewController.view];
[self.view addSubview:toolbar];
if ([audioPlayer pause]){
[timer invalidate];
} else {
self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(secondViewController) userInfo:nil repeats:NO];
}
[viewController release];
}
</code></pre>
<p>Any idea how to fix it.</p>
<p>Thanks for help.</p>
|
iphone
|
[8]
|
3,583,157 | 3,583,158 |
get_object_vars explanation needed
|
<p>one of my php tutorial is showing bellow function. i know it is used to check attribute existence but and i couldn't get its real meaning, i mean what is the meaning of its comment lines ? can anyone explain it to me?</p>
<pre><code>private function has_attribute($attribute) {
//get_object_vars returns an associative array with all attributes
//(incl.private ones!) as the keys and their current values as the value
$object_vars = get_object_vars($this);
//we don't care about the value, we just want to know if the key exists
//will return true or false
return array_key_exists($attribute, $object_vars);
}
</code></pre>
|
php
|
[2]
|
5,554,200 | 5,554,201 |
Process with() statement after if() condition in one line
|
<p>This line doesn't make much sense, but I wonder why it raises a syntax error:</p>
<p><code>x = 1; if x: with open("x.txt") as f: f.write(x)</code></p>
<p>How can I execute <code>with</code> block after <code>if</code> statement in one line?</p>
|
python
|
[7]
|
1,080,273 | 1,080,274 |
How to retrieve objects values stored in a Java ArrayList
|
<pre><code>ArrayList<yellowPage> ob1 = new ArrayList<yellowPage>();
yellowPage thing = new yellowPage(100,100);
thing.calc(i,y,s3);
ob1.add(thing);
</code></pre>
<p>I stored some data in <code>thing</code>. How can I retrieve the value stored in <code>ob1.thing</code>?</p>
|
java
|
[1]
|
4,882,674 | 4,882,675 |
Why dont i have rights on uploaded file?
|
<p>I've just created a php snippet that allows me to upload pictures. Im working on my personal pc that runs Windows7, IIS7 and PHP.</p>
<p>The wierd thing is that Im allowed to upload and it works great, but if i go to the folder: <code>c:\inetpub\wwwroot\imgupload\uploads</code> and try to view the image then im now allowed because i dont have any rights. Adding my user to file rights solves the problem but thats a bit silly aint it? im using php's <code>move_uploaded_file()</code></p>
<p>any thoughts?</p>
|
php
|
[2]
|
5,395,896 | 5,395,897 |
Any way to apply onclick events to a large list of li dynamically?
|
<p>Ok, I have an unordered list like so:</p>
<pre><code><ul id=list>
<li> Item 1 </li>
<li> Item 2 </li>
<li> Item 3 </li>
<li> Item 4 </li>
<li> Item 5 </li>
</ul>
</code></pre>
<p>Is there any simple way of creating onclick events for each of the individual li's?</p>
<p>Here's my objective... I have CSS setup like so:</p>
<pre><code>#list li {...some styles here...}
#list li:active {...change background color and font color on click...}
</code></pre>
<p>So again, any simple way of doing this? I know I can achieve it by simply adding an onclick event to each of the individual li's, but any smart way of doing this?</p>
<p>(For clarification - I'm actually going to be using an 'ontouchstart' event for mobile webkit)</p>
|
javascript
|
[3]
|
3,135,468 | 3,135,469 |
Why does the context change in this JS snippet?
|
<p><a href="http://jsfiddle.net/raylu/C6Tkn/" rel="nofollow">http://jsfiddle.net/raylu/C6Tkn/</a></p>
<pre><code>function a() {
document.write(this + '<br />');
}
a();
a.apply('hello');
var b = function() {
a();
}
b.apply('hi');
</code></pre>
<p>I would expect the last line to output 'hi', but instead it outputs window.</p>
|
javascript
|
[3]
|
3,520,403 | 3,520,404 |
What is the Equivalent of C#'s "List <String>" in PHP?
|
<p>I'm working with an API and it is asking me to provide a <code>List <String></code> value. I'm writing PHP and can only seem to find this type in C#.</p>
<p>Is it an array? A comma-separated string?</p>
|
php
|
[2]
|
6,032,568 | 6,032,569 |
What's the Python2.5 equivalent of Python2.6 translate with None as first param?
|
<p>In Python 2.6, I can run the following fine to strip out chars like <code>-()</code></p>
<pre><code>'(123) 456-7890'.translate(None, '-(), ')
</code></pre>
<p>Python2.5 translate does not accept None, how can I do the above in 2.5?</p>
|
python
|
[7]
|
1,189,109 | 1,189,110 |
Whats the difference between <?php functionhere(); ?> and <?=functionhere();?>
|
<p>Can someone explain to me when <code><?=</code> needs to be used or why this programmer would code this way? I'm working on creating a third party module for <a href="http://www.spbas.com/" rel="nofollow">SPBAS</a> and I nearly figured it out, I just don't know the significance of the two different options I've specified.</p>
<p>Thanks in advance.</p>
|
php
|
[2]
|
5,582,049 | 5,582,050 |
VisualBasic Convert.FromBase64String equivalent on PHP
|
<p>I would like to know the VisualBasic Convert.FromBase64String equivalent on PHP.</p>
<p>Thanks.</p>
|
php
|
[2]
|
1,928,850 | 1,928,851 |
Adding and Removing an active class
|
<p>I know this should be simple and has been covered a million times already but I just can;t seem to get it to work.</p>
<p>It's your basic script that makes the last link you clicked in a list become the 'active' link my adding the 'active' class to it.</p>
<p>HTML</p>
<pre><code><ul id="projectsList">
<li><a href="#" class="activeProject" id="portoftyne">Port of Tyne</a></li>
<li><a href="#" id="eaga">Eaga</a></li>
<li><a href="#" id="gong">Gong</a></li>
<li><a href="#" id="nufc">NUFC</a></li>
</ul>
</code></pre>
<p>jQuery</p>
<pre><code> $(document).ready(function() {
$('#projectsList a').click(function(){
$('.activeProject').removeClass('activeProject')
$(this).addClass("activeProject");
});
});
</code></pre>
<p>Should work, doesn't at all.</p>
<p><strong>EDIT</strong> Nothing wrong with this code, it works fine. There was a section of code above it in the document that was preventing it from working.</p>
|
jquery
|
[5]
|
3,607,510 | 3,607,511 |
Android / layout: how to create a header-content layout
|
<p>How do I go about creating the following layout in Android?</p>
<p>I want a "header", that is, a header that stays the same at all times. The only thing that should change is the area below the header.</p>
<p>Think of it as a webpage, where the content-area is where its all happening =)</p>
<pre><code>+--------------------+
| H E A D E R |
+--------------------+
| |
| |
| |
| C O N T E N T |
| |
| |
| |
+--------------------+
</code></pre>
<p>Sure, its easy enough to create a LinearLayot, add a View on the top and then another view below that - tada! But what Im after is how you "set up" or design the project so its easy to just change whats in the Content.</p>
<p>What I <b>really</b> would like is to be able to "swipe" (see <a href="http://stackoverflow.com/questions/1959106/android-how-to-create-different-screens-and-nav-between-them-using-touch-and-d">here</a>) the area and then just "roll in" a new View/thing in the Content-area, but keep the same header.</p>
<p>What I really miss is a comprehensive library of layoyt-examples...</p>
<p>regards</p>
|
android
|
[4]
|
780,930 | 780,931 |
PHP: filename without file extension- best way?
|
<p>I am trying to pull the filename out of a directory without the extension.</p>
<p>I am kludging my way through with the following:</p>
<pre><code>foreach ($allowed_files as $filename) {
$link_filename = substr(basename($filename), 4, strrpos(basename($filename), '.'));
$src_filename = substr($link_filename, 0, strrpos($link_filename) - 4);
echo $src_filename;
}
</code></pre>
<p>...But that can't work if the extension string length is more than 3.
I looked around in the PHP docs to no avail.</p>
|
php
|
[2]
|
1,826,426 | 1,826,427 |
how to prevent to calling another function in JS?
|
<pre><code>function datePicker(event)
{
//do something`enter code here`
}
document.onclick=function() {
//do something
}
</code></pre>
<p>When I call datePicker() function I want to prevent the calling second method .
How to do that ?</p>
|
javascript
|
[3]
|
589,444 | 589,445 |
How to get valid Bit Error Rate or Rx Qual
|
<p>I am trying to get bit Error rate by using getGthe following coding but i am always get -1 only. Do you anybody have idea to get valid Bit Error Rate. please help to get correct value.</p>
<p>The code are following.</p>
<pre><code>public class GetGsmSignalStrengthActivity extends Activity {
TelephonyManager Tel;
MyPhoneStateListener MyListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Tel = ( TelephonyManager )getSystemService(Context.TELEPHONY_SERVICE);
Tel.listen(MyListener ,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
private class MyPhoneStateListener extends PhoneStateListener
{
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength)
{
super.onSignalStrengthsChanged(signalStrength);
TextView dummy1 = (TextView)findViewById(R.id.textView5);
String x,m ="";
x=String.valueOf(signalStrength.getGsmBitErrorRate());
dummy4.setText("Bit Error : " +x);
}
}
}
</code></pre>
|
android
|
[4]
|
3,951,743 | 3,951,744 |
How to get the x509 certificate encoding type in Java
|
<p>I am trying to read a certificate for a remote host using Java. I want to get the encoding type. I typed:</p>
<pre><code> System.out.println("The encoding is: "+ x509Cert.getEncoded().toString());
</code></pre>
<p>The output I get is:</p>
<pre><code>The encoding is: [B@597c3925
</code></pre>
<p>What is the problem ?</p>
<p>EDIT: x509Cert is an object of type X509Certificate.</p>
|
java
|
[1]
|
5,677,402 | 5,677,403 |
TypeError: can only concatenate list (not "int") to list
|
<p>I'm trying to do something usefull with some itens in list in the following code:</p>
<pre><code>IPS=['10.254.243.83','10.254.243.82']
def commands(cmd):
command = Popen(cmd, shell=True, stdout=PIPE)
command_strip = command.stdout.read().strip()
print command_strip
def main():
for ip in IPS:
ping = call('ping -c 3 %s' % ip, shell=True)
commands(ping)
if __name__ == "__main__":
main()
</code></pre>
<p>Then, it returns me:
python teste.py</p>
<pre><code>PING 10.254.243.83 (10.254.243.83) 56(84) bytes of data.
64 bytes from 10.254.243.83: icmp_seq=1 ttl=61 time=2.72 ms
64 bytes from 10.254.243.83: icmp_seq=2 ttl=61 time=2.05 ms
64 bytes from 10.254.243.83: icmp_seq=3 ttl=61 time=1.88 ms
--- 10.254.243.83 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 1.885/2.224/2.728/0.363 ms
Traceback (most recent call last):
File "teste.py", line 15, in ?
main()
File "teste.py", line 12, in main
commands(ping)
File "teste.py", line 5, in commands
command = Popen(cmd, shell=True, stdout=PIPE)
File "/usr/lib/python2.4/subprocess.py", line 543, in __init__
errread, errwrite)
File "/usr/lib/python2.4/subprocess.py", line 891, in _execute_child
args = ["/bin/sh", "-c"] + args
TypeError: can only concatenate list (not "int") to list
Can someone help me with this error ?
</code></pre>
|
python
|
[7]
|
292,470 | 292,471 |
How do I call method in current view controller of tabbar controller?
|
<pre><code>@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *tabBarCtrl;
}
@end
@interface FirstViewController : UIViewController {
}
-(void)myMethod;
@end
</code></pre>
<p>I want to call myMethod in FirstViewControlle.m from MyAppDelegate.m.
I tried this.</p>
<pre><code>[self.tabBarCtrl.selectedViewController myMethod];
</code></pre>
<p>Compiler says "UIViewController may not respond to myMethod".
How do I call FirstViewController's method?</p>
|
iphone
|
[8]
|
2,072,583 | 2,072,584 |
How to get time difference in milliseconds
|
<p>I can't wrap my brain around this one so I hope someone can help. I have a song track that has the song length in milliseconds. I also have the date the song played in DATETIME format. What I am trying to do is find out how many milliseconds is left in the song play time.</p>
<p>Example</p>
<pre><code>$tracktime = 219238;
$dateplayed = '2011-01-17 11:01:44';
$starttime = strtotime($dateplayed);
</code></pre>
<p>I am using the following to determine time left but it does not seem correct.</p>
<pre><code>$curtime = time();
$timeleft = $starttime+round($tracktime/1000)-$curtime;
</code></pre>
<p>Any help would be greatly appreciated.</p>
|
php
|
[2]
|
3,671,205 | 3,671,206 |
DashPathEffect does not work when singleline is enabled
|
<p>When i
<br>- disable setSingleLine(false),
<br>- The dashed line, that i set using DashPathEffect, is nicely drawn as expected</p>
<p>But
<br>- enable setSingleLine(true),
<br>- the DashPathEffect i have set for my paint object does not work. No line is being drawn.
<br>- If i remove the path effect, the solid line is able to draw. Why???</p>
|
android
|
[4]
|
4,809,591 | 4,809,592 |
Jquery sorting by user entered text
|
<p>Is there a way to sort a array of names by a value that a user provides.</p>
<p>eg.</p>
<pre><code>names = ['Tom', 'John', 'Sam', 'Jane']
</code></pre>
<p>if the user then enters the name 'Sam' the array should change to:</p>
<pre><code>names = ['Sam', 'Tom', 'John', 'Jane']
</code></pre>
<p>also is it possible to sort where a name contains a certain word like 'Samuel' also contains
the word 'Sam'</p>
|
jquery
|
[5]
|
1,123,186 | 1,123,187 |
Returning the product of a list
|
<p>Is there a more concise, efficient or simply pythonic way to do the following?</p>
<pre><code>def product(list):
p = 1
for i in list:
p *= i
return p
</code></pre>
<p>EDIT:</p>
<p>I actually find that this is marginally faster than using operator.mul:</p>
<pre><code>from operator import mul
# from functools import reduce # python3 compatibility
def with_lambda(list):
reduce(lambda x, y: x * y, list)
def without_lambda(list):
reduce(mul, list)
def forloop(list):
r = 1
for x in list:
r *= x
return r
import timeit
a = range(50)
b = range(1,50)#no zero
t = timeit.Timer("with_lambda(a)", "from __main__ import with_lambda,a")
print("with lambda:", t.timeit())
t = timeit.Timer("without_lambda(a)", "from __main__ import without_lambda,a")
print("without lambda:", t.timeit())
t = timeit.Timer("forloop(a)", "from __main__ import forloop,a")
print("for loop:", t.timeit())
t = timeit.Timer("with_lambda(b)", "from __main__ import with_lambda,b")
print("with lambda (no 0):", t.timeit())
t = timeit.Timer("without_lambda(b)", "from __main__ import without_lambda,b")
print("without lambda (no 0):", t.timeit())
t = timeit.Timer("forloop(b)", "from __main__ import forloop,b")
print("for loop (no 0):", t.timeit())
</code></pre>
<p>gives me</p>
<pre><code>('with lambda:', 17.755449056625366)
('without lambda:', 8.2084708213806152)
('for loop:', 7.4836349487304688)
('with lambda (no 0):', 22.570688009262085)
('without lambda (no 0):', 12.472226858139038)
('for loop (no 0):', 11.04065990447998)
</code></pre>
|
python
|
[7]
|
4,423,622 | 4,423,623 |
Android key accumulation problem?
|
<p>I have problem with key:</p>
<p>When my App is loading, i press back key many times (about 20 times).
Via logcat, sometime i see:</p>
<pre><code>Key pressed - back key
Key Released - back key
Key pressed - back key
Key Released - back key
</code></pre>
<p>And sometime no log here. but when load finish, i'' see:</p>
<pre><code>Key pressed - back key
Key Released - back key
Key pressed - back key
Key Released - back key
Key pressed - back key
Key Released - back key
Key pressed - back key
Key Released - back key
...
enough 20 times
</code></pre>
<p>look like the phone save it to buffer :(</p>
<p>An the question, How can i remove this buffer? :((</p>
|
android
|
[4]
|
2,611,492 | 2,611,493 |
I need a Pop up with description when i click an image
|
<p>i need a pop up with description of an image when i click that image. How can this be done? Is there any plugin in wordpress that can do this?</p>
|
jquery
|
[5]
|
745,911 | 745,912 |
Remove trailing backslashes from char
|
<p>This is probably a novice question but I am not very good at C++ and still an early beginner. MY question is how do I strip bk any trailing backslashes from a char:</p>
<pre><code>extern "C" UINT __stdcall DeleteTrailingBackslash(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
LPWSTR szValueBuf = NULL;
char szInstallPath[MAX_PATH];
hr = WcaInitialize(hInstall, "DeleteTrailingBackslash");
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
hr = WcaGetProperty(L"INSTALLLOCATION",&szValueBuf);
ExitOnFailure(hr, "failed to get Install Location");
wcstombs(szInstallPath, szValueBuf, 260);
// I would like to strip back the trailing backslashes
// and re add the property to my MSI
hr = MsiSetProperty(hInstall, "INSTALLLOCATION", szInstallPath);
ExitOnFailure(hr, "failed to set the install location");
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
</code></pre>
<p><code>szInstallPath</code> could have either none, one or two backslashes, I need to remove backslashes if there are any. Can anyone point me in the right direction please for good website tutorials or anything?</p>
<p>Thanks</p>
|
c++
|
[6]
|
1,565,672 | 1,565,673 |
What is the meaning of NULL != value in C++?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bcondition">What is the difference between these (bCondition == NULL) and (NULL==bCondition)?</a> </p>
</blockquote>
<p>I was going through a piece of C++ code and came across a code like</p>
<pre><code>if (NULL != threadInfo)
{
...
...
}
</code></pre>
<p>I was just wondering is there any difference between using the expression </p>
<pre><code>if (threadInfo != NULL)
{
...
...
}
</code></pre>
<p>what is said above.
While reading the first one reads " If NULL not equals to ThreadInfo" and the second one reads "If threadInfo not equals to NULL". To me the second one makes more sense. </p>
|
c++
|
[6]
|
1,841,560 | 1,841,561 |
compare strings with one having nonreadable chars
|
<p>I am having problem regarding comparing two strings. One string has one or more nonreadable characters in it while other other string is same but in readable format.</p>
<p>When I try to use this, I am having trouble</p>
<pre><code>if (Alemria=Almería)...
</code></pre>
<p>I am having such string <code>Almería</code> in a table.</p>
<p>How can this be done?</p>
|
c#
|
[0]
|
315,118 | 315,119 |
How to retain checkbox state in jQuery
|
<p>I have added the followng code to disable the dropdown on unchecking the checkbox in jQuery, but the checkbox is not retaining the value:</p>
<pre><code>$(document).ready(function(){
//on check of the checkbox,the dropdown is enabled or disabled.
$("[id$=chkCashSettlementType]").toggle(
function()
{
$("[id$=ddlSettlementCurrency]").attr('disabled',$("[id$=chkCashSettlementType]").not(':checked'));
$("[id$=chkCashSettlementType]").attr('checked',false);
},
function()
{
$("[id$=ddlSettlementCurrency]").removeAttr('disabled');
$("[id$=chkCashSettlementType]").attr('checked',true);
}
)
});
</code></pre>
<p>Where did I go wrong?</p>
|
jquery
|
[5]
|
6,011,460 | 6,011,461 |
Back button affect on elements created dynamically by jquery
|
<p>I'm developing a page that makes extensive use of jQuery to dynamically create elements on the page.</p>
<p>After I post through to the next page and then click the back button, all the dynamically created elements disappear when using Chrome and IE.</p>
<p>However, in Firefox and Safari, the elements remain on the page.</p>
<p>How do I get Chrome and IE to display the same behavior as Firefox and Safari?</p>
<p>Thanks</p>
|
jquery
|
[5]
|
4,227,180 | 4,227,181 |
this code gives 0 as height and width for the first time it iterates and the second time gives the right dimensions
|
<pre><code>var icon1 = new Image();
icon1.src = resource;
var width = icon1.width;
var height = icon1.height;
</code></pre>
<p>This code when iterates gives 0 as width and height for the first time it iterates and for the second time it gives right dimensions.</p>
|
javascript
|
[3]
|
804,124 | 804,125 |
A LIFO data structure that holds max N items
|
<p>In java, which LIFO data structure class allows me to specify a MAX item size which automatically discards old items whenever adding an item will cause it to exceed MAX size.</p>
|
java
|
[1]
|
3,961,838 | 3,961,839 |
Python "ImportError: No module named numpy"
|
<p>Okay so I'm fairly new to Python, I ran the commands </p>
<pre><code>sudo easy_install pip
sudo pip install numpy
</code></pre>
<p>Afterwards, I typed python followed by <code>import numpy</code> and got the error <code>ImportError: No module named numpy</code></p>
<p>Did I miss something? Do I need to add something to sys.path?</p>
|
python
|
[7]
|
3,630,217 | 3,630,218 |
GDI+ and system graphics cards
|
<p>From my research I have seen that <code>GDI+</code> (if i am wrong correct me please) is used by <code>Graphics</code> to draw various object, but also to my knowledge I am unsure if it utilizes the systems graphics card? If it does not could someone please lead me to a way that I can tell it to utilize the graphics cards many features, like the shader etc, or at-least how to code my own DirectX, OpenGL engine? </p>
<p>Thanks in advance.</p>
<p>P.S. The main thing I wish to complete is to draw a pixel by pixel representation of various object.</p>
|
c#
|
[0]
|
1,706,554 | 1,706,555 |
PHP check if $_SESSION['text'] is text
|
<p>How can I check check that <code>$_SESSION['text']</code> is indeed text and not some malicious .exe?</p>
<p><strong>AND</strong>, if i do destroy_session(...) but set </p>
<pre><code>$a = $_SESSION;
</code></pre>
<p>does $a become NULL now?</p>
|
php
|
[2]
|
4,127,891 | 4,127,892 |
Iterators and multi-dimensional vectors?
|
<p>So, I am trying to build a two-dimensional vector that will hold indexes for selecting tiles from a tileset.</p>
<p>An iterator in one dimension is simple enough:</p>
<pre><code>std::vector<int> vec;
std::vector<int>::iterator vec_it;
for(int i=5; i>0; --i){
vec.push_back(i); }
//prints "5 4 3 2 1 "
for(vec_it = vec.begin(); vec_it != vec.end(); ++vec_it){
std::cout<<*vec_it<<' ';
}
</code></pre>
<p>However, I'm running into trouble when adding the second dimension. Here's the code that <b>doesn't</b> work:</p>
<pre><code>std::vector<std::vector<int> > vec(5);
std::vector<std::vector<int> >::iterator vec_it;
std::vector<int>::iterator inner_it;
for(int i=0; i<5; ++i){
vec[i].assign(5, 0);
}
for(vec_it = vec.begin(); vec_it != vec.end(); ++vec_it){
for(inner_it = *vec_it->begin(); inner_it != *vec_it->end(); ++inner_it){
std::cout<<*inner_it<<' ';
}
std::cout<<std::endl;
}
//should print:
//0 0 0 0 0
//0 0 0 0 0
//0 0 0 0 0
//0 0 0 0 0
//0 0 0 0 0
</code></pre>
<p>The compile fails with a nearly-incomprehensible error where I try to do <code>inner_it = *vec_it->begin()</code>, so I suppose my question is, how badly did I screw up?</p>
|
c++
|
[6]
|
1,690,360 | 1,690,361 |
Add method onto a single jQuery node
|
<p>Say that I have two html nodes like this:</p>
<pre><code><div class='node a'>one</div>
<input class='node b' value='two'>
</code></pre>
<p>and I'd like to add a method for $('.node.a'), but not for node b. What I'd really like to do is something like this:</p>
<pre><code>$('.node.a').addMethod('val', function() {
return $('.node.b').val();
});
alert($('.node.a').val()); // alerts 'two'
</code></pre>
<p>Clearly I don't want to override the 'val' method for every jQuery node. Is it possible to do this?</p>
<p><strong>* UPDATE *</strong></p>
<p>As per mgibsonbr's suggestion, I wrote a jQuery plugin to do this for me. Instead of using jQuery data method, I only run different functionality if the node in question is the one being called. This means that this form will not work for jquery lists that match multiple html nodes. Here it is:</p>
<pre><code>// overrides a method thats supposed to be called on a single node (a method like val)
$.fn.overrideNodeMethod = function(methodName, action) {
var originalVal = $.fn[methodName];
var thisNode = this;
$.fn[methodName] = function() {
if (this[0]==thisNode[0]) {
return action.apply(this, arguments);
} else {
return originalVal.apply(this, arguments);
}
};
};
</code></pre>
|
jquery
|
[5]
|
5,388,313 | 5,388,314 |
Comparing values of each integer within a range
|
<pre><code>n= int(raw_input(" Enter a number"))
i = 0
length = 0
maxLength = 0
for i in range(1, n - 1):
if length > maxLength:
maxLength = length
i = i + 1
*run other program which gets value*
code
code
code
print i
print maxLength
</code></pre>
<p>So, what I have so far is a program that of course gets a value, what I need to do with this value, is create a loop that will compare the value of each integers value within range of integers between 1 and the user input or "n", than output the integer with the highest value, and what that value is within the range.</p>
|
python
|
[7]
|
3,721,242 | 3,721,243 |
Execute with a run time of O(n^3 log n) with 2 loops
|
<p>I've been trying to figure this out for a while and I just cant get it. Any help would be great. I'm programming in C++.</p>
<p>Find a run time of O(n^3 log n) using two looping structures.</p>
|
c++
|
[6]
|
4,199,183 | 4,199,184 |
homepage url as mysite.com/ rather than mysite.com/index.html
|
<p>I have a site I want to deploy and as part of the finishing touch, I'd like to have the url in the browser show www.mysite.com/ instead of www.mysite.com/index.html</p>
<p>How is this done?</p>
<p>Thanks. </p>
|
asp.net
|
[9]
|
4,476,885 | 4,476,886 |
Does it make sense to use std::uninitialized_fill() with any allocator?
|
<p>Does it make sense to initialize memory with <code>std::uninitialized_fill()</code> in a library when an allocator passed as argument by the user has been used to get the memory itself? I ask this because an allocator is supposed to have provide its own <code>construct()</code> method (other than the <code>allocate()</code> method), the implementation of which might differ from the standard one, so probably <code>std::uninitialized_fill()</code> is not always appropriate in all the cases.</p>
<p>To be precise, my doubts come from the C++ book written by Stroustrup (appendix E "Standard-Library Exception Safety", section E. 3.1), in which the author gives a possible implementation of a <code>template<class T, class A> vector<T,A>::vector(size_type n, const T& val, const A& a)</code>: the allocator a is used to get the memory for the vector, then <code>std::uninitialized_fill()</code> is used to initialize the obtained memory.</p>
<p>He also gives the implementation of <code>std::uninitialized_fill()</code>, which internally uses the standard placement new to initialize the the memory, but there is no longer evidence of the <code>construct()</code> method of the allocator passed as argument to the vector constructor.</p>
|
c++
|
[6]
|
1,953,456 | 1,953,457 |
How do I sync application data between an iPhone and another computer?
|
<p>I'm working on an iPhone application that would allow viewing and editing of data that I want to keep in sync with a desktop application. I don't see anything in the SDK that directly addresses data synchronization, nor can I find anything that allows my to "hook" into the iTunes sync process.</p>
<p>I could do something kludgy like hiding the data in a photo or address book entry, but that just seems like a bad idea. I could use WebDAV or HTTP to get/put data to a server, but it makes the application more complicated.</p>
<p>I guess I was expecting this to be a common use-case for iPhone apps (syncing arbitrary application data between a desktop and the iPhone) and that there would be a set of APIs in the SDK that cover this. Maybe there is and I just can't find it.</p>
|
iphone
|
[8]
|
3,751,325 | 3,751,326 |
NullReferenceException in copy/ paste of image
|
<p>I am getting an error by implementing this simple code. I donot understand where I am doing mistake.</p>
<p>// ERROR</p>
<blockquote>
<p>An unhandled exception of type 'System.NullReferenceException' occurred in ImageCSharp.exe<br>
Additional information: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.</p>
</blockquote>
<p>I can get clipboard text but why i can't get /set image.</p>
<p>//CODE</p>
<pre><code> public void copy()
{
// Determine the active child form.
fImage activeChild = this.ActiveMdiChild as fImage;
if (activeChild != null)
{
PictureBox mypicbox = activeChild.picbox;
string win_name = activeChild.Tag.ToString();
Clipboard.SetImage(mypicbox.Image);
Clipboard.SetText(win_name);
}
}
private void paste()
{
Image im= Clipboard.GetImage();
this.pictureBox1.Image = im;
MessageBox.Show(im.Size.ToString());
}
</code></pre>
<p>regards,</p>
|
c#
|
[0]
|
2,129,355 | 2,129,356 |
Create an iterator from a certain point
|
<p>for example i got a list</p>
<pre><code>L = [1,33,55,777,'abc'....]
</code></pre>
<p>i want to iterate it from a certain point like from the second element,this is what i used to do</p>
<pre><code>for x in L[1:]:
print(x)
</code></pre>
<p>thus works but made a shallow copy of part of the original list,or i can use the subscript</p>
<pre><code>for x in range(1,len(L)):
print(l[x])
</code></pre>
<p>is there a way in python to create an iterator in lowerer cost ?which may looks like this one:</p>
<pre><code>for x in iter(L,1): #iter from index 1 to the end
print(L[x])
</code></pre>
|
python
|
[7]
|
1,746,582 | 1,746,583 |
Creating a 2D array for JQuery
|
<p>I have an array that i want to include when creating a 2D array:</p>
<pre><code>var v=[22,34,13,13];
var dataV = new Array();
for(var i=0; i<4; i++)
dataV = [i,v[i]];
console.log(dataV);
</code></pre>
<p>Output should be:</p>
<pre><code>[[0, 22],
[1, 34],
[2, 13],
[3, 13]]
</code></pre>
<p>I am using this array with JQuery charts. However the chart seems to only show the last value (13).
Anyone know if i am not converting my array properly.</p>
|
javascript
|
[3]
|
2,883,841 | 2,883,842 |
jquery selector for selected siblings of a common parent
|
<p>I have a menu structure as follows:</p>
<pre><code><li><a href="#" class="navCars">Cars</a><img src="images/navbar-menu-divider.png" class="divider"></li>
<li><a href="#" class="navTrucks">Trucks <img src="images/navbar-menu-down-arrow.png/"></a><img src="images/navbar-menu-divider.png" class="divider"></li>
<li><a href="#" class="navBoats">Boats <img src="images/navbar-menu-down-arrow.png/" class="menu_arrow"></a><img src="images/navbar-menu-divider.png" class="divider"></li>
</code></pre>
<p>For the Trucks and Boats items which support a dropdown, I need to change the .divider images to the left and right of a given menu item on mouse over. I've tried this selector to grab the right side:</p>
<pre><code>$( ":parent .divider", this ).attr( "src", "images/navbar-menu-hover-right.png" );
</code></pre>
<p>Which doesn't seem to work. To get the left side, I need to go up a level, find the previous sibling, then get its .divider (though I'm sure there are several alternatives).</p>
<p>Any help from jquery magicians appreciated!</p>
|
jquery
|
[5]
|
3,595,409 | 3,595,410 |
Why does this C++ code output the result?
|
<p>This is the <code>C++</code> code:</p>
<pre><code>#include<iostream>
using namespace std;
int a=8;
int fun(int &a)
{
a=a*a;
return a;
}
int main()
{
cout << a << endl \
<< fun(a) << endl \
<< a << endl;
return 0;
}
</code></pre>
<p>why does it output:</p>
<h2><code>64 64 8</code></h2>
<p>the <code><<</code> operator's associativity is left to right, so why not output <code>8 64 64</code>?</p>
<p>Does it have the relation to the sequence point and the effect side? </p>
|
c++
|
[6]
|
2,399,424 | 2,399,425 |
Disable click event for status bar in android
|
<p>I want to disable the click event for status bar in android.how TO DO THIS.</p>
<p>Thanks in advance.</p>
|
android
|
[4]
|
3,430,830 | 3,430,831 |
How to get File-Type of an Image in a HTML page?
|
<p>I've wrote a short script to upload images from a URL so as not to hotlink to them. If the image extension is not a .jpeg then the image that is uploaded is broken. I can't figure out how to preserve the file extension or filename so I've had to add a timestamp to them and a static extension.</p>
<pre><code><?php
ini_set('user_agent', 'TEST/1.0 +http://127.0.0.1');
require_once('simple_html_dom.php');
// Create DOM from URL
$html = file_get_html('http://www.discogs.com/viewimages?release='.$_POST["album_id"]);
// Grab the coverart
$img = $html->find('.image_frame', 0);
$url = $img->src;
$file = file_get_contents($url);
$image = 'discogs_'.time().'_image.jpeg';
file_put_contents('/path/to/file/'.$image,$file);
echo $image;
?>
</code></pre>
<p><strong>Updated code with Baba's help</strong>: <a href="http://codepad.org/3zH3B882" rel="nofollow">http://codepad.org/3zH3B882</a></p>
|
php
|
[2]
|
859,087 | 859,088 |
body onload event after click on link
|
<p>Basically, I have link on my page test.php page.</p>
<pre><code> <a href="demo.php">click</a> <!-- test.php page -->
</code></pre>
<p>I want to call function on body onload event on demo.php page everytime but only when click on link above then it would not be called on page refresh.</p>
<pre><code> <body onLoad="JavaScript:event(1,product,100);"> <!-- demo.php page -->
</code></pre>
|
javascript
|
[3]
|
1,708,012 | 1,708,013 |
Android device telephone number
|
<p><strong>I am using the below method to get the phone number of my device</strong></p>
<pre><code>
private void getMyNumber()
{
// read_phone_State permission is specified
String ph_num ="";
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
ph_num = telephonyManager.getLine1Number(); // returning null
ph_num = telephonyManager.getSimSerialNumber(); // returning sim serial number
ph_num = telephonyManager.getSubscriberId(); // returning id
ph_num = telephonyManager.getVoiceMailNumber(); // returning null
}
</code></pre>
<p>Any ideas ... how to get the phone number</p>
|
android
|
[4]
|
2,546,625 | 2,546,626 |
Python : populate a new column with an if/else statement
|
<p>I have a csv file composed of three column.</p>
<p>My goal is to add a fourth column and populate it with a statement based on my columns n°2 and n°3.</p>
<p>Here is the beginning of my code : </p>
<pre><code>import csv, sys, locale, operator
abord = "/home/julien/csv/ABORD.csv"
file1 = open (abord, 'rb')
reader1 = csv.reader (file1, delimiter = ';', quotechar=' ')
next(reader1)
for row1 in reader1:
ID = row1 [0]
LARG_1 = row1 [1]
LARG_2 = row1 [2]
</code></pre>
<p>And I want to make things like that :</p>
<pre><code>if LARG_1 > 10 and LARG_2 <20:
print "result OK" in a fourth column "CONTROL"
else:
print "result fail" in the fourth column "CONTROL"
then save the csv, nom composed of 4 columns
</code></pre>
<p>Do you know how I could do it ? Thank you !</p>
|
python
|
[7]
|
3,837,056 | 3,837,057 |
Which 2D game engine should I use?
|
<p>I'm a newbie programmer and I want to make a 2D platformer game in python.I can make simple programs, but I haven't made any games yet. There are number of game engines out there, but I can't choose :D The engine should have some simple tutorials for beginners. I am considering Pyglet, because I've read some good stuff about it, but I can't find any suitable tutorials about it.</p>
<p>Thanks for your help.</p>
|
python
|
[7]
|
3,330,527 | 3,330,528 |
iPhone Development Developer Program and a Client
|
<p><strong>Note:</strong> I have given up on compiling iPhone Apps without a developer certificate for the SDK 3.x... for now. But <a href="http://stackoverflow.com/questions/2357731/self-signing-code-in-xcode-for-iphone">it wasn't for a lack of trying.</a> Anyway...</p>
<p>I work for a client who will will be making iPhone Apps but will <strong>not</strong> deliver them through the AppStore for the time being. I will be testing and deploying iPhone apps to a device I own, and they will need to distribute to their iPhones/iPod Touches. If I buy a $99 developer certificate, will that be enough to distribute an app onto iPhones that are <strong>not</strong> connected to my computer?</p>
<p><strong>If not, how can this be done for testing -- distributing to other iPhones -- with the least number of certificates?</strong> <a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/128-Managing_Devices/devices.html" rel="nofollow">I have checked this out a bit</a>, but I haven't been able to fully undertand it (I'm kind of busy trying to learn to program for the iPhone :)</p>
|
iphone
|
[8]
|
5,366,083 | 5,366,084 |
iPhone:iPhone Configuration profile email setting unable to edit on the device?
|
<p>I have an iPhone program, which picks an iPhone Configuration profile which has set-up for an email(pop). My program downloads this profile and installs on the device via safari browser to create the new email account on the device. The issue is, after installed the profile successfully, if i want to manually edit the account information(for ex: username, email address) from “Settings->Mail, Contacts, Calendars” mail account screen on the device, i'm not allowed to edit except 'password' and 'description' field. Is it restricted by iOS? If we install any Configuration Profile on the device which creates mail box, then we can't edit the account information(for ex: username, email address) from “Settings->Mail, Contacts, Calendars” mail account screen on the device? </p>
<p>Please provide me the answer if anyone come across with this issue.</p>
<p>Thank you!</p>
|
iphone
|
[8]
|
3,795,752 | 3,795,753 |
Java graph plotting library
|
<p>I have to draw a line graph for some inputs (x/y), what is the best java client library for graph plotting</p>
|
java
|
[1]
|
2,809,688 | 2,809,689 |
Android : how to set Default zoom lable of pdf inside webview?
|
<p>Is there any way to increase the default zoom level of pdf showing in webview?</p>
<p>I am using the google docs url for open the pdf inside web view. it's open pdf file correctly but it's only zoom my file upto 100%. i want to zoom upto 200% like adobe reader.</p>
<p>Thanks in advance !</p>
|
android
|
[4]
|
868,093 | 868,094 |
sqlite tutorial create and view
|
<p>I am looking for an example or tutorial for sqlite. What I need to do is put info into the database from an input then on another screen display what has been inputted previously.</p>
<p>I know it's pretty basic stuff but I don't know what to do. (I'm not asking for someone to do it for me just a tutorial that I could learn from</p>
<p>any help would be appreciated</p>
|
android
|
[4]
|
169,990 | 169,991 |
Workaround for setBackgroundDrawable on android?
|
<p>The <code>setBackgroundDrawable()</code> method of the <code>View</code> class in is now deprecated in android SDK API level 16.</p>
<p>The new method is <code>setBackground()</code> but of course it's only available in API 16.</p>
<p>How can I workaround it if I want my application to be compatible with previous API levels ? (at least API 14)</p>
<p>The goal is to eliminate any warnings and an @SupressWarnings is not a solution for me.</p>
|
android
|
[4]
|
649,008 | 649,009 |
extract last argument from url using php
|
<p>I have either an URL like this: <code>http://url.com/test.html?var1?var2</code> or like this: <code>http://url.com/test.html?var2</code></p>
<p>how can I, using php always extract var2? meaning $variable = var2.</p>
<p>Please note that somehow the server I'm working on doesn't support $_GET. It just doesn't work.</p>
<p>thank you for your kind help :)</p>
<p>EDIT: after using <code>print_r($_GET)</code> on this url: <code>http://xxxxxx.com/partners/?page_id=1012?selectuser=1</code> I get: <code>Array ( [page_id] => 1012?selectuser=1 )</code></p>
<p>but when i do an <code><?php echo $_GET['selectuser']; ?></code> nothing gets echoed...</p>
<p>EDIT 2: doing an <code><?php var_dump($_GET['selectuser']); ?></code> on <code>http://xxxxxx.com/partners/?page_id=1012?selectuser=1</code> I get <code>NULL</code></p>
|
php
|
[2]
|
3,416,474 | 3,416,475 |
c++ way to enlarge size of array by two?
|
<p>This is my current code. Is there a nicer way to do the same in c++?</p>
<pre><code>{
// create more room in array
Point *temp = new Point[pointList.getSize()*ENLARGE_TIMES];
memcpy(temp,pointList._pointList,sizeof(Point)*pointList.getSize());
pointList.~PointList();
pointList._pointList = temp;
pointList.setSize(pointList.getSize()*ENLARGE_TIMES);
pointList._pointList[iterator] = point;
iterator++;
pointsCounter++;
continue;
}
</code></pre>
<p><strong>EDIT: can't use a vector</strong></p>
|
c++
|
[6]
|
2,660,476 | 2,660,477 |
Enum with methods for functionality (Combine Class / Enum)
|
<p>I may miss some sort of point here, if that's the case - please include that discussion as a part of my question :).</p>
<p>This is a shortened down and renamed sample of a working code. The GetTicks(..) is a single sample, which could be any sort of functionality (value of <code>> 0 < 9</code> should return a specific Enum a.so).</p>
<pre><code>public static class Something
{
public enum TypeOf : short
{
Minute = 2, Hour = 3, Day = 4, ........
}
public static long GetTicks(Something.TypeOf someEnum)
{
long ticks = 0;
switch (someEnum)
{
case Something.TypeOf.Minute:
ticks = TimeSpan.TicksPerMinute;
break;
case Something.TypeOf.Hour:
ticks = TimeSpan.TicksPerHour;
break;
....
}
return ticks;
}
}
// This class is called from anywhere in the system.
public static void SomeMethod(string dodo, object o, Something.TypeOf period)
{
// With the design above
long ticks = Something.GetTicks(period);
// Traditional, if there was a simple enum
if (period == Something.Day)
ticks = TimeSpan.FromDays(1).Ticks;
else if (period == Something.Hour)
ticks = TimeSpan.FromHours(1).Ticks;
}
</code></pre>
<p>The idea is to collect functionality that concerns a enum, near as possible to the enum itself. The enum is the reason function. Also I find it easy and natural to look for such functionality near the enum. Also it's easy to modify or extend.</p>
<p>The drawback I have, is that I have to state the enum more explicit <code>Something.TypeOf</code>. The design may look no-standard? and would apply if the enum was for internal use in the class.</p>
<p>How would you do this more nice?
I tried abstract, base inheritance, partial. None of them seem to apply.</p>
|
c#
|
[0]
|
5,133,651 | 5,133,652 |
perfekt editor with a black theme for windows
|
<p>like many of you, I code my javascript projects in eclipse because it offers hundrets of different views and optional built in svn/git support </p>
<p>after working for hours with eclipse my eyes really feel punished because of the bright white workspace windows. also the code completion lacks many things.. even now that JS is a really etablished language. and also the eclipse javascript validator fails so many times, throwing annoying error pop ups.</p>
<p>at first i tried to find another editor with git/svn built in support, that also comes with a black theme. i couldnt find anything useful here.
secondly i became aware that there is an eclipse theming plugin and another one for fullscreen. both are a good start, but it still looks like a hacky solution.. </p>
<p>it seems you cant theme the eclipse frames and things like the code sync are also no themable, so you end up with black marks on a black background.</p>
<p>is there something between VIM and eclipse that you are maybe aware about? even if i would have to do my svn / git via console/tortoise, but i cant stand the overcrowded looks of eclipse any longer. </p>
|
javascript
|
[3]
|
3,224,857 | 3,224,858 |
stl list - complexity
|
<p>Are all the inserts (anywhere) for the list constant?</p>
<p>What about access? </p>
<p>Front, back - constant time?</p>
<p>and in the middle of the list - linear time?</p>
|
c++
|
[6]
|
2,968,667 | 2,968,668 |
Is it good to cache page with cookies?
|
<p><b>I use cookies for page cache, is that okay?</b></p>
<p>To show partially static contents( updated very rarely from database),
i don't like to interact much with database so can i use cookie to store that results in client's computer and display data directly from it?</p>
<p>For data authenticity and integrity, i created a crc for data and stored along with data in that cookie.
THe algorithm of crc calculation is hardcoded(assume), so</p>
<p><b>Does the idea has any demerits?</b></p>
|
php
|
[2]
|
318,711 | 318,712 |
Setting focus on hidden textbox field using Javascript
|
<p>How can I set focus on hidden textbox element?</p>
<p>I tried using </p>
<pre><code>document.getElementById("textControl_fd_component_JSON_TASK_NStext64").focus;
</code></pre>
<p>But, this does not work here </p>
<pre><code>alert(document.activeElement.id); returns null.
</code></pre>
<p>When I made this field visible, above script worked fine. </p>
<p>Any guesses where I am getting it wrong?</p>
|
javascript
|
[3]
|
2,182,433 | 2,182,434 |
download the file from the navigation link from the website by logging in from Console application C#
|
<p>I would like to download excel file from the website using user name and password. After logging in, there is a link for downloading the excel file. When I clicked it, the Save as message asks me to save in the desired folder. I am using this function and it doesn't work. It just downloads the html page. Any suggestions would be appreciated. </p>
<p>ftpfullpath is the url + file name</p>
<p>if I use the login form url, it shows error.</p>
<pre><code> public static void DownloadFileFTP()
{
//Delete if Data feed file is already existed
if (File.Exists(GetFileName.source_path))
{
File.Delete(GetFileName.source_path);
}
//Create a WebClient
WebClient request = new WebClient();
//Set up credentials
request.Credentials = new NetworkCredential(Properties.Resources.UserName, Properties.Resources.Password);
//Download the data into Byte array
byte[] fileData = request.DownloadData(Properties.Resources.ftpfullpath);
//Create a Filestream to write to Byte array
FileStream sourceFile = File.Create(GetFileName.source_path);
try
{
//Write full byte array to the file
sourceFile.Write(fileData, 0, fileData.Length);
Console.WriteLine("Download Complete " + GetFileName.source_path);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
if (sourceFile != null)
{
sourceFile.Close();
sourceFile = null;
}
}
}
</code></pre>
|
c#
|
[0]
|
2,808,110 | 2,808,111 |
Creating a list of lists with consecutive numbers
|
<p>I am looking for a convenient way to create a list of lists for which the lists within the list have consecutive numbers. So far I only came up with a very unsatisfying brute-typing force solution (yeah right, I just use python for a few weeks now):</p>
<pre><code>block0 = []
...
block4 = []
blocks = [block0,block1,block2,block3,block4]
</code></pre>
<p>I appreciate any help that works with something like <code>nrBlocks = 5</code>. </p>
|
python
|
[7]
|
5,367,589 | 5,367,590 |
Problem in getting response from webserver
|
<p>I am sending data to webserver in the Querystrings by creating URL dynamically. When I view that URl in UIAlertView it shows me correct one.</p>
<p>And when i try to get response using NSURL code, it does not respond.
Below is the code.</p>
<pre><code>NSString *uu = @"http://www.zenhomeenergy.com/ZenIphoneServUpdate.aspx?CustomerID=11&FirstName=Rob&LastName=O'Connell&State=VIC&Street=4 Southey Street Brighton&PostCode=3186&Email=rob@rob.com&Mobile=04545455454&HomePhone=54545545545&WorkPhone=787878787878&PrimaryResidence=False&HomeOwner=True";
NSString *text = [NSString stringWithContentsOfURL:[NSURL URLWithString:uu]];
if(text) {
if([text isEqualToString:@"Success."]) {
textView.text = [textView.text stringByAppendingString:@"Success.\n"];
} else {
textView.text = [textView.text stringByAppendingString:@"Failed.\n"];
}
}
</code></pre>
<p>If you try putting the above URL into browser it says "Success."
But the code above does not work.</p>
<p>OR if you have another easier way of sending data please tell me that as well.</p>
<p>Please Help.</p>
|
iphone
|
[8]
|
1,535,446 | 1,535,447 |
Notice warnings dealing with PHP
|
<p>I am making a quiz on a webpage for my media class, however, I am running into trouble. When i submit my quiz, I am receiving notices that say: </p>
<blockquote>
<p>Notice: Undefined variable: all_my_variables in /var/www/html/horvati2-results.php on line 65 </p>
<p>Notice: Undefined variable: current_timestamp in /var/www/html/horvati2-results.php on line 69 </p>
<p>Notice: Undefined variable: SERVER in /var/www/html/horvati2-results.php on line 70 </p>
</blockquote>
<p>This portion of my PHP looks like this:</p>
<pre><code> $csv_filehandle = fopen("/var/www/html/data/quiz.csv",'a');
fputcsv($csv_filehandle,array($summer,$spring,$fall,$winter));
fclose ($csv_filehandle);
$visit_id = uniqid('',TRUE);
$json_filehandle = fopen("/var/www/html/data/$visit_id.json",'w');
fwrite($json_filehandle,json_encode($all_my_variables));
fclose($json_filehandle);
$all_my_variables = array(
'timestamp' => $current_timestamp,
'user_ip' => $SERVER['REMOTE_ADDR'],
'summer' => $summer,
'spring' => $spring,
'fall' => $fall,
'winter' => $winter,
);
$current_hour = date_default_timezone_set("America/Chicago");
$current_timestamp = date(DATE_RFC822);
</code></pre>
<p>I would greatly appreciate some help!</p>
|
php
|
[2]
|
473,971 | 473,972 |
myVar.constructor --or-- typeof myVar ---What is the difference?
|
<p>What is the difference between...</p>
<pre><code>if(myVar.constructor == String)
</code></pre>
<p>and </p>
<pre><code>if(typeof myVar == "string")
</code></pre>
|
javascript
|
[3]
|
3,218,358 | 3,218,359 |
Please add a timer to this code given
|
<p>Sorry.. Since question was not clear deleting the question</p>
|
java
|
[1]
|
725,544 | 725,545 |
Facebook session Fetching from facebook app in iphone
|
<p>I have created a sample iphone application that uses facebook api. Its work fine.I have logged in using facebook api and store the accessstoken and expiredate in NSUserDefault. When they again enter into my application.I have checked the facebook session is valid,if its valid we cannot show a login screen.</p>
<p>We use the session for further operation. This is the process my app working now.</p>
<p>What i want is , I have downloaded a facebook app in my iphone.I logged into facebook app using my facebook account. Now i want to run my sample application,it shows an login dialog.
Here i dont want to get user credential because they already logged in on facebook app.So i want to get that facebook sesssion and use it in my application.</p>
<p>Is it possible ? Thanks in advance..........</p>
<p>My objective is to get the facebook session from another application .(If he logged in using facebook account.)</p>
|
iphone
|
[8]
|
35,310 | 35,311 |
PHP Mail() $to cannot be 2 letters?
|
<p>i have a mail form that will send mail if it is going to a name like </p>
<pre><code>"someone@someplace.com"
</code></pre>
<p>but it will not work if the email address is </p>
<pre><code>"cs@someplace.com"
</code></pre>
<p>Does mail() do some sort of validation before sending?</p>
<p>Also, its my understanding that valid email addresses must have at least 2 valid characters before the @ symbol.</p>
<p>Thoughts?</p>
|
php
|
[2]
|
5,104,782 | 5,104,783 |
Android: Background music is playing while lock screen is on
|
<p>If my activity is running in the foreground and the display is turned off and then turned back on again the background music starts to play again before the screen is unlocked. The background music is paused in onPause() and continues to play in onResume(). So when the app is pushed to the background the music stops.
Is there a way to prevent the music from playing while the lock screen is on?</p>
<p>//André</p>
|
android
|
[4]
|
4,714,079 | 4,714,080 |
Getting the selected text from a select list using jQuery selector
|
<p>I'm trying to get the selected text from a dropdown using a selector. If I reference the dropdown directly by name it works:</p>
<pre><code>$('#aBigLongASP.NETWebformsGeneratedName_ddl_StateOfOption :selected').text()
</code></pre>
<p>I am however trying to use a selector to select the dropdown using only the last part of the name:</p>
<pre><code>$('#select[id$='ddl_StateOfOption']) :selected).text();
</code></pre>
<p>but I can't quite seem to get it to work. The Chrome developer tool throws the following error:</p>
<blockquote>
<p>SyntaxError: Unexpected identifier</p>
</blockquote>
<p>Can anyone point out where the error is?</p>
|
jquery
|
[5]
|
2,075,768 | 2,075,769 |
Android - Notify the user about availability of new version from a Service
|
<p>I have written code to programmatically check a URL the for new version of application from a <code>Service</code>. The URL will return the latest version and URL of the APK file.</p>
<p>Now how can I notify the user about the update from the <code>Service</code>?</p>
<p>I want to show some dialog box/some message box in the layout itself with the direct link to the APK or a clickable link where user can manually download the APK file.</p>
<pre><code>if (latestVersionCode > currentVersionCode) {
// Notify the user
}
</code></pre>
|
android
|
[4]
|
2,663,266 | 2,663,267 |
android emulator is not showing display . .
|
<p>In AVD manager if i click start the AVD, launching status is showing and the emulator process in task manager is created. but the AVD is not displaying. I am having the same problem with eclipse also. the eclipse console displaying that : </p>
<p>[2012-04-29 10:33:53 - HelloAndroid] Launching a new emulator with Virtual Device 'DeployAVD'</p>
<p>and nothing happens after that. what is the problem here??</p>
<p>thanks.</p>
|
android
|
[4]
|
4,154,186 | 4,154,187 |
Why is it true that "every variable does not necessarily have a name"?
|
<p>I have this as a T/F question on my study guide for the test with the teacher's answer as true, but can't seem to find a definitive answer as to why which I would like to know.</p>
|
java
|
[1]
|
4,307,628 | 4,307,629 |
Resume Activity with back button
|
<p>I have an application I am creating with a DashboardActivity & a SettingsActivity. On the dashboard, I have one object displayed, but when I go into settings, I want to be able to select/deselect X options. Once the user clicks the back button, I save that data locally and to the server. Once the phone receives a success message from the server that it was stored properly, I want to reload the dashboard. </p>
<p>I thought I would do this with the onPause and onResume, but they are called when the DashboardActivity is first created. What would be the best way to reload the dashboard by calling my web service after the settings were saved to the server? Here is what I am doing when the back button is hit</p>
<pre><code>@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//Save data to the server once the user hits the back button
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
SchoolSearchActivity.this.divisionProxy = new DivisionProxy(SchoolSearchActivity.this.saveUserDivisionHandler);
SchoolSearchActivity.this.divisionProxy.submitUserDivisions(SchoolSearchActivity.this.userDivisions, SchoolSearchActivity.this.user_id);
//SchoolSearchActivity.this.finish();
//Toast.makeText(SchoolSearchActivity.this, "Divisions Saved",Toast.LENGTH_LONG).show();
}
return true;
}
</code></pre>
<p>The above opens an HTTP connection, and when the response is received, the handler processes the response. I want to:
1) submit the data to the server
2) return to the previous activity
3) show a progress dialog until the response from #1 returns (response handler is in the settings activity; and we are now in the dashboard activity)
4) "refresh" the dashboard</p>
<p>What is the best way to accomplish this so I can just resume the dashboard as it was. Like I said, when I overwrite the onResume method, it is called when the activity is first created. I was considering putting my webservice call in onResume, so it's called once everytime you make it to the Activity, but it doesn't seem like the cleanest way.</p>
<p>What would you suggest for 1-4?</p>
|
android
|
[4]
|
4,074,690 | 4,074,691 |
How can we post message to google plus by oauth api?
|
<p>I have went through google api documentation and so many reference links. but i have never seen related to google plus post message. In Google API Documentation They shows </p>
<p>Note: The Google+ API currently provides read-only access to public data. All API calls require either an OAuth 2.0 token or an API key.</p>
<p>Is there any other way to implement this?. Please, can any one help me? </p>
|
php
|
[2]
|
2,791,084 | 2,791,085 |
automatically pick random select choices in web form
|
<p>I have a page with a bunch of radio fields. How can I create a script that will loop through each select group and pick a random choice from each.</p>
<p>I already have sections of the site implemented with scriptaculous, which has known jquery compatibility issues.</p>
|
javascript
|
[3]
|
1,224,087 | 1,224,088 |
Async task android onPostExecute
|
<p>In my android application i use AsyncTask to download the image from internet.</p>
<p>I pass the url and my AsyncTask does the download. But how do i return the bitmap back to my activity. Currently i pass the callback function to my asynctask constructor and in the OnPostExecute i invoke the callback function. Is this the correct way to do it.</p>
|
android
|
[4]
|
4,705,394 | 4,705,395 |
iPhone database load
|
<p>I have a sqlite databse that holds a table. The table contains about 7500 data. I've fetch the 7500 data in a UITableView. A UISearchBar is used to search the UITableView.There is no problem in simulator but when I run in a iPhone device, then it will take time to load and when I type to SearchBar then it hangs the device keyboard.</p>
<p>Is there any optimal solution to load 7500 data in a UITableView?</p>
|
iphone
|
[8]
|
127,512 | 127,513 |
Ajax PHP Search, Query result instead of XML
|
<p>I'm following the <a href="http://www.w3schools.com/php/php_ajax_livesearch.asp" rel="nofollow">tutorial from w3schools</a> on ajax search and I'm having some trouble tweaking the code. The structure I got is: </p>
<p><strong>search.php</strong> - ( <em>Where the search terms ?q=search will output a result as</em> <code>echo $result</code> )</p>
<p><strong>livesearch.php</strong> - ( <em>Where it will exchange information between search.php and search.html</em> )</p>
<p><strong>search.html</strong> - ( <em>Where it contains java script and what not</em> )</p>
<p>How can I, please, make it instead of grabbing information from XML, grab from the output string in search.php? In other words, if the HTTP request is "livesearch.php?q=searchTerm", I want to output "searchTerm."</p>
|
php
|
[2]
|
3,664,549 | 3,664,550 |
How to stop an Activity from parent Activity?
|
<pre><code>_alerts = new Intent(homeActivity,Alertss.class);
homeActivity.startActivity(_alerts);
...
...
...
homeActivity.stopService(_alerts);
</code></pre>
<p>I need to stop the Activity i created from the object where i created it. I tried it in the way above but it did not work. Can any one suggest me a way to do this.</p>
|
android
|
[4]
|
3,182,948 | 3,182,949 |
Python: get datetime for '3 years ago today'?
|
<p>This must be a duplicate (and documented), but I can't find the answer via Google.</p>
<p>In Python, how do I get a datetime object for '3 years ago today'?</p>
<p>Thanks!</p>
<p>UPDATE: FWIW, I don't care hugely about accuracy... i.e. it's Feb 29th today, I don't care whether I'm given Feb 28th or March 1st in my answer. Concision is more important than configurability, in this case.</p>
|
python
|
[7]
|
622,395 | 622,396 |
Get files form dir with glob and check if it is in array then include?
|
<p>How could I use the php function <code>glob</code> to get files from a directory and put them in an array and then include them with <code>index.php?file=filename</code> if it exists?</p>
<p>This is what I came up with so far but it doesn't work.</p>
<pre><code>$files = glob("files/*.php");
$file = array($files);
if (in_array(..
</code></pre>
<p>OR is there a smarter way to do this without having to write all pages in the <code>index.php</code>?</p>
|
php
|
[2]
|
1,001,807 | 1,001,808 |
networkStream.Read is blocking
|
<p>I'm writing a simple application which will connect with a server. However I want to send simple chat commands aswell (see <code>Console.ReadLine</code> below). However this script won't get to <code>string Message = Console.ReadLine();</code> since it's blocked at <code>bytesRead = clientStream.Read(message, 0, 4096);</code>.</p>
<p>I want to continue this script, but if there's bytes incoming, it should process them (like it's doing now) and if no bytes are incoming, it should go through the script and wait for user input). How can this be achieved?</p>
<pre><code> TcpClient tcpClient = (TcpClient)client;
NetworkStream clientStream = tcpClient.GetStream();
byte[] message = new byte[4096];
int bytesRead;
while (true)
{
bytesRead = 0;
try
{
// Blocks until a client sends a message
bytesRead = clientStream.Read(message, 0, 4096);
}
catch (Exception)
{
// A socket error has occured
break;
}
if (bytesRead == 0)
{
// The client has disconnected from the server
break;
}
// Message has successfully been received
ASCIIEncoding encoder = new ASCIIEncoding();
// Output message
Console.WriteLine("To: " + tcpClient.Client.LocalEndPoint);
Console.WriteLine("From: " + tcpClient.Client.RemoteEndPoint);
Console.WriteLine(encoder.GetString(message, 0, bytesRead));
// Return message
string Message = Console.ReadLine();
if (Message != null)
{
byte[] buffer = encoder.GetBytes(Message);
clientStream.Write(buffer, 0, buffer.Length);
clientStream.Flush();
}
</code></pre>
|
c#
|
[0]
|
1,229,828 | 1,229,829 |
Do you think that storing a variable length encoding in std::string or std::wstring is OK and do you do it?
|
<p>I'm kind of horrified that people actually suggest using UTF-8 inside a <code>std::string</code> and are OK with UTF-16 <code>std::wstring</code>.</p>
<p>Do you actually do this? Do you think that it is OK?</p>
|
c++
|
[6]
|
4,276,184 | 4,276,185 |
Get date of first day of week
|
<p>I was wondering if you guys know how to get the date of currents week's monday based on todays date? </p>
<p>i.e 2009-11-03 passed in and 2009-11-02 gets returned back</p>
<p>/M</p>
|
c#
|
[0]
|
1,062,911 | 1,062,912 |
Android,Problem:Trying to Send a Link By email
|
<p>i am sending a simple email and in the body i put a Link .</p>
<p>My problem is the link is not recognize as Link but only as String</p>
<p>Here the code:</p>
<pre><code> intent.putExtra(Intent.EXTRA_EMAIL,new String[]{ "Support@bift.net"});
Uri myUri = Uri.parse("http://www.stackoverFlow.com/");
intent.putExtra(Intent.EXTRA_TEXT, "Check out this great application:"+"\n"+ myUri);
intent.putExtra(Intent.EXTRA_SUBJECT, "Traveler's Pharmacy");
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "Choose Email Client"));
startActivity(intent);
</code></pre>
<p>Thanks for helping</p>
|
android
|
[4]
|
1,126,814 | 1,126,815 |
Sending the iphone camera captured images to the web service?
|
<p>I wanted to capture image using iphone camera and send the images to the webserivce on the click of capture itself can any one help me.
I wanted some example code or referral example code links.</p>
|
iphone
|
[8]
|
4,248,092 | 4,248,093 |
Should I keep a copy in memory of the information being displayed?
|
<p>I am building a webapp to edit some information from a database. The database is being displayed as a table with editing capabilities.</p>
<p>When editing a value, generally I have to validate and do some other tasks, depending on the value that's being edited.</p>
<p>Should I keep a copy as array of objects in memory and use their methods or should I store all the information I need (type of value, id, etc) somewhere in the html table (as attributes or hidden inputs) and get them using several functions?</p>
<p>Which would be best practice?
Is it risky to have many objects stored in memory (taking into account memory usage of the browser)?</p>
|
javascript
|
[3]
|
4,004,073 | 4,004,074 |
Javascript: Mathfloor still generating a 0
|
<p>In my script to generate a playing card, it's generating a 0, even though my random generator is adding a 1, so it should never be 0. What am I doing wrong?! If you refresh, you'll eventually get a "0 of Hearts/Clubs/Diamonds/Spades":</p>
<pre><code>var theSuit;
var theFace;
var theValue;
var theCard;
// deal a card
function generateCard() {
var randomCard = Math.floor(Math.random()*52+1)+1;
return randomCard;
};
function calculateSuit(card) {
if (card <= 13) {
theSuit = "Hearts";
} else if ((card > 13) && (card <= 26)) {
theSuit = "Clubs";
} else if ((card > 26) && (card <= 39)) {
theSuit = "Diamonds";
} else {
theSuit = "Spades";
};
return theSuit;
};
function calculateFaceAndValue(card) {
if (card%13 === 1) {
theFace = "Ace";
theValue = 11;
} else if (card%13 === 13) {
theFace = "King";
theValue = 10;
} else if (card%13 === 12) {
theFace = "Queen";
theValue = 10;
} else if (card%13 === 11) {
theFace = "Jack";
theValue = 10;
} else {
theFace = card%13;
theValue = card%13;
};
return theFace;
return theValue
};
function getCard() {
var randomCard = generateCard();
var theCard = calculateFaceAndValue(randomCard);
var theSuit = calculateSuit(randomCard);
return theCard + " of " + theSuit + " (this card's value is " + theValue + ")";
};
// begin play
var myCard = getCard();
document.write(myCard);`
</code></pre>
|
javascript
|
[3]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.