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 |
|---|---|---|---|---|---|
431,610 | 431,611 | Where can I find Java API code | <p>I heard that Java is a opensource code. so, Can I get Java API coding methodology? If so, please let me know where can I get the source code for Java APIs.</p>
| java | [1] |
1,833,913 | 1,833,914 | Android: Unexpected recent apps behavior | <p>Our app has 2 Activities- A <code>MainActivity</code> (associated with Launcher icon) and an <code>AuxActivity</code> for handling URI events.</p>
<p>I'm seeing an issue with this scenario, with my app initially exited:</p>
<ol>
<li><p>Open Browser, click on a URI to launch the <code>AuxActivity</code>.</p></li>
<li><p><code>AuxActivity</code> exits (calls finish()), user returns to Browser.</p></li>
<li><p>User brings up recent Apps (long-press home), and selects my app.</p></li>
</ol>
<p>Instead of starting <code>MainActivity</code>, I'm seeing <code>AuxActivity</code> being started with the same intent that represents a URI click (<code>android.intent.action.VIEW</code>). </p>
<p>Now instead of step 3, if the user were to open my app through its Home Screen icon, I get back to <code>MainActivity</code>, as expected.</p>
<p>How can I get step 3 to launch <code>MainActivity</code> instead?</p>
| android | [4] |
4,671,888 | 4,671,889 | Dynamic User Controls in asp.net | <p>Hello I am trying to lear how to create Dynamic User Controls in asp.net.</p>
<p>I just know that this type of controls are created or loaded at run time.</p>
<p>Someone knows a good tutorial about this topic?</p>
<p>thanks in advance,</p>
| asp.net | [9] |
5,487,742 | 5,487,743 | Looking for python module to help "neaten" up a server console window | <p>I'm looking for a Python module/framework/package that will assist me in making a sort of "better" console for my application. As it stands now, STDIN can be "pushed" to new lines by other messages being logged out to the console, therefore making it difficult to read what you are trying to type into a server console if it is a long command, or you are prone to typing errors.</p>
<p>Are there any sort of already existing modules that can help me do this? If it helps, it can be comparable to JLine, (at least I think, I have no first-hand experience with JLine).</p>
<p>Oh, and if you don't understand what I'm talking about, you can check the closest thing I can find of an example <a href="http://www.youtube.com/watch?v=NFeuo5XTsII&feature=player_detailpage#t=483s" rel="nofollow">here.</a> Basically, that bottom line in the console is where all commands are entered, and it doesnt get pushed back when the server is in use; it is sort of static in a sense.</p>
<p>Any ideas? Thanks!</p>
| python | [7] |
4,815,547 | 4,815,548 | Contoling powepoint presentation through IPHONE | <p>Hi all I have to develop one Iphone app in which I need two major functionality. First functionality should be to control the whole power-point presentation from iphone and simultaneously I want to refer to my short hand notes which I would make with this application itself. so in a nutshell with one button click event I want my keynotes to be added in which I can curl to next pages and add keynotes or open the existing key notes and want to control the whole power point presentation within that page. How would I integrate the power-point controlling feature in iPhone and also short notes functionality. </p>
<p>Can you guys please provide me the solution how to develop this sort of native app in iphone </p>
| iphone | [8] |
2,493,899 | 2,493,900 | alarm sound in android application | <p>I want to know that how to set my own sound in setting alarm in android </p>
| android | [4] |
3,078,728 | 3,078,729 | Longtail video php API integration issue | <p>Looking to integrate the longtail php(bits on the run) video API into an application ,i want to be able to retrieve all the keys from the content server and associate them with a column in my mysql database song_id, and use an anchor tag with a query string to be able to retrieve the correct video when click on . Pretty much confuse how to do the integration .after calling the API , an array was return. .how to i query the API to be able to access all the key?</p>
<pre><code>$response = $botr_api->call("/videos/list",array('video_key'=>$video_key));
if ($response['status'] == "error") { die($response); }
Array
(
[status] => ok
[video] => Array
(
[status] => ready
[sourceurl] =>
[description] =>
[tags] => Kompa
[views] => 1
[title] => Pou'n Ale
[sourceformat] =>
[mediatype] => video
[custom] => Array
(
)
[duration] => 263.37
[upload_session_id] =>
[link] =>
[author] =>
[key] => ZLMzClv9
[error] =>
[date] => 1356543180
[md5] => c12663ebc91858f8223d7d2673048bdb
[sourcetype] => file
[size] => 388334729
)
)
</code></pre>
| javascript | [3] |
4,725,063 | 4,725,064 | How set Alternate Cell Color in a Grid | <p>How set alternate cell Color in a grid ?
I've found a lot of questions/tutorials
about how to set row colors but nothing
about cells' color.
Thanks in advance</p>
| android | [4] |
3,749,310 | 3,749,311 | Simple generic collection to add elements | <p>What collection should I use from C# that suports generic only for adding elements ?
I tried using <code>ArrayList</code>, but I see that it's a non-generic type.</p>
<p>Sorry if this is a duplicate. Thanks.</p>
| c# | [0] |
1,239,432 | 1,239,433 | how to replace a string in php | <p>i want to replace '<' and '>' sign in string.
e.g</p>
<pre>$str = 'if x<y and y>z';
echo str_replace( '<', 'something', $str ) . "\n";</pre>
<p>this give the following result</p>
<pre>if xsomethingy and y>z</pre>
<p>my question is how can i replace '>' to text 'something'</p>
| php | [2] |
1,879,293 | 1,879,294 | Android's RelativeLayout Unit Test setup | <p>i'm trying to write an unit test for my Android's RelativeLayout. Currently, my testcode setup is as follow:</p>
<pre><code>public class SampleRelativeLayoutTest extends AndroidTestCase {
private ViewGroup testView;
private ImageView icon;
private TextView title;
@Override
protected void setUp() throws Exception {
super.setUp();
// inflate the layout
final Context context = getContext();
final LayoutInflater inflater = LayoutInflater.from(context);
testView = (ViewGroup) inflater.inflate(R.layout.sample_layout,
null);
// manually measure and layout
testView.measure(500, 500);
testView.layout(0, 0, 500, 500);
// init variables
icon = (ImageView) testView.findViewById(R.id.icon);
title = (TextView) testView.findViewById(R.id.title);
}
</code></pre>
<p>However, I encountered NullPointerException with the following stack trace</p>
<pre><code>java.lang.NullPointerException
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:427)
at android.view.View.measure(View.java:7964)
at com.dqminh.test.view.SampleRelativeLayoutTest.setUp(SampleRelativeLayoutTest.java:33)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
</code></pre>
<p>What should I change in my setUp() code to make the test run properly ?</p>
| android | [4] |
2,475,387 | 2,475,388 | Package.Open() exception: Access to path is denied | <p>I been trying to fix this problem for the whole day, but no matter what I do I keep on getting the same exception: UnauthorizedAccessException was unhandled at line
using (Package package = Package.Open(d.FullName, FileMode.Create, FileAccess.ReadWrite))</p>
<p>The full code is:</p>
<pre><code>NTAccount act = new NTAccount("c9lu-PC","c9lu");
DirectoryInfo d = System.IO.Directory.CreateDirectory(path);
DirectorySecurity security = d.GetAccessControl();
security.AddAccessRule(new FileSystemAccessRule(act,FileSystemRights.FullControl,InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
d.SetAccessControl(security);
using (Package package = Package.Open(d.FullName, FileMode.Create, FileAccess.ReadWrite)) // where the exception occurs
{
PackageHelper.createPart(package, "/pages.zip" , MediaTypeNames.Application.Zip,
(stream) =>
{
using (var parts = ZipPackage.Open(stream, FileMode.Create))
{
}
}
);
}
</code></pre>
<p>I really don't know what the problem is, please help me out.</p>
| c# | [0] |
3,008,940 | 3,008,941 | Does service gets restarted automatically after an application is manually force closed from settings screen | <p>I am testing one scenario where i have to test whether the application service gets restarted after an application is manually force closed from settings screen.</p>
<p>When i force close the app in logs it shows:-</p>
<p>06-30 11:26:30.283: WARN/ActivityManager(116): Scheduling restart of crashed service com.test.app/.comm.PushService in 5000ms</p>
<p>But the service never gets restart after a 5sec.</p>
<p>I have override all necessary methods in the service(returns START_STICKY in onStartCommand).</p>
<p>What am i missing..?. Help Appreciated</p>
| android | [4] |
4,619,959 | 4,619,960 | Does NSDictionary always give output surrounded by double quotes? | <p>This is my code:</p>
<pre><code>//elementsValues is type of NSDictionary. currentElementValue is type of NSString.
//resultArray is type of NSArray.
//elementName = [[NSString stringWithFormat:@"SignOnResult"];
[self.elementsValues setObject:self.currentElementValue forKey:elementName];
[self.resultArray addObject:self.elementsValues];
NSLog(@"%@",[resultArray valueForKey:@"SignOnResult"]);
</code></pre>
<p>The output i get is printed in between " ". So does NSDictionary give output always in " " ?
I dont want the string in " ". </p>
| iphone | [8] |
886,569 | 886,570 | Python int to binary? | <p>Are there any canned Python methods to convert an Integer (or Long) into a binary string in Python?</p>
<p>There are a myriad of dec2bin() functions out on Google... But I was hoping I could use a built-in function / library.</p>
| python | [7] |
4,587,190 | 4,587,191 | Getting specific days in a month | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5421972/how-to-find-the-3rd-friday-in-a-month-with-c">How to find the 3rd Friday in a month with C#?</a> </p>
</blockquote>
<p>There's a condition that a specific event will occur only on <strong>first</strong> and <strong>third</strong> *<em>Wednesday</em>* of every month. I am trying to achieve this like below,</p>
<pre><code>DateTime nextMeeting = DateTime.Today.AddDays(14);
int daysUntilWed = ((int)DayOfWeek.Wednesday - (int)nextMeeting.DayOfWeek + 7) % 7;
DateTime nextWednesday = nextMeeting.AddDays(daysUntilWed);
</code></pre>
<p>But I am not getting the desired result. I am sure, I am missing out on a logic or is there any method in ASP.NET through which I can do that?
More Detail: I am trying to display the next Wednesday (whichever is first) by clicking on a button which will set the label.</p>
| asp.net | [9] |
5,103,633 | 5,103,634 | Type error in python code | <p>When I try to execute the following:</p>
<pre><code> def breadthFirstSearch(initialState, goalTest, actions, successor):
agenda = Queue()
if goalTest(initialState):
return [(None, initialState)]
agenda.push(SearchNode(None, initialState, None,2))
while not agenda.empty():
parent=agenda.pop()
print "POP <: the popped state is ", parent.state
for a in actions:
newS=successor(parent.state, a)
if newS != None:
newN=SearchNode(a, newS, parent)
if goalTest(newS):
return newN.path()
else:
print "> PUSH: the pushed state is ", newN.state
agenda.push(newN)
return None
</code></pre>
<p>I get the following error: </p>
<pre><code>TypeError: 'dict' object is not callable
The line where error occured is:
newS=successor(parent.state, a)
</code></pre>
<p>By the way, successor is even not a dictionary </p>
| python | [7] |
1,179,734 | 1,179,735 | How to increment a value with leading zeroes? | <p>What would be the best way to increment a value that contains leading zeroes? For example, I'd like to increment "00000001". However, it should be noted that the number of leading zeroes will not exceed 30. So there may be cases like "0000012", "00000000000000099", or "000000000000045".</p>
<p>I can think of a couple ways, but I want to see if someone comes up with something slick.</p>
| python | [7] |
4,539,300 | 4,539,301 | What means syntax like the following: @var=("","") | <p>I'm using eclipse and I put a script into my project. In a config-file there are php-statements like the following:</p>
<pre><code>@ftp_mode=(0,0,0);
@ftp_user=("","","");
</code></pre>
<p>Eclipse marks them as syntax errors but everything works. So I want to know if this is an error and if not what means it? It looks like an assignment, but there's no <code>$</code>-sign ...</p>
<p>Thanks in advance.</p>
<p>Regards Binabik</p>
| php | [2] |
5,224,167 | 5,224,168 | Read default browser's cookie in Android | <p>I am building an App which can be downloaded from my web server using the default browser. While the user is getting to download the App, I am actually creating a cookie and saving it on their device.</p>
<p>For some reason, I need to read the cookie which I did set for them after they install the App at first launch only.</p>
<p>As such, I need a way to read the value of the browser's cookie which I did set for them before when they were installing the App from my server.</p>
<p>I don't mind putting a hidden Web View if it helps with the issue.</p>
<p>So to recap it all, I need a way in my App to read the value of a specific cookie which was set in the default browser (given I have the cookie name and the website URL).</p>
<p>Please advice...</p>
| android | [4] |
3,655,657 | 3,655,658 | Why does sometimes DateTime.TryParse work and other time only DateTime.ParseExact work? | <p>I have two laptops both with windows xp sp3, vs 2010 and target framework .Net 3.5. When processing DateTime variable, I found that with laptop1 </p>
<pre><code>DateTime oldOrderDate;
string strnewdate = string.Empty;
CultureInfo provider = CultureInfo.InvariantCulture;
if (DateTime.TryParse(items[1], out oldOrderDate))
strnewdate = oldOrderDate.ToString("yyyy-MM-dd");
</code></pre>
<p>returned an exception "string was not recognized as a valid datetime" , but the codes below:</p>
<pre><code>oldOrderDate = DateTime.ParseExact(items[1], "dd/MM/yyyy", provider);
strnewdate = oldOrderDate.ToString("yyyy-MM-dd");
</code></pre>
<p>works. OTOH, with laptop2, </p>
<pre><code>oldOrderDate = DateTime.ParseExact(items[1], "dd/MM/yyyy", provider);
strnewdate = oldOrderDate.ToString("yyyy-MM-dd");
</code></pre>
<p>returned an exception "string was not recognized as a valid datetime" , but the code below:</p>
<pre><code>if (DateTime.TryParse(items[1], out oldOrderDate))
strnewdate = oldOrderDate.ToString("yyyy-MM-dd");
</code></pre>
<p>works. So, my question is how I should do processing of a DateTime variable to work in both laptops. I'd really appreciate any advice you could give me. Thank's in advance.</p>
| c# | [0] |
4,210,497 | 4,210,498 | How to connect with camera by IP? | <p>I have got a task to make application which can to connect to camera by IP and show video from it. But I'm a new developer and I don't know it is possible or not. Please, give me an advice. </p>
| android | [4] |
1,869,242 | 1,869,243 | Compile time vs Run time Dependency - Java | <p>I was wondering difference between compile time and run time dependencies in Java.
It is related to class path, but how do they differ?
I googled but didn't find a satisfying answer.</p>
<p>Thanks
Kunal</p>
| java | [1] |
316,375 | 316,376 | How to exhaust the heap | <p>What is an easy way to cause a heap overflow in Java? I need to test how some external code responds when memory goes away.</p>
| java | [1] |
509,922 | 509,923 | How to check if a string matches an IP adress pattern in python? | <p>What is the fastest way to check if a string matches a certain pattern? Is regex the best way?</p>
<p>For example, I have a bunch of strings and want to check each one to see if they are a valid IP address (valid in this case meaning correct format), is the fastest way to do this using regex? Or is there something faster with like string formatting or something. </p>
<p>Something like this is what I have been doing so far:</p>
<pre><code>for st in strs:
if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', st) != None:
print 'IP!'
</code></pre>
| python | [7] |
1,804,398 | 1,804,399 | Enum to String? | <p>I've got an enum defined like this</p>
<pre><code>enum Tile { Empty, White, Black };
</code></pre>
<p>But let's suppose when written to the console, </p>
<pre><code>Console.Write(Tile.White);
</code></pre>
<p>I want it to print</p>
<pre><code>W
</code></pre>
<p><em>Or any other value</em>, I could use a <code>switch</code> for this, but is there a nicer way? Perhaps using attributes?</p>
<hr>
<p>Here's what I have in mind. Writing something like this,</p>
<pre><code>[AttributeUsage(AttributeTargets.Field)]
public class ReprAttribute : Attribute
{
public string Representation;
public ReprAttribute(string representation)
{
this.Representation = representation;
}
public override string ToString()
{
return this.Representation;
}
}
enum Tile {
[Repr(".")]
Empty,
[Repr("W")]
White,
[Repr("B")]
Black
};
// ...
Console.Write(Tile.Empty)
</code></pre>
<p>Would print</p>
<pre><code>.
</code></pre>
<p>Of course, that <code>override string ToString()</code> didn't do what I was hoping it would do (it still outputs "Empty" instead.</p>
<hr>
<p>This article summarizes it pretty well: <a href="http://blogs.msdn.com/b/abhinaba/archive/2005/10/20/c-enum-and-overriding-tostring-on-it.aspx" rel="nofollow">http://blogs.msdn.com/b/abhinaba/archive/2005/10/20/c-enum-and-overriding-tostring-on-it.aspx</a></p>
| c# | [0] |
5,827,354 | 5,827,355 | newly added row does not display in an asp.net repeater | <p>I am using the code highlighted below: I have to refresh the browser window to see the newly added row to a table shown in a repeater on the web page. Is there anyway I can just auto refresh the repeater control to see the newly added row. The updtemode attribute on the asp:UpdatePanel is set conditional. On the contrary, when I delete a row from the repeater, I can immediately see the updated repeater without have to refresh the browser. Why can't I see the updated repeater when I add a row? thanks for the help!</p>
<pre><code> if (!IsPostBack)
{
Class object1 = getObject();
List<T> lst = object1.getList();
repeater.DataSource = lst;
repeater.DataBind();
}
</code></pre>
| asp.net | [9] |
4,764,623 | 4,764,624 | Is there any way to detect if video can be played on a device? | <p>I've done a deep research on playing videos Android devices and I came to a conclusion that there are some Android devices that can't play videos that were recorded on other Android devices.</p>
<p>Right now I'm firing an intent to play video, but the player says "Sorry, the video cannot be played".</p>
<p>I've been wondering if is there a way to detect that the video can't be played before I fire the intent?</p>
| android | [4] |
2,981,327 | 2,981,328 | About Limiting Rss Feed | <p>I want only the latest 5 feeds to be shown on my website.<br>
I am using the following code to fetch rss feed... Can any one help to limited feeds to be shown... Thank You In ADVANCE :)</p>
<p>CODE THAT AM USING</p>
<pre><code><?php
require_once('rss_fetch.inc');
$url = 'http://news.google.com/news?ned=us&topic=h&output=rss';
$rss = fetch_rss($url);
echo "Site: ", $rss->channel['title'], "<br>\n";
foreach ($rss->items as $item ) {
$title = $item['title'];
$url = $item['link'];
$desc = $item['description'];
$category = $item['category'];
echo "<a href=$url>$title</a>$desc <br/>CATEGORY : $category <br/><br/> ";
}
?>
</code></pre>
| php | [2] |
4,944,284 | 4,944,285 | sendTextMessage(phoneNumber, null, message, null, null); always returns success even when message not sent | <p>I tried sms activity using <a href="http://www.mkyong.com/android/how-to-send-sms-message-in-android/" rel="nofollow">this link</a>
but the problem is that it always gives "message sent"
how to know if the message is really sent!</p>
<p>here is code</p>
<pre><code>try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
//...
}
</code></pre>
| android | [4] |
2,652,838 | 2,652,839 | Unrecognized configuration section log4net. web.config website | <p>I use log4net to log the errors in my web application and it works fine. However if I place the same code in website I get error "Unrecognized configuration section log4net"</p>
<p>here is my web.config section </p>
<p></p>
<pre><code><section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" requirePermission="false"/>
</code></pre>
<p></p>
<p></p>
<pre><code><root>
<level value="RELEASE" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="D:\ESSReport\Logs\ESSlog.log" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="4MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%newline%-5p%d{yyyy-MM-dd hh:mm:ss} [%thread] [%logger] [%line] %newline - %message" />
</layout>
</appender>
</code></pre>
<p></p>
<p>I have added dll to my website</p>
| asp.net | [9] |
5,156,065 | 5,156,066 | How to call in android? | <p>How do I call international mobile programmatically when clicking textview in android?</p>
| android | [4] |
1,942,191 | 1,942,192 | How to unregister a specific hotkey using c# | <p>I am using the below code to register a HotKey :</p>
<pre><code>RegisterGlobalHotKey(Keys.F4, USE_ALT);
private void RegisterGlobalHotKey(Keys hotkey, int modifiers)
{
try
{
// increment the hot key value - we are just identifying
// them with a sequential number since we have multiples
mHotKeyId++;
if (mHotKeyId > 0)
{
// register the hot key combination
if (RegisterHotKey(this.Handle, mHotKeyId, modifiers, Convert.ToInt16(hotkey)) == 0)
{
// tell the user which combination failed to register -
// this is useful to you, not an end user; the end user
// should never see this application run
MessageBox.Show("Error: " + mHotKeyId.ToString() + " - " +
Marshal.GetLastWin32Error().ToString(),
"Hot Key Registration");
}
}
}
catch
{
// clean up if hotkey registration failed -
// nothing works if it fails
UnregisterGlobalHotKey();
}
}
private void UnregisterGlobalHotKey()
{
// loop through each hotkey id and
// disable it
for (int i = 0; i < mHotKeyId; i++)
{
UnregisterHotKey(this.Handle, i);
}
}
</code></pre>
<p>How can i unregister the Hot key and Make Alt+ F4 keep working again ?</p>
| c# | [0] |
653,379 | 653,380 | Web Services For Mobile Application Olympics London 2012 | <p>Are there any web service for London Olympics 2012, which anyone can make use of , in either our own website or mobile app? I'm trying to build an app which should fetch and populate the games updates - event schedule, player details, rankings, etc. I'm aware that there is a way to populate the London2012 website within browser window of app; but I would like to fetch only few details and not all the ones, which are displayed on the website. That is why, I need the info on the the web service.</p>
| android | [4] |
2,949,531 | 2,949,532 | Why can you read, but not modify, global values? | <pre><code>>>> import sys
>>> print(sys.version)
2.4.4
>>> b = 11
>>> def foo2():
... a = b
... print a, b
...
>>> foo2()
11 11
>>> def foo3():
... a = b
... b = 12
... print a, b
...
>>> foo3()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in foo3
UnboundLocalError: local variable 'b' referenced before assignment
>>> def foo4():
... global b
... a = b
... b = 12
... print a, b
...
>>> foo4()
11 12
</code></pre>
<p><strong>Question</strong>> In <code>foo3</code>, why you can access global variable without declaring it but you still cannot modify it.</p>
| python | [7] |
2,183,677 | 2,183,678 | Sorting a SortedDictionary based on value, not key | <p>I have a SortedDictionary, the key is a int value and the matching value to each key is a class object. The class contains a int and a two datetime variable.</p>
<p>I need to sort my SortedDictionary based on the InTime datetime in my class. So that when I do a foreach to loop through my SortedDictionary I will have them sorted based on datetime.</p>
<p>Is this possible? How can I achieve it?</p>
<pre><code>enter code here
class Busdetail
{
public int BusNo { get; set; }
public DateTime InTime { get; set; }
public DateTime OutTime { get; set; }
}
</code></pre>
| c# | [0] |
5,880,831 | 5,880,832 | Why am I getting this error with my for loop? | <pre><code>public boolean isNumber(String t) {
for (int i = 0, i<= 9, i++) {
if t.equals(i) {
return true;
}
}
return false;
}
</code></pre>
<p>Copypastad the wrong method originally -<em>_</em>-
I have this inside a class compiling with this error: </p>
<p>data_structures/ExpressionEvaluator.java:40: illegal start of type for (int i = 0, i< 10, i++) { </p>
| java | [1] |
4,897,503 | 4,897,504 | Retrieving multiple selection of a ListBox | <p>I have a ListBox that contains some names from a database query.</p>
<p>How can I retrieve these names when selecting multiple items?</p>
| c# | [0] |
776,427 | 776,428 | Reading a tag from a textview | <p>I am setting a tag on a textview using the following code</p>
<pre><code> TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText("New Item");
tv.setTag("1");
</code></pre>
<p>How can I read the tag value I have set for this?</p>
| android | [4] |
1,999,326 | 1,999,327 | Print value of number (int) spelled out | <p>is there an out-of-box way to spell out an int in C#? For example if I have:</p>
<pre><code>int a = 53;
</code></pre>
<p>I want to print:</p>
<pre><code>"fifty three"
</code></pre>
<p>not</p>
<pre><code>"53"
</code></pre>
<p>If not, does anybody have any examples on how to accomplis this?</p>
<p>Thanks!</p>
| c# | [0] |
4,724,591 | 4,724,592 | How can I share data (which is updated every minute) accoss modules in Python? | <p>I have read in many posts that global variables are bad, but I need them!</p>
<p>My situation:</p>
<p>I have few variables defined in a dedicated module which are updated every minute and are used by other modules in the application. (Implemented after reading <a href="http://effbot.org/pyfaq/how-do-i-share-global-variables-across-modules.htm" rel="nofollow">this</a>), Do you think its a good approach or needs any improvement or any better idea?</p>
<p>Thanks</p>
| python | [7] |
5,084,854 | 5,084,855 | Flipping a picture across the vertical axis in python | <p>I am trying to flip a picture across its vertical axis in python but have no idea how to start. any suggestion would be appreciated. Thanks.</p>
| python | [7] |
1,391,165 | 1,391,166 | convert byte to binary | <p>I have FLY file I stored it to byte array and I can read it byte by byte.
I want to convert each byte to binary 0s and 1s </p>
<p>I want to convert variable b to binary 1s 0s. for example if b = 70 how to convert it to binary</p>
<p>what function I can use in C# to do this??</p>
<p>here is my code to read FLY file and store it byte array.</p>
<pre><code>byte[] myArray = System.IO.File.ReadAllBytes(@"myFlvFile.flv");
int r = 0;
foreach (var b in myArray)
{
r += 1;
txtBit.Text = Environment.NewLine + Convert.ToString(b);
if (r == 50)
return;
}
</code></pre>
| c# | [0] |
5,229,688 | 5,229,689 | getting rid of characters in an output in python | <p>If someone writes 'james', I want my program to style their name as j*a*m*e*s
I thought it would be simple:</p>
<pre><code>for letter in name:
print letter+' *',
</code></pre>
<p>but I don't know how to get rid of the last asterix at the end.</p>
<p>I had a friend show me in C though...so I understand the underlying concept, just not how to achieve it.
C is below:</p>
<pre><code>#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int i;
for ( i = 1; i < argc; i++ ) {
int len = strlen(argv[i]);
int j;
for (j = 0; j < len-1; j++)
printf("%c*",argv[i][j]);
printf("%c\n",argv[i][j]);
}
return 0;
}
</code></pre>
| python | [7] |
855,069 | 855,070 | Insert text generated in php in the html | <p>We can do</p>
<pre><code><img src="page.php" />
</code></pre>
<p>to display an image generated in php.</p>
<p>How can I do something like <code><div src="page.php" ></div></code> to display a text generated in php?</p>
<p>P.S: I know we can do <code><?php echo ""; ?></code> but my goal is to show people that it's from php, and not to modify the html content (only in memory).</p>
| php | [2] |
1,088,552 | 1,088,553 | How do I apply a sequence of insert/delete-character operations on a string? | <p>I have a text like this:</p>
<blockquote>
<p>My name is Bob and I live in America.</p>
</blockquote>
<p>I have some reference to the characters of this string, for example:</p>
<pre><code>from 3 to 7 chars, deleted
at 3 char, added "surname"
from 20 to 25, deleted
at 25 char ....
</code></pre>
<p>but these statements aren't ordered (and I can't order them).</p>
<p>So, this is the question: how can I modify the text without losing the reference of the characters?
For example, if I apply the first sentence, my text became:</p>
<blockquote>
<p>My is Bob and I live in America.</p>
</blockquote>
<p>and my third sentence doesn't work correctly anymore, cause I've lost the reference to the original 20th character.</p>
<p>Keep in mind that the text is pretty long, so I can't use any indexes...</p>
| java | [1] |
4,932,477 | 4,932,478 | Custom EditText not showing up in an alert dialog | <p>Good day, following the NotePad sample in the SDK, i wanted to have a custom EditText view show inside an alert dialog. My problem is, i can't seem to get any focus on the editText.. clicking in the EditText Area is not doing anything. </p>
<p>here is the code:</p>
<pre><code> LayoutInflater my_inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View noteView = my_inflater.inflate(R.layout.note_pad,null);
line_edit_text = (EditText)findViewById(R.id.notes);
String yes = getResources().getString(R.string.Yes);
String no = getResources().getString(R.string.No);
String mynote = getResources().getString(R.string.add_notes);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(mynote);
builder.setView(noteView);
builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
notes_to_save = line_edit_text.getText().toString();
dialog.dismiss();
}
});
builder.setNegativeButton(no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
final AlertDialog alert = builder.create();
//alert.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
alert.show();
</code></pre>
<p>All i did was take the code for the Custom EditText as well as the xml and put it in my code. but i can't see or get any focus for the EditText for the user to input. please help!</p>
<p>EDIT: just to point my question to a different direction, i have noticed that if i set another custom layout, it shows correctly, but it does not seem to load the view layout from the custom EditText in the sample SDK. </p>
| android | [4] |
5,502,166 | 5,502,167 | php fetchpage() function help, identifying image sizes from a url in php | <p>hey guys so im building an application and one of teh features it will have is the ability to show photo links from twitter inline sort of like what tweetdeck has done in their chrome browser version and sites like crowdreel have been able to do, i spent some time researching how to grab image tags from urls on google and found this fantastic script <a href="http://www.bitrepository.com/extract-images-from-an-url.html" rel="nofollow">http://www.bitrepository.com/extract-images-from-an-url.html</a></p>
<p>the script is great and does exactly what i need, however now my challenge is that the array returned from the links returns every image in the page including thumbnails ads etc, so a link to a page like this: <a href="http://lockerz.com/s/69901787" rel="nofollow">http://lockerz.com/s/69901787</a></p>
<p>will return an array with quite a few image links to sort through,
however what i need is a link to the main image so that i can display it inline with tweets, my idea is that i run some sort of code to figure out which of the images in the page is the largest? what are your thoughts on this? is this the right method or is there something easier thats built into php perhaps? thanks for all your help guys!</p>
| php | [2] |
3,198,362 | 3,198,363 | C++ .exe ignores classes, only running main (beginner) | <p>It's only running main, the output "Enter a word" but completely ignores the objects/class</p>
<p>I'm a newb, sorry if this is an inappropriately easy question.
This happens on both release and debug mode</p>
<pre><code>#include <iostream>
using namespace std;
class WordGame
{
public:
void setWord( string word )
{
theWord = word;
}
string getWord()
{
return theWord;
}
void displayWord()
{
cout << "Your word is " << getWord() << endl;
}
private:
string theWord;
};
int main()
{
cout << "Enter a word" << endl;
string aWord;
WordGame theGame;
cin >> aWord;
theGame.setWord(aWord);
theGame.displayWord();
}
</code></pre>
| c++ | [6] |
5,008,752 | 5,008,753 | Best way to effectively disconnect a test device from eclipse | <p>I am new to android development and I have been having problems with disconnecting my smartphone from my ubuntu development platform running Eclipse. When I initially plug my phone in with the usb, the system sees it and all is well. However, if I disconnect it from the system and then plug it back in, the system does not recognize it. I have been rebooting the system everytime it does this. Is there a way to "safely" unplug the phone without having to reboot? Should I close Eclipse? Do I need to "unmount" the phone or is there a way to "restart" the android.rules in the rules.d folder?</p>
<p>Any help would be appreciated.</p>
| android | [4] |
6,030,046 | 6,030,047 | How to disable show() in jquery on page load? | <p>I want to <code>show()</code> <code>"<div id="test">write text here</div"</code> on click and not on page load.</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
$("#click_test").stop(function(event){
event.preventDefault();
$("#test").slideup();
});
$("#click_test").click(function(event){
event.preventDefault();
$("#test").toggle();
});
});
</script>
</head>
<body>
<a href="#" id="click_test">Click Here</a>
<div id="test">write text here</div>
</code></pre>
<p>Thanks</p>
| jquery | [5] |
4,097,010 | 4,097,011 | Split a text file using the header | <p>I have an input text file which I am reading and storing everything in a list. After that I'm splitting the list according to the specific text occurence in the list. </p>
<p>Here is the function.</p>
<pre><code>import re
def readFile1(file1):
f = file1.read().split('\n')
#print f
ctrlList1 = []
mfcList1 = []
for str in f:
if re.search("MegaMon> mfc",str):
print "splitting\n"
break
else:
ctrlList1.append(str)
print ctrlList1, "\n\n\n"
</code></pre>
<p>This works fine and saves <code>ctrlList1</code> until the text <code>megamon> mfc</code> appears in the main list. But I want to save the lines after <code>MegaMon> mfc</code> in <code>mfcList1</code>. I am not able to do that. </p>
<p>I tried:</p>
<pre><code>if not re.search("MegaMon> mfc", str):
print "splitting\n"
continue
else:
mfcList1.append(str)
</code></pre>
<p>but this doesn't seem to be working. I need to save the text file in two different lists. Any help would be appreciated.</p>
| python | [7] |
5,149,769 | 5,149,770 | iphone xcode Landscape mode by default | <p>how can I set an iphone app to start in Landscape mode? and stays that way</p>
| iphone | [8] |
2,487,357 | 2,487,358 | Convert String to Decimal - leave digits | <p>I've got a form which allows a user to enter a price, for example, <code>10.00</code>. </p>
<p>However as the form is purley text a user could enter <code>$10.00</code> or <code>10.00 for book</code>.
I cannot change the UI, this has to be done under the hood.
So basically what ever the use types I just want a decimal result. </p>
<p>I started to do this</p>
<pre><code>public decimal FilterPrice(dynamic price) {
string convertPrice=price.ToString();
var filterNumber=
from letter in convertPrice
where char.IsDigit(letter)
select letter;
return something;
}
</code></pre>
<p>However this will strip out <code>.</code>. Any ideas how to do this? </p>
| c# | [0] |
3,987,526 | 3,987,527 | Write to file in android from input stream? | <p>Im getting an input stream, which is an mp3 in my raw folder, and then I am trying to write it back to the raw folder (I know this sounds stupid but I want to do it), but I get an error - file not found, myFile.mp3. Any ideas where I am going wrong?</p>
<pre><code>try
{
File f=new File("android.resource//com.apps/raw/myFile.mp3");
InputStream myRawResource = context.getActivity().getResources().openRawResource(mp3ID);
OutputStream out=new FileOutputStream(f);
byte buf[]=new byte[1024];
int len;
while((len=myRawResource.read(buf))>0)
out.write(buf,0,len);
out.close();
myRawResource.close();
}
catch (IOException e){
//error
}
</code></pre>
| android | [4] |
3,276,748 | 3,276,749 | Validate image type using javascript | <p>i have a form like this: </p>
<pre><code><form method=post src=upload enctype="multipart/form-data">
<input name="img1" id="img1" type="file">
<input type="submit" value="Upload">
</form >
</code></pre>
<p>Please how can I valid this form using javascript so that only jpg files are uploaded. thanks for reading.</p>
| javascript | [3] |
3,316,656 | 3,316,657 | Javascript: find closest number | <p>i would like to find rounded nearest number in javascript e.g.</p>
<p>10 --> 10</p>
<p>11 --> 10</p>
<p>12 --> 10</p>
<p>13 --> 15</p>
<p>16 --> 15</p>
<p>17 --> 15</p>
<p>18 --> 20</p>
<p>19 --> 20</p>
<p>20 --> 20</p>
| javascript | [3] |
116,173 | 116,174 | assigning a priority to processes before they are launched | <p>I have a specific number of process(C# .exe) that should be launched. how do i launch them according to their priority.</p>
<p>I know the Process.PriorityClass thing but it's not really useful because it only assigns the priority after the process is launched.</p>
<p>I have this code here (doesn't compares priority yet) but it doesn't work because the processes are not run so I can't assign the priority to them:</p>
<pre><code>Process process1 = new Process();
Process process2 = new Process();
Process process3 = new Process();
process1.StartInfo.FileName = "proc1";
process2.StartInfo.FileName = "proc2"'
process3.StartInfo.FileName = "proc3";
process1.PriorityClass = ProcessPriorityClass.AboveNormal;
process2.PriorityClass = ProcessPriorityClass.BelowNormal;
process3.PriorityClass = ProcessPriorityClass.High;
process2.Start();
process2.WaitForExit();
process1.Start();
process1.WaitForExit();
process3.Start();
</code></pre>
| c# | [0] |
224,709 | 224,710 | Question about bool in C++ | <p>I was wondering why the code below only returns "Test" four times, instead of five?</p>
<pre><code> #include <iostream>
#include <cassert>
using namespace std;
class CountDown
{
public: //Application Programmer Interface
CountDown(int start); // it is set to start
void next(); // subtracts one from it
bool end()const; //
private:
int it;
};
CountDown::CountDown(int start)
{
it = 0;
it = start;
}
void CountDown::next()
{
it = it - 1;
}
bool CountDown::end() const
{
if (it <= 0)
cout << "The countdown is now over" << endl;
}
int main()
{
for( CountDown i = 5 ; ! i.end(); i.next())
std::cerr << "test\n";
}
</code></pre>
| c++ | [6] |
4,097,577 | 4,097,578 | Migrating to OSGi? | <p>We're currently running server-side java apps on windows using JavaServiceWrapper and this has been a good solution for us. We have a small number of Spring-based lightweight applications.</p>
<p>But now we need to look at introducing some modularity into our services. To that end I have been thinking about OSGi.</p>
<p>I need to know which OSGi containers are ready for prime-time production use in a medium-ish load environment?</p>
<ul>
<li>Eclipse Equinox 3.5.x</li>
<li>Knopflerfish 3.x</li>
<li>Apache Felix 2.x</li>
<li>Anything else?</li>
</ul>
| java | [1] |
995,238 | 995,239 | private & protected constructor | <p>I am quite confused with the difference with private and protected constructor in java regarding the accessibility of the subclasses and creating instance. Some code example is even better. Thanks in advance. </p>
| java | [1] |
4,836,868 | 4,836,869 | DecForms to Java | <p>Can some one help me in approaches / Strategies in converting DecForms to Java? We have about 24 IFDL files which we need to convert to Java based technologies</p>
| java | [1] |
4,621,745 | 4,621,746 | when we need to provide template parameters to define a class? | <pre><code>template<typename T> class A // template parameterization
{
private:
T t;
A(const T& v) : t(v) {}
};
class B
{
template<typename T>
B(const T& v)
{
std::cout << v << std::endl;
}
};
// usage of A and B
A<int> a;
B b(10);
</code></pre>
<p>Question> In what circumstances, we have to provide template parameters in order to define a class variable.</p>
<p>For example,</p>
<p>If the class contains a template member variable or ???</p>
<p>Thank you</p>
| c++ | [6] |
3,433,192 | 3,433,193 | Javascript - Function call will not enter function body | <p>I have a function acting as a constructor that, when called, gets as far as the function definition in the debugger, but never to the function body. Is there a common reason this may happen that I am overlooking? Example code below:</p>
<p>myconstructor.js</p>
<pre><code>function MyConstructor(optionalParam) { //this breakpoint gets hit
var newobj = {}; //breakpoint never hit
//code to check for null parameter
//other code
};
</code></pre>
<p>main.js</p>
<pre><code>var myConstructor = new MyConstructor();
</code></pre>
<p>There must be something I have overlooked, but I can't see what that is. Neither firefox/firebug nor VS report errors or warnings.</p>
<p>Thanks!</p>
| javascript | [3] |
390,072 | 390,073 | COnvert date from Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time) to YYYY-MM-DD in javascript | <p>How can I convert the time from the format "Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)" to YYYY-MM-DD.</p>
<p>When I try to alert() the date then this will show the date like the following
- Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)</p>
<p>But I need the time in YYYY-MM-DD format.</p>
<p>are there any built function to convert.</p>
| javascript | [3] |
5,083,689 | 5,083,690 | PHP php.ini file in the web public root directory ? is it safe enough | <p>I heard when you want to change the php.ini settings when you don't have access to the php.ini in the root level that you can upload a php.ini to the web-root, is this correct ?</p>
<blockquote>
<p>Another way to customize your PHP settings is to create a file named <code>php.ini</code> and to upload it to your web server. This works in a way similar to the <code>.htaccess</code> file except you don’t have to add “php_value” at the beginning of the line</p>
</blockquote>
<p>if this correct that means anyone who type </p>
<pre><code>www.xx.com/php.ini
</code></pre>
<p><strong>should see the settings ? isnt this a security risk ?</strong></p>
| php | [2] |
1,719,990 | 1,719,991 | will any change to the member of class observed set off the observer to the member? | <p>Let me make a example to show this:</p>
<p>I have a class <strong>ClassA</strong>, it contains a public member <strong>memberA</strong>.
it also contains a public method <strong>methodA</strong>, which will change the value of memberA.</p>
<p>now I have a instant of ClassA: </p>
<pre><code>instantA
</code></pre>
<p>then I call this:</p>
<pre><code>[instantA addObserver:anObserver forKeyPath:@"memberA" options:NSKeyValueObservingOptionNew context:NULL];
</code></pre>
<p>why this will touch off observer:</p>
<pre><code>instantA.memberA = xxxxx;
</code></pre>
<p>but this won't:</p>
<pre><code>[instantA methodA];
</code></pre>
| iphone | [8] |
3,811,818 | 3,811,819 | Custom function shared by many aspx pages | <p>I have a few aspx pages which displays GridView controls. In each control I use custom functions to format displayed data. I want to put those functions in one static class. I did like this:</p>
<pre><code>namespace MyNS
{
public static class FormatFunctions
{
public static string Format1(string text)
{
return <formatted string>;
}
public static string Format2(string text)
{
return <formatted string>;
}
}
}
</code></pre>
<p>I can call those functions from codebehind file, but when I call them from aspx file like this:</p>
<pre><code><asp:TemplateField>
<ItemTemplate>
<%# FormatFunctions.Format1(Eval("field_name")) %>
</ItemTemplate>
</asp:TemplateField>
</code></pre>
<p>I got the following error:</p>
<pre><code>The name 'FormatFunctions' does not exist in the current context
</code></pre>
<p>How can I access those functions from aspx file. Should I add some headers to the aspx file?</p>
| asp.net | [9] |
4,888,761 | 4,888,762 | Make dots between numbers in php | <p>I would like to make dots between my total value.</p>
<p>If i have 425000 i would like it to show as 425.000</p>
<p>Is there a function in php that implodes dots for numbers or how can i do this then?</p>
| php | [2] |
4,222,967 | 4,222,968 | php string comparison considering spaces in between | <p>in php i need to compare 2 strings.</p>
<pre>str1="this is a string"</pre>
<pre>str2=" this is a string "</pre>
<p>I want to consider str1 and str2 to be the same string.</p>
<p>The way I can think is:</p>
<p>trim the strings first. extract the words of each string first, compare the words and then get the result.</p>
<p>Any better way i.e. bulit-in function or something else to make the comparison?</p>
| php | [2] |
3,169,547 | 3,169,548 | download URL works when pasted/entered in browser address bar, but not in href or window.open or Location | <p>why download URL works when pasted/entered in browser address bar, but not in href or window.open or Location
if i have a html file with this code</p>
<pre><code><html>
<head>
<script type="text/javascript" language="JavaScript">
function clickedButton()
{
window.location = 'http://s1.mihandownload.com/2012/Feisal/October/JetBrains_WebStorm_5.0.2_www.MihanDownload.com.rar'
}
</script>
</head>
<body>
<input type="button" value="Login" onClick="clickedButton()"/>
</body>
</html>
</code></pre>
<p>and open it by double click my download link work
but if i load page in localhost or server my link not working</p>
| javascript | [3] |
560,964 | 560,965 | jquery set value of div | <p>I have this div:</p>
<pre><code> <div style="height:100px; width:100px" class="total-title">
first text
</div>
</code></pre>
<p>and I have a jquery statement to change its value:</p>
<pre><code> $('div.total-title').html('test');
</code></pre>
<p>But it doesn't work.</p>
| jquery | [5] |
1,709,256 | 1,709,257 | Jquery Exit Popup | <p>I'm trying to use this tweak for my blog: <a href="http://www.tonylea.com/2011/creating-a-jquery-exit-popup/#comment-909" rel="nofollow">http://www.tonylea.com/2011/creating-a-jquery-exit-popup/#comment-909</a></p>
<p>Basically what it does is the popup should be showing up only when your mouse is moving upward out of the page. </p>
<p>Here's the code:</p>
<pre><code><script type="text/javascript">
var oldPosition = -1;
$(document).ready(function() {
$(document).mousemove(function(e) {
$('#exitpopup').css('left', (window.innerWidth/2 - $('#exitpopup').width()/2));
$('#exitpopup').css('top', (window.innerHeight/2 - $('#exitpopup').height()/2));
var position = e.pageY - $(window).scrollTop();
if(position < 10){
if(oldPosition != -1){
if(position < oldPosition){
// Show the exit popup
// make sure it's moving upward
$('#exitpopup_bg').fadeIn();
$('#exitpopup').fadeIn();
}
oldPosition = position;
}else{
oldPosition = position;
}
}
// $('#divData').html(oldPosition + " : " + position);
});
$('#exitpopup_bg').click(function(){
$('#exitpopup_bg').fadeOut();
$('#exitpopup').slideUp();
});
});
</script>
</code></pre>
<p><strong>Issue No.1:</strong> Although I don't see there's any problem in the code, the popup does also show up when your mouse is moving down into the page, why is this happening?</p>
<p><strong>Issue No.2:</strong> When you quickly drag your mouse out of the page, nothing shows up. Well, how do I make sure it also works under this situation? </p>
| jquery | [5] |
1,183,640 | 1,183,641 | Problem using Conditional Operation with Nullable Int | <p>A small problem. Any idea guys why this does not work?</p>
<pre><code>int? nullableIntVal = (this.Policy == null) ? null : 1;
</code></pre>
<p>I am trying to return 'null' if the left hand expression is True, else 1. Seems simple but gives compilation error - </p>
<p>Type of conditional expression cannot be determined because there is no implicit conversion between 'null' and 'int'</p>
<p>If I replace the " ? <strong>null</strong> : 1 " with any valid int, then there is no problem.</p>
| c# | [0] |
639,817 | 639,818 | How to manage AI actions based on percentages | <p>I am looking now for some time about how can a programmer simulate a AI decision based on percentages of actions for the final fantasy tactic-like games (strategy game).</p>
<p>Say for example that the AI character has the following actions:</p>
<p>Attack 1: 10%<br />
Attack 2: 9%<br />
Magic : 4%<br />
Move : 1%</p>
<p>All of this is far from equaling 100%</p>
<p>Now at first I though about having an array with 100 empty slots, attack would have 10 slots, attack 2 9 slots on the array. Combining random I could get the action to do then. My problem here is it is not really efficient, or doesn't seem to be. Also important thing, what do I do if I get on an empty slot. Do I have to calculate for each character all actions based on 100% or define maybe a "default" action for everyone ? </p>
<p>Or maybe there is a more efficient way to see all of this ? I think that percentage is the easiest way to implement an AI.</p>
| c# | [0] |
2,753,714 | 2,753,715 | Get image width and height without downloading in PYTHON | <p>Is there anyway to get image width and height without downloading from original location in PYTHON. I have an idea how to get image info when it is in our server. Buy no idea this can do with online resource image in PYTHON. </p>
<p>Finally done this as follow in python. Anyway have to download and get image info</p>
<pre><code>import cStringIO
import urllib
import Image
file = urllib.urlopen('http://static.php.net/www.php.net/images/php.gif')
im = cStringIO.StringIO(file.read())
img = Image.open(im)
print img.format, img.size, img.mode
GIF (120, 67) P
width, height = img.size
print width, height
</code></pre>
| python | [7] |
1,745,770 | 1,745,771 | Generate GUID with random length | <p>I need to generate random string for my automated tests. I use the following <em>Chinese</em> custom class to do it.</p>
<pre><code>public class UniqueIdGenerator
{
static public string GenerateUniqueId(int idLength) // generates uniqueID for all fields (0-175 characters)
{
string uniqueID = "";
string initialID = Guid.NewGuid().ToString().Remove(35);
if (idLength <= 35)
{
uniqueID = Guid.NewGuid().ToString().Remove(idLength);
}
if (idLength > 35 & idLength <= 70)
{
uniqueID = initialID + Guid.NewGuid().ToString().Remove(idLength - 35);
}
if (idLength > 70 & idLength <= 105)
{
uniqueID = initialID + initialID + Guid.NewGuid().ToString().Remove(idLength - 70);
}
if (idLength > 105 & idLength <= 140)
{
uniqueID = initialID + initialID + initialID + Guid.NewGuid().ToString().Remove(idLength - 105);
}
if (idLength > 140 & idLength <= 175)
{
uniqueID = initialID + initialID + initialID + initialID + Guid.NewGuid().ToString().Remove(idLength - 140);
}
return uniqueID;
}
</code></pre>
<p>How can I simplify it to use for any natural number?</p>
| c# | [0] |
2,964,614 | 2,964,615 | Java, comparing singlecharacter string to character | <p>Is there an easy way of comparing a string (which you know to contain only a single character) to a character? The method I am currently using feels a bit "clunky". </p>
<pre><code>c == "x".charAt(0)
</code></pre>
<p>Where c is a character. The reason I am using "x" (string) is because I don't know how to write x as a char, so I have to do this.</p>
| java | [1] |
5,549,031 | 5,549,032 | Show/Hide divs using Jquery | <p>I am having issues showing one div then hiding the previous div. </p>
<pre><code>var newElem = '#ID' + numVariable;
$('.elemPropGlobal').hide();
$(newElem).click(function (){
$('.elemPropGlobal').hide();
$($(this).attr('id') + 'Properties').show();
}
</code></pre>
<p>Divs that I click on</p>
<pre><code><div class="something" id="ID1" > some data</div>
<div class="something" id="ID2" > some data</div>
</code></pre>
<p>Divs that should show and hide </p>
<pre><code><div class="elemPropGlobal" id="ID1Properties" >
<div class="elemPropGlobal" id="ID2Properties" >
</code></pre>
| jquery | [5] |
829,531 | 829,532 | add items to list via button click in jquery | <p>I have a select list and need to append each selected value/text to a list on a button click. Here is some pseudo code</p>
<pre><code> $("#addButton").click(function () {
var selectedValue = "..."
var selectedText = "..."
//todo append each selected value & text
//to an unordered list
//on submit of form read in via querystring selected
//values and text from the unordered list
});
</code></pre>
<p>Any ideas?</p>
<p>Thanks</p>
| jquery | [5] |
4,877,022 | 4,877,023 | How can I listen when my view is scroll out of visible region | <p>In my android application, I have a scroll view which has a lot of children view.
How can I listen for an event when a view is switching from visible to 'non visible to user' due to user's scroll action? </p>
| android | [4] |
512,318 | 512,319 | activity does not close after taking picture Android | <p>Hi i have used SurfaceView and taking picture by below code</p>
<p>First i am starting activity by this code</p>
<pre><code> startActivityForResult(new Intent(PictureEditor.this, CustomCamera.class), CAMERA_REQUEST3);
</code></pre>
<p>and then getting result from this code </p>
<pre><code> @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == CAMERA_REQUEST3) {
BitmapFactory.Options abc = new BitmapFactory.Options();
abc.inJustDecodeBounds = true;
BitmapFactory.decodeFile((Environment.getExternalStorageDirectory() + File.separator + "tester.png"), abc);
abc.inSampleSize = calculateInSampleSize(abc, w, h) + 1;
abc.inJustDecodeBounds = false;
view.setBackBitmap(BitmapFactory.decodeFile((Environment.getExternalStorageDirectory() + File.separator + "tester.png"), abc));
}
</code></pre>
<p>Now the CustomeCamera Class's code is below</p>
<pre><code> // / Handles when mTakePicture is clicked
private OnClickListener mTakePictureAction = new OnClickListener() {
@Override
public void onClick(View v) {
if (mCamera != null)
mCamera.takePicture(CustomCamera.this);
}
};
</code></pre>
<p>Then </p>
<pre><code> @Override
public void takePicture(Activity activity) {
if (mCamera != null)
mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);
Intent returnIntent = new Intent();
activity.setResult(mActivity.RESULT_OK, returnIntent);
activity.finish();
}
</code></pre>
<p>the problem is image is captured but the activity is not getting finish! Can anybody suggest me what to do!</p>
| android | [4] |
4,279,681 | 4,279,682 | Javascript : problem in html page rendering | <p>when i am rendering a page I have a confirm button that pops up before the page is fully rendered . now if i delay in choosing an option from the confirm box my page is left half rendered and if i select an option from the confirm box quickly the page is fully rendered.
Why is this happening?</p>
| javascript | [3] |
5,572,432 | 5,572,433 | When should I use non-member operator overloading? | <p>Should I be using non-member overload or member overload? How do I tell which I should use?</p>
| c++ | [6] |
2,630,006 | 2,630,007 | Trigger facebook send button on click of button | <p>I want to trigger facebook send button on click of another button.
For more clarification- "I want to trigger send button on click of test button" on "59.144.174.74/test1.html" which is test link</p>
| javascript | [3] |
1,545,941 | 1,545,942 | I want to form a m x n matrix by giving some numbers as input in c# | <p>HI,</p>
<p>suppose i have given input numbers like this 1,2,3,4,5,6,7,8,9,0</p>
<p>i should form it as 3 x 3 matrix but my input has 10 elements how to form a matrix
for such input in c#</p>
| c# | [0] |
4,372,301 | 4,372,302 | Python: Find out what method on derived class called base class method | <p>Hope the title isn't to confusing wasn't sure how I should put it. I wonder if it's possible for the base class to know which method of the derived class called one of it's methods. </p>
<p>Example:</p>
<pre><code>class Controller(object):
def __init__(self):
self.output = {}
def output(self, s):
method_that_called_me = #is it possible?
self.output[method_that_called_me] = s
class Public(Controller):
def about_us(self):
self.output('Damn good coffee!')
def contact(self):
self.output('contact me')
</code></pre>
<p>So is it possible for the output method to know which method from the Public class called it?</p>
| python | [7] |
5,598,856 | 5,598,857 | Android handler skip/jump a second | <p>I am trying to implement a simple digital clock with second and two colons changing every second. I have thought about using DigitalClock but I want the colons to flash as well as the second and don't want to show am/pm. So I read the "Updating the UI from a Timer" and it suggests us to use Handler. So i use Handler and can change second and colons every second but the weird thing is that sometimes, it jumps a second (1,2,4,5,6). It seems the clock is a bit lagging. Is there any way to solve this problem? Thanks!</p>
<pre><code>tick_handler = new Handler();
Runnable updateSecond = new Runnable(){
@Override
public void run() {
second.setText(DataModel.getSeconds());
if(colon1.getVisibility()== View.VISIBLE){
colon1.setVisibility(View.INVISIBLE);
colon2.setVisibility(View.INVISIBLE);
} else {
colon1.setVisibility(View.VISIBLE);
colon2.setVisibility(View.VISIBLE);
}
tick_handler.postDelayed(this, 1000);
}
};
tick_handler.postDelayed(updateSecond, 0);
</code></pre>
| android | [4] |
1,965,020 | 1,965,021 | selecting a char in jquery | <p>I got a question,</p>
<pre><code><a id="shoppingLink1" href="?page=bestellen&amp;action=add&amp;id=2">
<img src="images/shoppingcartButton.png" class="shoppingButton" alt="shoppingcartButton" title="shoppingcartButton"/>
</a><br/>
</code></pre>
<p>in jquery, when i click on the shoppingButton i would like to select the last character from the id "shoppingLink". the "1" .</p>
<p>These are dynamicly added thou so if it comes to 10 it should automaticly select the last 2 characters. Anyone who can help me?</p>
| jquery | [5] |
467,919 | 467,920 | Access member of class from a constructor of another class | <p>My code looks something like this:</p>
<p>main.cpp</p>
<pre><code>#include <iostream>
#include "A.h"
#include "B.h"
using namespace std;
int main(){
int d,f;
A c();
d = c.GetStuff();
B *d = new C();
f = d->Get();
return 0;
}
</code></pre>
<p>A.h</p>
<pre><code>#ifndef A_H
#define A_H
class A
{
int a;
public A();
int GetStuff() {return(a) ;}
};
#endif
</code></pre>
<p>A.cpp</p>
<pre><code>#include "A.h"
A::A()
{
a = 42;//just some value for sake of illustration
}
</code></pre>
<p>B.h</p>
<pre><code>#ifndef B_H
#define B_H
Class B
{
public:
virtual int Get(void) =0;
};
class C: public B {
public:
C();
int Get(void) {return(a);}
};
#endif
</code></pre>
<p>B.cpp</p>
<pre><code>#include "B.h"
C::C() {
a // want to access this int a that occurs in A.cpp
}
</code></pre>
<p>My question is, what is the best way to gain access to "a" in B.cpp?
I tried using class "friend", but I am not getting results.</p>
<p>Any suggestions?
Thanks!</p>
| c++ | [6] |
4,948,914 | 4,948,915 | Calling a function from another javascript file | <p>I have javascript file in following directory </p>
<pre><code>/static
/handler.js
/evercookie.js
/jquery.js
</code></pre>
<p>All I want to do from handler.js function call a function in evercookie.js. for example<br>
in <code>handler.js</code> </p>
<pre><code> var ec = new evercookie();
cookiePresent = false
ec.get(suggestion_id, function(value) {
alert("Cookie value is " + value);
cookiePresent = true;
});
if (cookiePresent) {
return;
} else {
ec.set(suggestion_id, "1");
alert("cookie set for " + suggestion_id);
}
</code></pre>
<p>where <strong>evercookie()</strong> is in <code>evercookie.js</code> </p>
<p>when I try this it fails saying <code>evercookie not found</code> </p>
<p>How shall I fix this?</p>
| javascript | [3] |
3,503,052 | 3,503,053 | Is there a way to enter text into a website with python? | <p>Basically, I need to make a python program that can go to a website and enter text. <br>
For example, going to google and entering text into the search box and then pressing enter.<br>
Is that even possible?</p>
| python | [7] |
2,560,008 | 2,560,009 | Comparing two arraylists with multiple set fields | <p>I am trying to compare two ArrayLists, but I can't seem to get it work.</p>
<p>Suppose:</p>
<p>My main arrayList called List 1 gets its value through:</p>
<pre><code> ArrayList<xTypeClass> List1 = new ArrayList<xTypeClass>();
xTypeClass tmp = new xTypeCLass();
tmp.setName(name);
tmp.setaddress(address);
tmp.setPhone(phone);
tmp.setMonth(mo);
..etc
List1.add(tmp);
</code></pre>
<p>Now I have another list2 that holds the exact type format, but has different values. And I want to compare List2 to 1 and see which ones does not exist in List2 that does in List1 and add it to List2. I am having problem using double for loops to go around both list to find which exists and which doesn't. Can someone point me in the right direction? Comment below if you need any more information.</p>
| java | [1] |
5,754,473 | 5,754,474 | Android HTTP Post,Get Delete | <p>My application uses a HTTP Connection to send requests and read responses from the server. I used </p>
<pre><code> conn = (HttpURLConnection) new URL(strUrl).openConnection();
conn.setConnectTimeout(Constants.CONNECTION_TIMEOUT); conn.setReadTimeout(Constants.SOCKET_TIMEOUT);
conn.setRequestProperty("Connection", "close");
</code></pre>
<p>Is there any other ways to send POST and GET verbs to the server. Any opensource libraries that retries connections to the Server etc ??</p>
<p>Kind Regards,</p>
<p>Mateen.</p>
| android | [4] |
1,154,603 | 1,154,604 | jQuery error: Status: 'error'. Error code: 500 while performing an edit in jqgrid | <pre><code>navGrid('#pager',{view:false,del:true},
{
afterComplete: function(response){
alert(response.responseText);
}
},
{
afterComplete: function(response){
alert(response.responseText);
}
},
{
afterComplete: function(response){
alert(response.responseText);
}
}
);
// alert(xhr.statusText);
</code></pre>
| jquery | [5] |
5,176,246 | 5,176,247 | Extracting last two characters from a numeric string | <p>Okay. Say I have string</p>
<pre><code>'193'
</code></pre>
<p>And I want to remove the last numbers and store them in an array so I can do operations with them. I know substr can delete the 2 characters, but I'm not sure how to store them after they've been removed..</p>
| php | [2] |
2,278,084 | 2,278,085 | Stich Images to Video without NDK | <p>Is there a way in the Java Android SDK to take a series of images and "stitch" them into a video? For example, if there are 50 different images how can you take them and make a video (any format mpg, ogg, etc) out of it. I saw a couple of posts here about doing it with the NDK, but I know nothing about it and would prefer to stick with Java and the normal SDK.</p>
<p>Any Ideas?</p>
<p>Thanks!</p>
| android | [4] |
2,475,844 | 2,475,845 | converting str to int and vice versa | <p>I have a need to convert a string to an int and back after doing some processing. And the string has to be in words like below:</p>
<p>45 - forty five<br>
99 - ninety nine</p>
<p>I searched everywhere for a hint but couldn't find any. I know the obvious switch-case logic but I am curious if theres a more intelligent way doing it with less lines of code.</p>
| python | [7] |
3,041,710 | 3,041,711 | How to start manage application screen in android | <p>I want to start manage application(Settings->Application->manage application) screen programatically. I am unable to do it. Can anyone please help me?</p>
<p>Thanks in advance.</p>
| android | [4] |
519,841 | 519,842 | jQuery .animate | <p>I have the following issue: a list item that once clicked, a div slides up and changes opacity to 1. My goal is that on second click, the same div will get opacity 0.</p>
<p>I tried removing the original class and adding a new one, "selected" and then apply a click event on that. For some reason, the second part is not working. Any ideas? </p>
<pre><code>$(document).ready(function () {
$('li.slide1').click(function () {
$("div#slidebox1").animate({
opacity: .8,
top: -200,
}, 300);
$("li.slide1").removeClass("slide1").addClass("selected");
});
$("li.selected").click(function () {
$("div#slidebox1").animate({
opacity: 0,
}, 300);
});
});
</code></pre>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.