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,120,354 | 2,120,355 | Can't process list of dicts against list of strings | <pre><code>d = ['X + Y = Z', 'X <=Y']
p = [{'Y': 1, 'X': 0, 'Z': 0}, {'Y': 1, 'X': 0, 'Z': 3}, {'Y': 1, 'X': 0, 'Z': 6}, {'Y': 1, 'X': 0, 'Z': 9}, {'Y': 1, 'X': 1, 'Z': 0}, {'Y': 1, 'X': 1, 'Z': 3}]
</code></pre>
<p>I need to create create some structure which would store List of expressions, where variables are changed. </p>
<p>I need to know:
X, Y, Z current values
expressions with changed letters to integers</p>
<p>and it has to be for each dict of values</p>
<p>The problem is to see for what X,Y,Z, all expressions are True</p>
| python | [7] |
5,681,645 | 5,681,646 | New ASTRO File Manager (Android) broken with ACTION_GET_CONTENT? | <p>UPDATED: the successive version of ASTRO File Manager (Android) works again with ACTION_GET_CONTENT!</p>
<hr>
<p>Did anyone notice that the new version of ASTRO File Manager (Android) is broken with ACTION_GET_CONTENT?</p>
<p>This code used to work well to choose a zipfile with previous versions of ASTRO File Manager, and now it does not seem to work anymore. It shows only directories, and no files.</p>
<pre><code>Intent importTree = new Intent(Intent.ACTION_GET_CONTENT);
importTree.setType("file/*");
Intent c = Intent.createChooser(importTree, "Select zip file");
startActivityForResult(c, IMPORT_TREE);
</code></pre>
<p>The code still works with other file managers like OI File Manager (Open Intents).</p>
| android | [4] |
5,904,924 | 5,904,925 | Javascript loading clients local media | <p>This is new to me since I did something similar a few years back:</p>
<pre><code><input type="file" onchange="fileSelected(this.value)" />
</code></pre>
<p>This will provide a fakepath reference, IE, if I select <code>test.jpg</code> on my desktop it returns:</p>
<pre><code>c:/fakepath/test.jpg
</code></pre>
<p>My problem is, I'm developing an online application that lets clients design a page, that is, they select images, drag them onto the page etc.</p>
<p>My design ideally would be they select local files (that could be big in filesize) so there is no uploading involved immediately, I keep an array of the paths of the files and then at the end of the design process it saves the media and the positions of elements to the server.</p>
<p>However, fakepath is preventing me from doing this!</p>
<p>Do I <em>have</em> to upload the files each time? This would significantly slow down the design process.</p>
| javascript | [3] |
1,645,430 | 1,645,431 | Why this code could work | <p>I just found out this code actually work. I wonder why. row and col are both variables. I was trying to dynamically allocate a 2D vector. Could someone explain this? Thanks!</p>
<p>row and col are both "int"</p>
<pre><code>grid_ = new vector<vector<bool> > (row, col);
</code></pre>
| c++ | [6] |
1,859,721 | 1,859,722 | access object through dot-syntax string path | <p>How can I access <code>myobject[path][to][obj]</code> via a string <code>path.to.obj</code>? I want to call a function <code>Settings.write('path.to.setting', 'settingValue')</code> which would write <code>'settingValue'</code> to <code>settingObj[path][to][setting]</code>. How can I do this without <code>eval()</code>?</p>
<p>I finally figured it out around the same time as one of the users below answered it. I'll post mine here with documentation on how it works if anyone is interested.</p>
<pre><code>(function(){
var o = {}, c = window.Configure = {};
c.write = function(p, d)
{
// Split the path to an array and assaign the object
// to a local variable
var ps = p.split('.'), co = o;
// Iterate over the paths, skipping the last one
for(var i = 0; i < ps.length - 1; i++)
{
// Grab the next path's value, creating an empty
// object if it does not exist
co = (co[ps[i]])? co[ps[i]] : co[ps[i]] = {};
}
// Assign the value to the object's last path
co[ps[ps.length - 1]] = d;
}
c.read = function(p)
{
var ps = p.split('.'), co = o;
for(var i = 0; i < ps.length; i++)
{
co = (co[ps[i]])? co[ps[i]] : co[ps[i]] = {};
}
return co;
}
})();
</code></pre>
<p>The reason I was having problems is you have to skip the last path. If you include the last path, you end up just assigning an arbitrary object.</p>
| javascript | [3] |
5,725,419 | 5,725,420 | Creating a connection object in Python | <p>In a Python software I am working on, I have a number of objects that need to be able to be 'connected' to other objects (the term connected here referring to the fact that it just needs to point to the object it is connected to).</p>
<p>I have thought to create an connection class, which can create this link and store information about the properties of the connection. As shown below, when I create a new object, I have a method that allows me to add a new connection with a certain type to it. </p>
<pre><code>class ConnectableObject()
def addNewConnection(self, connectiontype)
self.connections.append(NewConnection(connectiontype))
</code></pre>
<p>The idea is that each object should have their own connection type... and that these are connectable. i.e Object A has a connection object associated with it, Object B has a connection object associated with it, and to connection the two objects I just connect their connections. That allows me to store information about each connection in the connection objects. Once this connection object is instantiated I'd like to store in the connection object 'who' created it, i.e object A... object B. Is there a way in Python to request from an Object what class it was created within?</p>
<p>Also, more generally, is there a cleaner way to implement connections between objects where each object connection can store its own properties?</p>
| python | [7] |
3,276,363 | 3,276,364 | Comparing two strings within if statement | <p>I have the following code:</p>
<pre><code>String tmp = "cif";
String control = tmp.substring(1);
if(control == "if") {
append = "if( ";
}
</code></pre>
<p>However, despite control being "if", the test will still fail. Any solutions?</p>
| java | [1] |
2,784,401 | 2,784,402 | PHP Send Mail Alternative | <p>I know PHPMailer and I'm using this but I have some user groups and send multiple emails to multiple groups, so at this time it runs too slow. Is there any other way or any third party tools? Is there any library?
thanks in advance</p>
| php | [2] |
3,719,947 | 3,719,948 | Get selector in event handler | <p>I answered <a href="http://stackoverflow.com/questions/6469116/asp-net-checkbox/6469251#6469251">this question</a> with this jQuery code:</p>
<pre><code>$('input[type="checkbox"][name$="chkSelect"]').click(function() {
$('input[type="checkbox"][name$="chkSelect"]').not(this).prop("checked", false);
});
</code></pre>
<p>... and it got me thinking: there must be a way to avoid duplicating the selector in the event handler.</p>
<p>I tried <code>$(this).selector</code> but that just returns an empty string. <a href="http://jsfiddle.net/Town/Qaj8h/" rel="nofollow">Here's a demo</a>.</p>
<p><strong>Is there a way to get the selector text in the event handler?</strong></p>
| jquery | [5] |
5,788,514 | 5,788,515 | If Yes button of Dialog box is clicked, run program again | <p>I'm writing a grade calculator, and at the end, I ask the user if they have another grade to calculate.</p>
<pre><code> Console.Write("Do you have another grade to calculate? ");
moreGradesToCalculate = Console.ReadLine();
moreGradesToCalculate = moreGradesToCalculate.ToUpper();
</code></pre>
<p>I want to display a dialog box with the options of Yes or No. </p>
<p>I want to be able to run the program again, if the DialogResult is Yes, and do something else if the result is No.</p>
| c# | [0] |
25,545 | 25,546 | Using jquery .load without a delay | <p>I create div place holders in my html and store the url for fetching on the rel attribute, some of these urls are slower to load</p>
<p>when using the folowing code, the each loop waits for each load function to be done before moving along to the next one which make an html with 5 placeholders load pretty slow:</p>
<pre><code>$("div[class=ajax_wrapper]").each(function() {
$(this).load($(this).attr('rel'), function(content) {
//alert(content);
});
});
</code></pre>
<p>How can I make the different divs load asynchronously?</p>
| jquery | [5] |
1,580,069 | 1,580,070 | Basic ImageButton onClick event not firing - surely something simple? | <p>I'm trying to get a simple onClick to fire from an ImageButton - it seems like a simple enough task, but I'm obviously missing something here.</p>
<p>Here is my java file:</p>
<pre><code>package com.jlbeard.android.testapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.Toast;
public class testapp extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//handle the button press
ImageButton mainButton = (ImageButton) findViewById(R.id.mainButton);
mainButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//show message
Toast.makeText(testapp.this, "Button Pressed", Toast.LENGTH_LONG);
}
});
}
}
</code></pre>
<p>Here is my layout file:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/whereToEat"
android:src="@drawable/where_to_eat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="8px"
/>
<ImageButton
android:id="@+id/mainButton"
android:src="@drawable/main_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@null"
android:clickable="true"
android:onClick="mainButtonClick"
/>
</RelativeLayout>
</code></pre>
<p>It seems to me that I'm missing something simple... but can't seem to figure it out. Thanks!</p>
| android | [4] |
1,469,342 | 1,469,343 | Can i use adapter for dialogs? | <p>I have some data that i want to show them in different dialogs with the same layout.Can i use an adapter like simpleCursorAdapter?</p>
<pre><code>entry.open();
Cursor cursor = entry.getData();
startManagingCursor(cursor);
Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.agonessingle);
dialog.setCancelable(true);
String description2 = DBHelper.DESCRIPTION;
String skord2 = DBHelper.SKOR;
String goala2 = DBHelper.GOALA;
String goalb2 = DBHelper.GOALB;
String title2 = DBHelper.TITLE;
String[] columns = new String[] { DBHelper.TITLE,
DBHelper.DESCRIPTION, DBHelper.SKOR, DBHelper.GOALA,
DBHelper.GOALB };
// THE XML DEFINED VIEWS WHICH THE DATA WILL BE BOUND TO
int[] to = new int[] { R.id.firstdialog, R.id.TextView1,
R.id.TextView2, R.id.TextView3, R.id.TextView4 };
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
R.layout.agonessingle, cursor, columns, to);
</code></pre>
<p>i was thinking something like this but i dont know how to set my adapter..</p>
| android | [4] |
4,371,915 | 4,371,916 | Read Windows 7 Registry c# | <p>Need to obtain following path from the registry:</p>
<p>%userprofile%</p>
| c# | [0] |
388,710 | 388,711 | Looping each() loop infinitely | <p>I am using jQuery to loop through each li element under a ul displaying them one by one. Here is the code:</p>
<pre><code> $('.article_ticker li:first').siblings().hide();
var list=$('.article_ticker li:first').siblings();
list.each(function(index)
{
$(this).siblings().hide().delay(2000).fadeOut();
$(this).fadeIn('fast');
});
</code></pre>
<p>This code works fine but once the 'each' loop ends, it doesn't repeat the sequence. I want to cycle to be repeated infinitely. Like after the last element fades out, first element should fade in.</p>
| jquery | [5] |
4,444,055 | 4,444,056 | Split screen in two | <p>I am trying to split my layout into two halves.When I try layout_weight,in splits it into two horizontal halves.How do i split the layout into two vertical halves.</p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
</code></pre>
<p>
<pre><code>android:id="@+id/linearLayout123" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="1"
android:layout_gravity="top"
android:id="@+id/linearLayout12"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button" />
</LinearLayout>
<LinearLayout android:layout_weight="1"
android:layout_gravity="bottom" android:id="@+id/linearLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
</LinearLayout>
</LinearLayout>
</code></pre>
| android | [4] |
3,837,390 | 3,837,391 | Android: Sharing webview across activites | <p>Is it possible to share a same webview object in two different activities in android ? Here is my use case. I have an Activity A that has a webview W. W occupies 50% of A. Now When I click on Webview W, in activity A, I want to launch Activity B with whole of it occupying webview W. In acitivity B, I do not want webview to requery the URI. Is it possible to do this in android ? Please help.</p>
| android | [4] |
2,415,006 | 2,415,007 | Load an activity in the background before displaying it | <p>Is it possible to load a new activity in the background before switching the view to that activity?</p>
<p>For example, I would like to have a slash screen activity that gets called and displays a splash screen. While this splash screen is displayed, the next activity is loaded, and when it is done loading (when it's onCreate() is finished) then the splash screen activity ends, and the new activity is displayed. </p>
<p>I know another option would be to display the splash screen in the new activity, and use async task to load all the data before removing the splash image... but I am stuck on that approach as well. The activity first has to load a fair amount of data, and then it has to dynamically add GUI elements based on that data. Once the GUI is fully loaded, I then want to remove the splash screen. The problem is that I cannot touch the UI thread from doInBackground(). How do I create my activity behind a splash screen, if I cannot update the UI from doInBackground? I know that onProgressUpdate() can access the UI thread, but I can't figure out how to implement it. </p>
<p>Any ideas? Thank you!</p>
| android | [4] |
5,579,619 | 5,579,620 | Exec command doesn't work as expected | <p>I'm trying to launch a CLI command from a PHP script:</p>
<p>in particular I wanna use this command <code>convert a.png a.tif</code> to convert an image to tiff.</p>
<p>When I launch this command from CLI it works as expected but if I launch from a PHP script with the following code it doesn't create any tiff image in my folder:</p>
<pre><code>$exec = "convert a.png a.tif";
exec($exec,$yaks,$err);
echo "<pre>";
print_r($yaks);
echo "$err";
echo "</pre>";
</code></pre>
<p>Moreover <code>$yaks</code> is empty and <code>$err</code> is set to 127.</p>
<p>I'm not an expert, why this doesn't work as expected?</p>
<p>Best regards</p>
<p><strong>UPDATE</strong></p>
<p>I used this command instead <code>$exec = "convert 4.png 4.tif 2>&1";</code> and I got in return <code>[0] => sh: convert: command not found</code></p>
<p>This seems to me strange since I can use it from CLI!</p>
<p><strong>FINAL UPDATE</strong></p>
<p>Thanks a lot guys!</p>
<pre><code>$exec = "/usr/local/bin/convert a.png a.tif";
</code></pre>
<p>This command solved the problem!
You're great.</p>
| php | [2] |
161,857 | 161,858 | What actually does this javascript snippet mean? | <p>From <a href="http://html5boilerplate.com/mobile" rel="nofollow">HTML5 Mobile Boilerplate's</a> helper.js:</p>
<pre><code>(function(document){
//all stuff here
})(document);
</code></pre>
<p>What does this snippet do or when does it run?</p>
| javascript | [3] |
5,205,070 | 5,205,071 | Arraylist remove elements | <p>I have a java code where i have an ArrayList and want to remove element from the arraylist.</p>
<pre><code> ArrayList <word> wordlist=new ArrayList<>();
public void removeWord(String inputWord){
for(word z:wordlist){
if(z.getWord() == inputWord)
wordlist.remove(inputWord);
System.out.println("the word" +inputWord+ "is removed");
}
System.out.println(wordlist.size());
}
</code></pre>
<p>the problem is that the element is not getting removed from the list.</p>
| java | [1] |
2,626,792 | 2,626,793 | what is intel x86 atom system image in android sdk manager? | <p>I am new to android development. I am setting up development environment.
So my question is, what is intel x86 atom system image in android sdk manager?
Should i install it or not?
the option is present in api level 15 & 16 but not in 17.</p>
<p>Thanks.</p>
| android | [4] |
3,818,024 | 3,818,025 | use CursorLoader with PagerAdapter in android | <p>Could i use <code>CursorLoader</code> with <code>PagerAdapter</code> in android if yes How to integrate them ? article , code snippet or hints to help me do this ? if no is there a workaround this ? </p>
| android | [4] |
2,911,138 | 2,911,139 | HTTP Live Streaming in iPhone | <p>I am using <code>MPMoviePlayerController</code> to stream http video files from web.
But am getting error and the video is not streaming.</p>
<p>Can I get any help for this?</p>
<pre><code>-(IBAction)play
{
NSString *urlString = [NSString stringWithFormat:@"<html><head><title>HTTP Live Streaming Example</title></head><body><video src=http link"];
NSURL *url = [NSURL fileURLWithPath:urlString];
_mpMoviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_mpMoviePlayer];
[self.view addSubview:_mpMoviePlayer.view];
[_mpMoviePlayer release];
}
</code></pre>
<p>This is my code and I am not able to get the streaming video. </p>
| iphone | [8] |
5,223,522 | 5,223,523 | Best idiom for a decrementing loop | <p>What's the best/preferred idiom for a decrementing for loop, and why?</p>
<pre><code>for(int idx=(len-1); idx>=0; idx--) {...}
</code></pre>
<p>or</p>
<pre><code>for(int idx=(len-1); idx>-1; idx--) {...}
</code></pre>
<p>or (based on sylvarking's answer, but using for to constrain the index scope)</p>
<pre><code>for(int idx=len; idx-->0; ) {...}
</code></pre>
<p>Is one or the other more likely to trip up another developer?</p>
| java | [1] |
4,556,240 | 4,556,241 | Music in Webview Activity kill when press back button to home activity | <p>I am coding the play mp3(Flash Embedded) in WebView(Second Activity), I can play the music in WebView as usually, but when I press back buttom to First Activity the music in Second Activity in WebView still playing, then I go to Second Activity again in WebView to stop the music but it's appear the new mp3 play list screen, I can't stop the music.</p>
<p>So, how can I kill the process when I press back button to First Activity(Home Screen)</p>
<p>Best Regards,
Virak</p>
| android | [4] |
3,462,174 | 3,462,175 | alias name should be same or not for updating app in android market? | <p>i had launched one app in android market and now i going to release next version.
i came to know that for updating the app i want to use same keystore and same password.
now i getting doubt about my alias name .
which one is better for updating my application in android market , whether i have to use same alias name or different alias name.
If i used different alias name application will get update or not.
2) is it possible change the password for my private keystore.
can any one explain about the steps to change the password</p>
| android | [4] |
701,840 | 701,841 | Using a 64bit DLL wiht 32 Borland C++ Builder | <p>I need to make a "data pool" of more than 4GB data, organized as 2 dimensional data arrays:</p>
<p>I have a 50 forms application made in 32bit CodeGear 2009 C++ Builder with many third party VCL components - thus not really an option right now to migrate to Visual Studio 2010 ( for now ). </p>
<p>The idea is to use a 64Bit DLL ( made with Visual Studio 2010 ? Or Delphi EX2 ? ) containing the data arrays - the idea is to call the 64bit DLL with x,y parameters of the data location in the array, and the DLL returns the value from the array.</p>
<p>Anyone have made such before ? Is it possible to call a 64Bit DLL from C++ Builder, how would the init code look like for dynamically loading the DLL at runtime ? </p>
<p>Any input is very much appreciated, as this is a show stopper.</p>
| c++ | [6] |
4,427,541 | 4,427,542 | A pointer to function in c++ | <p>When I did something with pointer to function I noticed something and didn't understand</p>
<p>I did this:</p>
<pre><code>#include <stdio.h>
int callback(void)
{
return 5;
}
void call(int (*cpmpare)(void))
{
int x;
x = cpmpare();
printf("%d", x);
}
void main()
{
int (*compare)(void);
int *a, b;
b = 5;
a = &b;
compare = callback;
printf("%p\n", &callback);
printf("%p\n", compare);
call(&callback);
}
</code></pre>
<p>And I did <code>compare = &callback</code> instead <code>compare = callback</code> and it did the same, compare got the same address as did callback.</p>
<h3>Why did it work both ways?</h3>
<p>From what I know comparing a pointer and a regular variable will be wrong.</p>
| c++ | [6] |
4,939,850 | 4,939,851 | C# App exit as expected, but why Windows 7 shows "This program has stop working" | <p>I wrote a C# App. The app exit while click on the Exit button.
The app close as expected, but why Windows 7 shows "This program has stop working", and windows 7 is trying to gather error information? The exit button is purposely designed to stop the app from working.</p>
<p>anyone has any clue, thanks.</p>
<hr>
<p>-## Added Info (02 Jan 2012)<br />
Thanks guys for answering my question.
This is my situation.</p>
<p>I have totally no idea of what is happening and I don't know what information should I provide in my question.</p>
<p>But, after reading you guys feedback. I have some clue of what is happening to my C# application.</p>
<p>Answering you guys' questions:<br />
Answer 1: This is a winform.<br />
Answer 2: The Exit Code of the Exit button. I have tried 2 solutions:</p>
<p>1st:<br />
this.Close();</p>
<p>2nd:<br />
Environment.Exit(0);</p>
<p>Answer 3: I'm not sure what is defined by threads at this moment. But since I'm sure what is threads, I guess there is no threads running behind.</p>
<p>Answer 4: Yes, I do have a 3rd party customize controls added into the winform.</p>
<p>Thanks you very much for your answers.<br />
I'll start investigating the below elements for the cause of this problem. <br />
item 1: The problem might be caused by the 3rd party controls<br />
item 2: Study if there any threads running<br />
item 3: Study the eventlog to find any related information.<br /></p>
<p>Thanks again guys.</p>
| c# | [0] |
5,680,537 | 5,680,538 | How is it that I can add properties to a closure in anonymous self executing function? | <p>why is it that when I do this:</p>
<pre><code>x = 5
(function bla(varX){
varX = 7; console.log(x); //7
})(x);
console.log(x); //5
</code></pre>
<p>the <code>x</code> doesn't change, since it's in a closure if I understand correctly,
but here:</p>
<pre><code>x = {a:5}
(function bla(varX){
varX.a = 7; console.log(varX.a);
})(x)
console.log(x.a); //7
</code></pre>
<p>Why does <code>x.a</code> gets overwritten and <code>x</code> doesn't?</p>
| javascript | [3] |
4,920,391 | 4,920,392 | Disabling all controls until the thread finishes executing | <p>Once i launch a win forms application, i create a background worker to do some initialization. While this initialization happens, i want all the buttons in the form to stay disabled. </p>
<p>I was thinking whats the best way to do this. One straightforward approach i could think of is setting a flag in the thread's completed event. Is there any other better approach?</p>
| c# | [0] |
5,640,970 | 5,640,971 | Get all elements without child node in jQuery | <p>I need to select elements without child node (including text since in <code><p></code> a text is a child node). </p>
<p>I used <code>empty</code>, but it also consider space as child node.</p>
<p><strong>Example:</strong> </p>
<p>Markup:</p>
<pre><code> <span> </span>
<span></span>
</code></pre>
<p>Script:</p>
<pre><code>$("span:empty").html("this was empty!");
</code></pre>
<p>Unfortunately, only the second element were selected and changed since the first element has space and it was considered child node.</p>
<p>How do I select elements without child node? I want to consider a space as nothing. Preferably, I want the code not to use loop to select them, there might be other ways.</p>
| jquery | [5] |
1,722,071 | 1,722,072 | C# Program to get modified date from URL directory | <p>I am fairly new to C# and was hoping for some assistance. I currently use Visual Studio 2008. What I am wanting to do is the following:</p>
<p>I have a server (\backupserv) that runs a RoboCopy script nightly to backup directories from 18 other servers. These directories are then copied down to \backup in directories of their own:</p>
<p>Example:
It copies down "Dir1", "Dir2", and "Dir3" from Server1 into \backupserv\backups\Server1 into their own directories (\backupserv\backups\Server1\Dir1, \backupserv\backups\Server1\Dir2, and \backupserv\backups\Server1\Dir3).</p>
<p>It does this for all 18 servers nightly between 12am and 6am. The RoboCopy runs via schedule task. A log file is created in \backupserv\backups\log and is named server1-dir1.log, server1-dir2.log, etc. </p>
<p>What I am wanting to accomplish in C# is the ability to have a 'report' showing the modified date of each text log file. To do this I need to browse the \backupserv\backups\log directory, determine the modified date, and have a report displayed (prefer HTML if possible). Along with the modified date I will be showing more information, but that is later.</p>
<p>Again, I am fairly new to C#, so, please be gentle. I was referred here by another programmer, and was told I would get some assistance.</p>
<p>If I have missed any detail please let me know and I will do my best to answer.</p>
| c# | [0] |
4,008,901 | 4,008,902 | HorizontalScrollView not scrolling on 1.5 API phones | <p>My main view is a <code>relativeView</code>. inside the <code>relativeView</code> I have a <code>HorizontalScrollView</code> which holds a <code>Linearlayout</code> with a bunch of buttons. On a 1.5 API phone the <code>HorizontalScrollView</code> does not scroll and I don't see all the buttons in the <code>LinearLayout</code>. On phones running 1.6API+ The <code>HorizontalSrollView</code> works just fine and I can scroll left and right and see all the buttons in my <code>LinearLayout</code>. </p>
<p>Any idea what is going on here?</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@+id/pscroll"
android:scrollbars="horizontal"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ad"
android:fillViewport="true"
android:scrollbarAlwaysDrawHorizontalTrack="true">
<LinearLayout android:orientation="horizontal" android:id="@+id/LinearLayout01" android:scrollbars="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:id="@+id/P1" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/P2" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</code></pre>
<p>etc...</p>
| android | [4] |
639,857 | 639,858 | Show relative time that changes to default date after Midnight | <p>I would like to show "posted Today at" if the posted was posted today, and I know how to do that, but I would like it to show the default date and time format as of 12:01am, obviously because ita no longer posted "today", is there a way I can do this? Thanks for the help.</p>
<hr>
<p>Thanks, I'll try that, here is what i have.</p>
<pre><code>if($params['time'] > (time() - (60*60*24))){
$old_time = $params['time'];
$hm = date("g:ia", $old_time);
$today = elgg_echo('friendly_time_today', array($hm));
return $today;
return $today;
} else if($params['time'] > (time() - (60*60*48))){
$old_time = $params['time'];
$hm = date("g:ia", $old_time);
$yesturday = elgg_echo('friendly_time_yesturday', array($hm));
return $yesturday;
return $yesturday; }
</code></pre>
| php | [2] |
1,197,580 | 1,197,581 | how to create a cursor with SQL Query if my table created also in SQL Query | <p>I have a problem, i created a table like this. </p>
<p>private static final String TABLE_CREATE ="CREATE TABLE IF NOT EXISTS alarm(REQ_CODE INT(3),HOUR INT(3),MINUTE INT(3),COUNT INT(3),REPEAT INT(3),DAYS VARCHAR2(100),SUN INT(3),MON INT(3),TUE INT(3),WED INT(3),THU INT(3),FRI INT(3),SAT INT(3));";</p>
<p>A i insert into table like
public void insertweekdays(int REQ_CODE,int HOUR,int MINUTE ,int COUNT,int REPEAT,String DAYS,int SUN,int MON,int TUE,int WED,int THU,int FRI,int SAT) {
mDb.execSQL("INSERT INTO " +TABLE_CREATE +
" VALUES ("+REQ_CODE+","
+HOUR+","+MINUTE+","+COUNT+","+REPEAT
+","+DAYS+","+SUN+","+MON+",'"+TUE+"',"+WED+","+THU+","
+FRI+","+SAT+");");</p>
<p>and my problem is how to create cursor to this.
please help me
}</p>
| android | [4] |
3,560,542 | 3,560,543 | jquery and 'innerHTML' wrapper | <p>hello<br>
have a next question:<br>
i.g. we have next html with structure: </p>
<pre><code><html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$($("#global").attr("innerHTML")).wrap('<div name="wrapper"></div>');
})
</script>
</head>
<body>
<div id="global">
<div id="container">
<div id="sub1">
<h1> hello world </h1>
</div>
<div id="sub2">
<h1> hello world again</h1>
</div>
</div>
<div id="container3">
<h1> hello world again</h1>
</div>
</div>
</body>
</html>
</code></pre>
<p>but <code>wrap</code> function, some why won't work on it, as I think, it happens, because <code>innerHTML</code> hasn't parent, so, how can i avoid this, and wrap few elements (which has 'one level' and common parent)?</p>
| jquery | [5] |
4,086,078 | 4,086,079 | PHP pagination: is_dir is truncating images when looping through readdir | <p>I just got pagination to work on my site, but I wanted to use a thumbnailer script that accepts a path, not a resource. This conflicts with how I pagination- using readdir to scan for a resource.</p>
<p>Right now I'm implementing a skip pattern I found online to keep track of images and their corresponding page numbers:</p>
<pre><code>while ( $count <= $skip && ($file = readdir($handle)) !== false ) {
if ( !is_dir($file))
$count++;
}
$count = 0;
</code></pre>
<p>So,</p>
<p>Question 1) This method sets $count = 0 after it's run, so I don't see how it can be useful for the rest of the script.</p>
<p>Question 2) This part actually displays the correct images on page according to page number. I set $imagesPerPage = 4, so 4 should display on all pages. But, since I'm doing an !is_dir check, it's truncating those first two items (which are directories . and ..), but it's not refilling those spots with actual images (bec all pages except the last page should have 4 images on them...)</p>
<pre><code>while ( $count++ < $imagesPerPage && ($file = readdir($handle)) !== false ) {
if(!is_dir($file)) {
$image = $imagePath . $file;
?>
<a href="../templates/viewComic.php?image=<?php echo $image ?>"><img src="../scripts/thumbnailer2.php?img=<?php echo $image ?>" /></a>
<?php
}
}
</code></pre>
<p><img src="http://i.stack.imgur.com/OecD5.jpg" alt="enter image description here"></p>
<p>Question 3) How can I get the pages to begin on 1 instead of 0? </p>
<p>Any help in understanding would be appreciated!</p>
| php | [2] |
2,777,585 | 2,777,586 | In C#, how do you create methods that append to variables? | <p>I've searched around for the answer to this many times, but I don't know what this type of method is called, so my searches ended up useless, nor can I explain it to the search engine.</p>
<p>How do you make a method that uses the variable it is appended to as it's parameter (like "myVariable**.ToString()**)?"</p>
<p>.ToString() works on any variable I append it to, and uses the variable behind it as a parameter, rather than entering the parameter within the brackets... An example of what I want to do would be:</p>
<pre><code> private void OpenExcel(string inFileName)
{
Excel.Application xlApp = new Excel.ApplicationClass();
Excel.Workbook xlBook = xlApp.Workbooks.Open(inFileName
, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing);
Excel.Worksheet xlSheet = (Excel.Worksheet)xlBook.Worksheets[1];
xlApp.Quit();
xlApp.releaseObject();
}
private void releaseObject(object obj)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
}
catch (Exception)
{
obj = null;
}
finally
{
GC.Collect();
}
}
</code></pre>
<p>I know this is kind of a stupid example, but it shows what I want to do with the "xlApp.releaseObject()".</p>
<p>Also... Can someone please tell me what that kind of method (or type of call, whatever it is) is called? I hate not knowing.</p>
| c# | [0] |
1,284,167 | 1,284,168 | What is meant by metadata in android? | <p>When you start a drag, you include both the data you are moving and metadata describing this data as part of the call to the system,the following explanation was found in android developers site</p>
<p>here,What is meant by metadata in android?</p>
| android | [4] |
2,067,686 | 2,067,687 | Response.BinaryWrite Div | <p>Is there a way to write PDF to a div from DataBase i.e. Retrieve a Byte[] from Database and Reponse.BinaryWrite to a div.</p>
<p>We do similar thing for Images using src = "anotherpage.aspx" where image is written on anotherpage.</p>
<p>Is it possible with PDF without using IFrame?</p>
| asp.net | [9] |
4,839,549 | 4,839,550 | switch on wifi in emulator | <p>I'm doing project on android chat application with both friends and anonymous. we finished with the design phase. now we need to create a network between two emulators present in two system so that we can do chat in two different systems. But in emulator wifi is not getting turned on. I tried with the F8 button still the wifi is not getting on. I'll be grateful for any help in regard of this.if wifi cant be turned on how to simulate the chat application in emulators.we have written server and client side program in java, but don know how to connect server and client Thanks in advance</p>
| android | [4] |
3,367,362 | 3,367,363 | A question regarding to the state maintainance | <p>If i have total 10 views such as from 1 to 2, 2 to 3,and same as upto 10</p>
<p>if i go to 5 th view,then i press home button and then i go to another application and then after doing some task ,i go to home button and then i press my application my 1 st view opens but i want to open my 5 th view</p>
<p>plzzzzzzzzz tell me solution for this
waiting fo reply</p>
| iphone | [8] |
1,833,495 | 1,833,496 | read and write in java | <p>I want print in the file every time line
But every time i want print a new line printed on the same line the old.</p>
<p>I want to print lines in the file </p>
<p>This my code</p>
<pre><code>BufferedReader read = new BufferedReader(new FileReader (SecurityScreen.path.get("ScoreFile")));
FileWriter file ;
BufferedWriter write = new BufferedWriter ( new FileWriter(SecurityScreen.path.get("ScoreFile")));
String temp = "" ;
String output = "";
String newLine = System.getProperty("line.separator");
String score= SecurityScreen.getPlayer() + "@" +gameTime + newLine;
// if(read.readLine()==null){
// write.write(score);
// }
try{
if((temp = read.readLine()) != null){
while (true) {
output += temp + newLine;
file = new FileWriter(SecurityScreen.path.get("ScoreFile"));
//write = new BufferedWriter(file);
write.write(output + newLine) ;
//score = SecurityScreen.getPlayer() + "@" +gameTime ;
write.write(score) ;
}
}
else {
write.write(score);
}
write.close();
}
catch(IOException e){
}
</code></pre>
| java | [1] |
2,050,640 | 2,050,641 | How to get diffreence between GMT time and any time zone in C++ | <p>I want a soultion in C++ to get hours diffreence between GMT time and any time zone.
e.g.
This is in Java I want to make in C++</p>
<pre><code>// New York
Calendar c = new GregorianCalendar(TimeZone.getTimeZone("America/New_York"));
// Alaska
c = new GregorianCalendar(TimeZone.getTimeZone("America/Anchorage"));
// Difference between New York and Alaska
</code></pre>
<p>Please tell me how I can get this time zone in C++</p>
| c++ | [6] |
210,955 | 210,956 | Binding public variable of a class to repeater | <p>I am trying to bind a public variable of a class to reapeater, but it says </p>
<blockquote>
<p>DataBinding: 'Class Name' does not contain a property with the name 'id'.</p>
</blockquote>
<p>So its obvious that repeater is trying to find properties in my class which does not exits as all are public variable.</p>
<p>Why is this limitation and what is the work around.</p>
<p>I can't change public variables to properties.</p>
| asp.net | [9] |
4,606,828 | 4,606,829 | form should not appear after the 30 button_click | <p>*<em>strong text</em>*I Have a doubt</p>
<p>i have created an application in VS2010 for windows application </p>
<p>i have used form1 in form1 i used a button, onclicking on to the button it will load a second form ie.. form2 in which image is added </p>
<p>the overall situation is when i execute the application i'll get form1 and by clicking on the button(which is in form1) it will display the form2 (means it will display the image in the form2)</p>
<p>i want to code in such a way that </p>
<p>for the first time when i click the button the form2 will appear than i'll close the form2</p>
<h2>then again when i click the button for the second time the form2 will appear than i'll close the form2</h2>
<h2>---</h2>
<h2>---</h2>
<hr>
<p>like for the 30th time when i click the button the form2 will appear than i'll close the form2</p>
<p>but the confusion here is </p>
<p>when i click the button for the 31th time the form2 should not appear what ever it may be the form2 should never display again</p>
<p>i am getting totally confused how to do this please help me</p>
<p>please guide me with the code please</p>
| c# | [0] |
281,976 | 281,977 | Add events to controls added dynamically | <p>I am working on winform app. and I have added some controls dynamicaly eg. <code>Button</code> now i want to add an event to that created button, how can i perform this? also can some one refer a <code>C#</code> book to me which has covered well all topics in winform? thanks.</p>
| c# | [0] |
2,802,029 | 2,802,030 | How to maintain a Unique List in Java? | <p>How to create a Unique List in Java. </p>
<p>Right now I am using <code>HashMap<String, Integer></code> to do this as the key is overwritten and hence at the end we can get <code>HashMap.getKeySet()</code> which would be unique. But I am sure there should be a better way to do this as the value part is wasted here.</p>
| java | [1] |
3,613,104 | 3,613,105 | how to use inline javascript code to auto center pop up window | <p>I have a in line javascript used in AJAX, would like to auto center when open, but make the change in the inline scriprt only. Is that possible? Here's my code:</p>
<pre><code><a href='javascript:void(0)' title='owner' onclick=\"window.open('owner.html','owner','height=320, width=300,location=no,scrollbars=yes')\ >some text</a>
</code></pre>
| javascript | [3] |
2,971,587 | 2,971,588 | Is hashCode() used any where? | <p>Does anyone use <code>hashCode()</code> anywhere?</p>
<p>Can anyone give me an example of the exact use of hashcode and in which cases we need to implement it?
<strong>Any specific area where HashCode is being used?</strong></p>
| java | [1] |
2,852,524 | 2,852,525 | Adding annotations to a map from custom contacts group | <p>How can I add annotations of all the contacts in my custom group, in a mapview.</p>
| iphone | [8] |
3,745,348 | 3,745,349 | c# string replace with backslash buggy? | <p>I have the following string:</p>
<pre><code> "\\\\AAA.AA.A.AA\\d$\\ivr\\vm\\2012May\\29\\10231_1723221348.vox"
</code></pre>
<p>I would like it to look like:</p>
<pre><code>"\\AAA.AA.A.AA\d$\ivr\vm\2012May\29\10231_1723221348.vox"
</code></pre>
<p>I have tried</p>
<pre><code>fileToConvert.Replace(@"\\",@"\")
</code></pre>
<p>This produces:</p>
<pre><code>"\\AAA.AA.A.AA\\d$\\ivr\\vm\\2012May\\29\\10231_1723221348.vox"
</code></pre>
<p>Why?!?</p>
<p>Thanks all!</p>
| c# | [0] |
3,943,140 | 3,943,141 | How do I access a c# variable's value in an .aspx page? | <p>The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). </p>
<p>we need to access the c# variable in .aspx page at the time we have problem</p>
<p>Please guide us?</p>
| asp.net | [9] |
514,939 | 514,940 | Pattern to create polymorphic objects with dependency constraint | <p>First, my structure :</p>
<p>AbstractObject<br>
--ObjectA<br>
--ObjectB</p>
<p>AbstractOtherObject<br>
--OtherObjectA<br>
--OtherObjectB</p>
<p>With polymorphism, I want to create an <code>AbstractOtherObject</code> based on my <code>AbstractObject</code>. More precisely, I want an <code>OtherObjectA</code> if it is an <code>ObjectA</code>, and same for B.<br>
The important point is that I don't want a dependency to <code>AbstractOtherObject</code> in <code>AbstractObject</code>. I can't make an abstract method<code>AbstractOtherObject toOtherObject()</code> in <code>AbstractObject</code>. </p>
<p>I can't find a solution that doesn't use <strong>instanceof</strong>. </p>
<p>Thanks in advance.</p>
<p>Update : pseudo code</p>
<p>If I didn't have the dependency constraint I would do this :</p>
<pre><code>public class Any{
void do(AbstractObject o){
AbstractOtherObject otherO = o.toOtherObject();
doSomething(otherO);
}
}
</code></pre>
<p>But since I don't want a dependency, I am only able to do something ugly like :</p>
<pre><code>public class Any{
void do(AbstractObject o){
AbstractOtherObject otherO;
if(o instanceof ObjectA){
otherO = new OtherObjectA(o);
} else {
otherO = new OtherObjectB(o);
}
doSomething(otherO);
}
}
</code></pre>
| java | [1] |
1,969,332 | 1,969,333 | static_cast with bounded types | <p>When you cast an int in short with a classic static_cast (or c cast), if the value is out of the short limits, the compiler will truncat the int.</p>
<p>For example:</p>
<pre><code>int i = 70000;
short s = static_cast<short>(i);
std::cout << "s=" << s << std::endl;
</code></pre>
<p>Will display:</p>
<pre><code>s=4464
</code></pre>
<p>I need a "inteligent" cast able to use the type limit and, in this case return 32767. Something like that:</p>
<pre><code>template<class To, class From>
To bounded_cast(From value)
{
if( value > std::numeric_limits<To>::max() )
{
return std::numeric_limits<To>::max();
}
if( value < std::numeric_limits<To>::min() )
{
return std::numeric_limits<To>::min();
}
return static_cast<To>(value);
}
</code></pre>
<p>This function works well with int, short and char, but need some improvments to works with double and float.</p>
<p>But is it not a reinvention of the wheel ?</p>
<p>Do you know an existing library to do that ?</p>
<p><em><strong>Edit:</em></strong></p>
<p>Thanks. The best solution I found is this one:</p>
<pre><code>template<class To, class From>
To bounded_cast(From value)
{
try
{
return boost::numeric::converter<To, From>::convert(value);
}
catch ( const boost::numeric::positive_overflow & )
{
return std::numeric_limits<To>::max();
}
catch ( const boost::numeric::negative_overflow & )
{
return std::numeric_limits<To>::min();
}
}
</code></pre>
| c++ | [6] |
192,660 | 192,661 | Android Audio record | <p>I want to know that how to record our voice and playback using AudioRecord functionality in android instead of MediaRecorder.</p>
<p>Please give me sample code or url.
Thanks in advance</p>
| android | [4] |
5,308,217 | 5,308,218 | Jquery - hide() then fadeIn() then fadeOut() is there a cleaner way? | <p>I'm trying to achieve some animation using jQuery. I have it working but I'm 100% sure there is a cleaner better way of doing and I'm hoping someone can point me in the right direction.</p>
<p>Here is my code:</p>
<pre><code>$(document).ready(function () {
$("#1-popup").hide(); // Hides the first popup
$("#2-popup").hide(); // Hides the second popup
$("#1-trigger").toggle(function () {
$("#2-popup").fadeOut("slow"); // Hides the second popup just incase its showing
$("#1-popup").fadeIn("slow"); // Fades in the first popup
}, function () {
$("#1-popup").fadeOut("slow"); // Fades out in the first popup
});
$("#2-trigger").toggle(function () {
$("#1-popup").fadeOut("slow"); // Hides the first popup just incase its showing
$("#2-popup").fadeIn("slow"); // Fades in the second popup
}, function () {
$("#2-popup").fadeOut("slow"); // Fades out the second popup
});
});
</code></pre>
<p>Its a little messy is there anyway to use an if statement in this?</p>
| jquery | [5] |
5,411,146 | 5,411,147 | Call Base class fun() in using "this" keyword (when a derived class is presen) | <p>I have the following code snippet</p>
<pre><code>Class Parent
{
public override String ToString()
{
return "in Parent";
}
public virtual void printer()
{
Console.write(this.ToString());
}
}
Class Child : Parent
{
public override String ToString()
{
return "in Derived";
}
public override void printer()
{
base.printer();
Console.write(this.ToString());
}
}
</code></pre>
<p>in Main I have</p>
<pre><code>Parent p = new Derived();
p.printer();
</code></pre>
<p>The output comes as "In Derived" 2 times. This is expected as most overridden method is called.</p>
<p>But, is it possible to call the ToString() method of the base class, in this case instead of the base calling the derived one?</p>
| c# | [0] |
5,395,958 | 5,395,959 | How to switch between CSS files using external Javascript | <p>I'm working on a website for my Web Design coursework and I'm writing both CSS scripts that will format the site for either a desktop browser or a mobile one, depending on whether the appropriate useragent is detected. I'm able to detect the presence of a mobile browser easily enough and the default CSS is desktop, the problem I have is switching between them. I've been told by the department's resident web programming guru that you should never place Javascript directly into the html file, and that it should all be off in external files, which so far I've been able to stick to.</p>
<p>Now my problem is that I can't find a way to determine which CSS file to load without using inline Javascript. The script I'm using to detect the presence of the mobile browser returns a boolean value depending on the result of checking the useragent, and I would use that to load the appropriate CSS file. </p>
<p><strong>Question</strong>: How should I write a Javascript file that will load the appropriate CSS file?</p>
<p>My script for detecting the mobile (Android) browser is:</p>
<pre><code>var deviceAndroid = "android";
function DetectAndroid()
{
if (uagent.search(deviceAndroid) > -1)
return true;
else
return false;
}
</code></pre>
| javascript | [3] |
777,771 | 777,772 | How can i redirect a php page to another php page ? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4864522/how-to-redirect-users-to-another-page">How to redirect users to another page?</a> </p>
</blockquote>
<p>I'm a beginner in the programming field....I want to redirect a php page to another one..How is it possible in the most easiest way? My concept is just to move,to the home page from the login page after doing the checking of user id and password. </p>
| php | [2] |
951,761 | 951,762 | how to assign the hover to 2 elements | <p>I am trying to assign hover event to 2 elements at the same time. Are there better ways to do this?</p>
<pre><code>//I want to assign hover to another element.
$element1=$('hi');
$element2=$('hi2');
//I need to assign element 1 and element 2 to the same hover function...
$element1.hover(function(e){
codes......
})
</code></pre>
<p>Thanks for any helps.</p>
| jquery | [5] |
1,543,841 | 1,543,842 | Mantaining dropdown.. Script is so long? | <p>I've read that using session is one way to retain the values from PHP submit failure. The data is wiped out as soon as you send the form to the server so to get back the data, a session should be use. I have a dropdown that is a list of country. It contains more than 60-80 countries. I used the ternary condition to make the script shorter but it's still very long and tiresome.</p>
<p>It looks like this</p>
<pre><code><option value="Afghanistan" <?php echo (isset($_SESSION["errors"]) && $_SESSION["country"] == "Afghanistan") ? "SELECTED" : ""; ?> >Afghanistan</option>
<option value="Albania" <?php echo (isset($_SESSION["errors"]) && $_SESSION["country"] == "Albania") ? "SELECTED" : ""; ?>>Albania</option>
<option value="Algeria" <?php echo (isset($_SESSION["errors"]) && $_SESSION["country"] == "Algeria") ? "SELECTED" : ""; ?>>Algeria</option>
</code></pre>
<p>As I continue this, I thought that there must be another way. Is this a good method? When I see php scripts that is very long, I tend to think that I'm not doing the right way. The list goes on up till now.</p>
| php | [2] |
4,541,523 | 4,541,524 | Memory wise, is storing a string as byte cheaper than its UTF equivalent? | <p>If I store a string as a byte, does it use less memory than if it was stored in UTF-8?</p>
<p>e.g.</p>
<pre><code>string text = "Hello, World!";
</code></pre>
<p>Versus encoding it into a byte variable?</p>
| c# | [0] |
247,069 | 247,070 | Worst PHP practice found in your experience? | <p>What are the worst practices found in PHP code?</p>
<p>Some examples:</p>
<ul>
<li>Use of $array[reference] without single quotes</li>
<li>Instance "hidden" variables into inclusion files, which are needed later</li>
<li>Lots of recursive inclusion not using "_once" functions</li>
</ul>
<p><em>Note</em>: maybe subjective or "fun" if you like.</p>
| php | [2] |
4,580,682 | 4,580,683 | append data in serialized array with php | <p>I am writing a php script for creating serialized array as follow:</p>
<pre><code>$x=Array();
$x[0]=$_GET['fname'];
$x[1]=$_GET['lname'];
$str=serialize($x);
print $str;
$y=$_GET['hf'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("formdemo", $con);
$sql="update rohit set data='$str' where fid='$y'";
</code></pre>
<p>now I want to append more data on this array. what should I do for that </p>
<p>Thanx</p>
| php | [2] |
2,892,449 | 2,892,450 | String comparison in java | <p>I take a string from an array that stores strings. Then I print it for check and see that is this that i want. When I compare it with the string that it suppose to be I get error.
When I print bString it is "root"!!! When I compare it is not! </p>
<pre><code>System.out.println(aString);
if (aString.equals("root")) {
System.out.println("its ok!");
}
</code></pre>
| java | [1] |
194,508 | 194,509 | PHP - Printing out values of arrays inside arrays | <p>I have a system that inputs multiple images via a backend script ... i want to be able to echo out the images into a list on the frontend so i can manipulate them.</p>
<p>Im not exactly sure how i would do this using a loop.</p>
<p>In my PHP im viewing the contents of the array using the following:</p>
<pre><code><?php print_r($node->rotator['und']); ?>
</code></pre>
<p>When it prints out, its giving me the following information</p>
<pre><code>Array (
[0] => Array ( [fid] => 4 [alt] => [title] => [uid] => 1 [filename] => fredmanhhh.jpeg [uri] => public://fredmahjk.jpeg [filemime] => image/jpeg [filesize] => 108646 [status] => 1 [timestamp] => 1311781185 [rdf_mapping] => Array ( ) )
[1] => Array ( [fid] => 6 [alt] => [title] => [uid] => 1 [filename] => 92_mr_t_snickers1.jpeg [uri] => public://92_mr_t_snickers1_1.jpeg [filemime] => image/jpeg [filesize] => 475757 [status] => 1 [timestamp] => 1311785879 [rdf_mapping] => Array ( ) )
)
</code></pre>
<p>What i need to do with a loop is extract the [filename] and add that inside the list tag for each image thats been uploaded.</p>
<p>If anyone could help me, that would be grand.</p>
<p>Cheers</p>
| php | [2] |
600,672 | 600,673 | jQuery kill link if li has children | <p>Given the following structure:</p>
<pre><code><ul>
<li><a href="example.com>1</a></li>
<li><a href="example.com>2</a></li>
<li><a href="example.com>3</a>
<ul>
<li><a href="example.com">3.1</a></li>
<li><a href="example.com">3.2</a>
<ul>
<li><a href="example.com">3.2.1</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="example.com>4</a></li>
</ul>
</code></pre>
<p>I'd like to auto remove or kill the link for <code>3</code> and <code>3.2</code> </p>
<p>Basically any li that has children the link should be removed.
What's the best way to go about this?</p>
| jquery | [5] |
144,261 | 144,262 | iPhone:How to get window frame in UIInterfaceOrientationLandscapeLeft or Right? | <p>I want to get exactly window frame with x,y,width and height position in <code>UIInterfaceOrientationLandscapeLeft</code>, <code>UIInterfaceOrientationLandscapeRight</code>, <code>UIInterfaceOrientationPortraitUpsideDown</code> and <code>UIInterfaceOrientationPortrait</code>.</p>
<p>Please give me any link or any idea to develop this functionality.</p>
<p>Thanks in advance</p>
| iphone | [8] |
750,237 | 750,238 | aspnet command line tools location | <p>Microsoft provides a number of command line tools for working with asp.net applications. I haven't had any trouble using these tools. One thing that I can not understand though, is the location of these tools.</p>
<p>Even for applications targeting newer versions of .net, these tools are located in the .net v2 directory. On my machine, that's <code>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727</code>. Why do these tools not exist in the <code>v3.0</code> or <code>v3.5</code> directories? And why do the ones in the older directory work on the newer framework?</p>
<p>This is more of an idle curiosity than required knowledge for me, but I would like to know.</p>
<h2>Update:</h2>
<p>Thanks for the good answers everyone. These answers raise a new question though. I hope you will forgive me for asking it here, since it is so highly related. If .net 3.5 is really just using the CLR from 2.0, why is 2.0 compatible with Windows 2000, but not 3.5? It would seem to me that if the updates in 3.0 and 3.5 run inside the framework of the earlier version, then they must maintain compatibility with the same platforms as the earlier version too. Why is this wrong?</p>
| asp.net | [9] |
4,736,293 | 4,736,294 | Maintain count in python list comprehension | <p>In Python, is there any <code>counter</code> available during the list comprehension as it would be in case of a <code>for</code> loop?</p>
<p>It would be more clear why I need a counter, with this example:</p>
<p>I wish to achieve the following:</p>
<p>Initial List: <code>['p', 'q', 'r', 's']</code></p>
<p>Desired List: <code>[(1, 'P'), (2, 'Q'), (3, 'R'), (4, 'S')]</code></p>
<p>In the desired list, first element of every tuple are ordinal numbers. If it were just flat list, I could have used <code>zip</code> to achieve this. But however, the list I am dealing with is nested, three level deep (think of hierarchical data), and it is generated through list comprehension.</p>
<p>So, I was wondering is there any way to introduce those ordinal numbers during list comprehension. If not, what would be the best possible solution.</p>
<p>P.S. : Here the lower case letters are converted to uppercase, but that is not a part of problem, think of it as just a data conversion.</p>
<p>Code:</p>
<pre><code>allObj = Category.objects.all()
tree =[(_, l1.name, [(__, l2.name, [(___, l3.name) for l3 in allObj if l3.parentid == l2.categoryid]) for l2 in allObj if l2.parentid == l1.categoryid]) for l1 in allObj if l1.parentid == None]
</code></pre>
<p><code>allObj</code> contains data from table category, which in turn contains hierarchical data represented in the form of Adjacency List.</p>
<p>I have put <code>_</code> where I need ordinal numbers to be. Notice that the list is nested, so there will be a separate counter at each level represented by 1, 2 & 3 <code>_</code>s.</p>
| python | [7] |
3,392,063 | 3,392,064 | How to get all the li in javascript? | <pre><code><ul id="tab">
<li onclick="clicker()" class="li01">one test</li>
<li onclick="clicker()" class="li02">two test</li>
<li onclick="clicker()" class="li03">three test</li>
<div class="web_clear"></div>
</ul>
<div class="web_index">
content....
</div>
</code></pre>
<p>i used <code>document.getElementsByTagName("ul").childNodes;</code> to get all the li. but it doesn't work. </p>
| javascript | [3] |
3,382,163 | 3,382,164 | How to use JQuery to highlight a checkobx when it is checked | <p>I am trying to use JQuery to highlight the checkboxes checked by a user,<br/>
and when they will be un-highlighted when the user unchecked those checkoxes.<br/></p>
<p>But how is it possible to do this effect?</p>
| jquery | [5] |
5,007,686 | 5,007,687 | Why is the Process.GetProcessesByName() always null? | <p>I try to use program to check the process if it exists.</p>
<pre><code>using System;
using System.Diagnostics;
using System.ServiceProcess;
namespace ServProInfo
{
class Program
{
public static int IfProcessExist(string processName)
{
try
{
Process[] targetProcess = Process.GetProcessesByName(processName);
int proLen = targetProcess.Length;
if (proLen == 0)
{
Console.WriteLine("The process does NOT exist or has exited...");
return 0;
}
Console.WriteLine("The process status is: Running");
return 1;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace + "\r\n" + ex.Source);
return -1;
}
}
static void Main(string[] args)
{
string type = args[0];
string name = args[1];
switch (type)
{
case "p":
IfProcessExist(name);
break;
}
}
}
}
</code></pre>
<p>However, the Process[] targetProcess is alway null, even when I set processName as an exist process's name.</p>
<p>How could I correct the program? </p>
| c# | [0] |
2,879,062 | 2,879,063 | jQuery Event for link click not firing | <p>I have the following function:</p>
<pre><code> $("a#mylink").click(function(e){
e.preventDefault();
$.ajax({ url: $(this).attr("href") });
$(this).parent().parent().fadeOut("slow");
});
</code></pre>
<p>A link is being created on the page with the following code:</p>
<pre><code>'<div style="margin-top: 4px; border: solid 2px #515151; color: #515151; width: 300px;"><span style="padding-left: 4px">' +
file.name+
' </span><div style="float: right; padding-right: 4px;"><a class="mylink" href="remove.aspx?img='+safeUrl+'">Remove</a></div>' +
'</div>'
</code></pre>
<p>When I click the link, a new page pops up and it does not hit my function. Any ideas?</p>
| jquery | [5] |
2,099,125 | 2,099,126 | Basic Python repetition exercise | <p>I was trying to learn Python when I came upon this question. I am not asking for you to answer the question for me, I just need some help. <strong>Note: I am only allowed to use loops and if statements etc. Nothing ahead.</strong> I don't understand where I can use loops to create this program or the formulas needed.</p>
<p>Your parents need to buy a new vehicle and they are trying to
decide whether to purchase a hybrid or not. Hybrid vehicles
produce less CO2 emissions and have better fuel efficiency
compared to their non-hybrid counterpart. However, hybrid
vehicles also cost a lot more money than their non-hybrid version.
Help your parents make a decision as to which type of vehicle to
buy (strictly in terms of the financial cost and not taking into account the environmental
benefits). The typical family drives 20,000 kms each year and gas currently costs $1.30/litre.</p>
<p>Allow the user to enter the cost of the hybrid and non-hybrid vehicle along with the
combined fuel efficiency of those vehicles. Also, allow the user to enter the average amount
of kilometers they drive each year (note: the average is 20000 km/year). Then output how
many years of ownership it will take for the two cars to equal in cost. Assume that the price
of gas stays the same at $1.30/litre.</p>
<p>Obviously, the cost of gas will increase each year (this is called inflation). Incorporate into your calculation the idea that gas
prices will rise by 3% each year (i.e. annual inflation rate is 3%).</p>
<p><strong>This is what I have so far:</strong> </p>
<pre><code>count=0
total=0
gas=1.30
avgkm=20000
normalcost=input("Please enter the cost of the non-hybrid vehicle: ")
hybridcost=input("Please enter the cost of the hybrid vehicle: ")
fueleff=input("Please enter the combined fuel effiency of both vehicles: ")
</code></pre>
| python | [7] |
434,119 | 434,120 | google.ads.AdView not take the full width of screen in samsung galaxy notes | <p>Actually i am displaying an google.ads.AdView in my app at the bottom of the screen..All works fine. But the only problem is that it doesn't take the full width of the screen while showing in samsung galaxy notes, however while displaying in nexus s it take the full width of the screen.</p>
<p>Why this happen, is there is a way to solve this issue.</p>
<p><strong>My xml Layout where i put my google.ads.AdView is</strong></p>
<pre><code><LinearLayout
android:id="@+id/bottom_control_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="a14e5222d46c63d"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
</LinearLayout>
</code></pre>
| android | [4] |
4,690,697 | 4,690,698 | Android development: How to find out which applications are currently accessing the internet? | <p>Is there any method that can help me track internet usage by application? I need to find out which app is using Internet at the moment.</p>
<p>I've managed to get all applications with INTERNET permission but I don't know how to get only those applications that are connected to internet.</p>
<pre><code>for(int i=0; i<applications.size(); i++){
ApplicationInfo info = applications.get(i);
if(PackageManager.PERMISSION_GRANTED==packageManager.checkPermission(Manifest.permission.INTERNET, info.packageName)){
netApplications.add(info);
}
}
</code></pre>
| android | [4] |
4,832,969 | 4,832,970 | How do I unpack a list with fewer variables? | <pre><code>k = [u'query_urls', u'"kick"', u'"00"', u'msg=1212', u'id=11']
>>> name, view, id, tokens = k
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
</code></pre>
<p>I need to provide 5 variables to unpack this list. Is there a way to unpack with fewer, so that <code>tokens</code> gets the rest of the list. I don't want to write another line to append to a list....</p>
<p>Thanks. </p>
<hr>
<p>Of course I can slice a list, assign individually, etc. But I want to know how to do what I want using the syntax above.</p>
| python | [7] |
3,826,665 | 3,826,666 | Is it possible in Android to create a view that overlaps the actionbar? | <p>I have created a menu out of a tablelayout. When activated, the menu will animate over the background view, until it covers the whole window.</p>
<p>I would like for this menu to also overlap the actionbar, when the menu is visible. My question is, is it possible to have a view overlap the action bar container? If so, how might I achieve this?</p>
| android | [4] |
3,231,928 | 3,231,929 | How to test input value for null or zero with jQuery | <p>I need to keep the focus on the text input when the user moves to the next input without putting something in the previous one. In short, if it is null (left blank) or not valid, how do I keep the focus on that input until the conditions are satisfied?</p>
| jquery | [5] |
5,506,235 | 5,506,236 | Override image constructor in JS? | <p>Is it possible to override the <code>Image</code> constructor in JS? So that, for example, every time a <code>new Image()</code> is created, a message is written to the console?</p>
| javascript | [3] |
1,765,816 | 1,765,817 | Multidimensional Associative array email check | <p>I have an array multidimensional associative array.</p>
<pre><code>Array
(
[0] => Array
(
[username] => uname1
[name] => fullname1
[email] => uname1@email.com
)
[1] => Array
(
[username] => uname2
[name] => fullname2
[email] => uname2
)
[2] => Array
(
[username] => uname3
[name] => fullname3
[email] => uname3@email
)
[3] => Array
(
[username] => uname4
[name] => fullname4
[email] => uname4@
)
}
</code></pre>
<p>It should validate email address using the regular expression.The return array should consists of an array with only valid array.The array should be </p>
<pre><code>Array
(
[0] => Array
(
[username] => uname1
[name] => fullname1
[email] => uname1@email.com
}
</code></pre>
<p>since [1,2,3] have invalid email address.</p>
| php | [2] |
5,498,541 | 5,498,542 | unable to view graphical layout while doing android application | <p>i am new to android application..i am developing a application but i am unable to view graphical layout.It is showing empty.Some of my asked to open with android layout editor.Even though i open with androidlayouteditor it is not showing any graphical representation.Please help me.</p>
<p>thanks and regards,
pradeep kovvuru</p>
| android | [4] |
328,743 | 328,744 | set android alarm at specific time | <p>i set the alarm at specific time but every time i open the application it will turn on
this is the code i used :</p>
<pre><code> AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,0010000,intent,0);
Calendar time = Calendar.getInstance();
time.set(Calendar.HOUR, 5);
time.set(Calendar.MINUTE, 59);
time.set(Calendar.SECOND, 0);
alarmManager.set(AlarmManager.RTC,time.getTimeInMillis(),pendingIntent);
</code></pre>
| android | [4] |
1,654,705 | 1,654,706 | How to identify a PHP variable is an array or not | <p>How to check whether the PHP variable is an array?
$value is my PHP variable and how to check whether it is an array?</p>
| php | [2] |
832,576 | 832,577 | how to make condition on selection of checkbox in user controler | <p>I have a user control </p>
<pre><code><input id="check" type="checkbox" />
<label>&nbsp;</label>
<fieldset class="clearfix" id="fieldset-exception">
<legend>Student Information</legend>
<div class="fiveper">
<label for="StudentID">
Exception ID:
<span><%=Html.EditorFor(x => x.studentid)%></span>
</label>
<label for="Classroom">
Origination:
<span><%=Html.EditorFor(model => model.Classroom)%></span>
</label>
<label for="Subject">
Age:
<span><%=Html.EditorFor(model => model.subject)%></span>
</label>
</div>
$('#btnAll').click(function() {
$('#Details input[type=checkbox]').attr('checked', 'checked');
});
</code></pre>
<p>I am checking all checkboxes using above code
but I need to make condition here that user need to select atleast one checkbox to do something?
i have other button to go other page based on this checkbox checked?
can anybody tell me how to check that and how to make that condition here?
Thanks
thanks</p>
| jquery | [5] |
5,338,327 | 5,338,328 | How would I check a string for a certain letter in Python? | <p>How would I tell Python to check the below for the letter x and then print "Yes"? The below is what I have so far...</p>
<pre><code>dog = "xdasds"
if "x" is in dog:
print "Yes!"
</code></pre>
| python | [7] |
5,696,802 | 5,696,803 | Which jQuery attribute do I need to use to find specific text? | <p>I'm trying to target the <code>a</code> tags that contain the html <code>next &raquo;</code> and add a class to that tag. I have tried using jQuery's <code>contains</code> but obviously it didn't work since I'm here. </p>
<pre><code>$('a').contains('next &raquo;').addClass('next');
</code></pre>
<p>Which attribute do I need to use for this?</p>
| jquery | [5] |
3,717,392 | 3,717,393 | get list of files in order of creation | <p>i am currently reading in a list of files from different directories into a LIST:</p>
<pre><code>public List<string> MapMyFiles()
{
List<string> batchaddresses = new List<string>();
foreach (object o in lstViewAddresses.Items)
{
try
{
batchaddresses.AddRange(Directory.GetFiles(o.ToString(), "*-E.esy"));
}
catch
{
if (MessageBox.Show(o.ToString() + " does not exist. Process anyway?", "Continue?", MessageBoxButtons.YesNo)
== DialogResult.Yes) { }
else
{
Application.Exit();
}
}
}
</code></pre>
<p>how would i sort them by date of creation in the list?</p>
| c# | [0] |
5,162,736 | 5,162,737 | Different constants in android projects that have same code base(library project) | <p>I have an android library project.
Two projects-A and B are using that library project code.</p>
<p>I have this code in the shared android library project
RequestAdFromAdmob(constantAdId)</p>
<p>I wish to use a different ad id for project A and project B, so what is the best practice to do it?</p>
<p>Thanks</p>
| android | [4] |
4,351,722 | 4,351,723 | Any php code to detect the browser with version and operating system? | <p>I tried to search in google but cannot find a complete solution (i only find something detects only the browser's type like firefox, opera) .</p>
<p>i want a php class or code to check the user's Browser including the <strong>version</strong> and also the operating system. </p>
<p>Thanks</p>
| php | [2] |
1,670,753 | 1,670,754 | Maintaining application state in Android | <p>I am having trouble finding out how to maintain the state of my Android app in development.</p>
<p>Just to clarify, I am not talking about maintaining activity state (i.e. keeping track of textbox values, checkboxes, etc on a specific activity). </p>
<p>Let's say for example my application has two activities <code>A</code> and <code>B</code>. When I start my app, it takes me to activity <code>A</code>, and pressing a button on it takes me to activity <code>B</code>. At this point, I press the home button on my phone to return to the main Android UI and exiting my app . However, if I choose to run my app again, it should take me to activity <code>B</code>, which is where I left off before pressing the home button, but instead it is taking me to activity <code>A</code>. </p>
<p>Does anyone know how I can rectify this? </p>
<p>(I am using a Samsung Vibrant in case if you need to know)</p>
| android | [4] |
4,330,324 | 4,330,325 | Explicit access to Python's built in scope | <p>How do you explicitly access name in Python's built in scope? </p>
<p>One situation where I ran in to this was a in module, say called foo, which happened to have an open function. In another module foo's open function would be accessible as foo.open which works well. In foo itself though, open blocks the built in open. How can you access the built in version of a name like open explicitly?</p>
<p>I am aware it is probably practically bad idea to block any built in name, but I am still curious to know if there is a way to explicitly access the built in scope.</p>
| python | [7] |
5,013,987 | 5,013,988 | Outputting data from a for loop | <p>Can you please help me in getting data out of this for loop. It actually should print the names of 3 months, which it does if i dont use the $ period variable in there and use echo instead. But I want to put the value into the $period variable, so I can use it else where in my script. Right now, it print out only one month.</p>
<pre><code>for ($i=1; $i<=3; $i++)
{
$period = '<option value="">';
$period .= date('F, Y', strtotime('+'.$i.' month'));
$period .= '</option>';
}
echo $period;
</code></pre>
| php | [2] |
2,765,479 | 2,765,480 | Letter into words | <p>I'll be placing my class to show additional things that I need work with. Would it work if I did typecasting? Or I just have to learn strings?</p>
<pre><code>class NumberBox
{
private:
int number;
char letter;
public:
NumberBox *next_ptr;
void setNumber(int number)
{
this->number = number;
}
void setLetter(char letter)
{
this->letter = letter;
}
int getNumber()
{
return number;
}
int getLetter()
{
return letter;
}
};
int main()
cout << "Please Give the faction for the first Card" << endl;
cin >> faction[0];
if(faction [0] == 's' || faction [0] == 'c' || faction [0] == 'h' || faction [0] == 'd')
{
if(faction[0] == 's')
{
faction[0] = "spade";
factionHead_ptr->setLetter("spade");
}
}
</code></pre>
<p>How do you do it? Like If The user input <code>'s'</code> then it would be Spade.</p>
| c++ | [6] |
4,433,896 | 4,433,897 | Adding SSL on a single Page in ASP.NET | <p>I want 'only' my Login page to be SSL enabled. When the user logsin using https://mysite.login.aspx, after the login the user should be taken to an <a href="http://mysite.default.aspx" rel="nofollow">http://mysite.default.aspx</a></p>
<p>Please tell me step by step how to do it.</p>
| asp.net | [9] |
5,258,822 | 5,258,823 | How to find if there are active downloads using API level 8? | <p>Is there a way to find if there is active downloads programmatically working on API level 8?
I need to do an application for android that turns off wifi if there a no downloads active.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.